Ejemplo n.º 1
0
 void textureString_MouseLeftClick(GameComponent sender, MouseEvent mouseEvent)
 {
     currentIndex = textSprite.IndexOf(sender);
     if (Selected != null)
     {
         Selected.Invoke(this, EventArgs.Empty);
     }
 }
Ejemplo n.º 2
0
        void ItemSettingComponent_Inputed(IFocusable sender, InputEventArgs args)
        {
            if (args.InputInfo.IsPressed(ButtonType.Cross))
            {
                sound.Play(PPDSetting.DefaultSounds[2], -1000);
                FocusManager.RemoveFocus();
            }
            else if (args.InputInfo.IsPressed(ButtonType.Down))
            {
                current.Selected = false;
                SpriteObject targetSprite = CurrentIsInManual ? manualUseSprite : autoUseSprite;
                var          index        = targetSprite.IndexOf(current);
                index++;
                if (index >= targetSprite.ChildrenCount)
                {
                    index = 0;
                }
                current          = targetSprite[index] as UseItemComponent;
                current.Selected = true;
                sound.Play(PPDSetting.DefaultSounds[0], -1000);
            }
            else if (args.InputInfo.IsPressed(ButtonType.Up))
            {
                current.Selected = false;
                SpriteObject targetSprite = CurrentIsInManual ? manualUseSprite : autoUseSprite;
                var          index        = targetSprite.IndexOf(current);
                index--;
                if (index < 0)
                {
                    index = targetSprite.ChildrenCount - 1;
                }
                current          = targetSprite[index] as UseItemComponent;
                current.Selected = true;
                sound.Play(PPDSetting.DefaultSounds[0], -1000);
            }
            else if (args.InputInfo.IsPressed(ButtonType.Left))
            {
                if (!CurrentIsInManual && manualUseSprite.ChildrenCount > 0)
                {
                    current.Selected = false;
                    var index = autoUseSprite.IndexOf(current);
                    if (index >= manualUseSprite.ChildrenCount)
                    {
                        index = manualUseSprite.ChildrenCount - 1;
                    }
                    current          = manualUseSprite[index] as UseItemComponent;
                    current.Selected = true;
                    sound.Play(PPDSetting.DefaultSounds[0], -1000);
                }
            }
            else if (args.InputInfo.IsPressed(ButtonType.Right))
            {
                if (CurrentIsInManual && autoUseSprite.ChildrenCount > 0)
                {
                    current.Selected = false;
                    var index = manualUseSprite.IndexOf(current);
                    if (index >= autoUseSprite.ChildrenCount)
                    {
                        index = autoUseSprite.ChildrenCount - 1;
                    }
                    current          = autoUseSprite[index] as UseItemComponent;
                    current.Selected = true;
                    sound.Play(PPDSetting.DefaultSounds[0], -1000);
                }
            }
            else if (args.InputInfo.IsPressed(ButtonType.Circle) ||
                     args.InputInfo.IsPressed(ButtonType.Triangle) ||
                     args.InputInfo.IsPressed(ButtonType.Square))
            {
                bool isInManual = CurrentIsInManual;
                current.Parent.RemoveChild(current);

                if (isInManual)
                {
                    autoUseSprite.AddChild(current);
                }
                else
                {
                    manualUseSprite.AddChild(current);
                }

                AdjustPositions();
                ItemUseManager.Manager.ToggleAutoUse(current.ItemType);
                sound.Play(PPDSetting.DefaultSounds[3], -1000);
            }
        }