Exemple #1
0
    private void Awake()
    {
        srcInBattleUnit = this.GetComponent <InBattleUnit>();

        InBattleUnit.evtAttackEvent += Attacking;

        Debug.Log("ActionEventSpine Awake");
    }
Exemple #2
0
    public void HitBuff(InBattleUnit other)
    {
        int heal        = other.data.AttackFactor;
        int calculation = Mathf.Clamp((data.TotalHitPoints - data.HitPoints), 0, heal);

        data.HitPoints += calculation;

        HealAnimation(calculation);

        //---

        DamageText dt = DamageTextPool.Instance.GetDamageText();

        Vector3 pos = this.transform.position;

        pos.y += 200;
        dt.SetDamageText(pos, calculation, false, false, Color.green);

        Debug.Log("a");
    }
Exemple #3
0
    private IEnumerator MoveJerk(InBattleUnit other, Vector3 position)
    {
        yield return(new WaitForSeconds(1.0f));

        if (PlayerNumber == 0)
        {
            yield return(new WaitForSeconds(1.3f));
        }

        if (unitType == UnitType.Spear || unitType == UnitType.Sword || unitType == UnitType.Axe)
        {
            spine.SetAnimation("03_move");
            iTween.MoveTo(this.gameObject, iTween.Hash("x", position.x, "islocal", true, "time", 0.5f));
            yield return(new WaitForSeconds(0.5f));
        }

        spine.SetAnimation("02_attack", false);

        //if (PlayerNumber == 0)
        //    ;
        //			SoundManager.PlaySFX(string.Format("{0}_Attack", unit.spineName));

        //spineAnimation.SetAnimation("02_attack", false);

        //targetSpine.AnimationState.SetAnimation(0, "02_attack", false);


        //      if (effectList[0] != null)
        //          effectList[0].SetActive(true);

        //      yield return new WaitForSeconds(1.5f);

        //Reset();

        //	spineAnimation.SetAnimation("01_idle");
    }
Exemple #4
0
    public void HitDamage(InBattleUnit other)
    {
        //      int damage = other.data.AttackFactor;
        //      int calculation = Mathf.Clamp(damage - data.DefenceFactor, 1, damage);
        //      HitPoints -= calculation;
        //data.HitPoints = HitPoints;

        int damage = other.data.AttackFactor;

        int calculation = Mathf.Clamp(damage - data.DefenceFactor, 1, damage);

        //--

        int nFinalDmg = this.AdvantageState(calculation, other.unitType);

        data.HitPoints -= nFinalDmg;


        Debug.Log("HitDamage c= " + calculation + " fianl = " + nFinalDmg);

        HitDamageAnimation(nFinalDmg);

        DamageText dt = DamageTextPool.Instance.GetDamageText();

        Vector3 pos = this.transform.position;

        pos.y += 200;
        dt.SetDamageText(pos, calculation, false, false, Color.red);


        if (data.HitPoints <= 0)
        {
            data.Destroyed(other.data);
            data.Cell.PlayerNumber = -1;
        }
    }
