Beispiel #1
0
 /// <summary>
 /// Initializes all the properties of this component.
 /// </summary>
 /// <param name="speed">The speed of the projectile.</param>
 /// <param name="start">The start location of this projectile.</param>
 /// <param name="target">The target of this projectile. (Arrows home onto their targets like in most RTS games.</param>
 /// <param name="info">Info to produce a hitsplat on impact.</param>
 /// <param name="damage">The damage this projectile deals.</param>
 /// <param name="gravMult">A modifier on how much gravity should affect this projectile.</param>
 public void Init(float speed, Vector3 start, Soldier target, HitsplatInfo info, int damage, float gravMult = 1)
 {
     this.info      = info;
     this.damage    = damage;
     this.start     = start;
     this.target    = target;
     this.speed     = speed;
     this.gravity   = Physics.gravity.y * gravMult;
     this.totalTime = Vector3.Distance(start, target.transform.position) / speed;
     initialYVel    = gravity * -.5f * totalTime;
 }
Beispiel #2
0
 internal void Init(HitsplatInfo hitsplatInfo, Soldier soldier)
 {
     this.text = this.GetComponent <TextMeshPro>();
     this.transform.SetParent(soldier.transform);
     this.transform.localPosition = new Vector3(0, .5f, -.15f);
     text.text = "" + hitsplatInfo.damage;
     if (hitsplatInfo.result.IsCrit())
     {
         text.text += "\nCrit!";
         text.color = new Color32(255, 107, 107, 255);
     }
     else if (hitsplatInfo.result == AttackResult.MISS)
     {
         text.color = new Color32(128, 128, 120, 255);
         text.text  = "Miss";
     }
 }
    private void PerformMeleeAttack()
    {
        float        atkDefRatio = (float)user.stats.Att / (float)target.stats.Att;
        float        power       = basicAttackPowers[user.stats.BasicAttackLevel];
        float        agiRatio    = Mathf.Sqrt((float)user.stats.Agi / (float)target.stats.Agi);
        AttackResult hit         = AttackResultUtils.TryToHit(agiRatio);
        float        damage      = atkDefRatio * hit.DamageMultiplier() * power;

        target.currentHP -= (int)damage;
        user.currentMP   -= (int)basicAttackCosts[user.stats.BasicAttackLevel];
        HitsplatInfo info = new HitsplatInfo
        {
            damage = (int)damage,
            type   = DamageType.SLASH,
            result = hit
        };

        target.CreateHitsplat(info);
    }
    private void PerformRangedAttack()
    {
        //Calculate the damage this projectile will cause.
        float        atkDefRatio = (float)user.stats.Att / (float)target.stats.Att;
        float        power       = basicAttackPowers[range][user.stats.BasicAttackLevel];
        float        agiRatio    = Mathf.Sqrt((float)user.stats.Agi / (float)target.stats.Agi);
        AttackResult hit         = AttackResultUtils.TryToHit(agiRatio);
        float        damage      = atkDefRatio * hit.DamageMultiplier() * power;
        HitsplatInfo info        = new HitsplatInfo
        {
            damage = (int)damage,
            type   = DamageType.STAB,
            result = hit
        };

        //Send the projectile on its way. It handles its own animation, etc, after that.
        RangedProjectile projectile = GameObject.Instantiate <RangedProjectile>(user.basicRangedProjectile);

        projectile.Init(10, user.transform.position, target, info, (int)damage);

        user.currentMP -= (int)basicAttackCosts[user.stats.BasicAttackLevel];
    }
Beispiel #5
0
 /// <summary>
 /// Creates a hitsplat. In the base class because lots of actions use it.
 /// </summary>
 /// <param name="info"></param>
 protected void CreateHitsplat(HitsplatInfo info)
 {
     Debug.Log(info.damage + ", " + info.type);
 }