Exemple #1
0
        private void addCounterComponent(object sender, RoutedEventArgs e)
        {
            CounterComponent c = new CounterComponent(0, 1);

            componentList.Add(c);
            addCounter(c);
        }
Exemple #2
0
        /// <summary>
        /// Compile single input function
        /// </summary>
        /// <param name="component">Component to be compiled</param>
        /// <param name="input">Function logical input</param>
        /// <param name="codeBuffer">Compiler's code buffer</param>
        /// <returns></returns>
        internal static string CompileInputFunctionComponent(ComponentBase component, string input, CompilerBuffer codeBuffer)
        {
            string buffer = string.Empty;

            if (component is OSF)
            {
                buffer = OSF_FN + "(" + codeBuffer.OSRCount + ", " + input + ")";
                codeBuffer.OSFCount++;
            }
            else if (component is OSR)
            {
                buffer = OSR_FN + "(" + codeBuffer.OSRCount + ", " + input + ")";
                codeBuffer.OSRCount++;
            }
            else if (component is CounterComponent)
            {
                CounterComponent counter = component as CounterComponent;

                if (component is CTD)
                {
                    buffer = CTD_FN + "(" + counter.Limit + ", &" + counter.FullName + ", " + codeBuffer.OSRCount + ", " + input + ")";
                    codeBuffer.OSRCount++;
                }
                else if (component is CTU)
                {
                    buffer = CTU_FN + "(" + counter.Limit + ", &" + counter.FullName + ", " + codeBuffer.OSRCount + ", " + input + ")";
                    codeBuffer.OSRCount++;
                }
            }

            return(buffer);
        }
Exemple #3
0
        private void addCounter(NameComponent component)
        {
            CounterComponent com        = (CounterComponent)component;
            Canvas           canvas     = createNameComponent(componentList.getList().IndexOf(com));
            Label            startLabel = new Label();
            Label            stepLabel  = new Label();
            TextBox          startBox   = new TextBox();
            TextBox          stepBox    = new TextBox();

            AddComponentsToCanvas(canvas, startBox, startLabel);
            AddComponentsToCanvas(canvas, stepBox, stepLabel);

            startBox.PreviewTextInput += handleNonNurmeric;
            stepBox.PreviewTextInput  += handleNonNurmeric;
            startBox.TextChanged      += StartNumberChanged;
            stepBox.TextChanged       += StepNumberChanged;

            startBox.Width     = 100;
            stepBox.Width      = 70;
            startLabel.Content = "Start at: ";
            stepLabel.Content  = "With step size: ";

            Canvas.SetLeft(startLabel, 5);
            Canvas.SetLeft(startBox, 100);
            Canvas.SetLeft(stepLabel, 220);
            Canvas.SetLeft(stepBox, 340);
            nameCanvas.Children.Add(canvas);
            initialiseTextBox(startBox, com.StartNumber.ToString());
            initialiseTextBox(stepBox, com.Step.ToString());
            EnlargeCanvas(nameCanvas, 40);
        }
Exemple #4
0
        public void IncrementCount_Invoke_IncreaseCurrentValue()
        {
            var someClass = new CounterComponent();

            someClass.IncrementCount();

            Assert.IsNotNull(someClass.currentCount > 0);
        }
Exemple #5
0
        private void StartNumberChanged(object sender, TextChangedEventArgs e)
        {
            TextBox          tb        = (TextBox)sender;
            int              index     = nameCanvas.Children.IndexOf((UIElement)tb.Parent);
            CounterComponent component = (CounterComponent)componentList.getList()[index];

            if (!tb.Text.Equals(""))
            {
                component.StartNumber = int.Parse(tb.Text);
            }
        }
        public void Restart(FieldComponent field, CounterComponent counter)
        {
            for (var x = 0; x < field.Map.GetLength(0); x++)
            for (var y = 0; y < field.Map.GetLength(1); y++)
            {
                field.Map[x, y] = Random.NextInt(SharedData.ColorsCount);
            }

            counter.GameOver = false;

            for (int i = 0; i < counter.Players.Count; i++)
            {
                counter.Players[i].Size = 1;
            }
        }
        private void GameOver(CounterComponent counter, FieldComponent field, bool isWin)
        {
            if (isWin)
            {
                counter.Players[0].Wins++;
            }

            counter.GamesPlayed++;
            counter.GameOver = true;
            Core.Instance.SwitchScene(
                new WindTransition
            {
                SceneLoadAction = () =>
                {
                    this.scene.Restart(field, counter);
                    return(this.scene);
                }
            });
        }
Exemple #8
0
        protected override void LoadDisplay()
        {
            var player            = new GameObject("PlayerOneSelection", new Vector2(10, 10));
            var playerText        = new TextComponent(FontGraphics.PropertialFont_8X8, "PLAYER ONE");
            var startText         = new TextComponent(FontGraphics.PropertialFont_8X8, "PRESS SPACE TO START", new Vector2(0, 100));
            var counter           = new CounterComponent(ObjectEvent.PreviousCharacter, ObjectEvent.NextCharacter, 0, _playerCharacters.Count() - 1);
            var sprites           = new SpriteMappingsComponent(RpgGraphics.GameboySpriteMapping, _playerCharacters, new Vector2(10, 50), counter);
            var nextCharacter     = new KeyboardEventComponent(Keys.Right, ObjectEvent.NextCharacter);
            var previousCharacter = new KeyboardEventComponent(Keys.Left, ObjectEvent.PreviousCharacter);
            var action            = new KeyboardActionComponent(Keys.Space, Action);

            player.AddComponent(playerText);
            player.AddComponent(startText);
            player.AddComponent(counter);
            player.AddComponent(sprites);
            player.AddComponent(nextCharacter);
            player.AddComponent(previousCharacter);
            player.AddComponent(action);
            DisplayLayer.AddGameObject(player);
        }
Exemple #9
0
        private void CreatePlayerTwo(Vector2 startPosition)
        {
            var player     = new GameObject("PlayerTwoSelection", new Vector2(10, 10) + startPosition);
            var playerText = new TextComponent(FontGraphics.PropertialFont_8X8, "PLAYER TWO");
            var startText  = new TextComponent(FontGraphics.PropertialFont_8X8, "PRESS TAB TO START", new Vector2(0, 100));
            var counter    = new CounterComponent(ObjectEvent.PreviousCharacter, ObjectEvent.NextCharacter, 0,
                                                  _playerCharacters.Count() - 1);
            var sprites = new SpriteMappingsComponent(RpgGraphics.GameboySpriteMapping, _playerCharacters, new Vector2(10, 50),
                                                      counter);
            var nextCharacter     = new KeyboardEventComponent(Keys.D, ObjectEvent.NextCharacter);
            var previousCharacter = new KeyboardEventComponent(Keys.A, ObjectEvent.PreviousCharacter);
            var action            = new KeyboardActionComponent(Keys.Tab, Action);

            player.AddComponent(playerText);
            player.AddComponent(startText);
            player.AddComponent(counter);
            player.AddComponent(sprites);
            player.AddComponent(nextCharacter);
            player.AddComponent(previousCharacter);
            player.AddComponent(action);
            DisplayLayer.AddGameObject(player);
        }