Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
#if UNITY_STANDALONE
        // Need to check whether the player has pressed the key and theEnemy is not null
        if (Input.GetKeyDown(KeyBindScript.attackKey))
        {
            //Need to see if the Player is talking to NPC or not
            if (!openInventory)
            {
                if (!LocalDataSingleton.instance.talking)
                {
                    theHeroMeleeSystem.meleeAttack();
                }
                GameObject.FindGameObjectWithTag("GameController").GetComponent <PlayerController>().TryInteract();
            }
        }
        else if (Input.GetKeyDown(KeyBindScript.rangeKey) && !LocalDataSingleton.instance.talking)
        {
            theHeroRangeSystem.shootArrow();
        }
        else if (Input.GetKeyDown(KeyBindScript.inventoryKey))
        {
            // Need to make sure that the player is not talking and he is not opening inventory
            switch (openInventory)
            {
            case true:
                if (LocalDataSingleton.instance.talking)
                {
                    LocalDataSingleton.instance.Inventorycanvas.SetActive(!LocalDataSingleton.instance.Inventorycanvas.activeSelf);
                    LocalDataSingleton.instance.talking = LocalDataSingleton.instance.Inventorycanvas.activeSelf;
                    GameObject.FindGameObjectWithTag("Player").GetComponent <HeroesMovement>().stopMovement();
                    openInventory = false;
                }
                break;

            default:
                if (!LocalDataSingleton.instance.talking)
                {
                    LocalDataSingleton.instance.Inventorycanvas.SetActive(!LocalDataSingleton.instance.Inventorycanvas.activeSelf);
                    LocalDataSingleton.instance.talking = LocalDataSingleton.instance.Inventorycanvas.activeSelf;
                    GameObject.FindGameObjectWithTag("Player").GetComponent <HeroesMovement>().stopMovement();
                    openInventory = true;
                }
                break;
            }
            //if (!LocalDataSingleton.instance.talking && !openInventory)
            //{
            //    LocalDataSingleton.instance.Inventorycanvas.SetActive(!LocalDataSingleton.instance.Inventorycanvas.activeSelf);
            //    LocalDataSingleton.instance.talking = LocalDataSingleton.instance.Inventorycanvas.activeSelf;
            //    GameObject.FindGameObjectWithTag("Player").GetComponent<HeroesMovement>().stopMovement();
            //}
        }
#endif
    }
Ejemplo n.º 2
0
 public void pressedShoot()
 {
     //Debug.Log("Trying to shoot");
     if (!LocalDataSingleton.instance.talking)
     {
         if (heroRangeAttack == null)
         {
             //Debug.Log("Finding GameObject 1st");
             heroRangeAttack = GameObject.FindObjectOfType <HeroRangeScript>();
         }
         if (thePlayerJoystick == null)
         {
             thePlayerJoystick = GameObject.FindObjectOfType <PlayerDrag>();
         }
         thePlayerJoystick.playerHasPressedButton();
         heroRangeAttack.shootArrow();
     }
 }