Ejemplo n.º 1
0
    private void ProcessInput()
    {
        //Left
        if (Input.GetMouseButtonDown(0) || Input.GetButtonDown("Destruct"))
        {
            if (DialogueManager.Instance.IsInDialogue)
            {
                m_CurrentDialogue.NextDialogue();
            }
            else if (m_CurrentInteractable != null)
            {
                if (m_CurrentInteractable.InteractableType == EInteractableType.Dialogue)
                {
                    m_CurrentDialogue = m_CurrentInteractable.GetComponent <DialogueInteractable>();
                    if (m_CurrentDialogue == null)
                    {
                        Debug.LogError("No DialogueInteractable component found");
                    }
                    else
                    {
                        m_CurrentDialogue.StartDialogue(EndDialogue);
                    }
                }
                else
                {
                    m_CurrentInteractType = EInteractType.Destruct;
                    if (m_CurrentInteractable.InteractableType == EInteractableType.Destructable)
                    {
                        m_PlayerResources.AddResource(m_CurrentInteractable.ResourceType, m_CurrentInteractable.ResourceValue);
                        m_CurrentInteractable.StartDestruct();
                    }

                    if (PlayerDataModule.Inst.playerMovement.playerState == PlayerMovement.PlayerState.IdleLeft || PlayerDataModule.Inst.playerMovement.playerState == PlayerMovement.PlayerState.MovingLeft)
                    {
                        PlayerDataModule.Inst.playerMovement.playerState = PlayerMovement.PlayerState.DestructLeft;
                    }

                    if (PlayerDataModule.Inst.playerMovement.playerState == PlayerMovement.PlayerState.IdleRight || PlayerDataModule.Inst.playerMovement.playerState == PlayerMovement.PlayerState.MovingRight)
                    {
                        PlayerDataModule.Inst.playerMovement.playerState = PlayerMovement.PlayerState.DestructRight;
                    }
                }
            }
        }

        //Right
        if (Input.GetMouseButtonDown(1) || Input.GetButtonDown("Repair"))
        {
            m_CurrentInteractType = EInteractType.Repair;

            if (m_CurrentInteractable != null && m_CurrentInteractable.InteractableType == EInteractableType.Repairable && m_PlayerResources.resources[(int)m_CurrentInteractable.ResourceType].Count > 0)
            {
                m_PlayerResources.UseResource(m_CurrentInteractable.ResourceType, m_CurrentInteractable.ResourceValue);
                m_CurrentInteractable.StartRepair();
            }

            if (PlayerDataModule.Inst.playerMovement.playerState == PlayerMovement.PlayerState.IdleLeft || PlayerDataModule.Inst.playerMovement.playerState == PlayerMovement.PlayerState.MovingLeft)
            {
                PlayerDataModule.Inst.playerMovement.playerState = PlayerMovement.PlayerState.RepairLeft;
            }

            if (PlayerDataModule.Inst.playerMovement.playerState == PlayerMovement.PlayerState.IdleRight || PlayerDataModule.Inst.playerMovement.playerState == PlayerMovement.PlayerState.MovingRight)
            {
                PlayerDataModule.Inst.playerMovement.playerState = PlayerMovement.PlayerState.RepairRight;
            }
        }
    }
Ejemplo n.º 2
0
 private void EndDialogue()
 {
     m_CurrentDialogue = null;
 }