Beispiel #1
0
    public List <GameObject> PopulateMonsters(int number)
    {
        MapSquare         highestOpen      = firstSquare;
        List <GameObject> monsterList      = new List <GameObject> ();
        List <MapSquare>  monsterPlacement = new List <MapSquare> ();

        foreach (MapSquare square in openSquares)
        {
            monsterPlacement.Add(square);
        }

        for (int i = 0; i < number; i++)
        {
            //find the most open square that doesn't already have a monster


            int highest = 0;

            foreach (MapSquare square in monsterPlacement)
            {
                if (square.distanceFromWall > highest)
                {
                    if (square.hasMonster == 0)
                    {
                        highest     = square.distanceFromWall;
                        highestOpen = square;
                    }
                }
            }
            for (int x = -2; x <= 2; x++)
            {
                for (int y = -2; y <= 2; y++)
                {
                    mapGrid [highestOpen.x + x, highestOpen.y + y].hasMonster = 1;
                }
            }
            float roll = UnityEngine.Random.Range(0, 1f);
            if (roll > .5f)
            {
                Rockman newRockman = Instantiate(rockman, CoordsToWorldPosition(highestOpen.x, highestOpen.y), Quaternion.identity) as Rockman;
                monsterList.Add(newRockman.gameObject);
            }
            else
            {
                Mudman newMudman = Instantiate(mudman, CoordsToWorldPosition(highestOpen.x, highestOpen.y), Quaternion.identity) as Mudman;
                monsterList.Add(newMudman.gameObject);
            }
        }

        return(monsterList);
    }
Beispiel #2
0
 public void SetOwner(Mudman monster)
 {
     owner = monster;
 }