Exemple #1
0
    private void LightGenerate(Room room, int[,] collideGrid)
    {
        for (int y = 0; y < room.Height; y++)
        {
            for (int x = 0; x < room.Width; x++)
            {
                if (collideGrid[y, x] != 3)
                {
                    continue;
                }

                int[,] neighbours = GridMath.GetNeighbours(collideGrid, new Vector2Int(x, y), 0);

                // if empty below
                if (neighbours[2, 1] == 0)
                {
                    if (Roll.Chance(5))
                    {
                        Vector3 worldLocation = new Vector3(x - Mathf.FloorToInt(room.Width / 2) + 0.5f, y - Mathf.FloorToInt(room.Height / 2) + 0.5f, 0f);

                        GameObject torch = Instantiate(_torchPrefab, worldLocation, Quaternion.identity);
                        torch.transform.parent = room.LightContainer;
                    }
                }
            }
        }
    }
Exemple #2
0
    private Tile SelectRandomGrassTile()
    {
        Tile selectedTile = Grass[0];

        // roll for shrub
        if (Roll.Chance(30))
        {
            selectedTile = Grass[(int)UnityEngine.Random.Range(4, 7)];

            // roll shrub for flower
            if (Roll.Chance(8))
            {
                selectedTile = Grass[(int)UnityEngine.Random.Range(1, 4)];
            }
        }

        return(selectedTile);
    }
Exemple #3
0
 private void WallsGenerateInner(Room room, int[,] collideGrid, int conversionThreshold = 33)
 {
     for (int y = 0; y < room.Height; y++)
     {
         for (int x = 0; x < room.Width; x++)
         {
             if (y == 1 | x == 1 | y == (room.Height - 2) | x == (room.Width - 2))
             {
                 if (collideGrid[y, x] == 0)
                 {
                     if (Roll.Chance(conversionThreshold))
                     {
                         collideGrid[y, x] = 2;
                     }
                 }
             }
         }
     }
 }
    private void DoMovePattern()
    {
        // FOLLOW PLAYER
        if (MovePattern == MovementPattern.FollowPlayer)
        {
            _moveWait = false;
            _animator.SetBool("MoveWait", false);

            if (_hopInAir)
            {
                return;
            }

            SetDestination();
            SetDirection();
        }

        // RANDOM LOCATION
        else if (MovePattern == MovementPattern.RandomLocation)
        {
            if (_moveWait)
            {
                return;
            }

            CheckArrived();

            if (_destArrived | _dest == null | _direction == Vector2.zero)
            {
                SetDestination();

                if (Roll.Chance(_chanceToMoveWait))
                {
                    StartCoroutine("MoveWait", Random.Range(0f, 2f));
                }
            }

            SetDirection();
        }
    }