コード例 #1
0
ファイル: BasicBullet.cs プロジェクト: nankink/Myobu
    private void OnTriggerEnter(Collider other)
    {
        rb.constraints = RigidbodyConstraints.FreezeAll;
        currentSpeed   = 0;
        Attack attackStruct;

        // Damage section.
        Rigidbody targetRigidbody = other.GetComponent <Rigidbody>();

        if (targetRigidbody != null)
        {
            HealthClass targetHealth = other.GetComponent <HealthClass>();
            if (targetHealth != null)
            {
                attackStruct = ValkyDetection.GetAttackStruct(owner, projectileDirection, damage, yKnockbackOffset, knockbackForce, uniformKnockback);

                targetHealth.TakeDamage(attackStruct);
            }
        }
        Release();


        #region old code

        /* Damage section.
         *
         * RaycastHit groundHit;
         * Physics.Raycast(transform.position, Vector3.down, out groundHit, 20, groundLayer);
         * Vector3 impostorPos = groundHit.point;
         *
         * Rigidbody targetRigidbody = other.GetComponent<Rigidbody>();
         * if (targetRigidbody != null)
         * {
         *  RaycastHit gHit;
         *  Physics.Raycast(other.transform.position, Vector3.down, out gHit, 20, groundLayer);
         *  Vector3 hitImpostorPos = gHit.point;
         *
         *  Vector3 knockDirection = Vector3.Normalize(impostorPos - hitImpostorPos);
         *  if(knockDirection.Equals(Vector3.zero)) Debug.Log("distance between objects is zero");
         *  knockback = knockDirection * knockbackForce;
         *  knockback.y = yKnockbackOffset;
         *  Attack attackStruct = new Attack(damage, knockback, uniformKnockback);
         *
         *  HealthClass targetHealth = other.GetComponent<HealthClass>();
         *  if (targetHealth == null)
         *  {
         *      return;
         *  }
         *  else
         *  {
         *      targetHealth.TakeDamage(attackStruct);
         *  }
         * }
         * Release();
         */
        #endregion
    }
コード例 #2
0
ファイル: Rocket_2.cs プロジェクト: nankink/Myobu
    public void Explosion(bool fromGround)
    {
        Dictionary <HealthClass, Attack> damageables = new Dictionary <HealthClass, Attack>();

        damageables = ValkyDetection.GetDamageablesInRangeTwoSections(owner, this.transform.position, minRange, maxRange, projectileDirection, fromGround, damage, yKnockbackOffset, knockbackForce, uniformKnockback);
        if (damageables != null)
        {
            foreach (KeyValuePair <HealthClass, Attack> entry in damageables)
            {
                entry.Key.TakeDamage(entry.Value);
            }
            damageables.Clear();
        }
    }
コード例 #3
0
ファイル: ElasticCollision.cs プロジェクト: nankink/Myobu
    private void OnCollisionEnter(Collision other)
    {
        if (hitboxActive)
        {
            projectileDirection = Vector3.Normalize(awakePosition - asleepPosition);

            HealthClass targetHealth = other.gameObject.GetComponent <HealthClass>();
            if (targetHealth != null)
            {
                rb.Sleep();

                Attack attackStruct = ValkyDetection.GetAttackStruct(transform, projectileDirection, GetDamage(), 0, knockbackForce, false);
                targetHealth.TakeDamage(attackStruct);
            }
        }
    }
コード例 #4
0
ファイル: Rocket_2.cs プロジェクト: nankink/Myobu
    public void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer == groundLayer)
        {
            Explosion(false);
            Release();
        }
        else
        {
            rb.Sleep();
            currentSpeed = 0;
            Attack attackStruct;

            HealthClass healthClass = other.gameObject.GetComponent <HealthClass>();
            if (healthClass != null)
            {
                attackStruct = ValkyDetection.GetAttackStruct(owner, projectileDirection, damage, yKnockbackOffset, knockbackForce, uniformKnockback);
                healthClass.TakeDamage(attackStruct);
            }
            Release();
        }
    }
