internal void ExecuteOrders(float dt, CCPoint position, float rotation, bool decayOnly = false)
 {
     // advance the cloud tail lifecycle
     if (CloudTailNode != null)
     {
         CloudTailNode.Advance(dt, position, rotation, decayOnly);
     }
 }
 internal ManeuverAbility(float powerMin, float powerMax, float rotationBonusMin = 0, float rotationBonusMax = 0)
 {
     PowerMax         = powerMax;
     PowerMin         = powerMin;
     RotationBonusMax = rotationBonusMax;
     RotationBonusMin = rotationBonusMin;
     if (PowerMax > 0)
     {
         CloudTailNode = new CloudTailNode();
     }
 }
Ejemplo n.º 3
0
        public override void Update(float dt)
        {
            base.Update(dt);
            switch (State)
            {
            case GameState.PLANNING:
                break;

            case GameState.EXECUTING_ORDERS:
            {
                TimeLeftExecutingOrders -= dt;
                if (Aircraft.CloudFrameCountdown != 0)
                {
                    Aircraft.CloudFrameCountdown--;
                }
                else
                {
                    Aircraft.CloudFrameCountdown = Aircraft.CLOUD_FRAME_COUNTDOWN;
                }
                if (powerUpCheckCountDown != 0)
                {
                    powerUpCheckCountDown--;
                }
                else
                {
                    powerUpCheckCountDown = PU_CHECK_COUNTDOWN;
                    // check if any powerup is close enough to be picked up
                    foreach (var aircraft in PlayerAircrafts)
                    {
                        if (aircraft.MyState == Aircraft.State.SHOT_DOWN)
                        {
                            continue;
                        }
                        CCPoint aPos = aircraft.Position;
                        foreach (var powerUp in PowerUps)
                        {
                            // only pick up power-ups that are close in x-y but also in z direction
                            if (powerUp.VertexZ > -10f && CCPoint.Distance(powerUp.Position, aPos) < PowerUp.PICKUP_DISTANCE)
                            {
                                // pick up the powerup
                                if (!PopUp.TriggeredPowerUp)
                                {
                                    PopUp.ShowPopUp(GUILayer, PopUp.Enum.TRIGGERED_POWERUP);
                                }
                                powerUp.StartPickupAnimation();
                                aircraft.ChangePowerUpCount(powerUp.Power, 1);
                                PowerUps.Remove(powerUp);
                                break;
                            }
                        }
                    }
                }
                // DEBUG: Console.WriteLine("EXECUTING ORDERS; dt: " + dt);
                // go through all aircrafts and let them execute their orders
                List <Aircraft> aircraftToBeRemoved = new List <Aircraft>();
                // first the enemies (organized into squadrons)
                foreach (var aircraft in ActiveAircrafts)
                {
                    aircraft.ExecuteOrders(dt);
                    if (aircraft.ToBeRemoved)
                    {
                        aircraftToBeRemoved.Add(aircraft);
                    }
                }
                // then the player aircrafts
                foreach (var aircraft in PlayerAircrafts)
                {
                    aircraft.ExecuteOrders(dt);
                    if (aircraft.ToBeRemoved)
                    {
                        aircraftToBeRemoved.Add(aircraft);
                    }
                }
                // remove aircrafts that have to be removed
                foreach (var aircraft in aircraftToBeRemoved)
                {
                    if (!aircraft.ControlledByPlayer)
                    {
                        // add a powerup
                        if ((new Random()).Next(3) < 2)
                        {
                            var powerUp = aircraft.GeneratePowerUp();
                            if (powerUp != null)
                            {
                                powerUp.Position = aircraft.Position;
                                AddPowerUp(powerUp);
                            }
                        }
                    }
                    // add an explosion
                    var cloudNode = new CloudTailNode();
                    cloudNode.AddCloud(new CircleCloud(aircraft.Position, 0, CCColor4B.White, true, aircraft.ContentSize.Width * 16, 6f));
                    ExplosionNodes.Add(cloudNode);

                    // if the aircraft is not completely made up of scrap parts add it to the salvageable wrecks
                    foreach (var part in aircraft.TotalParts)
                    {
                        if (!(part is BodyScrap) && !(part is DoubleWingScrap) && !(part is RotorScrap) && !(part is RudderScrap) && !(part is WeaponScrap))
                        {
                            DownedAircrafts.Add(aircraft);
                            break;
                        }
                    }
                    RemoveAircraft(aircraft);
                }
                // go through all projectiles and let them advance
                // check whether a projectile needs to be removed
                List <Projectile> projectilesToBeRemoved = new List <Projectile>();
                foreach (var projectile in Projectiles)
                {
                    projectile.Advance(dt);
                    if (projectile.CanBeRemoved())
                    {
                        projectilesToBeRemoved.Add(projectile);
                    }
                }
                // go through all clouds that are directly bounds to you
                List <CloudTailNode> cloudsToBeRemoved = new List <CloudTailNode>();
                foreach (var cloudNode in ExplosionNodes)
                {
                    cloudNode.Advance(dt);
                    if (!cloudNode.HasClouds())
                    {
                        cloudsToBeRemoved.Add(cloudNode);
                    }
                }
                foreach (var cloudNode in cloudsToBeRemoved)
                {
                    ExplosionNodes.Remove(cloudNode);
                }
                UpdateDrawNodes();
                if (TimeLeftExecutingOrders <= 0)
                {
                    StartPlanningPhase();
                }
            }
            break;
            }
        }