コード例 #1
0
 public override IEnumerator CastSpell(Item_Weapon Weapon)
 {
     doneCasting = false;
     updatedHits.Clear ();
     GetComponent<Collider> ().enabled = true;
     yield return new WaitForFixedUpdate ();
     ChargeMults.x = Random.Range (ChargeMultsMin.x, ChargeMultsMax.x);
     ChargeMults.y = Random.Range (ChargeMultsMin.y, ChargeMultsMax.y);
     Item_Weapon adjustedWeapon = new Item_Weapon (Weapon.name, (int) Mathf.Clamp (Mathf.RoundToInt(Weapon.dmgMin * dmgMult), 1, Mathf.Infinity), (int) Mathf.Clamp (Mathf.RoundToInt(Weapon.dmgMax * dmgMult), 1, Mathf.Infinity), Weapon.range, knockback, 0);
     List<Health> hitObjs = new List<Health> ();
     hitbox.GetComponent<Rigidbody> ().AddRelativeForce (Vector3.up*ChargeMults.y * ChargeSpeed, ForceMode.VelocityChange);
     yield return new WaitForSeconds (0.075f);
     FX.Play ();
     if(transform.root.GetComponent<Enemy> ())
         transform.root.GetComponent<Enemy> ().disableWalk = true;
     hitbox.GetComponent<Rigidbody> ().AddRelativeForce (Vector3.forward*ChargeMults.x * ChargeSpeed, ForceMode.VelocityChange);
     yield return new WaitForSeconds (0.05f);
     if (transform.root.GetComponent<Enemy> ())
         transform.root.GetComponent<Enemy> ().disableWalk = true;
     while (!hitbox.CollidingWithSolids) {
         if (transform.root.GetComponent<Enemy> ())
         transform.root.GetComponent<Enemy> ().disableWalk = true;
         foreach (Health hit in updatedHits) {
             if (hit != health && hit.health != 0 && !hitObjs.Contains (hit)) {
                 if(hit && transform.root.GetComponent<Enemy>() && !hit.transform.root.GetComponent<Enemy>() ||
                    hit && !transform.root.GetComponent<Enemy>() && hit.transform.root.GetComponent<Enemy>())
                 {
                     adjustedWeapon.DealDamage (hit, transform, knockMultipliers, Weapon.IDs);
                     hitObjs.Add (hit);
                 }
             }
         }
         yield return new WaitForEndOfFrame();
     }
     FX.Stop ();
     health.invulnerable = false;
     doneCasting = true;
     GetComponent<Collider> ().enabled = false;
 }
