Example #1
0
        protected override void CheckCollisionWithUserPlane()
        {
            Plane p = refToLevel.UserPlane;

            if (p != null)
            {
                if (boundRectangle.Intersects(p.Bounds))
                {
                    if (Owner is Soldier)
                    {
                        p.Hit(p.MaxOil * 0.1f, 0); // trafienie przez bazooke
                    }
                    else
                    if (Owner is ShipConcreteBunkerTile)
                    {
                        p.Hit(p.MaxOil * 0.1f, 0); // trafienie przez bazooke
                    }
                    else
                    {
                        p.Hit(p.MaxOil * 0.5f, 0);
                        //  if(p.Oil <= 0)
                        //  {
                        // trafienie przez rakiete samolotowa
                        // refToLevel.Controller.OnPlaneDestroyed(p); //odrejestruje samolot gracza.
                        // p.Destroy();
                        //  }
                    }

                    refToLevel.Controller.OnRocketHitPlane(this, p);
                    //odrejestruje rakiete.
                    Destroy();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Funkcja sprawdza czy samolot bedzie mogl trafic rakieta w inny obiekt.
        /// </summary>
        /// <param name="plane">Samolot strzelajacy.</param>
        /// <param name="enemyPlane">Samolot, ktory chemy trafic.</param>
        /// <returns>Zwraca true jesli moze trafic wrogi samolot; false - w przeciwnym
        /// przypadku.</returns>
        /// <author>Michal Ziober</author>
        public static CollisionDirectionLocation CanHitEnemyPlane(Plane plane, Plane enemyPlane, float tolerance, bool biDirectional)
        {
            if (!biDirectional)
            {
                if (plane.Direction == Direction.Right && plane.Center.X > enemyPlane.Center.X)
                {
                    return(CollisionDirectionLocation.NONE);
                }

                if (plane.Direction == Direction.Left && plane.Center.X < enemyPlane.Center.X)
                {
                    return(CollisionDirectionLocation.NONE);
                }
            }

            if (System.Math.Abs(plane.Center.X - enemyPlane.Center.X) < 10 &&
                System.Math.Abs(plane.Center.Y - enemyPlane.Center.Y) < 10)
            {
                return(CollisionDirectionLocation.NONE);
            }

            if (System.Math.Abs((plane.Center - enemyPlane.Center).EuclidesLength) > ViewRange)
            {
                return(CollisionDirectionLocation.NONE);
            }

            Quadrangle planeQuad = new Quadrangle(plane.Bounds.Peaks);

            planeQuad.Move(0, -HeightShift);
            Line lineA = new Line(planeQuad.Peaks[1], planeQuad.Peaks[2]);

            for (int i = 0; i < enemyPlane.Bounds.Peaks.Count - 1; i++)
            {
                PointD start = enemyPlane.Bounds.Peaks[i];
                start += new PointD(Math.RangeRandom(-tolerance * 0.5f, -tolerance * 0.5f), Math.RangeRandom(-tolerance * 0.5f, -tolerance * 0.5f));

                PointD finish = enemyPlane.Bounds.Peaks[i + 1];
                finish += new PointD(Math.RangeRandom(-tolerance * 0.5f, -tolerance * 0.5f), Math.RangeRandom(-tolerance * 0.5f, -tolerance * 0.5f));

                Line lineB = new Line(start, finish);



                PointD cut = lineA.Intersect(lineB);
                if (cut == null)
                {
                    continue;
                }

                if ((enemyPlane.Center - cut).EuclidesLength < HitShift)
                {
                    //ViewHelper.AttachCross(plane.Level.Controller.GetFramework().SceneMgr, cut, 10);
                    //return true;

                    return((plane.Direction == Direction.Right && plane.Center.X > enemyPlane.Center.X || plane.Direction == Direction.Left && plane.Center.X < enemyPlane.Center.X) ? CollisionDirectionLocation.BACKWARD : CollisionDirectionLocation.FORWARD);
                }
            }

            return(CollisionDirectionLocation.NONE);
        }
Example #3
0
 /// <summary>
 /// Publiczny konstruktor dwuparametrowy.
 /// </summary>
 /// <param name="refLevel">Referncja do planszy.</param>
 /// <param name="owner">Wlasciciel broni.</param>
 public WeaponManager(LevelRef refLevel, Plane owner)
     : this(refLevel,
            owner,
            owner.GetConsts().RocketCount,
            owner.GetConsts().BombCount, owner.GetConsts().TorpedoCount)
 {
 }
Example #4
0
 public EnemyFighterView(Plane plane, IFrameWork frameWork, SceneNode parentNode)
     : base(plane, frameWork, parentNode, "EnemyFighter" + enemyPlaneCounter.ToString())
 {
     //nazwa musi byc unikalnym stringiem
     enemyPlaneCounter++;
     random = new Random();
     if (LevelView.IsNightScene)
     {
         InitLight(innerNode, new ColourValue(0.1f, 0.9f, 0.1f), new Vector3(9.1f, 0.05f, -1.9f),
                   new Vector2(2.0f, 2.0f));
         InitLight(innerNode, new ColourValue(0.1f, 0.9f, 0.1f), new Vector3(-9.1f, 0.05f, -1.9f),
                   new Vector2(2.0f, 2.0f));
     }
 }
Example #5
0
        public EnemyBomberView(Plane plane, IFrameWork frameWork, SceneNode parentNode)
            : base(plane, frameWork, parentNode, "EnemyBomber" + enemyBomberCounter.ToString())
        {
            //nazwa musi byc unikalnym stringiem
            enemyBomberCounter++;
            random = new Random();
            if (LevelView.IsNightScene)
            {
                InitLight(innerNode, new ColourValue(0.1f, 0.9f, 0.1f), new Vector3(15.1f, 1.25f, -2.9f),
                          new Vector2(2.0f, 2.0f));
                InitLight(innerNode, new ColourValue(0.1f, 0.9f, 0.1f), new Vector3(-15.1f, 1.25f, -2.9f),
                          new Vector2(2.0f, 2.0f));
            }

            animationMgr[PlaneNodeAnimationManager.AnimationType.IDLE].Duration *= 2.0f;
        }
Example #6
0
        protected override void CheckCollisionWithUserPlane()
        {
            Wof.Model.Level.Planes.Plane p = refToLevel.UserPlane;
            if (p != null)
            {
                float damage = GetDamage(p);

                if (damage > 0)
                {
                    refToLevel.Controller.OnGunHitPlane(refToLevel.UserPlane);
                    refToLevel.UserPlane.Hit(damage, 0);

                    //powiadamia controler o trafieniu.

                    Destroy();
                }
            }
        }
 public void OnPlaneEnterRestoreAmmunitionTile(Plane plane)
 {
 }
 public void OnFlakFire(FlakBunkerTile bunker, Plane plane, Wof.Model.Level.Common.PointD pos, bool hit)
 {
 }
 public void OnReleasePlane(Plane plane, EndAircraftCarrierTile carrierTile)
 {
     levelView.OnReleasePlane(plane, carrierTile);
     currentLevel.OnReleaseLine(carrierTile);
 }
Example #10
0
 public F4UPlaneView(Plane plane, IFrameWork frameWork, SceneNode parentNode)
     : base(plane, frameWork, parentNode)
 {
     bodyMaterialName          = "F4U1FUSD";
     destroyedBodyMaterialName = "F4U1FUSDDestroyed";
 }
Example #11
0
 public static CollisionDirectionLocation CanHitEnemyPlane(Plane plane, Plane enemyPlane, bool biDirectional)
 {
     return(CanHitEnemyPlane(plane, enemyPlane, 0, biDirectional));
 }
Example #12
0
 public P47PlaneView(Plane plane, IFrameWork frameWork, SceneNode parentNode)
     : base(plane, frameWork, parentNode)
 {
     StartSmokeTrails();
     StopSmokeTrails();
 }
Example #13
0
 public void OnPrepareChangeDirection(Direction newDirection, Plane plane, TurnType turnType)
 {
     levelView.OnPrepareChangeDirection(newDirection, plane, turnType);
 }
Example #14
0
 public void OnEnemyPlaneBombed(Plane plane, Ammunition ammunition)
 {
 }
Example #15
0
 public void OnEngineRepaired(Plane p)
 {
 }
Example #16
0
 public void OnEngineFaulty(Plane p)
 {
 }
Example #17
0
 public void OnTurnOnEngine(bool engineStartSound, Plane userPlane)
 {
 }
Example #18
0
 public void OnTurnOffEngine(Plane p)
 {
 }
Example #19
0
 public void OnPlaneWrecked(Plane Plane)
 {
     currentLevel.NextLife();
     levelView.NextLife();
 }
Example #20
0
 public void OnPlaneLeaveRestoreAmmunitionTile(Plane plane)
 {
 }
Example #21
0
        public void UpdateFuelAndOilState(float timeSinceLastFrame)
        {
            Plane p = gameScreen.CurrentLevel.UserPlane;
            //  infoElement.Caption = "Oil: " + (int) (p.Oil) + ", leak:"+p.OilLeak;
            float var, oil, fuel;

            // fuel
            fuel = p.Petrol / p.MaxPetrol;
            lastFuelIndicatorDither += timeSinceLastFrame;
            if (lastFuelIndicatorDither > 0.04)// 50ms
            {
                if (p.IsEngineWorking)
                {
                    var = (0.7f * p.AirscrewSpeed / 1300.0f) * (random.Next(-1, 2) / 100.0f);
                }
                else
                {
                    var = 0;
                }
                if (fuel > 1.01f)
                {
                    fuel = 1.0f;
                }
                if (fuel < -0.01f)
                {
                    fuel = 0.0f;
                }
                fuel += var;
                lastFuelIndicatorDither = 0;
            }

            RefreshFuel(fuel);

            bool fuelLedOn = fuel < 0.2f;

            if (lastFuelLedOn != fuelLedOn)
            {
                if (fuelLedOn)
                {
                    ViewHelper.ReplaceMaterial(hud, "Panels/Panel2", "Panels/Panel2_on");
                }
                else
                {
                    ViewHelper.ReplaceMaterial(hud, "Panels/Panel2_on", "Panels/Panel2");
                }
                lastFuelLedOn = fuelLedOn;
            }



            // oil
            oil = p.Oil / p.MaxOil;
            lastOilIndicatorDither += timeSinceLastFrame;
            if (lastOilIndicatorDither > 0.04) // 50ms
            {
                if (p.IsEngineWorking)
                {
                    var = (0.7f * p.AirscrewSpeed / 1300.0f) * (random.Next(-1, 2) / 100.0f);
                }
                else
                {
                    var = 0;
                }
                oil += var;
                if (oil > 1.01f)
                {
                    oil = 1.0f;
                }
                if (oil < -0.01f)
                {
                    oil = 0.0f;
                }

                lastOilIndicatorDither = 0;
            }
            RefreshOil(oil);



            bool oilLedOn = oil < 0.2f;

            if (lastOilLedOn != oilLedOn)
            {
                if (oilLedOn)
                {
                    ViewHelper.ReplaceMaterial(hud, "Panels/Panel4", "Panels/Panel4_on");
                }
                else
                {
                    ViewHelper.ReplaceMaterial(hud, "Panels/Panel4_on", "Panels/Panel4");
                }
                lastOilLedOn = oilLedOn;
            }
        }
Example #22
0
 public void OnSpinBegin(Plane plane)
 {
     levelView.OnBeginSpin(plane);
 }
Example #23
0
 public void OnWarCry(Plane plane)
 {
 }
Example #24
0
 public void OnPotentialBadLanding(Plane p)
 {
 }
Example #25
0
 public void OnPlaneDestroyed(Plane plane)
 {
     levelView.OnPlaneDestroyed(plane);
 }
Example #26
0
 public void OnRocketHitPlane(Rocket rocket, Plane plane)
 {
 }
Example #27
0
 public void OnPlaneCrashed(Plane plane, TileKind tileKind)
 {
     levelView.OnPlaneCrashed(plane, tileKind);
 }
Example #28
0
 public void OnBunkerFire(BunkerTile bunker, Plane plane, bool planeHit)
 {
 }
Example #29
0
 public void OnSecondaryFireOnCarrier(Plane userPlane)
 {
 }
Example #30
0
 public void OnCatchPlane(Plane plane, EndAircraftCarrierTile carrierTile)
 {
     levelView.OnCatchPlane(plane, carrierTile);
 }