private void Update() { var temp = CheckObstacleForward(); if (temp.Length != 0) { Obstacles.Clear(); Obstacles.AddRange(temp); SetState(bypassObstacleState); } else if (!currentState.IsFinished) { currentState.Run(); } else { if (TargetFood != null) { SetState(moveToFoodState); } else { SetState(findFoodState); } } }
private void OnPlayerTookShowel(object sender, EventArgs e) { DestroyHQFence(); var concreteFence = CreateConcreteHQFence(); SubscribeObstacles(concreteFence); foreach (var obstacle in concreteFence) { foreach (var playerTank in PlayersManager.Tanks) { playerTank.CheckPosition += obstacle.GetCheckPositionListener(); } foreach (var compTank in CompsManager.Tanks) { compTank.CheckPosition += obstacle.GetCheckPositionListener(); } } Obstacles.AddRange(concreteFence); _showelDelayTimer.Stop(); _showelDelayTimer.Start(); }
private void OnShowelDelayTimerTick(object sender, EventArgs e) { _showelDelayTimer.Stop(); DestroyHQFence(); var brickFence = CreateBrickHQFence(); SubscribeObstacles(brickFence); foreach (var obstacle in brickFence) { foreach (var playerTank in PlayersManager.Tanks) { playerTank.CheckPosition += obstacle.GetCheckPositionListener(); } foreach (var compTank in CompsManager.Tanks) { compTank.CheckPosition += obstacle.GetCheckPositionListener(); } } Obstacles.AddRange(brickFence); }
public void AddObstacles(IEnumerable <Obstacle> obstacle) { if (Obstacles.Any(x => obstacle.Any(x.OverlapsWith))) { throw new Exception("Przeszkoda nakłada się na już istniejącą przeszkodę."); } Obstacles.AddRange(obstacle); GeneratePathfindingMap(); GenerateWalkableMap(); }