コード例 #2
0
 public override IEnumerator CastSpell(Item_Weapon Weapon)
 {
     doneCasting = false;
     updatedHits.Clear ();
     GetComponent<Collider> ().enabled = true;
     yield return new WaitForFixedUpdate ();
     CastFX.Play ();
     Item_Weapon adjustedWeapon = new Item_Weapon (Weapon.name, Mathf.Clamp (Weapon.dmgMin * dmgPerHit, 0, Mathf.Infinity), Mathf.Clamp (Weapon.dmgMax * dmgPerHit, 0, Mathf.Infinity), Weapon.range, knockback, 0);
     List<Health> Hits = new List<Health> (updatedHits);
     hitting.AddRange (Hits);
     for(int i = 0; i < hitAmount; i++)
     {
         foreach (Health hit in Hits) {
             if(hit != health && hit.health != 0)
             {
                 if(hit && transform.root.GetComponent<Enemy>() && !hit.transform.root.GetComponent<Enemy>() ||
                    hit && !transform.root.GetComponent<Enemy>() && hit.transform.root.GetComponent<Enemy>()){
                     Instantiate (ExplosionFX, hit.transform.position - Vector3.up*1.375f, transform.rotation);
                     adjustedWeapon.knockback = Random.Range (knockback, knockbackMax);
                     adjustedWeapon.DealDamage(hit, transform, knockMultipliers, Weapon.IDs);
                 }
             }
         }
         if(Hits.Count > 0)
         {
             yield return new WaitForSeconds(hitDelay);
         }
         GameObject[] tempFX = GameObject.FindGameObjectsWithTag ("TempFX_MH");
         foreach(GameObject PS in tempFX) {
             Destroy (PS);
         }
     }
     if(Hits.Count > 0)
         yield return new WaitForSeconds (finalHitDelay);
     adjustedWeapon.dmgMin = Weapon.dmgMin;
     adjustedWeapon.dmgMax = Weapon.dmgMax;
     adjustedWeapon.knockback = finalKnockback;
     foreach (Health hit in Hits) {
         if(hit != health && hit.health != 0)
         {
             if(hit && hit.transform && transform.root.GetComponent<Enemy>() && !hit.transform.root.GetComponent<Enemy>() ||
                hit && hit.transform && !transform.root.GetComponent<Enemy>() && hit.transform.root.GetComponent<Enemy>()){
                 Instantiate (ExplosionFX, hit.transform.position - Vector3.up*1.375f, transform.rotation);
                 Vector2 tempKMF = knockMultipliersFinal;
                 if (DynamicFinalXKnock != 0) {
                     knockMultipliersFinal.x = transform.InverseTransformDirection(hit.GetComponent<Rigidbody>().velocity).z*-DynamicFinalXKnock;
                     knockMultipliersFinal.y *= adjustedWeapon.knockback;
                     adjustedWeapon.knockback = 1;
                 }
                 adjustedWeapon.DealDamage(hit, transform, knockMultipliersFinal, Weapon.IDs);
                 if (DynamicFinalXKnock != 0) {
                     knockMultipliersFinal.x = tempKMF.x;
                     knockMultipliersFinal.y = tempKMF.y;
                     adjustedWeapon.knockback = finalKnockback;
                 }
             }
         }
     }
     doneCasting = true;
     yield return new WaitForSeconds (hitDelay);
     GameObject[] tempFX2 = GameObject.FindGameObjectsWithTag ("TempFX_MH");
     foreach(GameObject PS in tempFX2) {
         Destroy (PS);
     }
     GetComponent<Collider> ().enabled = false;
     foreach (Health hit in Hits) {
         if(hitting.Contains (hit))
             hitting.Remove (hit);
     }
 }
コード例 #3
0
ファイル: Punch.cs プロジェクト: eeveelution/Wynnunity_Source
    void Hit()
    {
        RaycastHit hit;
        if (heldItem is Item_Weapon) {
            Item_Weapon heldWeapon = (Item_Weapon)heldItem;
            if (Physics.Raycast (Camera.main.transform.position, Camera.main.transform.forward, out hit, heldWeapon.range, hittableLayers)) {
                if (hit.transform != transform) {
                    if(hit.transform.GetComponent<Health>()) {
                        if (!walk.moving) {
                            knockMult = 1;
                        } else if (walk.speed == walk.baseSpeed)
                            knockMult = WalkKnockbackMult;
                        else if (walk.speed == walk.sprintSpeed)
                            knockMult = SprintKnockbackMult;
                        if (hit.transform.GetComponent<Enemy> ()) {
                            hit.transform.GetComponent<Enemy> ().disableWalk = true;
                        }
                        heldWeapon.DealDamage (hit.transform.GetComponent<Health>(), transform, knockDirectionMult, heldWeapon.IDs);

                    }
                }
            }
        } else if (Physics.Raycast (Camera.main.transform.position, Camera.main.transform.forward, out hit, Itemrange, hittableLayers)) {
            if (hit.transform != transform) {
                if(hit.transform.GetComponent<Health> () && hit.transform.GetComponent<Health> ().health != 0) {
                    if (!walk.moving) {
                        knockMult = 1;
                    } else if (walk.speed == walk.baseSpeed)
                        knockMult = WalkKnockbackMult;
                    else if (walk.speed == walk.sprintSpeed)
                        knockMult = SprintKnockbackMult;
                    if (hit.transform.GetComponent<Enemy> ()) {
                        hit.transform.GetComponent<Enemy> ().disableWalk = true;
                    }
                    Item_Weapon heldWeapon = new Item_Weapon("", 1, 1, 0, 1, 1);
                    heldWeapon.DealDamage (hit.transform.GetComponent<Health>(), transform, knockDirectionMult, null);

                }
            }
        }
    }