예제 #1
0
    void SetAvailableSpawnpoints()
    {
        Pathfinding.BakePaths();
        availableSpawns = new List <EnemySpawnPoint>();

        for (int i = 0; i < Game.game.enemySpawnPoints.Count; i++)
        {
            EnemySpawnPoint sp = Game.game.enemySpawnPoints[i];
            Vector2         wp = Pathfinding.finder.WorldToNode(sp.worldPosition) + new Vector2(0.5f, 0.5f);
            int             x  = Mathf.RoundToInt(wp.x) - 1;
            int             y  = Mathf.RoundToInt(wp.y) - 1;

            if (Game.isWalled[x, y] == Game.WallType.None && sp.path != null)
            {
                availableSpawns.Add(sp);
                sp.blocked = false;
            }
            else
            {
                sp.blocked = true;
            }
        }

        // So many steps just to convert a single coordinate to rounded numbers..
    }
예제 #2
0
    public void SetSpawnIndicators()
    {
        foreach (GameObject i in currentIndicators)
        {
            Destroy(i);
        }

        currentIndicators.Clear();
        SetAvailableSpawnpoints();
        Pathfinding.BakePaths();

        for (int i = 0; i < Game.game.enemySpawnPoints.Count; i++)
        {
            EnemySpawnPoint point = Game.game.enemySpawnPoints[i];

            Vector3    next         = Game.game.GetVoidDirection(point.worldPosition);
            Quaternion rotation     = Quaternion.Euler(0f, 0f, Angle.CalculateAngle(point.worldPosition, next) + 180f);
            GameObject newIndicator = (GameObject)Instantiate(enemySpawnIndicator, point.worldPosition, rotation);

            currentIndicators.Add(newIndicator);
            SpriteRenderer sprite = newIndicator.GetComponentInChildren <SpriteRenderer> ();

            if (point.blocked)
            {
                sprite.color = Color.red;
            }
            else
            {
                sprite.color = Color.green;
            }
        }
    }