예제 #1
0
        void Update()
        {
            if (Input.GetButtonDown("Interact"))
            {
                dropTimer.Reset();
                if (AbilitySelectedIndex == Constants.NullInt)
                {
                    if (AbilityHighlightedIndex != Constants.NullInt)
                    {
                        if (playerAbilityInventory.GetPlayerAbility(AbilityHighlightedIndex) != null)
                        {
                            AbilitySelectedIndex = AbilityHighlightedIndex;
                        }
                    }
                }
                else if (AbilitySelectedIndex != Constants.NullInt)
                {
                    transform.GetChild(AbilitySelectedIndex).GetComponent <Image>().color = highlightColor;
                    AbilitySelectedIndex = Constants.NullInt;
                }
            }

            if (Input.GetButton("Interact"))
            {
                if (AbilityHighlightedIndex != Constants.NullInt)
                {
                    if (playerAbilityInventory.GetPlayerAbility(AbilityHighlightedIndex) != null)
                    {
                        if (dropTimer.Tick())
                        {
                            playerAbilityInventory.DropPlayerAbility(AbilityHighlightedIndex);
                            transform.GetChild(AbilityHighlightedIndex).GetComponent <Image>().color = highlightColor;
                            Destroy(transform.GetChild(AbilityHighlightedIndex).GetChild(0).gameObject);
                        }
                    }
                }
            }

            axis = Input.GetAxisRaw("HorizontalMovement");
            if (axis != 0 && !axisInUse)
            {
                axisInUse = true;
                if (AbilitySelectedIndex != Constants.NullInt)
                {
                    AbilitySelectedIndex += (int)Mathf.Sign(axis);
                }

                if (AbilitySelectedIndex == Constants.NullInt)
                {
                    AbilityHighlightedIndex += (int)Mathf.Sign(axis);
                }
            }

            if (axis == 0)
            {
                axisInUse = false;
            }
        }