Exemplo n.º 1
0
    private void GenerateEnvironment()
    {
        //go over all the tiles on the board
        for (int i = 0; i < (int)worldSize.x; i++)
        {
            for (int j = 0; j < (int)worldSize.y; j++)
            {
                // Spawn plant
                Vector3 spawnCoordinates = (Vector3)PlayGrid.getGridCoordinates(new Vector2(i, j));
                //determine if a plant should be instantiated
                if (Random.Range(0f, 1f) < plantDensity)
                {
                    spawnVegitation(spawnCoordinates);
                    //Instantiate(plant, spawnCoordinates, Quaternion.identity);
                }
                else if (Random.Range(0f, 1f) < NPCreatureDensity)
                {
                    spawnNPCreature(spawnCoordinates, -1);
                    //Instantiate(NPCreature, spawnCoordinates, Quaternion.Euler(0f, 0f, Random.Range(-180f, 180f)));
                }
            }
        }

        //spawn the player creatures
        GameObject player1 = Instantiate(playerCreature, (Vector3)PlayGrid.getGridCoordinates(new Vector2(30, 10)), Quaternion.identity);

        player1.GetComponent <PlayCreature>().Birth(1, new Vector2(30, 10), false);
    }
Exemplo n.º 2
0
 private void stepForward(Vector2 directionVector)
 {
     TargetUnitPosition = UnitPosition + directionVector;
     if (!PlayGrid.checkIfOutOfBounds(TargetUnitPosition))
     {
         // Take a step forward (update current NPCreature position)
         gameObject.GetComponent <Transform>().position = PlayGrid.getGridCoordinates(TargetUnitPosition);
     }
     else
     {
         // flip direction vector
         gameObject.transform.Rotate(0, 0, 180);
     }
 }
Exemplo n.º 3
0
    private void Reproduce()
    {
        int     i = Mathf.RoundToInt(Random.Range(1f, PlayGrid.PlayFieldSize.x - 1));
        int     j = Mathf.RoundToInt(Random.Range(1f, PlayGrid.PlayFieldSize.x - 1));
        Vector3 spawnCoordinates = (Vector3)PlayGrid.getGridCoordinates(new Vector2(i, j));

        board.spawnNPCreature(spawnCoordinates, 0);
        if (outputStats)
        {
            Debug.Log("NPCreatures reproduced");
        }
        //Debug.Log("NPCreatures created a child at [" + i + "," + j + "]");

        children++;
    }