public void Dead(SkillEffect skill)
        {
            //TurnOnRagdoll ();
            int randomIndex = Random.Range(0, 2) + 1;

            if (isPlayerControl)
            {
                this.Animator.Play("Frank_Dead" + randomIndex.ToString(), 0, 0f);
            }
            else
            {
                if (this.CharacterData.IsGrappled && ((DirectDamage)skill).Type == GrapplerType.DownStab)
                {
                    this.Animator.Play("Ybot_Dead_Executed", 0, 0f);
                }
                else
                {
                    this.Animator.Play("Ybot_Dead" + randomIndex.ToString(), 0, 0f);
                }
            }
            this.CharacterData.Dead(this);
            data.IsDead = true;

            gameObject.layer = LayerMask.NameToLayer("Default");

            AIProgress agent = GetComponent <AIProgress> ();

            if (agent != null)
            {
                agent.Dead();
                AIAgentManager.Instance.TotalAIAgent.Remove(agent);
            }
        }
Ejemplo n.º 2
0
        public override void OnEnter(StatewithEffect stateEffect, Animator animator, AnimatorStateInfo animatorStateInfo)
        {
            AIProgress AI = stateEffect.CharacterControl.AIProgress;

            if (UseCrowdMethod)
            {
                RegisterInCrowdState(AI);
            }
        }
Ejemplo n.º 3
0
        public override void UpdateEffect(StatewithEffect stateEffect, Animator animator, AnimatorStateInfo stateInfo)
        {
            AIProgress AI = stateEffect.CharacterControl.AIProgress;

            if (AI.HitCountOnGuard >= TriggerHitCount)
            {
                stateEffect.CharacterControl.CharacterData.FirstFramesOfBlock = -FrameOffset;
                AI.HitCountOnGuard = 0;
            }
        }
Ejemplo n.º 4
0
 public void RegisterInCrowdState(AIProgress AI)
 {
     if (AI.IsInCrowd)
     {
         if (!AIAgentManager.Instance.CurrentAgentCrowd.Contains(AI))
         {
             AIAgentManager.Instance.CurrentAgentCrowd.Add(AI);
         }
     }
     else
     {
         if (AIAgentManager.Instance.CurrentAgentCrowd.Contains(AI))
         {
             AIAgentManager.Instance.CurrentAgentCrowd.Remove(AI);
         }
     }
 }
        public void Init()
        {
            animator    = GetComponentInChildren <Animator> ();
            detector    = GetComponentInChildren <TriggerDetector> ();
            controller  = GetComponent <CharacterController> ();
            aiProgress  = GetComponent <AIProgress> ();
            manualInput = GetComponent <ManualInput> ();

            ParticleSystemTag[] particleSystemTags = GetComponentsInChildren <ParticleSystemTag> ();
            foreach (ParticleSystemTag p in particleSystemTags)
            {
                if (p.tag == VFXType.Trail)
                {
                    particleSystemTrail = p.GetComponent <ParticleSystem> ();
                    particleSystemTrail.Pause(true);
                    particleSystemTrail.Clear();
                }
                else if (p.tag == VFXType.Hold)
                {
                    particleSystemHold = p.GetComponent <ParticleSystem> ();
                    particleSystemHold.Pause(true);
                    particleSystemHold.Clear();
                }
            }

            if (manualInput != null)
            {
                isPlayerControl = true;
            }
            else
            {
                isPlayerControl = false;
            }
            // load data process xxxx
            SetRagdollAndAttackingParts();
            //this.CharacterData.OnDead += Dead;
            //this.CharacterData.OnDamage += Dead;
            if (aiProgress != null)
            {
                aiProgress.enabled = false;
            }
            if (manualInput != null)
            {
                manualInput.enabled = false;
            }
        }
        public void GetStunned()
        {
            AIProgress agent = GetComponent <AIProgress> ();

            if (agent != null)
            {
                agent.StopMove();
                //AIAgentManager.Instance.TotalAIAgent.Remove (agent);
            }

            if (isPlayerControl)
            {
                this.Animator.Play("Stun", 0, 0f);
            }
            else
            {
                this.Animator.Play("Stun", 0, 0f);
                this.CharacterData.IsStunned = true;
                this.Animator.SetBool(TransitionParameter.Stunned.ToString(), true);
            }
            this.CharacterData.GetHitTime = 0f;
        }
Ejemplo n.º 7
0
        public override void OnEnter(StatewithEffect stateEffect, Animator animator, AnimatorStateInfo animatorStateInfo)
        {
            if (State == GuardState.Begin)
            {
                stateEffect.CharacterControl.CharacterData.FirstFramesOfBlock = InitBlockFrame;
                if (stateEffect.CharacterControl.isPlayerControl)
                {
                    VirtualInputManager.Instance.ClearAllInputsInBuffer();
                }
            }

            AIProgress AI = stateEffect.CharacterControl.AIProgress;

            if (AI != null)
            {
                AI.ResetInput();
            }
            stateEffect.CharacterControl.CharacterData.GetHitTime              = 0f;
            stateEffect.CharacterControl.CharacterData.IsGuarding              = true;
            stateEffect.CharacterControl.CharacterData.BlockCount              = MaxBlockAttackCount;
            stateEffect.CharacterControl.CharacterData.GuardDamageReduction    = GuardDamageReduction;
            stateEffect.CharacterControl.CharacterData.GuardKnockbackReduction = GuardKnockbackReduction;
            stateEffect.CharacterControl.CharacterData.GuardStunReduction      = GuardStunReduction;

            /*
             * if (State != GuardState.End) {
             *  stateEffect.CharacterControl.CharacterData.IsGuarding = false;
             * }
             *
             * else {
             *  stateEffect.CharacterControl.CharacterData.FirstFramesOfBlock = MaxBlockFrame;
             *  stateEffect.CharacterControl.CharacterData.BlockCount = 0f;
             *  animator.SetBool (TransitionParameter.Move.ToString (), false);
             * }
             */
        }
Ejemplo n.º 8
0
        public override void OnEnter(StatewithEffect stateEffect, Animator animator, AnimatorStateInfo animatorStateInfo)
        {
            AIProgress AI = stateEffect.CharacterControl.AIProgress;

            AI.HitCountOnGuard += 1;
        }
Ejemplo n.º 9
0
        public override void UpdateEffect(StatewithEffect stateEffect, Animator animator, AnimatorStateInfo stateInfo)
        {
            AIProgress AI = stateEffect.CharacterControl.AIProgress;

            if (!AI.enabled || AI.pathFindingAgent == null || AI.enemyTarget == null)
            {
                return;
            }
            if (AI.pathFindingAgent.IsStopped())
            {
                //AI.ResetInputVector ();
                return;
            }
            AI.pathFindingAgent.GoToTarget();

            if (AlwaysFaceTarget)
            {
                Vector3 direction = AI.enemyTarget.gameObject.transform.position - AI.gameObject.transform.position;
                direction.y = 0f;
                Quaternion rotation = Quaternion.LookRotation(direction, Vector3.up);
                animator.transform.root.rotation = Quaternion.Slerp(animator.transform.root.rotation, rotation, Time.deltaTime * Smooth);
            }

            if (UseCrowdMethod)
            {
                RegisterInCrowdState(AI);
            }

            if (AI.IsInCrowd)
            {
                AI.inputVectorIncremental = new Vector2();

                Vector2 avoidanceVector = new Vector2();
                foreach (AIProgress agent in AIAgentManager.Instance.CurrentAgentCrowd)
                {
                    if (AI == agent)
                    {
                        continue;
                    }
                    Vector3 avoidanceDir = AI.gameObject.transform.position - agent.gameObject.transform.position;
                    avoidanceDir.y = 0f;
                    if (avoidanceDir.magnitude < AvoidanceRadius)
                    {
                        float f = 1.0f - avoidanceDir.magnitude / AvoidanceRadius;
                        avoidanceVector += (new Vector2(avoidanceDir.x, avoidanceDir.z)).normalized * f * AvoidanceForce;
                    }
                }
                if (AIAgentManager.Instance.CurrentAgentCrowd.Count > 2)
                {
                    avoidanceVector = avoidanceVector / (AIAgentManager.Instance.CurrentAgentCrowd.Count - 1);
                }

                Vector2 keepoutVector = new Vector2();
                Vector3 keepoutDir    = AI.gameObject.transform.position - AI.enemyTarget.gameObject.transform.position;
                float   factor        = 0f;
                if (AI.IsInFear)
                {
                    if (keepoutDir.magnitude < FearKeepoutRadius)
                    {
                        factor        = 1.0f - keepoutDir.magnitude / FearKeepoutRadius;
                        keepoutVector = (new Vector2(keepoutDir.x, keepoutDir.z)).normalized * factor * FearKeepoutForce;
                    }
                }
                else
                {
                    if (keepoutDir.magnitude < KeepoutRadius)
                    {
                        factor        = 1.0f - keepoutDir.magnitude / KeepoutRadius;
                        keepoutVector = (new Vector2(keepoutDir.x, keepoutDir.z)).normalized * factor * KeepoutForce;
                    }
                }

                AI.inputVectorIncremental += avoidanceVector;
                AI.inputVectorIncremental += keepoutVector;
                // test
            }
            AI.SetInputVector();
        }
Ejemplo n.º 10
0
        public override void OnExit(StatewithEffect stateEffect, Animator animator, AnimatorStateInfo stateInfo)
        {
            AIProgress AI = stateEffect.CharacterControl.AIProgress;

            AI.inputVectorIncremental = new Vector2();
        }
Ejemplo n.º 11
0
        public override void OnEnter(StatewithEffect stateEffect, Animator animator, AnimatorStateInfo animatorStateInfo)
        {
            AIProgress aiAgent = stateEffect.CharacterControl.gameObject.GetComponent <AIProgress> ();

            aiAgent.TurnOnHighlight(HighlightFactor);
        }