// Access text field
    void Start()
    {
        globalData  = ChangeSceneScript.Instance;
        updateField = true;

        // Get music configuration
        musicToggle.isOn = globalData.musicOn;


        // Add listener to change of toggle
        musicToggle.GetComponent <Toggle> ().onValueChanged.AddListener(
            delegate {
            globalData.setMusic(musicToggle.GetComponent <Toggle>().isOn);
        });

        // Add listener to Play button
        playButton.onClick.AddListener(() => {
            globalData.ChangeScene();
        });
    }
    //Handles input from player
    void Update()
    {
        //select J
        if (Input.GetKeyDown(KeyCode.J))
        {
            SmallItemSlot.ShowDescriptionPanel();
            MediumItemSlot.HideDescriptionPanel();
            LargeItemSlot.HideDescriptionPanel();
            choice = (int)Choices.Small;
        }
        if (Input.GetKeyDown(KeyCode.K))
        {
            SmallItemSlot.HideDescriptionPanel();
            MediumItemSlot.ShowDescriptionPanel();
            LargeItemSlot.HideDescriptionPanel();
            choice = (int)Choices.Medium;
        }
        if (Input.GetKeyDown(KeyCode.L))
        {
            SmallItemSlot.HideDescriptionPanel();
            MediumItemSlot.HideDescriptionPanel();
            LargeItemSlot.ShowDescriptionPanel();
            choice = (int)Choices.Large;
        }

        if (Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.D))
        {
            HoldADTime += Time.deltaTime;
            HoldADFill.transform.localScale = new Vector3(HoldADTime, 1, 1);
            print("been holding for " + (int)HoldADTime);
            if (HoldADTime > 1f)
            {
                ChangeSceneScript.ChangeScene(nextScene);
            }
        }

        if (Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.D))
        {
            HoldADTime = 0;
            HoldADFill.transform.localScale = new Vector3(HoldADTime, 1, 1);
            print("been holding for " + (int)HoldADTime);
        }
        if (Input.GetKey(KeyCode.Space))
        {
            HoldSpaceTime += Time.deltaTime;
            //don't stretch infinitely
            if (HoldSpaceTime < 1.01)
            {
                HoldSpaceFill.transform.localScale = new Vector3(HoldSpaceTime, 1, 1);
            }
            print("been holding for " + (int)HoldSpaceTime);
            if (HoldSpaceTime > 1f)
            {
                switch (choice)
                {
                case (int)Choices.None:
                    error.Play();
                    print("no selection");
                    break;

                case (int)Choices.Small:
                    SmallItemSlot.Buy();
                    break;

                case (int)Choices.Medium:
                    MediumItemSlot.Buy();
                    break;

                case (int)Choices.Large:
                    LargeItemSlot.Buy();
                    break;
                }
                HoldSpaceTime = 0f;
            }
        }
        if (Input.GetKeyUp(KeyCode.Space))
        {
            HoldSpaceTime = 0;
            HoldSpaceFill.transform.localScale = new Vector3(HoldSpaceTime, 1, 1);
            print("been holding for " + (int)HoldSpaceTime);
        }

        if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.D))
        {
            SmallItemSlot.HideDescriptionPanel();
            MediumItemSlot.HideDescriptionPanel();
            LargeItemSlot.HideDescriptionPanel();
            //reset choice nothing
            choice = (int)Choices.None;
        }
    }
Exemple #3
0
 public void Change()
 {
     ChangeSceneScript.ChangeScene(nextScene);
 }