Exemplo n.º 1
0
    void SpawnFiremen()
    {
        if ((_lastSpawnTime - Time.realtimeSinceStartup) >= _firemenSpawnSecondsInterval)
        {
            var mapSize = Game.GetMapSize();

            // Determine board edge
            int     boardEdge     = Random.Range(1, 5);
            Vector2 spawnLocation = Vector2.zero;
            switch (boardEdge)
            {
            case 1:
                spawnLocation = new Vector2(0, Random.Range(0, mapSize.y));
                break;

            case 2:
                spawnLocation = new Vector2(mapSize.x - 1, Random.Range(0, mapSize.y));
                break;

            case 3:
                spawnLocation = new Vector2(Random.Range(0, mapSize.x), 0);
                break;

            case 4:
                spawnLocation = new Vector2(Random.Range(0, mapSize.x), mapSize.y - 1);
                break;
            }
            EntityManager.CreateWatchman(spawnLocation);
            _lastSpawnTime = Time.realtimeSinceStartup;
        }
    }
Exemplo n.º 2
0
    public void GenerateGoblins()
    {
        var mapSize = Game.GetMapSize();

        for (int i = 0; i < 2; i++)
        {
            var x = Random.Range(0, mapSize.x - 1);
            var y = Random.Range(0, mapSize.y - 1);
            EntityManager.CreateGoblin(new Vector2(x, y));
        }
    }
Exemplo n.º 3
0
    public List <Vector2> getLegalMoves(Vector2 currentPosition)
    {
        List <Vector2> legalMoves = new List <Vector2> ();
        var            mapSize    = Game.GetMapSize();

        if (currentPosition.x != 0)
        {
            legalMoves.Add(new Vector2(currentPosition.x - 1, currentPosition.y));
        }
        if (currentPosition.x != mapSize.x - 1)
        {
            legalMoves.Add(new Vector2(currentPosition.x + 1, currentPosition.y));
        }
        if (currentPosition.y != 0)
        {
            legalMoves.Add(new Vector2(currentPosition.x, currentPosition.y - 1));
        }
        if (currentPosition.y != mapSize.y - 1)
        {
            legalMoves.Add(new Vector2(currentPosition.x, currentPosition.y + 1));
        }

        return(legalMoves);
    }