コード例 #5
0
ファイル: Rocket_1.cs プロジェクト: nankink/Myobu
    public void Explosion(bool fromGround)
    {
        rb.constraints = RigidbodyConstraints.FreezeAll;

        // GFX
        explosion.gameObject.SetActive(true);
        exploded = true;
        rocket.SetActive(false);
        fire.gameObject.SetActive(false);

        Dictionary <HealthClass, Attack> damageables = new Dictionary <HealthClass, Attack>();

        damageables = ValkyDetection.GetDamageablesInRangeTwoSections(owner, this.transform.position, minRange, maxRange, projectileDirection, fromGround, damage, yKnockbackOffset, knockbackForce, uniformKnockback);
        if (damageables != null)
        {
            foreach (KeyValuePair <HealthClass, Attack> entry in damageables)
            {
                entry.Key.TakeDamage(entry.Value);
            }
            damageables.Clear();
        }
    }
コード例 #6
0
ファイル: CC_Attacks.cs プロジェクト: nankink/Myobu
    public void SpinAttack()
    {
        c_Brain.c_anim.playerAnimator.SetTrigger("spinning");
        c_Brain.c_anim.spinFX.SetActive(true);

        // Disable rig and stuff
        if (c_Brain.weaponHolster.currentWeaponSelected != null)
        {
            c_Brain.weaponHolster.currentWeaponSelected.gameObject.SetActive(false);
        }

        // New code
        Dictionary <HealthClass, Attack> damageables = new Dictionary <HealthClass, Attack>();

        damageables = ValkyDetection.GetDamageablesObjectsInRangeRaycast(transform, this.transform.position, c_Brain.c_info.SpinRadius, true, c_Brain.c_info.SpinDamage, c_Brain.c_info.SpinYKnockbackOffset, c_Brain.c_info.SpinForceKnockback, true);
        if (damageables != null)
        {
            foreach (KeyValuePair <HealthClass, Attack> entry in damageables)
            {
                entry.Key.TakeDamage(entry.Value);
            }
            damageables.Clear();
        }
        // end new code
        // as it is now, this code doesnt work with rigidbody-only objects.

        #region old stuff

        /* OLD CODE
         * RaycastHit groundHit;
         * Physics.Raycast(transform.position, Vector3.down, out groundHit, 20, c_Brain.c_move.groundMask);
         * Vector3 impostorPos = groundHit.point;
         *
         * Collider[] hits = Physics.OverlapSphere(transform.position, c_Brain.c_info.SpinRadius, c_Brain.c_atk.damageableMask);
         * foreach (Collider hit in hits)
         * {
         *  Rigidbody targetRigidbody = hit.GetComponent<Rigidbody>();
         *  if (targetRigidbody != null)
         *  {
         *      RaycastHit gHit;
         *      Physics.Raycast(hit.transform.position, Vector3.down, out gHit, 20, c_Brain.c_move.groundMask);
         *      Vector3 hitImpostorPos = gHit.point;
         *
         *      Vector3 knockDirection = Vector3.Normalize(hitImpostorPos - impostorPos);
         *      knockback = knockDirection *  c_Brain.c_info.SpinForceKnockback;
         *      knockback.y =  c_Brain.c_info.YKnockbackOffset;
         *      Attack attackStruct = new Attack(c_Brain.c_info.SpinDamage, knockback, true);
         *
         *      HealthClass targetHealth = hit.GetComponent<HealthClass>();
         *      if (targetHealth == null)
         *      {
         *
         *          targetRigidbody.AddForce(knockback, ForceMode.Impulse);
         *      }
         *      else
         *      {
         *          targetHealth.TakeDamage(attackStruct);
         *      }
         *  }
         * }
         */
        #endregion
    }