Example #1
0
        public void StopAttackEffect()
        {
            if (effect != null)
            {
                VfxPooling.Release(Type, effect);

                targetAgent = null;
                effect      = null;
            }
        }
Example #2
0
        private void CheckAttack()
        {
            if (!string.IsNullOrEmpty(UnitInfo.Attack_Unit_ID) &&
                UnitInfo.Attack_Unit_ID.ToLower() != "null")
            {
                string[] strs    = UnitInfo.Attack_Unit_ID.Split('_');
                int      otherID = int.Parse(strs[3]);

                AgentRemote other = AgentRemoteManager.GetAgentRemote(otherID);
                targetAgent = other;

                if (other != null && !IsMoving())
                {
                    transform.forward = (other.transform.position - transform.position).normalized;
                    Animator.Play(AnimState.Attack1);

                    AttackTarget = other.transform;
                    if (effect == null)
                    {
                        Debugger.Log("call attack effect");
                        effect = VfxPooling.GetItem(Type);
                        effect.transform.position = transform.position;

                        effect?.Attack(AttackTarget);
                    }
                    else
                    {
                        effect.Attack(AttackTarget);
                    }
                }
            }
            else
            {
                AnimatorController.StateInfo attackState = Animator.GetStateInfo(AnimState.Attack1);
                if (attackState != null && attackState.IsPlaying)
                {
                    attackState.Stop();
                    StopAttackEffect();
                }
            }
        }