コード例 #1
0
 public void MeleeAttack()
 {
     if (!meleeAttacking)
     {
         MeleeWeapon mw = Database.instance.ItemsMeleeWeapon(roLo.loadout[armLocation]);
         // Stop movement if applicable
         RaycastHit2D enemy = Physics2D.CircleCast(
             new Vector2(transform.position.x, transform.position.y),
             0.15f,
             Vector2.up,
             0.15f,
             enemyMask);
         // TODO this will need to be more universal.
         if (enemy.collider != null)
         {
             print(enemy.collider.gameObject.name);
             if (canSpecial)
             {
                 if (roLo.loadout[armLocation].itemSpecial && roLo.power[(int)roLo.loadout[armLocation].itemLoc] > 0)
                 {
                     roLo.power[(int)roLo.loadout[armLocation].itemLoc] -= Database.instance.ItemSpecialItem(roLo.loadout[armLocation]).specialPowerUse;
                     special.ActivateSpecialActive(roLo.loadout[armLocation], enemy.collider.gameObject);
                 }
             }
             RobotFunctions.DealDamage(Damage(enemy.collider.gameObject), enemy.collider.gameObject, true);
             if (roLo.loadout[armLocation].itemType == ItemType.melee)
             {
                 Utilities.PlaySoundEffect(roLo.loadout[armLocation].itemSound[0]);
             }
             else
             {
                 Utilities.PlaySoundEffect(Database.instance.items[3].itemSound[0]);
             }
         }
         else
         {
             if (roLo.loadout[armLocation].itemType == ItemType.melee)
             {
                 Utilities.PlaySoundEffect(roLo.loadout[armLocation].itemSound[1]);
             }
             else
             {
                 Utilities.PlaySoundEffect(Database.instance.items[3].itemSound[1]);
             }
         }
         meleeAttacking = true;
     }
 }
コード例 #2
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     RobotFunctions.DealDamage(damage, coll.gameObject, false);
     Destroy(gameObject);
 }