Exemplo n.º 1
0
        /// <summary>
        /// Load sequences for current level from definitions XML
        /// </summary>
        private void LoadLevelSequences()
        {
            XDocument doc         = XDocument.Load(@"Content\Gameplay\LevelDefinitions.xml");
            var       definitions = doc.Document.Descendants(XName.Get("Level"));

            XElement levelDefinition = null;

            foreach (var definition in definitions)
            {
                if (int.Parse(
                        definition.Attribute(XName.Get("Number")).Value) == levelNumber)
                {
                    levelDefinition = definition;
                    break;
                }
            }

            // Used to skip moves if we are resuming a level mid-play
            int skipMoves = 0;

            // If definitions are found, create a sequences
            if (null != levelDefinition)
            {
                sequence = new LinkedList <ButtonColors[]>();

                foreach (var pattern in
                         levelDefinition.Descendants(XName.Get("Pattern")))
                {
                    if (skipMoves < MovesPerformed)
                    {
                        skipMoves++;
                        continue;
                    }

                    string[]       values = pattern.Value.Split(',');
                    ButtonColors[] colors = new ButtonColors[values.Length];

                    // Add each color to a sequence
                    for (int i = 0; i < values.Length; i++)
                    {
                        colors[i] = (ButtonColors)Enum.Parse(
                            typeof(ButtonColors), values[i], true);
                    }

                    // Add each sequence to the sequence list
                    sequence.AddLast(colors);
                }

                if (MovesPerformed == 0)
                {
                    CurrentState = LevelState.Ready;
                    delayPeriod  = TimeSpan.Zero;
                }
                else
                {
                    InitializeUserInputStage();
                }
            }
        }
Exemplo n.º 2
0
 public Button(string text, Vector2 position, SpriteFont font, ButtonColors colors)
 {
     Text = text;
     Position = position;
     Colors = colors;
     State = ButtonState.Enabled;
     Font = font;
 }
Exemplo n.º 3
0
    // Use this for initialization
    private void Start()
    {
        btn       = GetComponent <Button>();
        loadItems = FindObjectOfType <CategoryLoadItems>();
        btn.onClick.AddListener(delegate() { loadItems.loadItems((Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), this.gameObject.name)); });
        ButtonColors col = GetComponent <ButtonColors>();

        col.GetMyHighlightedColor = Color.yellow;
    }
Exemplo n.º 4
0
 public HMIMushroomButton()
 {
     this.TextRectangle = new Rectangle();
     this.m_ButtonColor = ButtonColors.RedMushroom;
     this.m_LegendPlate = LegendPlates.Large;
     this.m_OutputType  = OutputTypes.MomentarySet;
     this.sf            = new StringFormat();
     this.TextBrush     = new SolidBrush(Color.Black);
 }
Exemplo n.º 5
0
 public void AddButton(
     ButtonColors color,
     string text,
     EventHandler handle,
     string image = null,
     bool ChangeImageAlignment = false,
     object data    = null,
     bool isEnabled = true)
 {
     this.AddButtonInUI(new CustomButton(color), color, text, handle, image, ChangeImageAlignment, data, isEnabled);
 }
Exemplo n.º 6
0
        private void UIButtonColorChanged(object sender, RoutedEventArgs e)
        {
            Shirt        s = (Shirt)e.Source;
            ButtonColors b = s.ButtonColor;

            if (b == ButtonColors.None)
            {
                ButtonChoice.Visibility      = Visibility.Hidden;
                ButtonChoiceLabel.Visibility = Visibility.Hidden;
            }
            else
            {
                ButtonChoice.Visibility      = Visibility.Visible;
                ButtonChoiceLabel.Visibility = Visibility.Visible;
            }
        }
