Пример #1
0
    public void SpawnInEnemies()
    {
        //instantiate enemy at random position
        //TODO check for valid spawn point for enemies
        int spawnedEnemies = 0;

        do
        {
            int enemyX = Random.Range(0, map.mapWidth);
            int enemyZ = Random.Range(0, map.mapLength);

            if (map.Nodes[enemyX, enemyZ].objectsOnNode.Count == 0 && !map.Nodes[enemyX, enemyZ].blocksMovement)
            {
                spawnedEnemies++;
                int        typeCoin       = UnityEngine.Random.Range(0, map.EnemyTransforms.Length);
                Transform  enemyTransform = map.EnemyTransforms[typeCoin];
                GameObject enemy          = (GameObject)Instantiate(enemyTransform.gameObject);
                enemy.GetComponent <EnemyMover>().currentNode = map.Nodes[enemyX, enemyZ];

                EnemiesController.ec.Enemies.Add(enemy.GetComponent <EnemyController>());
                enemy.transform.position = map.Nodes[enemyX, enemyZ].transform.position;
                EnemyController.totalEnemies++;
                enemy.name = "Enemy " + EnemyController.totalEnemies;
                map.Nodes[enemyX, enemyZ].AddToNode(enemy);
                //enemy.AddComponent<FallingSpawn>();
                enemy.SetActive(true);
                FallingSpawn fs = enemy.GetComponent <FallingSpawn>();
                //StartCoroutine(fs.FallIntoPlace());
                fs.FallIntoPlaceTweened();
                AudioController.ac.PlaySpawnNoise();
                enemy.GetComponent <EnemyController>().turnFinished = true;
            }
        } while (spawnedEnemies < numberOfEnemies);
    }
Пример #2
0
    public void SpawnPhone(int nodeX, int nodeZ)
    {
        //Relies on the calling method having checked for a clear space
        MoveNode node = Nodes[nodeX, nodeZ];

        GameObject phone  = Instantiate(PhoneTransform.gameObject);
        int        phoneX = nodeX;
        int        phoneZ = nodeZ;

        phone.GetComponent <Phone>().currentNode = Nodes[phoneX, phoneZ];
        PhoneController.pc.currentPhone          = phone.GetComponent <Phone>();
        Nodes[phoneX, phoneZ].AddToNode(phone);
        phone.transform.position = Nodes[phoneX, phoneZ].transform.position;
        foreach (Transform t in phone.transform)
        {
            Renderer[] renderers = t.GetComponentsInChildren <Renderer>();
            foreach (Renderer r in renderers)
            {
                r.enabled = false;
            }
        }
        FallingSpawn fs = phone.GetComponent <FallingSpawn>();

        //StartCoroutine(fs.FallIntoPlace());
        fs.FallIntoPlaceTweened();
    }
Пример #3
0
    public void SpawnEnemy(int nodeX, int nodeZ, EnemyType type)
    {
        MoveNode node = Nodes[nodeX, nodeZ];

        if (node.objectsOnNode.Count == 0)
        {
            GameObject enemy  = (GameObject)Instantiate(EnemyTransforms[(int)type].gameObject);
            int        enemyX = nodeX;
            int        enemyZ = nodeZ;
            enemy.GetComponent <EnemyMover>().currentNode = Nodes[enemyX, enemyZ];
            EnemyController.totalEnemies++;
            Nodes[enemyX, enemyZ].AddToNode(enemy);
            EnemiesController.ec.Enemies.Add(enemy.GetComponent <EnemyController>());
            enemy.transform.position = Nodes[enemyX, enemyZ].transform.position;
            enemy.name = "Enemy " + EnemyController.totalEnemies;
            foreach (Transform t in enemy.transform)
            {
                Renderer[] renderers = t.GetComponentsInChildren <Renderer>();
                foreach (Renderer r in renderers)
                {
                    r.enabled = false;
                }
            }
            FallingSpawn fs = enemy.GetComponent <FallingSpawn>();
            //StartCoroutine(fs.FallIntoPlace());
            fs.FallIntoPlaceTweened();
        }
        else
        {
            Debug.Log("Node (" + nodeX + "," + nodeZ + ") full, can't spawn here!");
        }
    }
Пример #4
0
 public void SpawnInWorldBlocks()
 {
     //spawn in world
     foreach (Transform t in transform)
     {
         FallingSpawn fs = t.GetComponent <FallingSpawn>();
         //if (fs != null) StartCoroutine(fs.FallIntoPlace());
         if (fs != null)
         {
             fs.FallIntoPlaceTweened();
         }
     }
 }
Пример #5
0
    public void SpawnInPlayer()
    {
        //find spawn point
        MoveNode spawnPoint = map.Nodes[6, 2];

        //instantiate player at spawn point
        //TODO make random spawn point
        PlayerController.pc.transform.position = spawnPoint.transform.position;
        PlayerController.pc.Mover.currentNode  = spawnPoint;
        PlayerController.pc.Mover.currentNode.AddToNode(PlayerController.pc.gameObject);
        FallingSpawn fs = PlayerController.pc.GetComponent <FallingSpawn>();

        //StartCoroutine(fs.FallIntoPlace());
        fs.FallIntoPlaceTweened();
    }