예제 #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;
                        }
                    });
                }
            }
        }
    }
예제 #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");
                        }
                    });
                }
            }
        }
    }
예제 #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();
            }
        }
    }
예제 #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;
        //}
    }
예제 #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);
                            }
                        });
                    }
                }
            }
        }
    }
예제 #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);
             }
         }
     }
 }
예제 #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;
         });
     }
 }
예제 #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);
                });
            }
        }
    }
예제 #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);
                 });
             }
         }
     }
 }