Exemple #5
0
    private IEnumerator coUnitAction(GameObject fxAttack, GameObject fx)
    {
        yield return(new WaitForSeconds(0.1f));

        if (srcInBattleUnit.targetUnit != null)
        {
            targetInBattleUnit = srcInBattleUnit.targetUnit.GetComponent <InBattleUnit>();

            if (srcInBattleUnit.PlayerNumber != targetInBattleUnit.PlayerNumber)
            {
                if (fxAttack != null)
                {
                    goAttackFX = GameObject.Instantiate(fxAttack);
                    goAttackFX.transform.parent        = this.transform.parent.transform;
                    goAttackFX.transform.localScale    = new Vector3(1, 1, 1);
                    goAttackFX.transform.localPosition = new Vector3(targetInBattleUnit.transform.localPosition.x,
                                                                     targetInBattleUnit.transform.localPosition.y / 2,
                                                                     targetInBattleUnit.transform.localPosition.z);
                    if (srcInBattleUnit.PlayerNumber == 0)
                    {
                        goAttackFX.transform.localRotation = new Quaternion(0, 0, 0, 0);
                    }
                    else if (srcInBattleUnit.PlayerNumber == 1)
                    {
                        goAttackFX.transform.localRotation = new Quaternion(0, -180, 0, 0);
                    }

                    goAttackFX.SetActive(true);
                }

                CameraShake.Shake(0.25f, 8f);

                targetInBattleUnit.spine.SetAnimation("04_hit", false);
                targetInBattleUnit.HitDamage(srcInBattleUnit);
            }
            else
            {
                if (fxAttack != null)
                {
                    goAttackFX = GameObject.Instantiate(fxAttack);
                    goAttackFX.transform.parent        = this.transform.parent.transform;
                    goAttackFX.transform.localScale    = new Vector3(1, 1, 1);
                    goAttackFX.transform.localPosition = new Vector3(targetInBattleUnit.transform.localPosition.x,
                                                                     targetInBattleUnit.transform.localPosition.y / 2,
                                                                     targetInBattleUnit.transform.localPosition.z);

                    goAttackFX.transform.localRotation = new Quaternion(0, 0, 0, 0);
                    goAttackFX.SetActive(true);
                }

                targetInBattleUnit.HitBuff(srcInBattleUnit);

                //--
                srcInBattleUnit.GetUnitData().bCounter     = true;
                srcInBattleUnit.GetUnitData().bInBattleEnd = true;

                targetInBattleUnit.GetUnitData().bCounter     = true;
                targetInBattleUnit.GetUnitData().bInBattleEnd = true;

                //       BattleManager.instance.cellGrid.battleInformation.RefreshBattleUnit();

                yield return(new WaitForSeconds(1.0f));
            }

            //        BattleManager.instance.cellGrid.battleInformation.RefreshBattleUnit();

            yield return(new WaitForSeconds(1.0f));

            if (targetInBattleUnit.GetUnitData().HitPoints <= 0)
            {
                targetInBattleUnit.spine.SetAnimation("05_die", false);
                yield return(new WaitForSeconds(1.0f));
            }
            else
            {
                targetInBattleUnit.spine.SetAnimation("01_idle");
            }

            // src Attack End & idle
            srcInBattleUnit.bIsAttacking = false;
            srcInBattleUnit.spine.SetAnimation("01_idle");
            srcInBattleUnit.GetUnitData().bInBattleEnd = true;

            // Destory FX
            Destroy_Fx(goHitFX);
            Destroy_Fx(goAttackFX);


            //---------------------------------------------------
            //---right count attack

            /*
             * 첫 반격이거나 살아 있고 반격 범위에 있으면
             *
             */
            if (targetInBattleUnit.GetUnitData().bCounter == false &&
                targetInBattleUnit.GetUnitData().HitPoints > 0 &&
                IsCounterAttack())
            {
                /*
                 * 반격 후 전투 종료
                 */
                if (srcInBattleUnit.GetUnitData().bInBattleEnd == true &&
                    targetInBattleUnit.GetUnitData().bInBattleEnd == true)
                {
                    // End Process
                    Debug.LogError("InBattle End 1");

                    srcInBattleUnit.spine.SetAnimation("01_idle");
                    targetInBattleUnit.spine.SetAnimation("01_idle");
                    InBattleActionReset();

                    BattleEnd();
                }
                else
                {
                    // counter attack
                    targetInBattleUnit.GetUnitData().bCounter = true;

                    targetInBattleUnit.spine.SetAnimation("02_attack", false);
                    targetInBattleUnit.targetUnit = srcInBattleUnit;

                    Debug.LogError("Counter Attack Start");
                }
            }
            else
            {
                /*
                 * 반격 안하는 경우 전투 종료
                 */
                InBattleActionReset();

                BattleEnd();

                Debug.LogError("InBattle End 3");
            }
        }
    }
Exemple #6
0
 public void DealDamage(InBattleUnit other, Vector3 position)
 {
     //MoveAsAttacking(position);
     MoveAsAttacking(other, position);
     //other.Defend(this);
 }
Exemple #7
0
    public void  MoveAsAttacking(InBattleUnit other, Vector3 position)
    {
        targetUnit = other;

        StartCoroutine(MoveJerk(other, position));
    }