Ejemplo n.º 1
0
    public void InstantiateObject()
    {
        GameObject objectToInstantiate = Instantiate(options [currentOption].prefab, transform.position, Quaternion.identity);

        if (options [currentOption].type == PlayerDeadOptionType.MOB)
        {
            Base_Mob mob = objectToInstantiate.GetComponent <Base_Mob> ();
            mob.Ini(null, playerTag.Id, playerTag.Team, true);
        }
        else if (options [currentOption].type == PlayerDeadOptionType.POWERUP)
        {
            PickupRespawn pickup = objectToInstantiate.GetComponent <PickupRespawn> ();
            pickup.duration = -1f;

            PickupGun gun = objectToInstantiate.GetComponent <PickupGun> ();
            if (gun != null)
            {
                return;
            }

            Powerup powerup = objectToInstantiate.GetComponent <Powerup> ();
            if (powerup != null)
            {
                powerup.SetValue(options[currentOption].baseValue);
                return;
            }

            AmmoPickup ammo = objectToInstantiate.GetComponent <AmmoPickup> ();
            if (ammo != null)
            {
                ammo.SetValue((int)options [currentOption].baseValue);
                return;
            }
        }
    }
Ejemplo n.º 2
0
 public override bool PrimaryUseDown()
 {
     if (playerRef && transform.parent)
     {
         PickupGun otherHand = null;
         if (transform.parent.CompareTag(leftTag))
         {
             otherHand = playerRef.GetAttachedObject(SocketType.RIGHT) as PickupGun;
         }
         else if (transform.parent.CompareTag(rightTag))
         {
             otherHand = playerRef.GetAttachedObject(SocketType.LEFT) as PickupGun;
         }
         if (otherHand && otherHand.Reload())
         {
             Destroy(gameObject);
             return(true);
         }
         return(false);
     }
     else
     {
         Debug.LogWarning("No player reference or parent found");
         return(false);
     }
 }