Skip to content
Snippets Groups Projects
Commit 370edade authored by Robin Ruud Kristensen's avatar Robin Ruud Kristensen
Browse files

added logic for operating chests

parent ba1b9bee
No related branches found
No related tags found
1 merge request!79Ruud1
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Cinemachine;
using UnityEngine;
using UnityEngine.Tilemaps;
......@@ -23,35 +24,77 @@ namespace Bigsock
GameObject[] boss;
GameObject player;
GameObject door;
GameObject stairs;
GameObject[] enemies;
GameObject[] Chest;
List<GameObject> chests;
private int roomNr = 0;
void Start()
{
chests = new List<GameObject>();
neighborMapGenerator.RunProceduralGeneration();
player = GameObject.Find("BigSock");
Chest = GameObject.FindGameObjectsWithTag("Chest");
foreach(GameObject c in Chest)
{
chests.Add(c);
c.SetActive(false);
}
}
void LateUpdate()
{
boss = GameObject.FindGameObjectsWithTag("Boss");
stairs = GameObject.Find("stairs(clone)");
enemies = GameObject.FindGameObjectsWithTag((roomNr).ToString());
if (boss.Length == 0 && levels <= 1 && Input.GetKey(KeyCode.Return))
{
neighborMapGenerator.RunProceduralGeneration();
player.transform.position = new Vector3(9, 5, 0);
levels++;
roomNr = 0;
foreach(GameObject c in chests)
{
Destroy(c);
}
chests.Clear();
TilemapGenerator.resetMaps();
TilemapGenerator.SetRoomIDZero();
neighborMapGenerator.RunProceduralGeneration();
Chest = GameObject.FindGameObjectsWithTag("Chest");
Debug.Log("Size: " + Chest.Length);
foreach (GameObject c in Chest)
{
if(c != null)
{
c.SetActive(false);
chests.Add(c);
}
}
player.transform.position = new Vector3(9, 5, 0);
levels++;
}
int i = 0;
if(i == 0) {
cameraMap.InvalidateCache();
i++;
}
if (enemies.Length == 0)
{
chests[roomNr + (6*(levels - 1))].SetActive(true);
if(roomNr + 1 < NeighbourMapGenerator.GetRoomListCount() - 1)
{
roomNr++;
}
}
}
private void OnDestroy()
{
roomNr = 0;
foreach (GameObject c in chests)
{
Destroy(c);
}
NeighbourMapGenerator.ClearRoomList();
TilemapGenerator.SetRoomIDZero();
TilemapGenerator.resetMaps();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment