Ejemplo n.º 1
0
 public virtual void On_Suffer(WarMsgParam param)
 {
     STATE = NpcAnimState.Suffer;
     ResetActiveAnimState();
     OnSwitchRun(false);
     OnSwitchAnimatorLayerWeight(1, 0);
     animator.SetBool("isSuffer", true);
     animator.CrossFade("Suffer", 0f);
 }
Ejemplo n.º 2
0
 public virtual void On_Run(WarMsgParam param)
 {
     if (STATE != NpcAnimState.Killed)
     {
         STATE      = NpcAnimState.Run;
         SetHandler = RunHandle;
         OnSwitchRun(true);
         OnSwitchAnimatorLayerWeight(1, 1);
         StopAllCoroutines();
     }
 }
Ejemplo n.º 3
0
        IEnumerator CheckToSkill(WarMsgParam param)
        {
            val = 0f;
            while (cachedNpc.DisFromNextPos > 0.6f)
            {
                yield return(null);

                val -= 0.2f;
                if (val >= 0f && val <= 1f)
                {
                    animator.SetLayerWeight(1, val);
                }
            }
            OnSwitchRun(false);
            OnSwitchAnimatorLayerWeight(1, 0);

            STATE      = NpcAnimState.CastSkill;
            SetHandler = SkillHandle;
            string      m_str = param.param as string;
            NpcAnimInfo info  = JSON.Instance.ToObject <NpcAnimInfo>(m_str);

            if (info != null)
            {
                AnimationMsg msg = JSON.Instance.ToObject <AnimationMsg>(info.data);
                curMsg = msg;
                int index = msg.index;
                if (!string.IsNullOrEmpty(msg.animationName) && msg.animationName != "[]")
                {
                    animator.CrossFade(msg.animationName, 0.1f);
                }
                animationTimer      = msg.animationTimer - 0.02f;
                animationEventTimer = msg.animationEventTimer;
                canTriggerEvent     = true;
                if (index == 0)
                {
                    animator.SetBool("isSkill_1", true);
                    CreateEffect(NpcAnimEffect.Skill_1_Start);
                }
                else if (index == 1)
                {
                    animator.SetBool("isSkill_2", true);
                    CreateEffect(NpcAnimEffect.Skill_2_Start);
                }
                else if (index == 2)
                {
                    animator.SetBool("isSkill_3", true);
                    CreateEffect(NpcAnimEffect.Skill_3_Start);
                }
            }
        }
Ejemplo n.º 4
0
        public virtual void On_Stand(WarMsgParam param)
        {
            if (STATE == NpcAnimState.Suffer)
            {
                animator.SetBool("isSuffer", false);
            }
            if (STATE != NpcAnimState.Killed && STATE != NpcAnimState.Stand)
            {
                isAnimating = false;
                STATE       = NpcAnimState.Stand;
                SetHandler  = StandHandle;
                ResetActiveAnimState();
//                StopCoroutine("OnSwitchRun");
//                StartCoroutine(OnSwitchRun(false, true));
                StopAllCoroutines();
                StartCoroutine(CheckToStand());
            }
        }
Ejemplo n.º 5
0
 public virtual void On_Respawn(WarMsgParam param)
 {
     STATE      = NpcAnimState.Respawn;
     SetHandler = RespawnHandle;
     if (health != null)
     {
         health.value = 1f;
         if (isHero)
         {
             health.gameObject.SetActive(true);
         }
     }
     if (heroHealth != null)
     {
         heroHealth.value = 1f;
     }
     healthPoint = totalPoint;
     animator.SetBool("isDead", false);
 }
Ejemplo n.º 6
0
 public virtual void On_Killed(WarMsgParam param)
 {
     ClearUIObj();
     STATE = NpcAnimState.Killed;
     if (health != null)
     {
         health.value = 0f;
         health.gameObject.SetActive(false);
     }
     if (heroHealth != null)
     {
         heroHealth.value = 0f;
     }
     OnSwitchRun(false);
     OnSwitchAnimatorLayerWeight(1, 0);
     SetHandler = KilledHandle;
     animator.CrossFade("Die", 0f);
     animator.SetBool("isSuffer", false);
     animator.SetBool("isDead", true);
     animator.SetBool("isIdle", false);
     isAnimating = false;
 }
Ejemplo n.º 7
0
 public virtual void On_Idle(WarMsgParam param)
 {
     STATE = NpcAnimState.Idle;
     animator.SetBool("isIdle", true);
     animator.CrossFade("Idle", 0f);
 }
Ejemplo n.º 8
0
        IEnumerator CheckForAttack(WarMsgParam param)
        {
            val = 0f;
            if (cachedNpc.movable)
            {
                while (cachedNpc.DisFromNextPos > 0.6f)
                {
                    yield return(null);

                    val -= 0.2f;
                    if (val >= 0f && val <= 1f)
                    {
                        animator.SetLayerWeight(1, val);
                    }
                }
            }
            else
            {
                yield return(null);
            }

            OnSwitchRun(false);
            OnSwitchAnimatorLayerWeight(1, 0);

            STATE       = NpcAnimState.Attack;
            SetHandler  = AttackHandle;
            isAnimating = true;
            string      m_str = param.param as string;
            NpcAnimInfo info  = JSON.Instance.ToObject <NpcAnimInfo>(m_str);

            if (info != null)
            {
                AnimationMsg msg = JSON.Instance.ToObject <AnimationMsg>(info.data);
                if (msg != null)
                {
                    curMsg = msg;
                    int index = msg.index;
                    if (index < AttackCount)
                    {
                        if (!string.IsNullOrEmpty(msg.animationName) && msg.animationName != "[]")
                        {
                            animator.CrossFade(msg.animationName, 0.1f);
                        }
                        animationTimer      = msg.animationTimer - 0.02f;
                        animationEventTimer = msg.animationEventTimer;
                        canTriggerEvent     = true;
                        if (index == 0)
                        {
                            CreateEffect(NpcAnimEffect.Attack_1_Start);
                        }
                        else if (index == 1)
                        {
                            CreateEffect(NpcAnimEffect.Attack_2_Start);
                        }
                        else if (index == 2)
                        {
                            CreateEffect(NpcAnimEffect.Attack_3_Start);
                        }
                    }
                }
            }
        }