Esempio n. 1
0
        void DeleteMap()
        {
            for (int i = 0; i < currentLevelTiles.Count; i++)
            {
                Destroy(currentLevelTiles[i]);
            }
            currentLevelTiles = new List <GameObject>();

            itemSpawn = GameObject.Find("MapGenerator").GetComponent <ItemSpawn>();
            itemSpawn.DeleteItems();
        }
Esempio n. 2
0
        protected override void Start()
        {
            CaveGameManager.instance.AddEnemyToList(this);
            animator          = GetComponent <Animator> ();
            target            = GameObject.FindGameObjectWithTag("Player").transform;
            enemyPosition     = transform.position;
            isAttackingPlayer = false;
            if (CaveGameManager.instance.GetLevel() <= 1)
            {
                hp         = Random.Range(10, 50);
                multiplier = 1;
            }
            else if (CaveGameManager.instance.GetLevel() <= 5)
            {
                // 0-9:no reward, 10-19:fruit, 20-29:drink, 30-39: veg, 40-49: meat
                enemyHealthChange = GameObject.FindWithTag("GameManager").GetComponent <AIEnemyHealth>().GetHealthChange(CaveGameManager.instance.GetLevel());
                hp         = Random.Range(10, 50) + enemyHealthChange;
                multiplier = 1;
            }
            else if (CaveGameManager.instance.GetLevel() > 5 && CaveGameManager.instance.GetLevel() <= 10)
            {
                enemyHealthChange = GameObject.FindWithTag("GameManager").GetComponent <AIEnemyHealth>().GetHealthChange(CaveGameManager.instance.GetLevel());
                hp         = Random.Range(100, 500) + enemyHealthChange;
                multiplier = 10;
            }
            else if (CaveGameManager.instance.GetLevel() > 10 && CaveGameManager.instance.GetLevel() <= 15)
            {
                enemyHealthChange = GameObject.FindWithTag("GameManager").GetComponent <AIEnemyHealth>().GetHealthChange(CaveGameManager.instance.GetLevel());
                hp         = Random.Range(500, 1000) + enemyHealthChange;
                multiplier = 20;
            }
            else if (CaveGameManager.instance.GetLevel() > 15 && CaveGameManager.instance.GetLevel() <= 20)
            {
                enemyHealthChange = GameObject.FindWithTag("GameManager").GetComponent <AIEnemyHealth>().GetHealthChange(CaveGameManager.instance.GetLevel());
                hp         = Random.Range(1000, 5000) + enemyHealthChange;
                multiplier = 100;
            }
            else
            {
                enemyHealthChange = GameObject.FindWithTag("GameManager").GetComponent <AIEnemyHealth>().GetHealthChange(CaveGameManager.instance.GetLevel());
                hp         = Random.Range(5000, 20000) + enemyHealthChange;
                multiplier = 400;
            }

            originalHp = hp;
            healthBar.SetHealth(hp, originalHp);
            player    = GameObject.FindWithTag("Player").GetComponent <Bandit>();
            itemSpawn = GameObject.FindWithTag("GameManager").GetComponent <ItemSpawn>();
            base.Start();
        }
Esempio n. 3
0
        public void GenerateFirstMap()
        {
            if (currentLevelTiles.Count > 1)
            {
                DeleteMap();
            }
            exitCoord              = new Coordinate();
            mapFloorTiles          = new List <Coordinate>();
            mapEdgeTiles           = new List <Coordinate>();
            allMapRooms            = new List <List <Coordinate> >();
            originalRooms          = new List <Room>();
            passageEdgeTiles       = new List <Coordinate>();
            randomStartingLocation = new Vector2();
            itemSpawn              = GameObject.FindWithTag("GameManager").GetComponent <ItemSpawn>();
            GenerateMap();
            GenerateStartAndExit();
            DrawMap();
            int currEnemyCount = 0;

            foreach (Coordinate coord in mapFloorTiles)
            {
                if (UnityEngine.Random.Range(0, 150) >= 7)
                {
                    int randomNumber = UnityEngine.Random.Range(5, 1000);
                    itemSpawn.SpawnItem(-baseWidth / 2 - 0.5f + coord.x, -baseHeight / 2 - 0.5f + coord.y, randomNumber);
                }
                else
                {
                    if (currEnemyCount <= enemyCount)
                    {
                        GameObject enemyChoice = enemyTiles[UnityEngine.Random.Range(0, enemyTiles.Length)];
                        Instantiate(enemyChoice, new Vector2(-baseWidth / 2 - 0.5f + coord.x, -baseHeight / 2 - 0.5f + coord.y), Quaternion.identity);
                        currEnemyCount++;
                    }
                    else
                    {
                        int randomNumber = UnityEngine.Random.Range(5, 1000);
                        itemSpawn.SpawnItem(-baseWidth / 2 - 0.5f + coord.x, -baseHeight / 2 - 0.5f + coord.y, randomNumber);
                    }
                }
            }
        }