Merge branch 'master' into PiegamesDev
This commit is contained in:
commit
141760055f
21 changed files with 262 additions and 243 deletions
|
@ -19,7 +19,7 @@ GameObject:
|
|||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 4676354101874032}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: BulletSpawn
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -34,7 +34,7 @@ GameObject:
|
|||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 4830909199357604}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: Graphics
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -53,7 +53,7 @@ GameObject:
|
|||
- component: {fileID: 114874769993434856}
|
||||
- component: {fileID: 114835806183609276}
|
||||
- component: {fileID: 60772848946696534}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: Player
|
||||
m_TagString: Player
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -69,7 +69,7 @@ GameObject:
|
|||
m_Component:
|
||||
- component: {fileID: 4564951497896744}
|
||||
- component: {fileID: 212241819326847048}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: vehicleTMP
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -86,7 +86,7 @@ GameObject:
|
|||
- component: {fileID: 4240907079511616}
|
||||
- component: {fileID: 198696209911726984}
|
||||
- component: {fileID: 199437974736988364}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: Particle System
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
|
|
@ -22,7 +22,7 @@ GameObject:
|
|||
- component: {fileID: 61708904748430096}
|
||||
- component: {fileID: 50733723059255246}
|
||||
- component: {fileID: 114448442531622302}
|
||||
m_Layer: 0
|
||||
m_Layer: 9
|
||||
m_Name: Scorpion
|
||||
m_TagString: Enemy
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -38,7 +38,7 @@ GameObject:
|
|||
m_Component:
|
||||
- component: {fileID: 4615957218218632}
|
||||
- component: {fileID: 212910646889249274}
|
||||
m_Layer: 0
|
||||
m_Layer: 9
|
||||
m_Name: Graphics
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
|
|
@ -1013,13 +1013,13 @@ RectTransform:
|
|||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 1505922857439362}
|
||||
m_LocalRotation: {x: -0, y: -0, z: 0.08715578, w: 0.9961947}
|
||||
m_LocalRotation: {x: 0, y: 0, z: -0.7071068, w: 0.7071068}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0.49999988, y: 0.49999988, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 224833383346886274}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 10}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -7.3055115, y: -3.7793121}
|
||||
|
@ -1058,7 +1058,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 66.396866, y: 0}
|
||||
m_AnchoredPosition: {x: 64.16286, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 1, y: 0.5}
|
||||
--- !u!224 &224218339018349506
|
||||
|
|
|
@ -170,7 +170,7 @@ Transform:
|
|||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 816024605}
|
||||
m_RootOrder: 1
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!82 &368878861
|
||||
AudioSource:
|
||||
|
@ -448,9 +448,9 @@ Transform:
|
|||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 1908750962}
|
||||
- {fileID: 368878860}
|
||||
- {fileID: 1028937043}
|
||||
- {fileID: 1908750962}
|
||||
m_Father: {fileID: 734498092}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
@ -512,6 +512,7 @@ GameObject:
|
|||
- component: {fileID: 881384369}
|
||||
- component: {fileID: 881384368}
|
||||
- component: {fileID: 881384372}
|
||||
- component: {fileID: 881384373}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
|
@ -595,6 +596,25 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
followThis: {fileID: 0}
|
||||
--- !u!114 &881384373
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 881384367}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e40ea81463f7264a8ce9334d6bf62ac, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
mixer: {fileID: 24100000, guid: efb934a745665924d8c7dd46c0a117ae, type: 2}
|
||||
maintheme: {fileID: 24500006, guid: efb934a745665924d8c7dd46c0a117ae, type: 2}
|
||||
end: {fileID: 245089854461186482, guid: efb934a745665924d8c7dd46c0a117ae, type: 2}
|
||||
gameovers: {fileID: 801288609}
|
||||
soundeffects:
|
||||
- {fileID: 1908750963}
|
||||
- {fileID: 368878861}
|
||||
- {fileID: 801288609}
|
||||
--- !u!1 &1028937042
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -622,7 +642,7 @@ Transform:
|
|||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 816024605}
|
||||
m_RootOrder: 2
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!82 &1028937044
|
||||
AudioSource:
|
||||
|
@ -727,11 +747,6 @@ Prefab:
|
|||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 224011665836974194, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||
type: 2}
|
||||
propertyPath: m_RootOrder
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 224011665836974194, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||
type: 2}
|
||||
propertyPath: m_LocalPosition.x
|
||||
|
@ -865,6 +880,48 @@ GameObject:
|
|||
m_PrefabParentObject: {fileID: 1998375241450644, guid: 460d856ea4eb14cedb5fecde1fe6d743,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 1379476068}
|
||||
--- !u!1001 &1597985551
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 7.6580257
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 3.506653
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: -0.08491792
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_RootOrder
|
||||
value: 5
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
m_IsPrefabParent: 0
|
||||
--- !u!1 &1600556433
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -989,53 +1046,6 @@ AudioSource:
|
|||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
--- !u!1001 &1597985551
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 7.6580257
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 3.506653
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: -0.08491792
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
propertyPath: m_RootOrder
|
||||
value: 5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 50733723059255246, guid: 4c5ecfd27b4038941a6e493a8117ea0a,
|
||||
type: 2}
|
||||
propertyPath: m_GravityScale
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
|
||||
m_IsPrefabParent: 0
|
||||
--- !u!1 &1624368723
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1091,7 +1101,7 @@ Transform:
|
|||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 816024605}
|
||||
m_RootOrder: 0
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!82 &1908750963
|
||||
AudioSource:
|
||||
|
|
|
@ -10,7 +10,7 @@ public class Door : MonoBehaviour {
|
|||
BoxCollider2D triggerBox;
|
||||
|
||||
// Use this for initialization
|
||||
void Start() {
|
||||
void Awake() {
|
||||
BoxCollider2D[] colliders = GetComponents<BoxCollider2D>();
|
||||
foreach ( BoxCollider2D collider in colliders ) {
|
||||
if ( collider.isTrigger ) {
|
||||
|
@ -21,7 +21,6 @@ public class Door : MonoBehaviour {
|
|||
//Debug.Log("Found Door collider");
|
||||
}
|
||||
}
|
||||
Unlock();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Entities.Attack {
|
||||
|
@ -15,8 +16,14 @@ namespace Assets.Scripts.Entities.Attack {
|
|||
}
|
||||
|
||||
public void Attack() {
|
||||
RaycastHit2D hit = Physics2D.Raycast(owner.transform.position, owner.transform.localRotation * Vector3.up, range);
|
||||
Mob m = hit.collider.gameObject.GetComponent(typeof(Mob)) as Mob;
|
||||
RaycastHit2D[] hits = Physics2D.RaycastAll(owner.transform.position, owner.transform.localRotation * Vector3.up, range);
|
||||
List<RaycastHit2D> rh = new List<RaycastHit2D>(hits);
|
||||
RaycastHit2D hit = rh.Find(x => x.fraction != 0);
|
||||
Mob m = null;
|
||||
if (hit.collider != null && hit.collider.gameObject != null) {
|
||||
m = hit.collider.gameObject.GetComponent(typeof(Mob)) as Mob;
|
||||
}
|
||||
Debug.Log(m.tag);
|
||||
if ( m != null && m.tag != owner.tag) {
|
||||
m.InflictDamage(damage);
|
||||
}
|
||||
|
|
|
@ -27,14 +27,13 @@ namespace Assets.Scripts.Entities.Attack {
|
|||
public void Attack() {
|
||||
if ( bulletPrefab == null )
|
||||
return;
|
||||
Debug.Log("Instantiate Bullet");
|
||||
GameObject b = GameObject.Instantiate(bulletPrefab);
|
||||
b.transform.rotation = spawn.rotation;
|
||||
b.transform.position = spawn.position;
|
||||
Bullet bu = b.GetComponent<Bullet>();
|
||||
bu.SetDamage(damage);
|
||||
bu.SetOwner(owner);
|
||||
|
||||
GameController.instance.GetAudioControl().SfxPlay(0);
|
||||
}
|
||||
|
||||
public float GetCooldownTime() {
|
||||
|
|
|
@ -21,13 +21,17 @@ namespace Assets.Scripts.Entities {
|
|||
}
|
||||
|
||||
void Update() {
|
||||
|
||||
if ( victim == null || attack == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( Time.timeSinceLevelLoad >= nextAttackTime ) {
|
||||
RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.position - victim.transform.position, attack.GetRange());
|
||||
if ( hit.collider.gameObject == victim ) {
|
||||
RaycastHit2D[] hits = Physics2D.RaycastAll(transform.position, transform.localRotation * Vector3.up, attack.GetRange());
|
||||
List<RaycastHit2D> rh = new List<RaycastHit2D>(hits);
|
||||
RaycastHit2D hit = rh.Find(x => x.fraction != 0);
|
||||
if ( hit.collider != null && hit.collider.gameObject == victim ) {
|
||||
Debug.Log("Attacking Player!!!");
|
||||
attack.Attack();
|
||||
nextAttackTime = Time.timeSinceLevelLoad + attack.GetCooldownTime();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Assets.Scripts.Entities.Attack;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class Mob : Entity {
|
||||
protected readonly int maxHP;
|
||||
|
@ -25,6 +26,7 @@ public abstract class Mob : Entity {
|
|||
/// </summary>
|
||||
/// <param name="damage"></param>
|
||||
public void InflictDamage(int damage) {
|
||||
Debug.Log(tag + " received " + damage + " Damage");
|
||||
currentHP -= damage;
|
||||
if ( !isDead && currentHP <= 0 ) {
|
||||
isDead = true;
|
||||
|
|
|
@ -40,10 +40,11 @@ public class Player : Mob {
|
|||
Debug.Log("Collision");
|
||||
if ( collision.collider.tag == "wall" ) {
|
||||
Death();
|
||||
} else if ( collision.collider.tag == "enemy" ) {
|
||||
} else if ( collision.collider.tag == "Enemy" ) {
|
||||
Mob m = collision.collider.GetComponent(typeof(Mob)) as Mob;
|
||||
if ( m != null ) {
|
||||
InflictDamage(carDamage);
|
||||
//m.InflictDamage(carDamage);
|
||||
//InflictDamage(carDamage); // TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,6 @@ public class GameController : MonoBehaviour {
|
|||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLRD, RockLRD);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.Ground, Ground);
|
||||
genPrefabs.Add(GenerationProcessor.ExtendedTileType.Door, Door);
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
@ -177,7 +176,7 @@ public class GameController : MonoBehaviour {
|
|||
spawnpointRoot.transform.position = new Vector3(dg.start.roomPosition.x, dg.start.roomPosition.y, 0);
|
||||
GameObject spawn = new GameObject();
|
||||
spawn.transform.SetParent(spawnpointRoot.transform);
|
||||
spawn.transform.position = new Vector3(3, 3, 0);
|
||||
spawn.transform.position = new Vector3(dg.start.GetCenter().x, dg.start.GetCenter().y, 0);
|
||||
start.SetSpawnPointsRootObject(spawnpointRoot);
|
||||
|
||||
start.Reload();
|
||||
|
@ -226,6 +225,7 @@ public class GameController : MonoBehaviour {
|
|||
player = goal.GetPlayer();
|
||||
if ( player != null ) {
|
||||
cam.GetComponent<CameraControl>().SetFollow(player.gameObject);
|
||||
GetUI().InitHealthController(player);
|
||||
} else {
|
||||
Debug.Log("No Player spawned!");
|
||||
}
|
||||
|
@ -240,14 +240,22 @@ public class GameController : MonoBehaviour {
|
|||
//Time.timeScale = 0;
|
||||
if ( ui != null ) {
|
||||
Debug.Log("show Gameover UI");
|
||||
cam.GetComponent<AudioControl>().SfxPlay(2);
|
||||
ui.GetComponent<UIController>().ShowGameOverUI();
|
||||
} else {
|
||||
Debug.Log("No UI specified");
|
||||
}
|
||||
}
|
||||
|
||||
public AudioControl GetAudioControl() {
|
||||
return cam.GetComponent<AudioControl>();
|
||||
}
|
||||
|
||||
public UIController GetUI() {
|
||||
return ui.GetComponent<UIController>();
|
||||
}
|
||||
|
||||
public bool GameEnded() {
|
||||
return state == GameState.ENDED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,7 +404,6 @@ public class DungeonGenerator {
|
|||
}
|
||||
|
||||
public void GenerateInterior(GenRoom r) {
|
||||
|
||||
Vector2Int root = new Vector2Int (1, 1);
|
||||
|
||||
for (int x = r.bounds.x; x < r.bounds.x + r.bounds.width; x++)
|
||||
|
@ -415,10 +414,6 @@ public class DungeonGenerator {
|
|||
if (!r.tiles.ContainsKey(pos) || r.tiles[pos].type != Room.TileType.GROUND)
|
||||
continue;
|
||||
float prob = 0.0075f;
|
||||
if (UnityEngine.Random.value > 1 - prob)
|
||||
{
|
||||
r.tiles[pos].type = Room.TileType.ROCK;
|
||||
}
|
||||
if (UnityEngine.Random.value > 1 - prob * 2)
|
||||
{
|
||||
int count = (int ) (UnityEngine.Random.value * UnityEngine.Random.value * 6);
|
||||
|
@ -429,7 +424,18 @@ public class DungeonGenerator {
|
|||
if (r.tiles.ContainsKey(pos2) && r.tiles[pos2].type == Room.TileType.GROUND)
|
||||
r.tiles[pos2].type = Room.TileType.ROCK;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (UnityEngine.Random.value > 1 - prob)
|
||||
{
|
||||
r.tiles[pos].type = Room.TileType.ROCK;
|
||||
continue;
|
||||
}
|
||||
float prob2 = 0.02f;
|
||||
if (UnityEngine.Random.value > 1 - prob2)
|
||||
{
|
||||
r.spawnpoints.Add(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ public class GenRoom {
|
|||
public Vector2Int roomPosition;
|
||||
// All positions are in room space relative to the room's anchor
|
||||
public Dictionary<Vector2Int, GenTile> tiles = new Dictionary<Vector2Int, GenTile>();
|
||||
public HashSet<Vector2Int> spawnpoints = new HashSet<Vector2Int>();
|
||||
|
||||
public float Distance(GenRoom r) {
|
||||
return Math.Abs(GetCenter().x - r.GetCenter().x) + Math.Abs(GetCenter().y - r.GetCenter().y);
|
||||
|
|
|
@ -12,68 +12,30 @@ public class GenerationProcessor {
|
|||
}
|
||||
|
||||
public GameObject ProcessRoom(Dictionary<Vector2Int, GenTile> tiles) {
|
||||
GameObject root = new GameObject {
|
||||
name = "Room"
|
||||
};
|
||||
foreach ( Vector2Int v in tiles.Keys ) {
|
||||
ExtendedTileType type = ExtendedTileType.Ground;
|
||||
int rotation = 0;
|
||||
switch ( tiles[v].type ) {
|
||||
case Room.TileType.WALL:
|
||||
type = getCorrectWallType(tiles, v);
|
||||
switch (type)
|
||||
{
|
||||
case ExtendedTileType.BorderSingle:
|
||||
switch (tiles[v].position)
|
||||
{
|
||||
case GenTile.Position.BOTTOM:
|
||||
rotation = 180;
|
||||
break;
|
||||
case GenTile.Position.LEFT:
|
||||
rotation = 90;
|
||||
break;
|
||||
case GenTile.Position.TOP:
|
||||
rotation = 0;
|
||||
break;
|
||||
case GenTile.Position.RIGHT:
|
||||
rotation = 270;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ExtendedTileType.BorderInner:
|
||||
switch (tiles[v].position)
|
||||
{
|
||||
case GenTile.Position.BOTTOM_LEFT:
|
||||
rotation = 90;
|
||||
break;
|
||||
case GenTile.Position.TOP_LEFT:
|
||||
rotation = 0;
|
||||
break;
|
||||
case GenTile.Position.TOP_RIGHT:
|
||||
rotation = 270;
|
||||
break;
|
||||
case GenTile.Position.BOTTOM_RIGHT:
|
||||
rotation = 180;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Room.TileType.GROUND:
|
||||
type = ExtendedTileType.Ground;
|
||||
break;
|
||||
case Room.TileType.DOOR:
|
||||
type = ExtendedTileType.Door;
|
||||
break;
|
||||
case Room.TileType.ROCK:
|
||||
type = getCorrectRockType(tiles, v);
|
||||
break;
|
||||
}
|
||||
|
||||
CreateGOFromType(v, rotation, tiles[v].type, type, root);
|
||||
GameObject root = new GameObject {
|
||||
name = "Room"
|
||||
};
|
||||
foreach ( Vector2Int v in tiles.Keys ) {
|
||||
ExtendedTileType type = ExtendedTileType.Ground;
|
||||
int rotation = 0;
|
||||
switch ( tiles[v].type ) {
|
||||
case Room.TileType.WALL:
|
||||
type = getCorrectWallType(tiles, v);
|
||||
rotation = getCorrectWallRotation(type, tiles[v].position);
|
||||
break;
|
||||
case Room.TileType.GROUND:
|
||||
type = ExtendedTileType.Ground;
|
||||
break;
|
||||
case Room.TileType.DOOR:
|
||||
type = ExtendedTileType.Door;
|
||||
break;
|
||||
case Room.TileType.ROCK:
|
||||
type = getCorrectRockType(tiles, v);
|
||||
break;
|
||||
}
|
||||
|
||||
return root;
|
||||
CreateGOFromType(v, rotation, type, root);
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
private GameObject CreateGOFromType(Vector2 v, int rotation, Room.TileType type, ExtendedTileType t, GameObject root) {
|
||||
|
@ -83,7 +45,7 @@ public class GenerationProcessor {
|
|||
if ( prefabs.ContainsKey(t) && root != null ) {
|
||||
tmp = Object.Instantiate(prefabs[t], root.transform);
|
||||
tmp.transform.position = v;
|
||||
tmp.transform.Rotate(new Vector3(0, 0, rotation));
|
||||
tmp.transform.Rotate(new Vector3(0, 0, rotation));
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
@ -117,88 +79,93 @@ public class GenerationProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
private ExtendedTileType getCorrectRockType(Dictionary<Vector2Int, GenTile> tiles, Vector2Int position){
|
||||
|
||||
ExtendedTileType type = ExtendedTileType.Rock;
|
||||
|
||||
bool left = false;
|
||||
bool top = false;
|
||||
bool right = false;
|
||||
bool bottom = false;
|
||||
private int getCorrectWallRotation(ExtendedTileType type, GenTile.Position position) {
|
||||
int rotation = 0;
|
||||
switch (type) {
|
||||
case ExtendedTileType.BorderSingle:
|
||||
switch (position) {
|
||||
case GenTile.Position.BOTTOM:
|
||||
rotation = 180;
|
||||
break;
|
||||
case GenTile.Position.LEFT:
|
||||
rotation = 90;
|
||||
break;
|
||||
case GenTile.Position.TOP:
|
||||
rotation = 0;
|
||||
break;
|
||||
case GenTile.Position.RIGHT:
|
||||
rotation = 270;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ExtendedTileType.BorderInner:
|
||||
switch (position) {
|
||||
case GenTile.Position.BOTTOM_LEFT:
|
||||
rotation = 90;
|
||||
break;
|
||||
case GenTile.Position.TOP_LEFT:
|
||||
rotation = 0;
|
||||
break;
|
||||
case GenTile.Position.TOP_RIGHT:
|
||||
rotation = 270;
|
||||
break;
|
||||
case GenTile.Position.BOTTOM_RIGHT:
|
||||
rotation = 180;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return rotation;
|
||||
}
|
||||
|
||||
private ExtendedTileType getCorrectRockType(Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) {
|
||||
int meta = 0;
|
||||
Vector2Int toCheck = position + new Vector2Int(0, -1);
|
||||
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.ROCK)
|
||||
bottom = true;
|
||||
meta += 1;
|
||||
toCheck = position + new Vector2Int(-1, 0);
|
||||
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.ROCK)
|
||||
left = true;
|
||||
meta += 2;
|
||||
toCheck = position + new Vector2Int(0, 1);
|
||||
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.ROCK)
|
||||
top = true;
|
||||
meta += 4;
|
||||
toCheck = position + new Vector2Int(1, 0);
|
||||
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.ROCK)
|
||||
right = true;
|
||||
meta += 8;
|
||||
|
||||
if (top && !right && !left && !bottom)
|
||||
{
|
||||
return ExtendedTileType.RockU;
|
||||
}
|
||||
if (left && !right && !bottom && !top)
|
||||
{
|
||||
return ExtendedTileType.RockL;
|
||||
}
|
||||
if (right && !bottom && !left && !top)
|
||||
{
|
||||
return ExtendedTileType.RockR;
|
||||
}
|
||||
if (bottom && !right && !left && !top)
|
||||
{
|
||||
return ExtendedTileType.RockD;
|
||||
}
|
||||
if (left && top && !bottom && !right)
|
||||
{
|
||||
return ExtendedTileType.RockLU;
|
||||
}
|
||||
if (left && right && !top && !bottom)
|
||||
{
|
||||
return ExtendedTileType.RockLR;
|
||||
}
|
||||
if (left && bottom && !right && !top)
|
||||
{
|
||||
return ExtendedTileType.RockLD;
|
||||
}
|
||||
if (top && right && !left && !bottom)
|
||||
{
|
||||
return ExtendedTileType.RockUR;
|
||||
}
|
||||
if (top && bottom && !left && !right)
|
||||
{
|
||||
return ExtendedTileType.RockUD;
|
||||
}
|
||||
if (right && bottom && !top && !left)
|
||||
{
|
||||
return ExtendedTileType.RockRD;
|
||||
}
|
||||
if (left && top && bottom && !right)
|
||||
{
|
||||
return ExtendedTileType.RockLUD;
|
||||
}
|
||||
if (left && top && right && !bottom)
|
||||
{
|
||||
return ExtendedTileType.RockLUR;
|
||||
}
|
||||
if (top && right && bottom && !left)
|
||||
{
|
||||
return ExtendedTileType.RockURD;
|
||||
}
|
||||
if (left && right && bottom && !top)
|
||||
{
|
||||
return ExtendedTileType.RockLRD;
|
||||
}
|
||||
if (left && top && right && bottom)
|
||||
{
|
||||
return ExtendedTileType.RockLURD;
|
||||
}
|
||||
return type;
|
||||
switch(meta) {
|
||||
case 1:
|
||||
return ExtendedTileType.RockD;
|
||||
case 2:
|
||||
return ExtendedTileType.RockL;
|
||||
case 3:
|
||||
return ExtendedTileType.RockLD;
|
||||
case 4:
|
||||
return ExtendedTileType.RockU;
|
||||
case 5:
|
||||
return ExtendedTileType.RockUD;
|
||||
case 6:
|
||||
return ExtendedTileType.RockLU;
|
||||
case 7:
|
||||
return ExtendedTileType.RockLUD;
|
||||
case 8:
|
||||
return ExtendedTileType.RockR;
|
||||
case 9:
|
||||
return ExtendedTileType.RockRD;
|
||||
case 10:
|
||||
return ExtendedTileType.RockLR;
|
||||
case 11:
|
||||
return ExtendedTileType.RockLRD;
|
||||
case 12:
|
||||
return ExtendedTileType.RockUR;
|
||||
case 13:
|
||||
return ExtendedTileType.RockURD;
|
||||
case 14:
|
||||
return ExtendedTileType.RockLUR;
|
||||
case 15:
|
||||
return ExtendedTileType.RockLURD;
|
||||
default:
|
||||
return ExtendedTileType.Rock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@ public class EntityObjective : Objective {
|
|||
/// </summary>
|
||||
/// <param name="ply">Player</param>
|
||||
public override void ActivateGoal(Player ply) {
|
||||
if ( activated )
|
||||
return;
|
||||
activated = true;
|
||||
base.ActivateGoal(ply);
|
||||
foreach ( GameObject i in prefabList ) {
|
||||
Debug.Log("[ROOMS] Spawning Entity...");
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
public abstract class Objective {
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class Objective {
|
||||
protected Room room;
|
||||
protected Player player;
|
||||
bool activated;
|
||||
bool finished;
|
||||
protected bool activated;
|
||||
protected bool finished;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new Objective instance.
|
||||
|
@ -34,6 +36,7 @@
|
|||
protected virtual void ReachedGoal() {
|
||||
finished = true;
|
||||
room.Unlock();
|
||||
Debug.Log("[ROOM] Goal reached. Doors will open.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -20,11 +20,14 @@ public class StartObjective : Objective {
|
|||
/// </summary>
|
||||
/// <param name="ply">Player is ignored </param>
|
||||
public override void ActivateGoal(Player player) {
|
||||
if ( activated )
|
||||
return;
|
||||
if ( room.GetSpawnpoints().Count > 0 ) {
|
||||
GameObject ply = GameObject.Instantiate(playerPrefab);
|
||||
ply.transform.position = room.GetSpawnpoints()[0].position;
|
||||
player = ply.GetComponent<Player>();
|
||||
base.ActivateGoal(player);
|
||||
UpdateGoal();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ public class Room : MonoBehaviour {
|
|||
private Objective objective;
|
||||
|
||||
// Use this for initialization
|
||||
void Start() {
|
||||
void Awake() {
|
||||
doors = new List<Door>();
|
||||
if ( doorsRootObject != null ) {
|
||||
foreach ( Door d in doorsRootObject.GetComponentsInChildren<Door>() ) {
|
||||
|
@ -38,7 +38,7 @@ public class Room : MonoBehaviour {
|
|||
}
|
||||
//Debug.Log("[ROOMS] Spawnpoints: " + spawnpoints.Count);
|
||||
}
|
||||
//Unlock();
|
||||
Unlock();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -62,6 +62,7 @@ public class Room : MonoBehaviour {
|
|||
}
|
||||
//Debug.Log("[ROOMS] Spawnpoints: " + spawnpoints.Count);
|
||||
}
|
||||
Unlock(); // Ok to do so?
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class UIController : MonoBehaviour
|
||||
{
|
||||
|
@ -17,31 +18,36 @@ public class UIController : MonoBehaviour
|
|||
[SerializeField]
|
||||
HealthbarController healthcontroller;
|
||||
|
||||
|
||||
public void ShowPauseMenu()
|
||||
{
|
||||
[SerializeField]
|
||||
int mainMenuSceneIndex = 0;
|
||||
int firstSceneIndex = 1;
|
||||
|
||||
|
||||
void Update() {
|
||||
if (Input.GetKey(KeyCode.R) && GameController.instance.GameEnded()) {
|
||||
LoadSceneByIndex(firstSceneIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowPauseMenu() {
|
||||
pauseMenu.SetActive(true);
|
||||
}
|
||||
|
||||
public void ClosePauseMenu()
|
||||
{
|
||||
public void ClosePauseMenu() {
|
||||
pauseMenu.SetActive(false);
|
||||
}
|
||||
|
||||
public void LoadSceneByIndex(int index)
|
||||
{
|
||||
public void LoadSceneByIndex(int index) {
|
||||
Debug.Log("Loaded scene " + index);
|
||||
UnityEngine.SceneManagement.SceneManager.LoadScene(index);
|
||||
SceneManager.LoadScene(index);
|
||||
}
|
||||
|
||||
public void QuitGame()
|
||||
{
|
||||
public void QuitGame() {
|
||||
Debug.Log("Quit game");
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public void ShowGameOverUI()
|
||||
{
|
||||
public void ShowGameOverUI() {
|
||||
if (gameOverPanel != null) {
|
||||
Debug.Log("Loaded Canvas");
|
||||
gameOverPanel.SetActive(true);
|
||||
|
@ -51,8 +57,7 @@ public class UIController : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
public void InitHealthController(Player ply)
|
||||
{
|
||||
public void InitHealthController(Player ply) {
|
||||
healthcontroller.SetPlayer(ply);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
Physics2DSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 3
|
||||
m_Gravity: {x: 0, y: -9.81}
|
||||
m_Gravity: {x: 0, y: 0}
|
||||
m_DefaultMaterial: {fileID: 0}
|
||||
m_VelocityIterations: 8
|
||||
m_PositionIterations: 3
|
||||
m_VelocityIterations: 10
|
||||
m_PositionIterations: 4
|
||||
m_VelocityThreshold: 1
|
||||
m_MaxLinearCorrection: 0.2
|
||||
m_MaxAngularCorrection: 8
|
||||
|
@ -52,4 +52,4 @@ Physics2DSettings:
|
|||
m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432}
|
||||
m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745}
|
||||
m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804}
|
||||
m_LayerCollisionMatrix: c9ffffffc8ffffffc8ffffffffffffffc8ffffffc8ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
m_LayerCollisionMatrix: c9ffffffc8ffffffc8fcffffffffffffc8ffffffc8fffffffffffffffffffffffbfffffffbffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
|
|
|
@ -18,8 +18,8 @@ TagManager:
|
|||
- UI
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
- Player
|
||||
- Mobs
|
||||
-
|
||||
-
|
||||
-
|
||||
|
|
Loading…
Add table
Reference in a new issue