コード例 #1
0
        public override void Update()
        {
            if (_lastState != _state)
            {
                _lastState = _state;
                SetSelectorPos();
                SoundManager.PlaySoundEffect("menu_move");
            }

            base.Update();
        }
コード例 #2
0
    public void Unequip(EquipState item)
    {
        if (!shopCon.activeSelf)
            return;

        state.CurrentGold += item.sellCost;
        //// 돈 증가
        //if(!inventory.IsFull() && inventory.RemoveItem(item))
        //{
        //    //shop.AddItem(item);

        //}
        inventory.RemoveItem(item);
    }
コード例 #3
0
ファイル: Inventory.cs プロジェクト: phoneia/project_2
 public bool AddItem(EquipState item, out EquipState prevItem)
 {
     for (int i = 0; i < inventorySlots.Length; i++)
     {
         if (inventorySlots[i].Item == null)
         {
             prevItem = (EquipState)inventorySlots[i].Item;
             inventorySlots[i].Item = item;
             return(true);
         }
     }
     prevItem = null;
     return(false);
 }
コード例 #4
0
        public override void GetControl()
        {
            if (!InventoryManager.HasAnyBroom)
            {
                Exit = true;
                return;
            }

            base.GetControl();
            _state     = EquipState.Broom;
            _lastState = _state;

            SetSelectorPos();
        }
コード例 #5
0
        public override void HandleInput()
        {
            if (KeyInput.JustPressedRebindableKey(KeyFunctions.Up))
            {
                if (_state == EquipState.Broom)
                {
                    return;
                }

                if (_state >= EquipState.Shoes)
                {
                    _state = EquipState.Transformer;
                    return;
                }

                _state--;
            }
            else if (KeyInput.JustPressedRebindableKey(KeyFunctions.Down))
            {
                if (_state >= EquipState.Item)
                {
                    return;
                }

                _state++;
            }
            else if (_state >= EquipState.Shoes && KeyInput.JustPressedRebindableKey(KeyFunctions.Right))
            {
                if (_state == EquipState.Key3)
                {
                    return;
                }

                _state++;
            }
            else if (_state > EquipState.Shoes && KeyInput.JustPressedRebindableKey(KeyFunctions.Left))
            {
                _state--;
            }
            else if (KeyInput.JustPressedRebindableKey(KeyFunctions.Accept))
            {
                UseItem();
            }
            else
            {
                base.HandleInput();
            }
        }
コード例 #6
0
    public void Equip(EquipState item)
    {
        if (state.CurrentGold < item.buyCost)
            return;

        EquipState prevItem;
        if (inventory.AddItem(item, out prevItem))
        {
            if (prevItem != null)
            {

                //shop.AddItem(prevItem);
            }
            state.CurrentGold -= item.buyCost;
        }
        else
        {
            //shop.AddItem(item);
        }
    }
