Ejemplo n.º 1
0
 public void ToggleMode()
 {
     currentMember = flow.currentUnit;
     if (currentMember.charMode == Mode.Attack)
     {
         currentMember.charMode = Mode.Defense;
     }
     else if (currentMember.charMode == Mode.Defense)
     {
         currentMember.charMode = Mode.Attack;
     }
     else
     {
     }
     flow.SetUpNextTurn(1);
 }
    public void MoveCharacterToLocation(GameObject targetLocation)
    {
        ui.HideMoveHolder();
        flow.currentUnit.battleLocation = targetLocation.name;
        Facing f = flow.currentUnit.facing;

        flow.currentUnit.battleAnimator.transform.SetParent(targetLocation.transform);
        flow.currentUnit.battleAnimator.transform.localPosition = new Vector3(0.0f, flow.currentUnit.battleAnimator.transform.position.y, 0.0f);
        if (targetLocation.name.Contains(f.ToString()))
        {
            if (f == Facing.Right)
            {
                flow.currentUnit.facing = Facing.Left;
                flow.currentUnit.battleAnimator.GetComponent <SpriteRenderer>().flipX = false;
            }
            else if (f == Facing.Left)
            {
                flow.currentUnit.facing = Facing.Right;
                flow.currentUnit.battleAnimator.GetComponent <SpriteRenderer>().flipX = true;
            }
        }
        flow.SetUpNextTurn(2);
    }
Ejemplo n.º 3
0
 public void Defend()
 {
     flow.SetUpNextTurn(3);
 }
    IEnumerator WaitAndThenGetHit(UnitStats target)
    {
        ui.DisableMainButtons();
        ui.DisableTargetButtons();
        bool used = false;

        if (flow.currentUnit.currentMana >= ability.mpCost)
        {
            flow.currentUnit.battleAnimator.GetComponent <Animator>().Play(ability.defaultAttackAnimation + flow.currentUnit.facing.ToString());
            yield return(new WaitForSeconds(0.33f));

            if (ability.targetType == TargetType.One)
            {
                if (ability.heal > 0 && target.currentHealth < target.maxHealth)
                {
                    int toHeal = Mathf.RoundToInt(flow.currentUnit.modMagAttack * ability.heal);
                    target.RestoreHp(toHeal);
                    ui.ShowHealText(target, toHeal);
                    used = true;
                }
                else if (ability.damage > 0)
                {
                    DealDamageToTarget(target);
                    used = true;
                }
            }
            else if (ability.targetType == TargetType.AllFriendly)
            {
                foreach (UnitStats member in flow.friendlyUnits)
                {
                    UnitStats memberStats = member.GetComponent <UnitStats>();
                    if (ability.heal > 0 && memberStats.currentHealth < memberStats.maxHealth)
                    {
                        int toHeal = Mathf.RoundToInt(flow.currentUnit.modMagAttack * ability.heal);
                        memberStats.RestoreHp(toHeal);
                        ui.ShowHealText(memberStats, toHeal);
                        used = true;
                    }
                    else if (ability.damage > 0)
                    {
                        DealDamageToTarget(memberStats);
                        used = true;
                    }
                }
            }
            else if (ability.targetType == TargetType.All)
            {
                if (ability.heal > 0 && flow.currentUnit.currentHealth < flow.currentUnit.maxHealth)
                {
                    int toHeal = Mathf.RoundToInt(flow.currentUnit.modMagAttack * ability.heal);
                    flow.currentUnit.RestoreHp(toHeal);
                    ui.ShowHealText(flow.currentUnit, toHeal);
                    used = true;
                }
                else if (ability.damage > 0)
                {
                    DealDamageToTarget(flow.currentUnit);
                    used = true;
                }
                foreach (UnitStats member in flow.units)
                {
                    UnitStats memberStats = member.GetComponent <UnitStats>();
                    if (ability.heal > 0 && memberStats.currentHealth < memberStats.maxHealth)
                    {
                        int toHeal = Mathf.RoundToInt(flow.currentUnit.modMagAttack * ability.heal);
                        memberStats.RestoreHp(toHeal);
                        ui.ShowHealText(memberStats, toHeal);
                        used = true;
                    }
                    else if (ability.damage > 0)
                    {
                        DealDamageToTarget(memberStats);
                        used = true;
                    }
                }
            }
        }
        if (used)
        {
            flow.currentUnit.currentMana -= ability.mpCost;
            flow.SetUpNextTurn(ability.speedRank);
        }
        else
        {
            ui.EnableMainButtons();
        }
    }
 // Update is called once per frame
 public void UseItem(UnitStats target)
 {
     StartCoroutine(WaitAndThenGetHit(target));
     flow.SetUpNextTurn(2);
 }