Esempio n. 1
0
 public override void OnTakeDamage(DamageInfo info)
 {
     if (this.m_IsDead)
     {
         return;
     }
     base.OnTakeDamage(info);
     this.DecreaseHealth(info.m_Damage);
     if (this.m_Health == 0f)
     {
         this.Die();
     }
     else
     {
         if (this.CanPunchBack())
         {
             this.m_AI.m_GoalsModule.ActivateGoal(AIGoalType.PunchBack);
         }
         else
         {
             this.m_AI.m_GoalsModule.ActivateGoal(AIGoalType.ReactOnHit);
         }
         if (AI.IsSnake(this.m_AI.m_ID) && info.m_Damager == Player.Get().gameObject&& FistFightController.Get().IsActive())
         {
             this.m_AI.m_DamageModule.GivePlayerDamage();
             this.m_AI.m_SnakeSoundModule.PlayAttackSound();
         }
     }
 }
Esempio n. 2
0
        protected override void Prepare()
        {
            base.Prepare();
            if (!AI.IsSnake(this.m_AI.m_ID))
            {
                this.m_AI.m_PathModule.CalcPath(PathModule.PathType.MoveToEnemy);
                base.AddToPlan(this.m_Attack);
            }
            else
            {
                base.StartAction(this.m_Attack);
            }
            float num  = this.m_AI.m_EnemyModule.m_Enemy.m_LFoot.position.Distance(this.m_AI.transform.position);
            float num2 = this.m_AI.m_EnemyModule.m_Enemy.m_RFoot.position.Distance(this.m_AI.transform.position);

            if (num < num2)
            {
                this.m_Target = this.m_AI.m_EnemyModule.m_Enemy.m_LFoot.gameObject;
            }
            else
            {
                this.m_Target = this.m_AI.m_EnemyModule.m_Enemy.m_RFoot.gameObject;
            }
            if (!AI.IsSnake(this.m_AI.m_ID))
            {
                this.m_AI.m_AnimationModule.SetForcedSpeed(10f);
            }
        }
Esempio n. 3
0
        public bool GivePlayerDamage()
        {
            bool  result = false;
            float num    = (!Player.Get()) ? float.MaxValue : Player.Get().transform.position.Distance(this.m_AI.transform.position);
            float num2   = this.m_AI.m_Params.m_AttackRange;

            if (AI.IsSnake(this.m_AI.m_ID))
            {
                num2 *= 1.5f;
            }
            if (num <= num2)
            {
                Vector3    hit_dir    = Player.Get().transform.position + Vector3.up * Player.Get().GetComponent <CharacterController>().height * 0.5f - this.m_AI.transform.position;
                float      damage     = this.m_AI.m_Params.m_Damage;
                DamageType damageType = this.m_AI.m_Params.m_DamageType;
                HumanAI    humanAI    = (!this.m_AI.IsHuman()) ? null : ((HumanAI)this.m_AI);
                if (humanAI)
                {
                    Weapon weapon = (Weapon)humanAI.m_CurrentWeapon;
                    if (weapon)
                    {
                        damage     = ((WeaponInfo)weapon.m_Info).m_PlayerDamage;
                        damageType = weapon.GetDamageType();
                    }
                }
                float num3         = UnityEngine.Random.Range(0f, 1f);
                bool  critical_hit = num3 < 0.05f * (PlayerConditionModule.Get().GetHP() / PlayerConditionModule.Get().GetMaxHP());
                Player.Get().GiveDamage(base.gameObject, null, damage, hit_dir, damageType, this.m_AI.m_Params.m_PoisonLevel, critical_hit);
                result = true;
            }
            this.m_AI.m_GoalsModule.m_ActiveGoal.m_WasDamage = true;
            return(result);
        }
Esempio n. 4
0
 public override AIMoveStyle GetWantedMoveStyle()
 {
     if (AI.IsSnake(this.m_AI.m_ID))
     {
         return(AIMoveStyle.None);
     }
     return(base.GetWantedMoveStyle());
 }
Esempio n. 5
0
        private void UpdateRotation()
        {
            if (!AI.IsSnake(this.m_AI.m_ID))
            {
                return;
            }
            Vector3 normalized = (this.m_Target.transform.position - this.m_AI.transform.position).normalized;
            Vector3 upwards    = this.m_AI.m_EnemyModule.m_Enemy ? this.m_AI.m_EnemyModule.m_Enemy.transform.up : Vector3.up;

            this.m_AI.transform.rotation = Quaternion.Slerp(this.m_AI.transform.rotation, Quaternion.LookRotation(normalized, upwards), Time.deltaTime / 0.1f);
        }
Esempio n. 6
0
 private void UpdatePosition()
 {
     if (AI.IsSnake(this.m_AI.m_ID))
     {
         return;
     }
     if (this.m_Target.transform.position.Distance(this.m_AI.transform.position) > this.m_AI.m_Radius)
     {
         Vector3 normalized = (this.m_Target.transform.position - this.m_AI.transform.position).normalized;
         Vector3 position   = this.m_AI.transform.position + normalized * Time.deltaTime;
         this.m_AI.transform.position = position;
     }
 }
Esempio n. 7
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();
            }
        }
Esempio n. 8
0
        public bool GivePlayerDamage(Vector3 world_hit_dir)
        {
            bool  result = false;
            float num    = Player.Get() ? Player.Get().transform.position.Distance(this.m_AI.transform.position) : float.MaxValue;
            float num2   = this.m_AI.m_Params.m_AttackRange;

            if (AI.IsSnake(this.m_AI.m_ID))
            {
                num2 *= 1.5f;
            }
            if (this.m_AI.m_ID == AI.AIID.BlackCaiman)
            {
                num = Player.Get().transform.position.Distance(this.m_AI.GetHeadTransform().position);
                if (!this.m_AI.IsSwimming() && (this.m_AI.GetHeadTransform().position.y < Player.Get().transform.position.y - 1f || this.m_AI.GetHeadTransform().position.y > Player.Get().GetHeadTransform().position.y + 0.75f))
                {
                    if (this.m_AI.m_GoalsModule.m_ActiveGoal != null)
                    {
                        this.m_AI.m_GoalsModule.m_ActiveGoal.m_WasDamage = true;
                    }
                    return(result);
                }
            }
            if (num <= num2 || this.m_AI.m_ID == AI.AIID.BrasilianWanderingSpider)
            {
                float      damage     = this.m_AI.m_Params.m_Damage;
                DamageType damageType = this.m_AI.m_Params.m_DamageType;
                HumanAI    humanAI    = this.m_AI.IsHuman() ? ((HumanAI)this.m_AI) : null;
                if (humanAI)
                {
                    Weapon weapon = (Weapon)humanAI.m_CurrentWeapon;
                    if (weapon)
                    {
                        damage     = ((WeaponInfo)weapon.m_Info).m_PlayerDamage;
                        damageType = weapon.GetDamageType();
                    }
                }
                bool critical_hit = UnityEngine.Random.Range(0f, 1f) < 0.05f * (PlayerConditionModule.Get().GetHP() / PlayerConditionModule.Get().GetMaxHP());
                Player.Get().GiveDamage(base.gameObject, null, damage, this.m_AI.IsHumanAI() ? UnityEngine.Random.insideUnitSphere : world_hit_dir, damageType, this.m_AI.m_Params.m_PoisonLevel, critical_hit);
                result = true;
            }
            if (this.m_AI.m_GoalsModule.m_ActiveGoal != null)
            {
                this.m_AI.m_GoalsModule.m_ActiveGoal.m_WasDamage = true;
            }
            return(result);
        }