Exemplo n.º 7
0
 internal static void HandleCompatibility(string package, string vmName)
 {
     try
     {
         GrmHandler.AppCompatErrorWindow = new CustomMessageWindow();
         GrmHandler.AppCompatErrorWindow.TitleTextBlock.Text = BlueStacksUIUtils.DictWindows[vmName].mWelcomeTab.mHomeAppManager.GetAppIcon(package).AppName;
         if (!string.IsNullOrEmpty(AppRequirementsParser.Instance.GetLocalizedString(GrmHandler.sDictAppRuleSet[vmName][package].MessageWindow.HeaderStringKey)))
         {
             GrmHandler.AppCompatErrorWindow.BodyTextBlockTitle.Text       = AppRequirementsParser.Instance.GetLocalizedString(GrmHandler.sDictAppRuleSet[vmName][package].MessageWindow.HeaderStringKey);
             GrmHandler.AppCompatErrorWindow.BodyTextBlockTitle.Visibility = Visibility.Visible;
         }
         GrmHandler.AppCompatErrorWindow.BodyTextBlock.Text = AppRequirementsParser.Instance.GetLocalizedString(GrmHandler.sDictAppRuleSet[vmName][package].MessageWindow.MessageStringKey);
         if (GrmHandler.sDictAppRuleSet[vmName][package].MessageWindow.MessageType == MessageType.Info.ToString())
         {
             GrmHandler.AppCompatErrorWindow.MessageIcon.ImageName = "message_info";
         }
         else if (GrmHandler.sDictAppRuleSet[vmName][package].MessageWindow.MessageType == MessageType.Error.ToString())
         {
             GrmHandler.AppCompatErrorWindow.MessageIcon.ImageName = "message_error";
         }
         GrmHandler.AppCompatErrorWindow.MessageIcon.Visibility = Visibility.Visible;
         if (GrmHandler.sDictAppRuleSet[vmName][package].MessageWindow.DontShowOption)
         {
             GrmHandler.AppCompatErrorWindow.CheckBox.Content    = (object)LocaleStrings.GetLocalizedString("STRING_DOWNLOAD_GOOGLE_APP_POPUP_STRING_04", "");
             GrmHandler.AppCompatErrorWindow.CheckBox.Visibility = Visibility.Visible;
         }
         foreach (GrmMessageButton button1 in GrmHandler.sDictAppRuleSet[vmName][package].MessageWindow.Buttons)
         {
             GrmMessageButton button = button1;
             ButtonColors     color  = EnumHelper.Parse <ButtonColors>(button.ButtonColor, ButtonColors.Blue);
             GrmHandler.AppCompatErrorWindow.AddButton(color, AppRequirementsParser.Instance.GetLocalizedString(button.ButtonStringKey), (EventHandler)((o, e) => GrmHandler.PerformGrmActions(button.Actions, package, BlueStacksUIUtils.DictWindows[vmName])), (string)null, false, (object)null, true);
         }
         GrmHandler.AppCompatErrorWindow.Owner = (Window)BlueStacksUIUtils.DictWindows[vmName];
         BlueStacksUIUtils.DictWindows[vmName].ShowDimOverlay((IDimOverlayControl)null);
         GrmHandler.AppCompatErrorWindow.ShowDialog();
         BlueStacksUIUtils.DictWindows[vmName].HideDimOverlay();
     }
     catch (Exception ex)
     {
         Logger.Error("Exception while showing appcompat message to user. Exception: " + ex.ToString());
         BlueStacksUIUtils.DictWindows[vmName].mWelcomeTab.mHomeAppManager.OpenApp(package, false);
     }
 }
Exemplo n.º 8
0
 public void AddButtonInUI(
     CustomButton button,
     ButtonColors color,
     string text,
     EventHandler handle,
     string image,
     bool ChangeImageAlignment,
     object data,
     bool isEnabled)
 {
     if (button != null)
     {
         if (this.mButton1 == null)
         {
             this.mButton1 = button;
         }
         else
         {
             this.mButton2 = button;
             button.Margin = new Thickness(15.0, 0.0, 0.0, 0.0);
         }
         button.IsEnabled  = isEnabled;
         button.Click     += new RoutedEventHandler(this.Button_Click);
         button.MinWidth   = 100.0;
         button.Visibility = Visibility.Visible;
         BlueStacksUIBinding.Bind((Button)button, text);
         if (image != null)
         {
             button.ImageName   = image;
             button.ImageMargin = new Thickness(0.0, 6.0, 5.0, 6.0);
             if (ChangeImageAlignment)
             {
                 button.ImageOrder  = ButtonImageOrder.AfterText;
                 button.ImageMargin = new Thickness(5.0, 6.0, 0.0, 6.0);
             }
         }
     }
     this.mStackPanel.Children.Add((UIElement)button);
     this.mDictActions.Add((object)button, new Tuple <ButtonColors, EventHandler, object>(color, handle, data));
 }
