コード例 #1
0
    IEnumerator GetRandomObstacle() // find the obstacle to use
    {
        ObstacleToUse = new ObstacleKind();

        int random = Random.Range(0, 5 + 1);

        switch (random)
        {
        case 0:
            ObstacleToUse = ObstacleKind.arrow;
            break;

        case 1:
            ObstacleToUse = ObstacleKind.square;
            break;

        case 2:
            ObstacleToUse = ObstacleKind.circle;
            break;

        case 3:
            ObstacleToUse = ObstacleKind.rotator;
            break;

        case 4:
            ObstacleToUse = ObstacleKind.stick;
            break;

        case 5:
            ObstacleToUse = ObstacleKind.longs;
            break;
        }
        yield return(null);
    }
コード例 #2
0
ファイル: Board.cs プロジェクト: mjamaleddine/LightItUp
        internal List <Obstacle> GetObstacleList()
        {
            List <Obstacle> result = new List <Obstacle>();

            for (int row = 0; row < _Obstacles.GetLength(0); row++)
            {
                for (int column = 0; column < _Obstacles.GetLength(1); column++)
                {
                    ObstacleKind curObstacle = _Obstacles[row, column];
                    if (curObstacle != ObstacleKind.None)
                    {
                        result.Add(new Obstacle(column, row, curObstacle));
                    }
                }
            }

            return(result);
        }
コード例 #3
0
        public Board Generate()
        {
            int    obstacleCount = _BoardSettings.ObstacleCount;
            Random rnd           = new Random();

            List <Obstacle> obstacleList = new List <Obstacle>();

            for (int i = 0; i < obstacleCount; i++)
            {
                int column = 0;
                int row    = 0;
                do
                {
                    column = rnd.Next(_BoardSettings.Columns);
                    row    = rnd.Next(_BoardSettings.Rows);
                } while (obstacleList.Any(cur => cur.Column == column && cur.Row == row));

                ObstacleKind kind = ObstacleKind.Wall;
                obstacleList.Add(new Obstacle(column, row, kind));
            }

            ObstacleKind[,] obstacles = new ObstacleKind[_BoardSettings.Rows, _BoardSettings.Columns];
            for (int row = 0; row < _BoardSettings.Rows; row++)
            {
                for (int column = 0; column < _BoardSettings.Columns; column++)
                {
                    var obstacle = obstacleList.FirstOrDefault(cur => cur.Column == column && cur.Row == row);
                    if (obstacle != null)
                    {
                        obstacles[row, column] = obstacle.Kind;
                    }
                }
            }

            return(new Board(obstacles));
        }
コード例 #4
0
 public Obstacle(int row, int column, ObstacleKind kind)
 {
     Column = column;
     Row    = row;
     Kind   = kind;
 }
コード例 #5
0
ファイル: Events.cs プロジェクト: Selech/MiniGameProduction2
 public DamageCarriableEvent(ObstacleKind obstacleType)
 {
     this.obstacleType = obstacleType;
 }