示例#1
0
        private ISnakeSegment GenerateRandomSegment()
        {
            var position = _gameField
                           .GetRandomCell()
                           .Bounds
                           .Center
                           .ToVector2();
            var direction = DirectionHelper.GetRandom();
            var size      = new Size2(_gameSettings.TileSize, _gameSettings.TileSize);

            return(new SnakeSegment(position, size, direction));
        }
示例#2
0
    protected override void WhenDestroyed()
    {
        base.WhenDestroyed();
        Direction        firstDir = DirectionHelper.GetRandom();
        List <Direction> dirs     = new List <Direction>()
        {
            Direction.Down, Direction.Left, Direction.Right, Direction.Up
        }
        .Where(dir => dir != firstDir)
        .Where(dir => CheckTileIsNormal(pos.GetVector2i() + dir.ToVector2i())).ToList();
        Direction secondDir = Direction.None;

        if (dirs.Any())
        {
            secondDir = dirs.GetRandom();
        }

        SpawnMonster("ZacBaby", pos.X, pos.Y, firstDir);
        SpawnMonster("ZacBaby", pos.X, pos.Y, secondDir);

        /*
         *      if (CheckTileIsNormal (pos.X + 2, pos.Y) && CheckTileIsNormal (pos.X - 2, pos.Y))
         *      {
         *              SpawnMonster ("ZacBaby", pos.X + 2, pos.Y);
         *              SpawnMonster ("ZacBaby", pos.X - 2, pos.Y);
         *      }
         *      else if (CheckTileIsNormal (pos.X, pos.Y - 2) && CheckTileIsNormal (pos.X, pos.Y + 2))
         *      {
         *              SpawnMonster ("ZacBaby", pos.X, pos.Y - 2);
         *              SpawnMonster ("ZacBaby", pos.X, pos.Y + 2);
         *      }
         *      else if (CheckTileIsNormal (pos.X + 2, pos.Y) && CheckTileIsNormal (pos.X, pos.Y + 2))
         *      {
         *              SpawnMonster ("ZacBaby", pos.X + 2, pos.Y);
         *              SpawnMonster ("ZacBaby", pos.X, pos.Y + 2);
         *      }
         *      else if (CheckTileIsNormal (pos.X - 2, pos.Y) && CheckTileIsNormal (pos.X, pos.Y - 2))
         *      {
         *              SpawnMonster ("ZacBaby", pos.X - 2, pos.Y);
         *              SpawnMonster ("ZacBaby", pos.X, pos.Y - 2);
         *      }
         */
    }
示例#3
0
 public static MoveAction GetRandom()
 {
     return(new MoveAction(DirectionHelper.GetRandom()));
 }