Ejemplo n.º 1
0
    public virtual bool Hit(int inDamage, GameObject Attacker, float HitMove, bool bSturn, EHitAniType HitAniType)
    {
        if (curState == EState.Die)
        {
            return(false);
        }

        if (bSuperArmor)
        {
            return(false);
        }

        if (curState == EState.Defence)
        {
            if (bParringEnable)
            {
                ParringEffect();
                ReservedParringType = EReservedParringType.Start;
            }
            return(false);
        }

        curHealthPoint -= inDamage;

        if (curHealthPoint <= 0.0f)
        {
            AllStopAni();
            CDieAni ani = gameObject.GetComponentInChildren <CDieAni>();
            ani.PlayAni();
            curState = EState.Die;

            //CDieEffect Effect = new CDieEffect();
            //Effect.Init(Time.fixedTime, 1.0f, gameObject);
            //Effects.Add(Effect);
            //Invoke("DestroyCharacter", 1.0f);

            CircleCollider2D collider = gameObject.GetComponent <CircleCollider2D>();
            collider.isTrigger = false;

            Stop();
        }
        else
        {
            if (bSturn)
            {
                AllStopAni();
                CSturnAni ani = gameObject.GetComponentInChildren <CSturnAni>();
                ani.PlayAni();
                curState = EState.Sturn;
            }
            else if (curState == EState.Idle)
            {
                AllStopAni();
                CBaseAni ani = null;
                if (EHitAniType.Type1 == HitAniType)
                {
                    ani = gameObject.GetComponentInChildren <CHitAni>();
                }
                else if (EHitAniType.Type2 == HitAniType)
                {
                    ani = gameObject.GetComponentInChildren <CHit2Ani>();
                }
                else
                {
                    ani = gameObject.GetComponentInChildren <CHit3Ani>();
                }
                ani.PlayAni();
                curState = EState.Hit;
            }

            CHitEffect hitEffect = new CHitEffect();
            hitEffect.Init(Time.fixedTime, 1.0f, gameObject);
            Effects.Add(hitEffect);

            float   DiffPosX = gameObject.transform.position.x - Attacker.transform.position.x;
            Vector3 GoalPos  = 0 <= DiffPosX ? new Vector3(HitMove, 0.0f, 0.0f) : new Vector3(-HitMove, 0.0f, 0.0f);
            GoalPos = gameObject.transform.position + GoalPos;
            Move(gameObject.transform.position, GoalPos, true);
        }
        return(true);
    }
Ejemplo n.º 2
0
    public override bool Hit(int inDamage, GameObject Attacker, float HitMove, bool bSturn, EHitAniType HitAniType)
    {
        CDebugLog.Log(ELogType.Character, "Hit EnemyCharacter");

        bool bHit = base.Hit(inDamage, Attacker, HitMove, bSturn, HitAniType);

        if (bHit)
        {
            if (curState == EState.Die)
            {
                SoundMgr.PlaySound("Die2", ESoundType.Motion);
            }
            else
            {
                SoundMgr.PlaySound("Digital_Sword", ESoundType.Motion);
            }
        }

        return(bHit);
    }