Beispiel #1
0
        public override void OnTakeDamage(DamageInfo info)
        {
            if (this.m_IsDead)
            {
                return;
            }
            GameObject damager = info.m_Damager;

            if (damager != null && damager.IsPlayer())
            {
                this.ReplRequestOwnership(false);
            }
            base.OnTakeDamage(info);
            if (!AI.IsTurtle(this.m_AI.m_ID))
            {
                this.DecreaseHealth(info.m_Damage);
                if (this.m_Health > 0f)
                {
                    if (this.CanPunchBack())
                    {
                        this.m_AI.m_GoalsModule.ActivateGoal(AIGoalType.PunchBack);
                    }
                    else if (this.m_AI.m_GoalsModule.m_ActiveGoal == null || this.m_AI.m_GoalsModule.m_ActiveGoal.m_Type != AIGoalType.Hide)
                    {
                        this.m_AI.m_GoalsModule.ActivateGoal(AIGoalType.ReactOnHit);
                    }
                    if (AI.IsSnake(this.m_AI.m_ID) && info.m_Damager.IsPlayer() && FistFightController.Get().IsActive())
                    {
                        int         num      = UnityEngine.Random.Range(0, 2);
                        AnimEventID event_id = AnimEventID.GiveDamageLLeg;
                        if (num == 1)
                        {
                            event_id = AnimEventID.GiveDamageRLeg;
                        }
                        Vector3 world_hit_dir = this.m_AI.transform.TransformVector(DamageModule.GetHitDirLocal(event_id));
                        this.m_AI.m_DamageModule.GivePlayerDamage(world_hit_dir);
                        this.m_AI.m_SnakeSoundModule.PlayAttackSound();
                    }
                }
                return;
            }
            if (this.m_AI.m_GoalsModule.m_ActiveGoal == null || this.m_AI.m_GoalsModule.m_ActiveGoal.m_Type != AIGoalType.Hide)
            {
                this.m_AI.m_GoalsModule.ActivateGoal(AIGoalType.Hide);
                return;
            }
            if (this.m_AI.m_GoalsModule.m_ActiveGoal.m_Type == AIGoalType.Hide)
            {
                this.m_AI.m_GoalsModule.m_ActiveGoal.ResetDuration();
            }
        }
 public override void OnAnimEvent(AnimEventID id)
 {
     base.OnAnimEvent(id);
     if (this.m_AI.m_HealthModule && this.m_AI.m_HealthModule.m_IsDead)
     {
         return;
     }
     if (id == AnimEventID.GiveDamage || id == AnimEventID.GiveDamageLArm || id == AnimEventID.GiveDamageRArm || id == AnimEventID.GiveDamageLLeg || id == AnimEventID.GiveDamageRLeg)
     {
         if (this.m_BlockDamage)
         {
             this.m_BlockDamage = false;
             return;
         }
         Vector3 world_hit_dir = this.m_AI.transform.TransformVector(DamageModule.GetHitDirLocal(id));
         if (!this.GivePlayerDamage(world_hit_dir))
         {
             this.GiveConstructionDamage();
         }
     }
 }