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(); } } }
/// <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); }
/// <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) { }
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)); } }
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; }
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); }
public F4UPlaneView(Plane plane, IFrameWork frameWork, SceneNode parentNode) : base(plane, frameWork, parentNode) { bodyMaterialName = "F4U1FUSD"; destroyedBodyMaterialName = "F4U1FUSDDestroyed"; }
public static CollisionDirectionLocation CanHitEnemyPlane(Plane plane, Plane enemyPlane, bool biDirectional) { return(CanHitEnemyPlane(plane, enemyPlane, 0, biDirectional)); }
public P47PlaneView(Plane plane, IFrameWork frameWork, SceneNode parentNode) : base(plane, frameWork, parentNode) { StartSmokeTrails(); StopSmokeTrails(); }
public void OnPrepareChangeDirection(Direction newDirection, Plane plane, TurnType turnType) { levelView.OnPrepareChangeDirection(newDirection, plane, turnType); }
public void OnEnemyPlaneBombed(Plane plane, Ammunition ammunition) { }
public void OnEngineRepaired(Plane p) { }
public void OnEngineFaulty(Plane p) { }
public void OnTurnOnEngine(bool engineStartSound, Plane userPlane) { }
public void OnTurnOffEngine(Plane p) { }
public void OnPlaneWrecked(Plane Plane) { currentLevel.NextLife(); levelView.NextLife(); }
public void OnPlaneLeaveRestoreAmmunitionTile(Plane plane) { }
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; } }
public void OnSpinBegin(Plane plane) { levelView.OnBeginSpin(plane); }
public void OnWarCry(Plane plane) { }
public void OnPotentialBadLanding(Plane p) { }
public void OnPlaneDestroyed(Plane plane) { levelView.OnPlaneDestroyed(plane); }
public void OnRocketHitPlane(Rocket rocket, Plane plane) { }
public void OnPlaneCrashed(Plane plane, TileKind tileKind) { levelView.OnPlaneCrashed(plane, tileKind); }
public void OnBunkerFire(BunkerTile bunker, Plane plane, bool planeHit) { }
public void OnSecondaryFireOnCarrier(Plane userPlane) { }
public void OnCatchPlane(Plane plane, EndAircraftCarrierTile carrierTile) { levelView.OnCatchPlane(plane, carrierTile); }