Esempio n. 1
0
    public void SpawnEnemies()
    {
        for (int x = 0; x < gridSize.x; x++)
        {
            for (int y = 0; y < gridSize.y; y++)
            {
                switch (levelConfig.GetUnit(x, y))
                {
                case "0":
                {
                    if (grid[x, y] != null)
                    {
                        Destroy(grid[x, y].gameObject);
                        grid[x, y] = null;
                    }
                    break;
                }

                case "1":
                {
                    if (grid[x, y] == null)
                    {
                        grid[x, y] = Instantiate(warrior, new Vector3(x + transform.position.x,
                                                                      warrior.transform.position.y, y + transform.position.z), warrior.transform.rotation);
                    }

                    break;
                }

                case "2":
                {
                    if (grid[x, y] == null)
                    {
                        grid[x, y] = Instantiate(archer, new Vector3(x + transform.position.x,
                                                                     archer.transform.position.y, y + transform.position.z), archer.transform.rotation);
                    }

                    break;
                }

                case "3":
                {
                    if (grid[x, y] == null)
                    {
                        grid[x, y] = Instantiate(spearman, new Vector3(x + transform.position.x,
                                                                       spearman.transform.position.y, y + transform.position.z), spearman.transform.rotation);
                    }

                    break;
                }

                case "4":
                {
                    if (grid[x, y] == null)
                    {
                        grid[x, y] = Instantiate(shielder, new Vector3(x + transform.position.x,
                                                                       shielder.transform.position.y, y + transform.position.z), shielder.transform.rotation);
                    }

                    break;
                }

                case "5":
                {
                    if (grid[x, y] == null)
                    {
                        grid[x, y] = Instantiate(catapult, new Vector3(x + transform.position.x,
                                                                       catapult.transform.position.y, y + transform.position.z), catapult.transform.rotation);
                    }

                    break;
                }
                }
            }
        }
    }