Inheritance: FBLibrary.Core.BaseEntities.BaseBomb
Example #1
0
        public void ChangeDirection(Bomb bomb)
        {
            Point nextPosition = bomb.CellPosition;
            switch (_lookDirection)
            {
                case LookDirection.Up:
                    nextPosition.Y--;
                    break;
                case LookDirection.Down:
                    nextPosition.Y++;
                    break;
                case LookDirection.Left:
                    nextPosition.X--;
                    break;
                case LookDirection.Right:
                    nextPosition.X++;
                    break;
            }

            if (
                !FinalBomber.Instance.GamePlayScreen.World.Levels[FinalBomber.Instance.GamePlayScreen.World.CurrentLevel
                    ].
                    CollisionLayer[nextPosition.X, nextPosition.Y])
            {
                bomb.ChangeDirection(_lookDirection, -1);
                //bomb.ChangeSpeed(bomb.Speed + Config.BombSpeedIncrementeur);
                bomb.ResetTimer();
            }
        }
Example #2
0
        public void GameServer_PlacingBomb(int clientId, Point position)
        {
            Client client = GameServer.Instance.Clients.GetClientById(clientId);

            if (client != null)
            {
                if (client.Player != null)
                {
                    var bomb = new Bomb(clientId, position, client.Player.BombPower, client.Player.BombTimer, client.Player.Speed);
                    client.Player.CurrentBombAmount--;

                    bomb.Initialize(GameServer.Instance.GameManager.CurrentMap.Size,
                        GameServer.Instance.GameManager.CurrentMap.CollisionLayer,
                        GameServer.Instance.GameManager.HazardMap);

                    GameServer.Instance.GameManager.AddBomb(bomb);
                }
                else
                {
                    throw new Exception("This player doesn't exist ! (clientId: " + clientId + ")");
                }
            }
            else
            {
                throw new Exception("This client doesn't exist ! (clientId: " + clientId + ")");
            }
        }
Example #3
0
        public void AddBomb(Bomb bomb)
        {
            BombList.Add(bomb);

            base.AddBomb(bomb);
        }
Example #4
0
        private void RemoveBomb(Bomb bomb)
        {
            BombList.Remove(bomb);

            base.RemoveBomb(bomb);
        }
Example #5
0
        protected override void Move(GameTime gameTime, Map map, int[,] hazardMap)
        {
            #region Walk

            // If he hasn't reach his goal => we walk to this goal
            if (_aiNextPosition != new Vector2(-1, -1) &&
                !AIFunction.HasReachNextPosition(Position, Speed, _aiNextPosition))
            {
                IsMoving = true;
                Sprite.IsAnimating = true;

                CheckIsBlocked(map, hazardMap);

                Walk();

                ComputeWallCollision(map);
            }

            #endregion

            #region Search a goal
            // Otherwise => we find another goal
            else
            {
                // We place the player at the center of its cell
                Position = Engine.CellToVector(CellPosition);

                #region Bomb => AI

                // Try to put a bomb
                // Put a bomb
                if (!HasBadEffect || (HasBadEffect && BadEffect != BadEffect.NoBomb))
                {
                    if (AIFunction.TryToPutBomb(CellPosition, BombPower, map.Board, map.CollisionLayer, hazardMap,
                        Config.MapSize))
                    {
                        if (CurrentBombAmount > 0)
                        {
                            Bomb bo =
                                FinalBomber.Instance.GamePlayScreen.BombList.Find(
                                    b => b.CellPosition == CellPosition);
                            if (bo == null)
                            {
                                CurrentBombAmount--;
                                var bomb = new Bomb(Id, CellPosition, BombPower, BombTimer, Speed);

                                // We define a new way (to escape the bomb)
                                Path = AIFunction.MakeAWay(
                                    CellPosition,
                                    AIFunction.SetNewDefenseGoal(CellPosition, map.CollisionLayer, hazardMap,
                                        Config.MapSize),
                                    map.CollisionLayer, hazardMap, Config.MapSize);

                                FinalBomber.Instance.GamePlayScreen.AddBomb(bomb);
                            }
                        }
                    }
                }

                #endregion

                if (Path == null || Path.Count == 0)
                {
                    Sprite.IsAnimating = false;
                    IsMoving = false;
                    // We define a new goal
                    Path = AIFunction.MakeAWay(
                        CellPosition,
                        AIFunction.SetNewGoal(CellPosition, map.Board, map.CollisionLayer, hazardMap,
                            Config.MapSize),
                        map.CollisionLayer, hazardMap, Config.MapSize);

                    if (Path != null)
                    {
                        _aiNextPosition = Engine.CellToVector(Path[Path.Count - 1]);
                        Path.Remove(Path[Path.Count - 1]);

                        CheckIsBlocked(map, hazardMap);
                    }
                }
                else
                {
                    // We finish the current way
                    _aiNextPosition = Engine.CellToVector(Path[Path.Count - 1]);
                    Path.Remove(Path[Path.Count - 1]);
                    /*
                    // Update the way of the AI each time it changes of cell => usefull to battle against players (little bug here)
                    aiWay = AI.MakeAWay(
                        CellPosition,
                        AI.SetNewGoal(CellPosition, map.Board, map.CollisionLayer, hazardMap),
                        map.CollisionLayer, hazardMap);
                    */
                }
            }

            #endregion

            UpdatePlayerPosition(map);
        }
Example #6
0
        public void AddBomb(Bomb bomb)
        {
            if (World.Levels[FinalBomber.Instance.GamePlayScreen.World.CurrentLevel].
                            Board[bomb.CellPositionX, bomb.CellPositionY] is Player)
            {
                World.Levels[FinalBomber.Instance.GamePlayScreen.World.CurrentLevel].
                    Board[bomb.CellPosition.X, bomb.CellPosition.Y] = bomb;
                World.Levels[FinalBomber.Instance.GamePlayScreen.World.CurrentLevel].
                CollisionLayer[bomb.CellPosition.X, bomb.CellPosition.Y] = true;
            }

            BombList.Add(bomb);
        }