1
0
Fork 0

Add Objective generation | rename mainkaefer to bug

This commit is contained in:
Saibotk 2018-04-23 16:44:02 +02:00
parent 7914b4d9da
commit 1004f95997
10 changed files with 137 additions and 60 deletions

View file

@ -52,7 +52,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1303102899095328}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 7.6580257, y: 3.506653, z: -0.08491792}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4615957218218632}

View file

@ -623,6 +623,11 @@ Prefab:
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 60772848946696534, guid: 3d1911457c1e44f53b6b4044334db52f,
type: 2}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
m_IsPrefabParent: 0
@ -721,6 +726,11 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5d9a051e822e2cf4ea3ca01c5a4df37c, type: 3}
m_Name:
m_EditorClassIdentifier:
followSpeed: 0.05
minZoom: 5
zoomFactor: 4
zoomSpeed: 0.05
startingDist: 5
followThis: {fileID: 0}
--- !u!114 &881384373
MonoBehaviour:
@ -741,6 +751,11 @@ MonoBehaviour:
- {fileID: 1908750963}
- {fileID: 368878861}
- {fileID: 1908750963}
--- !u!1 &979562542 stripped
GameObject:
m_PrefabParentObject: {fileID: 1303102899095328, guid: 4c5ecfd27b4038941a6e493a8117ea0a,
type: 2}
m_PrefabInternal: {fileID: 1597985551}
--- !u!1 &1028937042
GameObject:
m_ObjectHideFlags: 0
@ -966,7 +981,7 @@ Prefab:
- target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743,
type: 2}
propertyPath: m_AnchoredPosition.x
value: 67.14285
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743,
type: 2}
@ -1045,6 +1060,10 @@ Prefab:
propertyPath: m_RootOrder
value: 5
objectReference: {fileID: 0}
- target: {fileID: 1303102899095328, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2}
m_IsPrefabParent: 0
@ -1366,6 +1385,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 87d25c2cd3eb97749b79f2cb5f7c5cea, type: 3}
m_Name:
m_EditorClassIdentifier:
scorpion: {fileID: 979562542}
BorderOuter: {fileID: 1062532744197412, guid: bc306521f11be424f9833117977b4319,
type: 2}
BorderInner: {fileID: 1893245914782828, guid: 7326753bf2b213d4e8c2ee93d78ba7d9,

View file

@ -5,15 +5,13 @@ using Assets.Scripts.Entities.Attack;
namespace Assets.Scripts.Entities {
public class Maikäfer : MonoBehaviourEnemy {
public class Bug : Enemy {
public Maikäfer() : base(15)
{
public Bug() : base(15) {
}
private void Start()
{
private void Start() {
SetAttack(new MeleeAttack(this.gameObject));
}
}

View file

@ -4,7 +4,11 @@ using UnityEngine;
using Assets.Scripts.Entities.Attack;
namespace Assets.Scripts.Entities {
class Enemy : Mob {
public class Enemy : Mob {
public enum Enemys {
SCORPION,
BUG
}
[SerializeField]
private float speed = 1;

View file

@ -1,11 +1,10 @@
using System.Collections;
using Assets.Scripts.Entities;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameController : MonoBehaviour {
private Room start;
private Room finish;
@ -13,6 +12,12 @@ public class GameController : MonoBehaviour {
WIN, DIED
}
// Enemy Prefabs
[Header("Enemys")]
[SerializeField]
GameObject scorpion;
[Space(10)]
// Generation Settings
[Header("Tile Prefabs")]
[SerializeField]
@ -61,6 +66,7 @@ public class GameController : MonoBehaviour {
GameObject RockLRD;
private Dictionary<GenerationProcessor.ExtendedTileType, GameObject> genPrefabs;
private Dictionary<Enemy.Enemys, GameObject> enemyPrefabs;
[Space(10)]
[Header("References")]
@ -91,29 +97,34 @@ public class GameController : MonoBehaviour {
// Use this for initialization
void Start () {
genPrefabs = new Dictionary<GenerationProcessor.ExtendedTileType, GameObject>();
genPrefabs.Add(GenerationProcessor.ExtendedTileType.BorderOuter, BorderOuter);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.BorderInner, BorderInner);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.BorderSingle, BorderSingle);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.Rock, Rock);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockL, RockL);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockU, RockU);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockR, RockR);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockD, RockD);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLU, RockLU);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLR, RockLR);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLD, RockLD);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLURD, RockLURD);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockRD, RockRD);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockUR, RockUR);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockUD, RockUD);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLUD, RockLUD);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLUR, RockLUR);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockURD, RockURD);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLRD, RockLRD);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.Ground, Ground);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.DoorInner, DoorInner);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.DoorOuter, DoorOuter);
genPrefabs = new Dictionary<GenerationProcessor.ExtendedTileType, GameObject> {
{ GenerationProcessor.ExtendedTileType.BorderOuter, BorderOuter },
{ GenerationProcessor.ExtendedTileType.BorderInner, BorderInner },
{ GenerationProcessor.ExtendedTileType.BorderSingle, BorderSingle },
{ GenerationProcessor.ExtendedTileType.Rock, Rock },
{ GenerationProcessor.ExtendedTileType.RockL, RockL },
{ GenerationProcessor.ExtendedTileType.RockU, RockU },
{ GenerationProcessor.ExtendedTileType.RockR, RockR },
{ GenerationProcessor.ExtendedTileType.RockD, RockD },
{ GenerationProcessor.ExtendedTileType.RockLU, RockLU },
{ GenerationProcessor.ExtendedTileType.RockLR, RockLR },
{ GenerationProcessor.ExtendedTileType.RockLD, RockLD },
{ GenerationProcessor.ExtendedTileType.RockLURD, RockLURD },
{ GenerationProcessor.ExtendedTileType.RockRD, RockRD },
{ GenerationProcessor.ExtendedTileType.RockUR, RockUR },
{ GenerationProcessor.ExtendedTileType.RockUD, RockUD },
{ GenerationProcessor.ExtendedTileType.RockLUD, RockLUD },
{ GenerationProcessor.ExtendedTileType.RockLUR, RockLUR },
{ GenerationProcessor.ExtendedTileType.RockURD, RockURD },
{ GenerationProcessor.ExtendedTileType.RockLRD, RockLRD },
{ GenerationProcessor.ExtendedTileType.Ground, Ground },
{ GenerationProcessor.ExtendedTileType.DoorInner, DoorInner },
{ GenerationProcessor.ExtendedTileType.DoorOuter, DoorOuter }
};
enemyPrefabs = new Dictionary<Enemy.Enemys, GameObject> {
{ Enemy.Enemys.SCORPION, scorpion }
};
}
// Update is called once per frame
@ -176,7 +187,7 @@ public class GameController : MonoBehaviour {
});
start.SetDoorsRootObject(doorRoot);
// WIP
// Spawnpoint
GameObject spawnpointRoot = new GameObject();
spawnpointRoot.name = "Spawnpoints";
spawnpointRoot.transform.SetParent(goStart.transform);
@ -210,6 +221,8 @@ public class GameController : MonoBehaviour {
foreach (GenRoom gr in dg.rooms) {
GameObject groom = gp.ProcessRoom(gr.tiles);
List<Transform> ltg = new List<Transform>(groom.GetComponentsInChildren<Transform>());
// Doors
GameObject doorRootg = new GameObject();
doorRootg.name = "Doors";
doorRootg.transform.SetParent(groom.transform);
@ -220,8 +233,21 @@ public class GameController : MonoBehaviour {
x.gameObject.GetComponent<Door>().SetParent(grom);
});
// Spawnpoints
GameObject tSpawnpointRoot = new GameObject();
tSpawnpointRoot.name = "Spawnpoints";
tSpawnpointRoot.transform.SetParent(groom.transform);
tSpawnpointRoot.transform.position = new Vector3(gr.roomPosition.x, gr.roomPosition.y, 0);
foreach(Vector2Int v in gr.spawnpoints) {
GameObject tspawn = new GameObject();
tspawn.transform.SetParent(tSpawnpointRoot.transform);
tspawn.transform.position = new Vector3(v.x, v.y, 0); // is this the center or the top left corner of a block?
}
grom.SetSpawnPointsRootObject(tSpawnpointRoot);
grom.SetDoorsRootObject(doorRootg);
grom.Reload();
DungeonGenerator.GenerateObjective(grom);
groom.transform.SetParent(mapRoot.transform);
}
@ -277,6 +303,10 @@ public class GameController : MonoBehaviour {
return ui.GetComponent<UIController>();
}
public Dictionary<Enemy.Enemys, GameObject> GetEnemyPrefabs() {
return enemyPrefabs;
}
public bool GameEnded() {
return state == GameState.ENDED;
}