Exemplo n.º 9
0
    public void TryLatching(ButtonColors currentColor) //color option to go in here?
    {
        tryingToLatch = currentColor;
        GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
        foreach (GameObject player in players)
        {
            Ship currentShip = player.GetComponent <Ship>();

            if (currentShip.tryingToLatch != ButtonColors.Null && currentShip.tryingToLatch == currentColor && currentShip != this)
            {
                if (connections.ContainsKey(currentShip))
                {
                    //Already bound, nothing done.
                    print("returning ");

                    return;
                }
                else
                {
                    float currentDistance = Vector3.Distance(gameObject.transform.position, currentShip.transform.position);
                    if (currentDistance > maximumDistanceForLatching)
                    {
                        print("too far");
                        continue;
                        //too far, nothing done.
                    }
                    //SUCCESFUL, BINDING
                    GameObject   rope          = Instantiate(ropePrefab as Object) as GameObject;
                    UltimateRope ropeComponent = rope.GetComponent <UltimateRope>();
                    speaker.clip = latching;
                    speaker.Play();
                    //Dictionary<ButtonColors, UltimateRope> tmpDict = new Dictionary<ButtonColors, UltimateRope>() {
                    //    { currentColor,ropeComponent}
                    //};

                    connections.Add(currentShip, new Dictionary <ButtonColors, UltimateRope>()
                    {
                        { currentColor, ropeComponent }
                    });
                    currentShip.connections.Add(this, new Dictionary <ButtonColors, UltimateRope>()
                    {
                        { currentColor, ropeComponent }
                    });

                    ropeComponent.RopeStart            = transform.FindChild("Hook").gameObject;
                    ropeComponent.RopeNodes[0].fLength = currentDistance * 1f;
                    ropeComponent.RopeNodes[0].goNode  = currentShip.transform.FindChild("Hook").gameObject;
                    ropeComponent.Regenerate();
                    rope.layer = LayerMask.NameToLayer("Bond");
                    if (currentColor == ButtonColors.Red)
                    {
                        rope.renderer.material.color = Color.red;
                    }
                    else if (currentColor == ButtonColors.Blue)
                    {
                        rope.renderer.material.color = Color.blue;
                    }
                    else if (currentColor == ButtonColors.Green)
                    {
                        rope.renderer.material.color = Color.green;
                    }
                    else if (currentColor == ButtonColors.Yellow)
                    {
                        rope.renderer.material.color = Color.yellow;
                    }
                }
            }
        }
    }
Exemplo n.º 10
0
 public CustomButton(ButtonColors color)
     : this()
 {
     this.ButtonColor = color;
 }
Exemplo n.º 11
0
        /// <summary>
        /// Load sequences for the current level from definitions XML
        /// </summary>
        private void LoadLevelSequences()
        {
            XDocument doc = XDocument.Load(@"Content\Gameplay\LevelDefinitions.xml");
            var definitions = doc.Document.Descendants(XName.Get("Level"));

            XElement levelDefinition = null;

            foreach (var definition in definitions)
            {
                if (int.Parse(
                    definition.Attribute(XName.Get("Number")).Value) == levelNumber)
                {
                    levelDefinition = definition;
                    break;
                }
            }

            int skipMoves = 0; // Used to skip moves if we are resuming a level mid-play

            // If definitions are found, create sequences
            if (null != levelDefinition)
            {
                sequence = new LinkedList<ButtonColors[]>();

                foreach (var pattern in
                    levelDefinition.Descendants(XName.Get("Pattern")))
                {
                    if (skipMoves < MovesPerformed)
                    {
                        skipMoves++;
                        continue;
                    }

                    string[] values = pattern.Value.Split(',');
                    ButtonColors[] colors = new ButtonColors[values.Length];

                    // Add each color to a sequence
                    for (int i = 0; i < values.Length; i++)
                    {
                        colors[i] = (ButtonColors)Enum.Parse(
                            typeof(ButtonColors), values[i], true);
                    }

                    // Add each sequence to the sequence list
                    sequence.AddLast(colors);
                }

                if (MovesPerformed == 0)
                {
                    CurrentState = LevelState.Ready;
                    delayPeriod = TimeSpan.Zero;
                }
                else
                {
                    InitializeUserInputStage();
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Draws the set of lit buttons according to the colors specified.
        /// </summary>
        /// <param name="toDraw">The array of colors representing the lit 
        /// buttons.</param>
        private void DrawLitButtons(ButtonColors[] toDraw)
        {
            Vector2 position = Vector2.Zero;
            Rectangle rectangle = Rectangle.Empty;

            for (int i = 0; i < toDraw.Length; i++)
            {
                switch (toDraw[i])
                {
                    case ButtonColors.Red:
                        position = Settings.RedButtonPosition;
                        rectangle = Settings.RedButtonLit;
                        break;
                    case ButtonColors.Yellow:
                        position = Settings.YellowButtonPosition;
                        rectangle = Settings.YellowButtonLit;
                        break;
                    case ButtonColors.Blue:
                        position = Settings.BlueButtonPosition;
                        rectangle = Settings.BlueButtonLit;
                        break;
                    case ButtonColors.Green:
                        position = Settings.GreenButtonPosition;
                        rectangle = Settings.GreenButtonLit;
                        break;
                }

                spriteBatch.Draw(buttonsTexture, position, rectangle, Color.White);
            }
        }