Exemplo n.º 1
0
    public void CreateCombatText(GameObject targetGo, int damage, BasicStats.AttackOutcome outcome)
    {
        GameObject combatTextGo = (GameObject)Instantiate(textPrefab, targetGo.transform.position, Quaternion.identity);

        combatTextGo.transform.SetParent(canvas, false);
        combatTextGo.GetComponent <RectTransform>().position = Camera.main.WorldToScreenPoint(GetTargetTopPosition(targetGo));

        combatTextGo.GetComponent <CombatText>().SetTextAttributs(textDirection, textSpeed, fadeDelay);
        SetTextProperties(combatTextGo.GetComponent <Text>(), combatTextGo.GetComponent <Animator>(), targetGo.tag, damage, outcome);

        combatTextGo.SetActive(true);
    }
Exemplo n.º 2
0
    private void SetTextProperties(Text textComponent, Animator anim, string targetTag, int damage, BasicStats.AttackOutcome outcome)
    {
        Color  chosenColor;
        string content;

        if (targetTag == "Player")
        {
            switch (outcome)
            {
            case BasicStats.AttackOutcome.Blocked:
                chosenColor = playerBlockTextColor;
                content     = "Block";
                break;

            case BasicStats.AttackOutcome.Crit:
                chosenColor = playerCritTextColor;
                content     = damage.ToString();
                anim.SetTrigger("Crit");
                break;

            case BasicStats.AttackOutcome.Hit:
                chosenColor = playerHitTextColor;
                content     = damage.ToString();
                break;

            case BasicStats.AttackOutcome.Miss:
                chosenColor = playerDodgeTextColor;
                content     = "Dodge";
                break;

            default:
                Debug.Log("There's no state in this name :" + outcome);
                chosenColor = Color.white;
                content     = "None";
                break;
            }
        }
        else
        {
            switch (outcome)
            {
            case BasicStats.AttackOutcome.Blocked:
                chosenColor = enemyBlockTextColor;
                content     = "Block";
                break;

            case BasicStats.AttackOutcome.Crit:
                chosenColor = enemyCritTextColor;
                content     = damage.ToString();
                anim.SetTrigger("Crit");
                break;

            case BasicStats.AttackOutcome.Hit:
                chosenColor = enemyHitTextColor;
                content     = damage.ToString();
                break;

            case BasicStats.AttackOutcome.Miss:
                chosenColor = enemyDodgeTextColor;
                content     = "Miss";
                break;

            default:
                Debug.Log("There's no state in this name :" + outcome);
                chosenColor = Color.white;
                content     = "None";
                break;
            }
        }

        textComponent.text  = content;
        textComponent.color = chosenColor;
    }
Exemplo n.º 3
0
 public int CalculateInflictedDamage(BasicStats attackerStats, BasicStats defenderStats, out BasicStats.AttackOutcome outcome)
 {
     if (Dodge(attackerStats.HitRate, defenderStats.DodgeRate))
     {
         outcome = BasicStats.AttackOutcome.Miss;
         return(0);
     }
     if (Block(attackerStats.BlockBreakRate, defenderStats.BlockRate))
     {
         outcome = BasicStats.AttackOutcome.Blocked;
         return(BlockDamageCalc(attackerStats.Attack, defenderStats.Defense));
     }
     if (Crit(attackerStats.CritRate))
     {
         outcome = BasicStats.AttackOutcome.Crit;
         return(CritDamageCalc(attackerStats.Attack, defenderStats.Defense, attackerStats.CritDamage));
     }
     outcome = BasicStats.AttackOutcome.Hit;
     return(DamageCalc(attackerStats.Attack, defenderStats.Defense));
 }