Exemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //Debug.Log("Trigger enter");
        if (collision.gameObject.GetComponent <Player>() && !isFromEnemy)
        {
            playerObject = collision.gameObject;

            if (collision.GetComponent <Player>() != null)
            {
                //Enable the button
                DynamicButton d = VirtualJoystick.CreateDynamicButton("tag_item");
                if (!d.active)
                {
                    VirtualJoystick.EnableDynamicButton(d);
                    d.button.onClick.AddListener(() =>
                    {
                        VirtualJoystick.DisableDynamicButton(d);
                        ItemCountSelection.instance.Activate(maxCount);
                        ItemCountSelection.instance.item = this;

                        if (playerObject.GetComponent <Player>())
                        {
                            CheckPointManager.RegisterCheckPointEvent += playerObject.GetComponentInChildren <PlayerInventory>().Save;
                        }
                    });
                }
            }
        }
    }
Exemplo n.º 2
0
    void LadderButtonLogic(RaycastHit2D info)
    {
        if (info.collider.tag == "tag_ladder")
        {
            //Debug.Log("State:  " + State.ToString());
            if (!State.Equals(typeof(ClimbingState)) && State.Equals(typeof(IdleState)))
            {
                DynamicButton d = VirtualJoystick.CreateDynamicButton("tag_ladder");
                if (!d.active)
                {
                    VirtualJoystick.EnableDynamicButton(d);

                    d.button.onClick.AddListener(() => {
                        if (!State.Equals(typeof(ClimbingState)))
                        {
                            Debug.Log("climb pressed");
                            userInputs.climbPressed = true;
                        }
                        else
                        {
                            userInputs.climbPressed = true;
                            VirtualJoystick.DisableDynamicButton("tag_ladder");
                        }
                    });
                }
            }
        }
    }
Exemplo n.º 3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.GetComponent <Player>())
        {
            if (collision.GetComponent <Player>() != null)
            {
                //Enable the button
                DynamicButton d = VirtualJoystick.CreateDynamicButton("tag_door");
                if (!d.active)
                {
                    VirtualJoystick.EnableDynamicButton(d);
                    d.button.onClick.AddListener(() =>
                    {
                        OpenDoor();
                        VirtualJoystick.DisableDynamicButton(d);
                    });
                }
            }
        }

        if (collision.gameObject.GetComponent <ItemBase>() != null)
        {
            if (collision.gameObject.GetComponent <ItemBase>().thrown&& !collision.gameObject.GetComponent <ItemBase>().isFromEnemy)
            {
                OpenDoor();
            }
        }
    }
Exemplo n.º 4
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        Player p = collider.GetComponent <Player>();

        if (p != null)
        {
            playerOnFocus = p;

            //Enable the button
            DynamicButton d = VirtualJoystick.CreateDynamicButton("tag_item");
            if (!d.active)
            {
                VirtualJoystick.EnableDynamicButton(d);
                d.button.onClick.AddListener(() =>
                {
                    //p.userInputs.doorOpenPressed = true;

                    //Disable the button
                    VirtualJoystick.DisableDynamicButton(d);
                });
            }
        }

        //if(collider.tag == "tag_player")
        //{
        //    promptPickUp = true;
        //    playerMechanics = collider.gameObject.GetComponent<PlayerMechanics>();
        //
        //    //Enable the button on the controls canvas
        //    VirtualJoystick.pickUpButton.SetActive(true);
        //    //Set the sprite to pick up sprite
        //    if(playerMechanics.itemPickedUp == null)
        //        VirtualJoystick.pickUpButton.GetComponent<UnityEngine.UI.Image>().sprite = VirtualJoystick.pickUpButton.GetComponent<PickUpButton>().pickupSprite;
        //}
    }
Exemplo n.º 5
0
    void OnTriggerStay2D(Collider2D collider)
    {
        if (gameObject.tag == "tag_ladder")
        {
            Player p = collider.GetComponent <Player>();
            if (p != null)
            {
                //Debug.Log("Player detected");
                playerOnFocus = p;
                if (p.State.Equals(typeof(IdleState)))
                {
                    //Enable the button
                    DynamicButton d = VirtualJoystick.CreateDynamicButton("tag_ladder");
                    if (!d.active)
                    {
                        VirtualJoystick.EnableDynamicButton(d);
                        d.button.onClick.AddListener(() =>
                        {
                            p.userInputs.climbPressed = true;

                            if (p.State.Equals(typeof(ClimbingState)))
                            {
                                //Disable the button
                                VirtualJoystick.DisableDynamicButton(d);
                            }
                        });
                    }
                }
            }
        }
    }
Exemplo n.º 6
0
 void ItemButtonLogic(RaycastHit2D info)
 {
     if (info.collider.tag == "tag_item")
     {
         if (State.Equals(typeof(IdleState)) || State.Equals(typeof(RunningState)))
         {
             //Create an item button
             DynamicButton d = VirtualJoystick.CreateDynamicButton("tag_item");
             if (!d.active)
             {
                 VirtualJoystick.EnableDynamicButton(d);
             }
         }
     }
 }
Exemplo n.º 7
0
 void EnableAbsorbButton()
 {
     absorbButton = VirtualJoystick.CreateDynamicButton("tag_absorb");
     if (!absorbButton.active)
     {
         VirtualJoystick.EnableDynamicButton(absorbButton);
         absorbButton.button.onClick.AddListener(() =>
         {
             player.userInputs.absorbPressed = true;
             Debug.Log("Absorb pressed");
             //Disable the button
             VirtualJoystick.DisableDynamicButton(absorbButton);
             absorbButton = null;
         });
     }
 }
Exemplo n.º 8
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        Player p = collider.GetComponent <Player>();

        if (p != null)
        {
            playerOnFocus = p;
            //Enable the button
            DynamicButton d = VirtualJoystick.CreateDynamicButton("tag_door");
            if (!d.active)
            {
                VirtualJoystick.EnableDynamicButton(d);
                d.button.onClick.AddListener(() =>
                {
                    p.userInputs.doorOpenPressed = true;

                    //Disable the button
                    VirtualJoystick.DisableDynamicButton(d);
                });
            }
        }
    }
Exemplo n.º 9
0
 private void OnTriggerEnter2D(Collider2D collider)
 {
     if (!dialogueSystem.IsDialoguePlaying())
     {
         Player p = collider.GetComponent <Player>();
         if (p != null)
         {
             playerOnFocus = p;
             DynamicButton d = VirtualJoystick.CreateDynamicButton("tag_question");
             if (!d.active)
             {
                 VirtualJoystick.EnableDynamicButton(d);
                 d.button.onClick.AddListener(() =>
                 {
                     dialogueSystem.StartDialogue(playerOnFocus);
                     //Disable the button
                     VirtualJoystick.DisableDynamicButton(d);
                 });
             }
         }
     }
 }