コード例 #7
0
ファイル: Equip_Item.cs プロジェクト: cesarrac/TheyRise-game
    public void SwitchRig(EquipState _curState)
    {
        // Reset the wpn's Sprite Renderer x and y flip values
        equipment_Holder.GetComponent<SpriteRenderer>().flipX = false;
        equipment_Holder.GetComponent<SpriteRenderer>().flipY = false;

        switch (_curState)
        {
            case EquipState.DOWN:
                // Switch to down rig

                equipState = EquipState.DOWN;

                // Set Parent...
                equipment_Holder.transform.SetParent(Weapon_Down, false);

                // ... and Reset their transform
                equipment_Holder.transform.localPosition = Vector3.zero;
                equipment_Holder.transform.localRotation = Quaternion.Euler(0, 0, 0);
                equipment_Holder.transform.localScale = new Vector3(1, 1, 1);

                // ... flip X is true for this case, so get the Sprite Renderer
                equipment_Holder.GetComponent<SpriteRenderer>().flipX = true;

                // ... then "sort" its sorting layer
                equipment_Holder.GetComponent<Weapon_SortingLayer>().CheckSortingLayer(wpn_render_Down);

                // ... tell the Attack Handler what the current active player arms are (for rotation)
                attk_handler.SetCurrentArms(Weapon_Down.transform.parent.parent);

                // .. Parent the sightStart to the correct holder
                sightStart.SetParent(Weapon_Down, false);

                // ... and reset its Transform
                sightStart.transform.localPosition = new Vector3(0, 0.12f, 0);
                sightStart.transform.localRotation = Quaternion.Euler(0, 0, 0);
                sightStart.transform.localScale = new Vector3(1, 1, 1);

                break;
            case EquipState.LEFT:
                // Switch to LEFT rig

                equipState = EquipState.LEFT;

                // Set Parent...
                equipment_Holder.transform.SetParent(Weapon_Left);

                // ... and Reset their transform
                equipment_Holder.transform.localPosition = Vector3.zero;
                equipment_Holder.transform.localRotation = Quaternion.Euler(0, 0, 0);
                equipment_Holder.transform.localScale = new Vector3(1, 1, 1);

                // ... flip X is true for this case, so get the Sprite Renderer
                equipment_Holder.GetComponent<SpriteRenderer>().flipX = true;

                // ... then "sort" its sorting layer
                equipment_Holder.GetComponent<Weapon_SortingLayer>().CheckSortingLayer(wpn_render_Left);

                // ... tell the Attack Handler what the current active player arms are (for rotation)
                attk_handler.SetCurrentArms(Weapon_Left.transform.parent.parent);

                // .. Parent the sightStart to the correct holder
                sightStart.SetParent(Weapon_Left, false);

                // ... and reset its Transform
                sightStart.transform.localPosition = new Vector3(0, 0.18f, 0);
                sightStart.transform.localRotation = Quaternion.Euler(0, 0, 0);
                sightStart.transform.localScale = new Vector3(1, 1, 1);

                break;
            case EquipState.UP:
                // Switch to up rig

                equipState = EquipState.UP;

                // First Set Parent...
                equipment_Holder.transform.SetParent(Weapon_Up);

                // ... and Reset their transform
                equipment_Holder.transform.localPosition = Vector3.zero;
                equipment_Holder.transform.localRotation = Quaternion.Euler(0, 0, 0);
                equipment_Holder.transform.localScale = new Vector3(1, 1, 1);

                // ... then "sort" its sorting layer
                equipment_Holder.GetComponent<Weapon_SortingLayer>().CheckSortingLayer(wpn_render_Up);

                // ... tell the Attack Handler what the current active player arms are (for rotation)
                attk_handler.SetCurrentArms(Weapon_Up.transform.parent.parent);

                // .. Parent the sightStart to the correct holder
                sightStart.SetParent(Weapon_Up, false);

                // ... and reset its Transform
                sightStart.transform.localPosition = new Vector3(0, 0.12f, 0);
                sightStart.transform.localRotation = Quaternion.Euler(0, 0, 0);
                sightStart.transform.localScale = new Vector3(1, 1, 1);

                break;
            case EquipState.RIGHT:
                // Switch to right rig

                equipState = EquipState.RIGHT;

                // Set Parent...
                equipment_Holder.transform.SetParent(Weapon_Right);

                // ... and Reset their transform
                equipment_Holder.transform.localPosition = Vector3.zero;
                equipment_Holder.transform.localRotation = Quaternion.Euler(0, 0, 0);
                equipment_Holder.transform.localScale = new Vector3(1, 1, 1);

                // ... then "sort" its sorting layer
                equipment_Holder.GetComponent<Weapon_SortingLayer>().CheckSortingLayer(wpn_render_Right);

                // ... tell the Attack Handler what the current active player arms are (for rotation)
                attk_handler.SetCurrentArms(Weapon_Right.transform.parent.parent);

                // .. Parent the sightStart to the correct holder
                sightStart.SetParent(Weapon_Right, false);

                // ... and reset its Transform
                sightStart.transform.localPosition = new Vector3(0, 0.18f, 0);
                sightStart.transform.localRotation = Quaternion.Euler(0, 0, 0);
                sightStart.transform.localScale = new Vector3(1, 1, 1);

                break;
            default:
                // Switch to Down rig

                equipState = EquipState.DOWN;

                // Set Parent...
                equipment_Holder.transform.SetParent(Weapon_Down, false);

                // ... and Reset their transform
                equipment_Holder.transform.localPosition = Vector3.zero;
                equipment_Holder.transform.localRotation = Quaternion.Euler(0, 0, 0);
                equipment_Holder.transform.localScale = new Vector3(1, 1, 1);

                // ... flip X is true for this case, so get the Sprite Renderer
                equipment_Holder.GetComponent<SpriteRenderer>().flipX = true;

                // ... then "sort" its sorting layer
                equipment_Holder.GetComponent<Weapon_SortingLayer>().CheckSortingLayer(wpn_render_Down);

                // ... tell the Attack Handler what the current active player arms are (for rotation)
                attk_handler.SetCurrentArms(Weapon_Down.transform.parent.parent);

                // .. Parent the sightStart to the correct holder
                sightStart.SetParent(Weapon_Down, false);

                // ... and reset its Transform
                sightStart.transform.localPosition = new Vector3(0, 0.12f, 0);
                sightStart.transform.localRotation = Quaternion.Euler(0, 0, 0);
                sightStart.transform.localScale = new Vector3(1, 1, 1);

                break;

        }
    }