Exemple #1
0
 private void RemovePlane(CrazyPlane cp)
 {
     if (cp.Pilot != null)
     {
         cp.Pilot.Delete();
     }
     if (cp.Blip != null)
     {
         cp.Blip.Remove();
     }
     if (cp.Vehicle != null)
     {
         cp.Vehicle.Delete();
     }
 }
Exemple #2
0
        private void OnTick(object sender, EventArgs e)
        {
            var player = Game.Player.Character;

            if (!mEnabled)
            {
                return;
            }

            int i = 0;

            while (i < mPlanes.Count)
            {
                var pl = mPlanes[i];
                if (pl.Vehicle == null || pl.Vehicle.IsDead)
                {
                    if (pl.Pilot != null)
                    {
                        pl.Pilot.Delete();
                    }
                    if (pl.Blip != null)
                    {
                        pl.Blip.Remove();
                    }
                    if (pl.Vehicle != null)
                    {
                        pl.Vehicle.MarkAsNoLongerNeeded();
                        //pl.Vehicle.Delete();
                    }
                    mPlanes.Remove(pl);
                    continue;
                }
                if (pl.Pilot == null)
                {
                    var ped = pl.Vehicle.CreatePedOnSeat(VehicleSeat.Driver, new Model(PedHash.Jesus01));
                    ped.Task.FightAgainst(player);
                    //var blip = ped.AddBlip();
                    //blip.SetAsHostile();
                    pl.Pilot = ped;
                    //pl.Blip = blip;
                }
                i++;
            }

            FireRockets();

            if (mPlanes.Count < 30)
            {
                var spawnPos = player.Position + Vector3.RandomXYZ() * 500f;
                spawnPos.Z = player.Position.Z + 300f;

                var plane = World.CreateVehicle(new Model(RandomPlane()), spawnPos);
                if (plane == null)
                {
                    return;
                }
                plane.EngineRunning = true;
                plane.ApplyForceRelative(Vector3.RelativeFront * 10f);

                var cp = new CrazyPlane()
                {
                    Vehicle   = plane,
                    SpawnTime = Game.GameTime
                };
                mPlanes.Add(cp);
            }
        }