Ejemplo n.º 1
0
    private void SpawnMonsters()
    {
        for (int i = 0; i < 12; i++)
        {
            while (true)
            {
                int x = Random.Range(0, generatorInstance.GetWorldSize().x);
                int y = Random.Range(0, generatorInstance.GetWorldSize().y - 34);

                // Dont spawn on top of the player or right next to them
                if (generatorSpec.GetSpawn().x > x - 5 && generatorSpec.GetSpawn().x < x + 5)
                {
                    continue;
                }
                if (generatorInstance.IsValidMonsterSpawn(new Vector2Int(x, y)))
                {
                    SlimeEnemy slime = Instantiate(slimeEnemyPrefab, new Vector2(x, y), Quaternion.identity);
                    slime.SetLightColor(Random.ColorHSV());
                    break;
                }
            }
        }

        for (int i = 0; i < 6; i++)
        {
            while (true)
            {
                int x = Random.Range(0, generatorInstance.GetWorldSize().x);
                int y = Random.Range(0, generatorInstance.GetWorldSize().y - 34);

                // Dont spawn on top of the player or right next to them
                if (generatorSpec.GetSpawn().x > x - 5 && generatorSpec.GetSpawn().x < x + 5)
                {
                    continue;
                }
                if (generatorInstance.IsValidMonsterSpawn(new Vector2Int(x, y)))
                {
                    DopplerEnemy doppler = Instantiate(dopplerEnemyPrefab, new Vector2(x, y), Quaternion.identity);
                    doppler.gameManager = this;
                    break;
                }
            }
        }
        SpiderEnemy spider = Instantiate(spiderEnemyPrefab, new Vector2(31, 146), Quaternion.identity);

        spider.gameManager = this;
    }
Ejemplo n.º 2
0
 //This method is used to update all of the current entities in the scene that can be updated.
 public void UpdateAllEntitiesInScene()
 {
     for (int i = 0; i < entityList.Count; i++)
     {
         //The SceneGraph only attempts to update an object if the "i" data member exists as a key in the dictionary, and therefore exists in the scene at this time.
         if (DoesKeyExist(i) == true)
         {
             // Only the objects which can be updatable are attempted to be updated.
             if (entityList[i].isUpdatable == true)
             {
                 if (entityList[i].type == ObjectType.Spider && entityList[i].objectID == spiderKey)
                 {
                     if (DoesKeyExist(lemmingKey) == true)
                     {
                         SpiderEnemy thisSpider = (SpiderEnemy)entityList[i];
                         thisSpider.RecieveLemmingPos(entityList[lemmingKey].position);
                         entityList[i] = thisSpider;
                     }
                 }
                 entityList[i].Move();
             }
         }
     }
 }
Ejemplo n.º 3
0
 private void Start()
 {
     spiEnemy = spider.GetComponent <SpiderEnemy>();
 }
Ejemplo n.º 4
0
 private void Start()
 {
     spider = transform.parent.GetComponent <SpiderEnemy>();
 }