View file

@ -1,4 +1,5 @@
using System;
using Assets.Scripts.Entities;
using System;
using System.Collections.Generic;
using UnityEngine;
@ -214,13 +215,13 @@ public class DungeonGenerator {
}
foreach ( GenRoom r in rooms )
makeRoomRelative(r);
makeRoomRelative(start);
makeRoomRelative(end);
makeRoomRelative(path);
MakeRoomRelative(r);
MakeRoomRelative(start);
MakeRoomRelative(end);
MakeRoomRelative(path);
}
public void makeRoomRelative(GenRoom room) {
public void MakeRoomRelative(GenRoom room) {
room.roomPosition = room.bounds.position;
foreach ( Vector2Int v in room.tiles.Keys ) {
v.Set(( v - room.roomPosition ).x, ( v - room.roomPosition ).y);
@ -439,4 +440,20 @@ public class DungeonGenerator {
}
}
}
public static void GenerateObjective(Room r) {
Dictionary<Enemy.Enemys, GameObject> enemyPrefabs = GameController.instance.GetEnemyPrefabs(); // TODO not so cool
// TODO add more types
Objective o;
// ENTITYOBJECTIVE ENEMYS:
List<GameObject> lg = new List<GameObject>();
//GameObject scorp = enemyPrefabs[Enemy.Enemys.SCORPION];
lg.Add(enemyPrefabs[Enemy.Enemys.SCORPION]);
EntityObjective eo = new EntityObjective(r, lg);
o = eo;
r.SetObjective(o);
}
}

View file

@ -19,6 +19,7 @@ public class GenRoom {
// 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 Objective objective = null;
public float Distance(GenRoom r) {
return Math.Abs(GetCenter().x - r.GetCenter().x) + Math.Abs(GetCenter().y - r.GetCenter().y);

View file

@ -1,4 +1,5 @@
using System.Collections;
using Assets.Scripts.Entities;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@ -26,13 +27,19 @@ public class EntityObjective : Objective {
public override void ActivateGoal(Player ply) {
if ( activated )
return;
activated = true;
base.ActivateGoal(ply);
foreach ( GameObject i in prefabList ) {
Debug.Log("[ROOMS] Spawning Entity...");
if(i == null || player == null) {
Debug.Log("[ROOMS] Failed.. Entity not set in GameController!");
return;
}
GameObject tempObject = GameObject.Instantiate(i);
List<Transform> spawnPointList = room.GetSpawnpoints();
tempObject.transform.position = spawnPointList[Random.Range(0, spawnPointList.Count)].position;
tempObject.GetComponent<Enemy>().SetVictim(player.gameObject);
tempObject.GetComponent<Enemy>().SetObjective(this);
entityList.Add(tempObject);
}