Пример #1
0
 void CallResetShot() //Calls the reenable function for the respective shot after a hit
 {
     if (tag == "BluePortal")
     {
         ItemInputHandler.ResetShot(true, false);
     }
     else if (tag == "OrangePortal")
     {
         ItemInputHandler.ResetShot(false, true);
     }
 }
Пример #2
0
    public static void ItemInteraction(bool ItemButtonPressed, bool ThrowButtonPressed)
    {
        if (PortalGunFound)
        {
            //Check if itembutton is pressed, the player is by an item and has nothing in his hand
            if (ItemButtonPressed && AtItem && !ItemInHandToggle)
            {
                FindObjectOfType <AudioManager>().PlayAt("ItemPickUp");

                //The Object that the player is currently on gets set as child of the player and moved to the hand
                LastHit.gameObject.transform.position = ArmLocationStatic.transform.position;
                LastHit.transform.SetParent(ArmLocationStatic.gameObject.transform);

                //The phyics and the colliders are turned off for the item
                LastHit.GetComponent <Rigidbody2D>().isKinematic = true;
                LastHit.GetComponent <Rigidbody2D>().simulated   = false;

                //The item gets saved in a non temporary variable
                ItemInHand       = LastHit;
                ItemInHandToggle = true;

                //Enables the hitbox of the fire extinguisher
                if (ItemInHand.name == "FireExtinguisher")
                {
                    ItemInHand.GetComponent <FireExt>().EnableFireExtHitbox();
                }
            }

            //If the itembutton is pressed and an item is in the hand it will be dropped
            else if (ItemButtonPressed && ItemInHandToggle)
            {
                FindObjectOfType <AudioManager>().PlayAt("ItemDrop");

                //Physics and colliders are turned back on
                ItemInHand.GetComponent <Rigidbody2D>().isKinematic = false;
                ItemInHand.GetComponent <Rigidbody2D>().simulated   = true;

                //Item gets removed from player
                ItemInHand.transform.parent = null;
                ItemInHandToggle            = false;
            }

            //If the trownbutton is pressed and an item is in the hand it will be thrown
            if (ThrowButtonPressed && ItemInHandToggle)
            {
                FindObjectOfType <AudioManager>().PlayAt("ItemThrow");

                //Item gets removed from player
                ItemInHand.transform.parent = null;

                //Physics and collider are turned back on
                ItemInHand.GetComponent <Rigidbody2D>().isKinematic = false;
                ItemInHand.GetComponent <Rigidbody2D>().simulated   = true;

                //Passes the object to the throwing/firing method
                ItemInputHandler.FireObject(ItemInHand, 500);

                ItemInHand       = null;
                ItemInHandToggle = false;

                ItemInputHandler.ItemWasShot = true;
            }
        }
    }