Ejemplo n.º 1
0
 public override bool CollideIrreversible(CollisionArea myArea, CollisionArea theirArea)
 {
     if (!theirArea.Type.IsPhysical()) return false;
     if (theirArea.Owner.IsDamageable)
     {
         theirArea.Owner.InflictDamage(_impactDamage, new DamageInfo(this));
         DoDamageOverTime(theirArea.Owner);
         Game.Stats.SendHit(this, theirArea.Owner);
     }
     Die();
     return true;
 }
Ejemplo n.º 2
0
 public override bool CollideIrreversible(CollisionArea myArea, CollisionArea theirArea)
 {
     var theirShip = theirArea.Owner as Ship;
     if (myArea.Type == CollisionAreaType.BonusCollect && theirShip != null)
     {
         DoBonusAction(theirShip);
         Game.SoundEngine.PlaySound("BonusCollection", this);
         DeathGobTypes = _collectGobTypes;
         Die();
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
 public override bool CollideIrreversible(CollisionArea myArea, CollisionArea theirArea)
 {
     if (myArea.Name == "Magnet" || myArea.Name == "Spread") return false;
     if (!IsExplodable(theirArea)) return false;
     var hasHitSound = _hitSound != "";
     if (hasHitSound) Game.SoundEngine.PlaySound(_hitSound, this);
     var baseResult = base.CollideIrreversible(myArea, theirArea);
     return hasHitSound || baseResult;
 }
Ejemplo n.º 4
0
 public override bool CollideIrreversible(CollisionArea myArea, CollisionArea theirArea)
 {
     return theirArea.Owner.IsDamageable ? base.CollideIrreversible(myArea, theirArea) : false;
 }
Ejemplo n.º 5
0
 public override void Activate()
 {
     base.Activate();
     IsHiding = true;
     Body.LinearDamping = _movementDamping;
     Body.AngularDamping = _rotationDamping;
     _magnetArea = CollisionAreas.First(area => area.Name == "Magnet");
     _spreadArea = CollisionAreas.First(area => area.Name == "Spread");
     _potentialTargets = new HashSet<Gob>();
     _potentialTargetsUpdateTimer = new AWTimer(() => Arena.TotalTime, TimeSpan.FromSeconds(0.5));
     _potentialTargetsUpdateTimer.SetCurrentInterval(TimeSpan.Zero); // Do the first update immediately.
 }
Ejemplo n.º 6
0
 private void CauseDamage(CollisionArea theirArea)
 {
     Game.Stats.SendHit(this, theirArea.Owner);
     var damage = _inflictDamage.Evaluate(PhysicsHelper.Distance(theirArea, Pos));
     theirArea.Owner.InflictDamage(damage, new DamageInfo(this));
 }
Ejemplo n.º 7
0
 public override void Activate()
 {
     base.Activate();
     CreateDockEffects();
     _chargingSound = Game.SoundEngine.CreateSound("HomeBaseLoop", this);
     _dockSound = Game.SoundEngine.CreateSound("HomeBaseLoopLow", this);
     _dockArea = CollisionAreas.First(area => area.Name == "Dock");
 }
Ejemplo n.º 8
0
 public override bool CollideIrreversible(CollisionArea myArea, CollisionArea theirArea)
 {
     if (ActionGob != null) ActionGob.Act();
     return true;
 }
Ejemplo n.º 9
0
 public override void Deserialize(NetworkBinaryReader reader, SerializationModeFlags mode, int framesAgo)
 {
     base.Deserialize(reader, mode, framesAgo);
     if ((mode & SerializationModeFlags.ConstantDataFromServer) != 0)
     {
         ModelName = wallModelName = reader.ReadCanonicalString();
         int collisionAreaCount = reader.ReadByte();
         _collisionAreas = wallCollisionAreas = new CollisionArea[collisionAreaCount];
         for (int i = 0; i < collisionAreaCount; ++i)
         {
             wallCollisionAreas[i] = new CollisionArea();
             wallCollisionAreas[i].Deserialize(reader, SerializationModeFlags.AllFromServer, framesAgo);
         }
         foreach (var area in wallCollisionAreas) area.Owner = this;
     }
 }
Ejemplo n.º 10
0
 private bool IsExplodable(CollisionArea area)
 {
     if (IsFriend(area.Owner)) return false;
     if (!area.Owner.IsDamageable) return false;
     if (!area.Type.IsPhysical()) return false;
     if (area.Owner.MaxDamageLevel <= 100 && area.Owner.MoveType == GobUtils.MoveType.Dynamic) return false;
     return true;
 }
Ejemplo n.º 11
0
 public void Deactivate()
 {
     if (!IsActive) throw new ApplicationException("Cannot deactivate an inactive RadialFlow");
     _collisionArea.Destroy();
     _collisionArea = null;
 }
Ejemplo n.º 12
0
 private void InitializeCollisionAreas()
 {
     var newCollisionAreas = new CollisionArea[_collisionAreas.Length + _sliceCount];
     Array.Copy(_collisionAreas, newCollisionAreas, _collisionAreas.Length);
     for (int i = 0; i < _sliceCount; i++)
         newCollisionAreas[_collisionAreas.Length + i] = new CollisionArea("Cone",
             new Triangle(Vector2.Zero, Vector2.UnitX, Vector2.UnitY), this,
             CollisionAreaType.Damage, CollisionMaterialType.Regular);
     _collisionAreas = newCollisionAreas;
     foreach (var area in _collisionAreas) area.Disable();
 }
Ejemplo n.º 13
0
 private bool IsHittable(CollisionArea area)
 {
     return area.Type.IsPhysical() && area.Owner.IsDamageable && area.Owner != Host;
 }
Ejemplo n.º 14
0
 public void SetCollisionAreas(CollisionArea area1, CollisionArea area2)
 {
     _area1 = area1;
     _area2 = area2;
     var gob1 = area1.Owner;
     var gob2 = area2.Owner;
     if (gob1 == null || gob2 == null) throw new ArgumentNullException((gob1 == null ? "gob1" : "") + (gob2 == null ? " gob2" : ""));
     _gob1ID = gob1.ID;
     _gob2ID = gob2.ID;
     _area1ID = gob1.GetCollisionAreaID(area1);
     _area2ID = gob2.GetCollisionAreaID(area2);
 }
Ejemplo n.º 15
0
 private void CreateCollisionAreas()
 {
     #if !VERY_SMALL_TRIANGLES_ARE_COLLIDABLE
     var verySmallTriangles = _indexMap.GetVerySmallTriangles(); // sorted in increasing order
     #else
     var verySmallTriangles = new List<int>();
     #endif
     TriangleCount = _indexData.Length / 3 - verySmallTriangles.Count();
     _collisionAreas = new CollisionArea[_indexData.Length / 3];
     var smallTriangleEnumerator = verySmallTriangles.GetEnumerator();
     var smallTrianglesRemaining = smallTriangleEnumerator.MoveNext();
     for (int i = 0; i + 2 < _indexData.Length; i += 3)
     {
         if (smallTrianglesRemaining && smallTriangleEnumerator.Current == i / 3)
         {
             smallTrianglesRemaining = smallTriangleEnumerator.MoveNext();
             continue;
         }
         var v1 = _vertexData[_indexData[i + 0]];
         var v2 = _vertexData[_indexData[i + 1]];
         var v3 = _vertexData[_indexData[i + 2]];
         var triangleArea = new Triangle(v1.ProjectXY(), v2.ProjectXY(), v3.ProjectXY());
         _collisionAreas[i / 3] = new CollisionArea("General", triangleArea, this, CollisionAreaType.Static, CollisionMaterialType.Rough);
     }
 }
Ejemplo n.º 16
0
 public override int GetCollisionAreaID(CollisionArea area)
 {
     // Note: Walls are the only gobs to have over 4 collision areas; there can be hundreds of them.
     // To fit collision area IDs into as few bits as possible, walls will always collide with
     // their first collision area. This should not have a visible effect on game clients.
     return 0;
 }
Ejemplo n.º 17
0
 public override bool CollideIrreversible(CollisionArea myArea, CollisionArea theirArea)
 {
     if (!theirArea.Type.IsPhysical()) return false;
     if (theirArea.Owner.IsDamageable)
     {
         Game.Stats.SendHit(this, theirArea.Owner);
         theirArea.Owner.InflictDamage(_impactDamage, new DamageInfo(this));
     }
     Arena.MakeHole(Pos, _impactHoleRadius);
     Die();
     return true;
 }
Ejemplo n.º 18
0
 public void Activate(Gob radiator)
 {
     if (IsActive) throw new ApplicationException("Cannot activate an active RadialFlow");
     _radiator = radiator;
     _flowEndTime = Now + TimeSpan.FromSeconds(_flowTime);
     var areaArea = new Circle(Vector2.Zero, _flowSpeed.Keys.Last().Position) { Density = 0 };
     _collisionArea = new CollisionArea("Flow", areaArea, radiator,
         CollisionAreaType.Flow, CollisionMaterialType.Regular);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// This constructor is only for serialisation.
        /// </summary>
        public Peng()
        {
            _emitter = new SprayEmitter();
            _updater = new PhysicalUpdater();
            _coordinateSystem = CoordinateSystem.Game;
            _playerRelated = false;
            _disregardHidingLeader = false;
            _dieImmediatelyWithLeader = false;
            _visibilityRadius = 50;
            _particles = new List<Particle>();

            // Set better defaults than class Gob does.
            DrawMode2D = new DrawMode2D(DrawModeType2D.Transparent);
            MoveType = MoveType.Static;

            // Remove default collision areas set by class Gob so that we don't need to explicitly state
            // in each peng's XML definition that there are no collision areas.
            _collisionAreas = new CollisionArea[0];
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Invokes an action for all collision areas that overlap an area.
 /// </summary>
 /// <param name="action">If returns false, the query will exit.</param>
 /// <param name="preFilter">Filters potential overlappers. This delegate is supposed to be light.
 /// It is called before testing for precise overlapping which is a more costly operation. To return true
 /// if the candidate qualifies for more precise overlap testing.</param>
 public void QueryOverlappers(CollisionArea area, Func<CollisionArea, bool> action, Func<CollisionArea, bool> preFilter = null)
 {
     PhysicsHelper.QueryOverlappers(_world, area, action, preFilter);
 }