Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        horizontal = Input.GetAxisRaw(GameController.Instance.horizontal);
        vertical   = Input.GetAxisRaw(GameController.Instance.vertical);
        if (canMove)
        {
            if (horizontal > 0)
            {
                GetComponent <SpriteRenderer>().flipX = false;
            }
            else if (horizontal < 0)
            {
                GetComponent <SpriteRenderer>().flipX = true;
            }
        }

        if (lastTriggerEnter != null)
        {
            if (Input.GetButtonDown(GameController.Instance.action))
            {
                if (!GameController.Instance.dialogController.DialogIsRunning())
                {
                    if (lastTriggerEnter.GetComponent <PNJ>() && lastTriggerEnter.activeSelf)
                    {
                        canMove = false;
                        PNJ pnj = lastTriggerEnter.GetComponent <PNJ>();
                        pnj.Interact();
                    }
                    else if (lastTriggerEnter.GetComponent <TeleportToZone>() && canMove)
                    {
                        lastTriggerEnter.GetComponent <TeleportToZone>().Teleport();
                        canMove = false;
                    }
                }
                else
                {
                    if (!GameController.Instance.dialogController.InInteraction())
                    {
                        GameController.Instance.dialogController.NextDialogue();
                    }
                    else
                    {
                        GameController.Instance.dialogController.ValidateChoice();
                        firstInteraction = true;
                    }
                }
            }
            else if (GameController.Instance.dialogController.InInteraction())
            {
                if (firstInteraction)
                {
                    GameController.Instance.dialogController.dialogBoxSystem.MoveSelector(0);
                    firstInteraction = false;
                }
                if (vertical == -1)
                {
                    GameController.Instance.dialogController.dialogBoxSystem.MoveSelector(1);
                }
                else if (vertical == 1)
                {
                    GameController.Instance.dialogController.dialogBoxSystem.MoveSelector(0);
                }
            }
        }
    }
Exemple #2
0
    private void Update()
    {
        bool canPunch = myPlayer.GetPlayerStats().GetCurrentHeat() + myPunchHeat + myPunchHeat * myPunchHeatMalus <= myPlayer.GetPlayerStats().GetMaxHeat() ? true : false;

        if (Input.GetButton("Ability"))
        {
            if (Input.GetButtonDown("Punch"))
            {
                myPlayer.GetPlayerUpgrades().UseAbility(UpgradeType.TYPEC);
            }
            else if (Input.GetButtonDown("Dash"))
            {
                myPlayer.GetPlayerUpgrades().UseAbility(UpgradeType.TYPEB);
            }
            else if (Input.GetButtonDown("Jump"))
            {
                myPlayer.GetPlayerUpgrades().UseAbility(UpgradeType.TYPEA);
            }
        }
        else if (Input.GetButtonDown("Punch") && !myIsPunching && canPunch)
        {
            myPlayer.GetPlayerStats().AddHeat(myPunchHeat + myPunchHeat * myPunchHeatMalus);
            if (myPunchCoroutine != null)
            {
                StopCoroutine(myPunchCoroutine);
            }
            myPunchCoroutine = StartCoroutine("IE_Punch");
        }
        else if (Input.GetButtonDown("Interact") && myCanOpenWorkbench && !myIsInWorkbench)
        {
            myIsInWorkbench = true;
            myPlayer.GetPlayerInventory().SetInWorkBench(true);
            myPlayer.GetPlayerMovement().Block(true);
        }
        else if (Input.GetButtonDown("Interact") && myCanOpenChest && myChestToOpen != null)
        {
            myChestToOpen.OpenChest();
        }
        else if (Input.GetButtonDown("Interact") && myCanInteract && myPNJ != null && !myPlayer.GetPlayerMovement().GetIsInDialogue())
        {
            myPNJ.Interact(true);
            myInteractionButtonGameObject.SetActive(false);
            myPlayer.GetPlayerMovement().SetIsInDialogue(true);
        }
        else if (Input.GetButtonDown("Cancel") && myCanOpenWorkbench && myIsInWorkbench)
        {
            myIsInWorkbench = false;
            myPlayer.GetPlayerInventory().SetInWorkBench(false);
            myPlayer.GetPlayerMovement().Block(false);
        }
        else if (Input.GetButtonDown("Cancel") && myCanInteract && myPNJ != null && myPlayer.GetPlayerMovement().GetIsInDialogue())
        {
            myPNJ.Interact(false);
            myInteractionButtonGameObject.SetActive(true);
            myPlayer.GetPlayerUI().HideDialogue();
            myPlayer.GetPlayerMovement().SetIsInDialogue(false);
        }

        if (myIsPunching)
        {
            myCurrentTimeToHit += Time.deltaTime;
            if (myCurrentTimeToHit >= myTimeToHit)
            {
                myCurrentTimeToHit = 0;
                myPlayer.GetPlayerMovement().Block(false);
                myIsPunching = false;
            }
        }
    }