示例#1
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");
                        }
                    });
                }
            }
        }
    }
示例#2
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;
                        }
                    });
                }
            }
        }
    }
示例#3
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.gameObject.GetComponent <Player>())
     {
         VirtualJoystick.DisableDynamicButton("tag_door");
     }
 }
示例#4
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();
            }
        }
    }
示例#5
0
    private void OnTriggerExit2D(Collider2D collider)
    {
        if (playerOnFocus != null)
        {
            if (collider.gameObject == playerOnFocus.gameObject)
            {
                playerOnFocus = null;

                //Disable the button
                VirtualJoystick.DisableDynamicButton("tag_item");
            }
        }

        //if(collider.tag == "tag_player")
        //{
        //
        //    promptPickUp = false;
        //    //Set the player to null only of the object is not picked up
        //    if (!pickedUp && collider.gameObject.GetComponent<PlayerMechanics>().itemPickedUp == null)
        //    {
        //        VirtualJoystick.pickUpButton.SetActive(false);
        //        playerMechanics = null;
        //    }
        //}
    }
示例#6
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;
        //}
    }
示例#7
0
    void AbsorbCharacter()
    {
        //Enable the virtual joystick button by checking the target's status
        Enemy e = DetectCharacter();

        if (e != null)
        {
            if (e.IsStunned())
            {
                //Enable Absorb Button
                if (absorbButton == null && !absorbing && !player.userInputs.absorbPressed)
                {
                    EnableAbsorbButton();
                }

                if (player.userInputs.absorbPressed)
                {
                    InitiateAbsorb(e, 3.0f);
                }
            }
            else if (absorbButton != null && !absorbing)
            {
                Debug.Log("Character is not stunned");
                VirtualJoystick.DisableDynamicButton(absorbButton);
                absorbButton = null;
            }
        }
        else if (absorbButton != null && !absorbing)
        {
            Debug.Log("character is null");
            VirtualJoystick.DisableDynamicButton(absorbButton);
            absorbButton = null;
        }
    }
示例#8
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);
                            }
                        });
                    }
                }
            }
        }
    }
示例#9
0
    private void OnTriggerExit2D(Collider2D collider)
    {
        if (playerOnFocus != null && collider.gameObject == playerOnFocus.gameObject)
        {
            playerOnFocus = null;

            //Disable the button
            VirtualJoystick.DisableDynamicButton("tag_door");
        }
    }
示例#10
0
 private void OnTriggerExit2D(Collider2D collider)
 {
     if (playerOnFocus != null && collider.gameObject == playerOnFocus.gameObject)
     {
         playerOnFocus = null;
         if (dialogueSystem.IsDialoguePlaying())
         {
             dialogueSystem.DialogueFinished();
         }
         //Disable the button
         VirtualJoystick.DisableDynamicButton("tag_question");
     }
 }
示例#11
0
 //TODO: consider putting this functiong in the virtual joystick class
 void ResetButtons()
 {
     for (int i = 0; i < VirtualJoystick.activeDynamicButtons.Count; i++)
     {
         for (int j = 0; j < info.Length; j++)
         {
             if (VirtualJoystick.activeDynamicButtons[i].tag == info[j].collider.tag)
             {
                 return;
             }
         }
         VirtualJoystick.DisableDynamicButton(VirtualJoystick.activeDynamicButtons[i]);
     }
 }
示例#12
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.gameObject.GetComponent <Player>() && !isFromEnemy)
     {
         VirtualJoystick.DisableDynamicButton("tag_item");
         ItemCountSelection.instance.Dectivate();
         ///Testing purpose to be removed later
         if (playerObject.GetComponentInChildren <PlayerInventory>() != null)
         {
             //  playerObject.GetComponentInChildren<PlayerInventory>().SaveInventoryData();
         }
         //////
     }
 }
示例#13
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;
         });
     }
 }
示例#14
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);
                });
            }
        }
    }
示例#15
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);
                 });
             }
         }
     }
 }