public override void OnCollison(IMessage<MessageType> msg, GameTime gameTime) { CollisionDetectedMsg message = msg as CollisionDetectedMsg; if (msg == null) throw new Exception("B_IceBulletLogicBehavior: message is not CollisionDetectedMsg"); ObjectEntity zom = message.TargetCollision as ObjectEntity; // Send message change to if (zom != null && zom.ObjectType == eObjectType.ZOMBIE) { LogicComponent logicCOm = zom.GetComponent(typeof(LogicComponent)) as LogicComponent; if (logicCOm == null) throw new Exception("B_IceBulletLogicBehavior: Expect Target Logic Component"); logicCOm.Health -= _damage; SlowMoveEffect slowEff = new SlowMoveEffect(); slowEff.TimeDurring = TimeSpan.FromSeconds(2); logicCOm.LogicBehavior.AddEffect(slowEff); PZObjectManager.Instance.RemoveObject(Owner.Owner.ObjectId); } base.OnCollison(msg, gameTime); }
public override void OnCollison(IMessage<MessageType> msg, GameTime gameTime) { CollisionDetectedMsg message = msg as CollisionDetectedMsg; if (msg == null) throw new Exception("B_IceBulletLogicBehavior: message is not CollisionDetectedMsg"); ObjectEntity zom = message.TargetCollision as ObjectEntity; // Send message change to if (zom != null && zom.ObjectType == eObjectType.ZOMBIE) { LogicComponent logicCOm = zom.GetComponent(typeof(LogicComponent)) as LogicComponent; if (logicCOm == null) throw new Exception("B_IceBulletLogicBehavior: Expect Target Logic Component"); logicCOm.Health -= _damage; SlowMoveEffect slowEff = new SlowMoveEffect(); slowEff.TimeDurring = TimeSpan.FromSeconds(2); logicCOm.LogicBehavior.AddEffect(slowEff); PZObjectManager.Instance.RemoveObject(Owner.Owner.ObjectId); justCollect = true; } // Sound if (justCollect) { if (gameTime.TotalGameTime - _lastTimeSound > _timeDelaySound) { SCSServices.Instance.AudioManager.PlaySound(_sound, false, true); _lastTimeSound = gameTime.TotalGameTime; } } justCollect = false; // base.OnCollison(msg, gameTime); }