Beispiel #1
0
        private IEnumerator CountDown()
        {
            while (!gameStarted)
            {
                yield return(new WaitForSeconds(0.05f));
            }
            yield return(new WaitForSeconds(1f));

            while (timeRemaining > 0)
            {
                if (this == null)
                {
                    yield break;
                }
                timeRemaining--;
                tbTime.Text = timeRemaining.ToString();
                yield return(new WaitForSeconds(1f));
            }

            timeRemaining = -1;
            audioMgr.PlaySound(audioMgr.speedRunner_Finish);
            yield return(new WaitForSeconds(1.5f));

            timeRemaining = -2;

            foreach (var sb in sbFaces)
            {
                sb.Dispose();
            }

            TextBoxBuilder tb = ScreenElement.BuildTextBox("End", screenDisplay.transform, DFont.Small).SetText("END").SetPosition(6, 17);
        }
Beispiel #2
0
        public override void StartApp()
        {
            GenerateLevel();
            Sprite sRocket    = gm.spriteDB.speedRunner_rocket;
            Sprite sSpeedMark = gm.spriteDB.speedRunner_rocketSpeedMark;
            Sprite sAsteroid  = gm.spriteDB.speedRunner_rocketAsteroid;
            Sprite sExplosion = gm.spriteDB.speedRunner_rocketExplosion;
            Sprite sFinish    = gm.spriteDB.speedRunner_rocketFinish;

            ScreenElement.BuildRectangle("Line", Parent).SetSize(1, 32).SetPosition(6, 0);
            rocket = ScreenElement.BuildSprite("Rocket", Parent).SetSize(8, 8).SetPosition(15, 32).SetSprite(sRocket);
            StartCoroutine(IASpawnRocket());

            for (int i = 0; i < visualRows.Length; i++)
            {
                visualRows[i] = ScreenElement.BuildContainer($"Row{i}", Parent).SetSize(24, 6).SetPosition(7, -6);
                for (int j = 0; j < 3; j++)
                {
                    ScreenElement.BuildSprite($"Asteroid{j}", visualRows[i].transform).SetSize(7, 6).SetPosition(j * 8, 0).SetSprite(sAsteroid);
                }
            }
            finishRow = ScreenElement.BuildContainer($"FinishRow", Parent).SetSize(25, 32).SetPosition(7, -32);
            for (int i = 0; i < 2; i++)
            {
                ScreenElement.BuildSprite($"FinishLine{i}", finishRow.transform).SetSize(6, 32).SetPosition(1 + (i * 17), 0).SetSprite(sFinish);
            }
            for (int i = 0; i < speedMarks.Length; i++)
            {
                speedMarks[i] = ScreenElement.BuildSprite($"SpeedMark{i}", Parent).SetSize(3, 5).SetPosition(2, 26 - (i * 6)).SetSprite(sSpeedMark);
                speedMarks[i].SetActive(false);
            }
            InvokeRepeating("CustomUpdate", 0f, THIS_DELTA_TIME);
        }
Beispiel #3
0
 /// <summary>
 /// Use this utility to tell if a Screen Element is currently within the screen.
 /// This is used to tell if we should draw the element or not during the Draw step.
 /// </summary>
 /// <param name="element">The Screen Element</param>
 /// <returns>True if the element is in the screen</returns>
 public static bool IsOnScreen(ScreenElement element)
 {
     return(!(element.Position.x > Camera.Instance.x + Camera.Instance.width ||
              element.Position.x + element.Size.x < Camera.Instance.x ||
              element.Position.y > Camera.Instance.y + Camera.Instance.height ||
              element.Position.y + element.Size.y < Camera.Instance.y));
 }
Beispiel #4
0
        private IEnumerator IAElevateRocket()
        {
            gm.LockInput();

            for (int i = 0; i < 32; i++)
            {
                rocket.Move(Direction.Up);
                yield return(new WaitForSeconds(1.5f / 32));
            }
            foreach (SpriteBuilder sb in speedMarks)
            {
                sb.SetActive(false);
            }
            finishRow.SetActive(false);

            yield return(new WaitForSeconds(0.5f));

            TextBoxBuilder tbGoal = ScreenElement.BuildTextBox("Goal", Parent, DFont.Small).SetText("GOAL!").SetSize(24, 5).SetPosition(9, 8);

            yield return(new WaitForSeconds(0.5f));

            currentScreen = 1;
            gm.UnlockInput();
            while (true)
            {
                tbGoal.SetActive(!tbGoal.Active);
                yield return(new WaitForSeconds(0.5f));
            }
        }
Beispiel #5
0
        private void OpenAreaSelection()
        {
            currentScreen = 1;
            //If the player is entering the map he already is in, start hovering in his current area, rather than the 'area 0' of that map.
            displayArea = (displayMap == originalMap) ? OriginalAreaIndexInCurrentMap : 0;

            if (currentAreaMarker != null)
            {
                currentAreaMarker.SetActive(false);
            }

            //The marker that indicates the area that is being chosen.
            hoveredMarker = ScreenElement.BuildRectangle("OptionMarker", screenDisplay.transform).SetSize(2, 2).SetFlickPeriod(0.25f)
                            .SetPosition(thisWorldData.areas[SelectedArea].coords);
            hoveredAreaName = ScreenElement.BuildTextBox("AreaName", screenDisplay.transform, DFont.Small).SetText("area").SetPosition(28, 5);

            if (displayMap == 0 || displayMap == 3)
            {
                hoveredAreaName.SetPosition(2, 1);
            }
            else
            {
                hoveredAreaName.SetPosition(2, 26);
            }

            hoveredAreaName.Text = string.Format("area{0:00}", SelectedArea + 1); //+1 because, in game, areas start at #1, not 0.
        }
Beispiel #6
0
        private IEnumerator IASpawnRocket(float delay = 0f)
        {
            yield return(new WaitForSeconds(delay));

            audioMgr.PlaySound(audioMgr.speedRunner_Start);

            rocket.SetPosition(15, 32);
            rocket.SetSprite(gm.spriteDB.speedRunner_rocket);

            for (int i = 0; i < 8; i++)
            {
                yield return(new WaitForSeconds(1f / 8));

                rocket.Move(Direction.Up);
            }
            TextBoxBuilder tbStart = ScreenElement.BuildTextBox("Start", Parent, DFont.Small).SetText("START").SetSize(24, 5).SetPosition(9, 8);

            yield return(new WaitForSeconds(0.5f));

            tbStart.SetActive(false);
            yield return(new WaitForSeconds(0.5f));

            tbStart.SetActive(true);
            yield return(new WaitForSeconds(1f));

            tbStart.SetActive(false);
            gameStarted = true;
        }
 /// <summary>
 /// Remove an element from the sorted lists
 /// </summary>
 /// <param name="element"></param>
 /// <returns></returns>
 public void Remove(ScreenElement element)
 {
     lock (this.modifiedQueue)
     {
         this.modifiedQueue.Enqueue(new KeyValuePair <ScreenElement, bool>(element, false));
     }
 }
        // ///////////////////////////////////////////////
        // CRUD classes
        // edit: update has to be done by the element we
        //       have no power to update its depth here
        // ///////////////////////////////////////////////

        /// <summary>
        /// Add a new Screen Element
        /// </summary>
        /// <param name="element"></param>
        public void Add(ScreenElement element)
        {
            lock (this.modifiedQueue)
            {
                this.modifiedQueue.Enqueue(new KeyValuePair <ScreenElement, bool>(element, true));
            }
        }
Beispiel #9
0
        private void MouseClickAll(object sender, MouseEventArgs e)
        {
            POINT p;

            if (GetCursorPos(out p) && clickCheck == 0)
            {
                ScreenElement structure             = ScreenElement.fromAutomationElement(ElementFromCursor());
                long          currTime              = new StartTime().getStartTime();
                long          timeSinceStartSession = currTime - startTime;
                if (double.IsInfinity(structure.x) || double.IsInfinity(structure.y))
                {
                    using (Graphics g = Graphics.FromImage(pictureBox1.Image))
                    {
                        g.DrawEllipse(new Pen(Color.Green), p.X, p.Y, 4, 4);
                    }
                    System.IO.File.AppendAllText(@"C:\Saif\Office\C#\Projects\MouseClick\file\" + startTime.ToString() + ".json", "\n{\"eventType\": \"md\"" + ", \"mouseX\": " + p.X + ", \"mouseY\": " + p.Y + ", \"elementX\": " + structureInCondition.x + ", \"elementY\": " + structureInCondition.y + ", \"elementW\": " + structureInCondition.width + ", \"elementH\": " + structureInCondition.height + ", \"time\": " + timeSinceStartSession + ", \"relative\": true" + "}");
                }
                else
                {
                    using (Graphics g = Graphics.FromImage(pictureBox1.Image))
                    {
                        g.DrawEllipse(new Pen(Color.Green), p.X, p.Y, 4, 4);
                    }
                    System.IO.File.AppendAllText(@"C:\Saif\Office\C#\Projects\MouseClick\file\" + startTime.ToString() + ".json", "\n{\"eventType\": \"mc\"" + ", \"mouseX\": " + p.X + ", \"mouseY\": " + p.Y + ", \"elementX\": " + structure.x + ", \"elementY\": " + structure.y + ", \"elementW\": " + structure.width + ", \"elementH\": " + structure.height + ", \"time\": " + timeSinceStartSession + ", \"relative\": true" + "}");
                }
            }
        }
        /// <summary>
        /// There is a new challenger for screen focus!
        /// Do the logic for giving focus to this new element.
        ///
        /// Note: There should only be a single "Click" per update step.
        ///         So the "Neither" enumeration is added to the LeftOrRight type.
        ///         "Neither" clicks should fire focus changes, but not click changes.
        ///         There are still problems with this method. Be careful with inadvertant recursion!
        /// </summary>
        /// <param name="element">The new element to get focus</param>
        /// <param name="clickType">Left of right click</param>
        public void SetNewFocus(ScreenElement element, LeftOrRight clickType)
        {
            // If nothing new is getting focus, then remove focus
            if (element == null)
            {
                if (this.screenFocus != null)
                {
                    this.screenFocus.UnClicked(null);
                    this.screenFocus = null;
                }
                return;
            }

            // Trigger Clicked and UnClicked events
            if (this.screenFocus == null)
            {
                this.screenFocus = element;
                element.Clicked(Input.MouseWorldPosition, clickType);
            }
            else if (this.screenFocus.Equals(element))
            {
                element.Clicked(Input.MouseWorldPosition, clickType);
            }
            else
            {
                screenFocus.UnClicked(element);
                this.screenFocus = element;
                element.Clicked(Input.MouseWorldPosition, clickType);
            }
        }
Beispiel #11
0
        /// <summary>
        /// Constructor for the DebugViewScreen
        /// </summary>
        public DebugViewScreen(ScreenElement previousScreen, ContentManager content,
                               GraphicsDevice graphicsDevice, WorldViewScreen.DebugStats stats, Game game)
            : base(previousScreen, graphicsDevice)
        {
            this.previous = previousScreen;

            // Initialize debug resources
            SpriteFont debugFont = content.Load <SpriteFont>("Fonts/debug");
            SpriteFont alphBeta  = content.Load <SpriteFont>("Fonts/alphbeta");

            textItem   = new TextItem(Vector2.Zero, debugFont, spriteBatch);
            debugStats = stats;

            // Hardware stats
            ManagementObjectSearcher   searcher      = new ManagementObjectSearcher("SELECT * FROM Win32_Processor");
            ManagementObjectCollection objCollection = searcher.Get();

            CPUItems = new List <string>();
            foreach (ManagementObject mObject in objCollection)
            {
                foreach (PropertyData property in mObject.Properties)
                {
                    if (property.Name == "Name")
                    {
                        CPUItems.Add(string.Format("{0}", property.Value));
                    }
                }
            }
        }
Beispiel #12
0
        private void DrawAreaMarkers(bool displayOriginalArea)
        {
            ClearMarkers(); //Destroy all current markers.

            int[] shownAreas = thisWorldData.GetAreasInMap(displayMap);

            foreach (int i in shownAreas)
            {
                if (gm.WorldMgr.GetAreaCompleted(originalWorld, i))
                {
                    RectangleBuilder marker = ScreenElement.BuildRectangle($"Area {i} Marker", Parent)
                                              .SetSize(2, 2).SetPosition(thisWorldData.areas[i].coords);
                    completedMarkers.Add(marker);
                }
                if (displayOriginalArea)
                {
                    if (originalArea == i)
                    {
                        currentAreaMarker = ScreenElement.BuildRectangle($"Current Area Marker", Parent)
                                            .SetSize(2, 2).SetPosition(thisWorldData.areas[i].coords).SetFlickPeriod(0.25f);
                        completedMarkers.Add(currentAreaMarker);
                    }
                }
            }
        }
Beispiel #13
0
        private void AddScreenElementData(global::UIModule.Scripts.UIElement uiElement)
        {
            ScreenElement screenElement = new ScreenElement(currentScreen);

            screenElement.TransformData = GetCurrentRectTransform(uiElement.GetComponent <RectTransform>());
            uiElement.screenElements.Add(screenElement);
        }
Beispiel #14
0
 private int result = 0; //0: nothing, 1: loading, 2: failure, 3: succeed.
 private void StartLoadingBar()
 {
     result           = 1;
     rbBlackScreen    = ScreenElement.BuildRectangle("BlackScreen0", Parent).SetSize(32, 32);
     sbLoading        = ScreenElement.BuildSprite("Loading", Parent).SetSprite(gm.spriteDB.loading).PlaceOutside(Direction.Up);
     loadingCoroutine = StartCoroutine(AnimateLoadingBar());
 }
Beispiel #15
0
 /// <summary>
 /// Setup text console
 /// </summary>
 public TextConsoleScreen(Game game, ScreenElement previousScreenElement,
                          GraphicsDevice graphicsDevice)
     : base(previousScreenElement, graphicsDevice)
 {
     // Initialize sprite resources
     consoleFont   = game.Content.Load <SpriteFont>("Fonts/debug");
     consoleString = "";
 }
        public SettingsScreen(Game game, ScreenElement previousScreenElement) :
            base(previousScreenElement, game.GraphicsDevice)
        {
            LoadUIStyle(game.Content);

            MainMenuManager     = new MainMenuManager(game, UIstyle, game.Content);
            game.IsMouseVisible = true;
        }
Beispiel #17
0
        public void CreateScreenElementWithIdEmptyShouldSucceed()
        {
            // Act
            var result = new ScreenElement(id, name, description, icon, true, ScreenElementType.Button, image);

            // Assert
            result.Should().NotBeNull();
        }
Beispiel #18
0
            public static ScreenElement fromAutomationElement(AutomationElement element, CacheRequest cacheRequest = null)
            {
                if (element == null)
                {
                    return(null);
                }

                try
                {
                    bool cacheRequestMine = cacheRequest == null;
                    if (cacheRequestMine)
                    {
                        cacheRequest = new CacheRequest();
                        cacheRequest.Add(AutomationElement.ClassNameProperty);
                        cacheRequest.Add(AutomationElement.ControlTypeProperty);
                        cacheRequest.Add(AutomationElement.AutomationIdProperty);
                        cacheRequest.Add(AutomationElement.IsControlElementProperty);
                        cacheRequest.Add(AutomationElement.BoundingRectangleProperty);
                        cacheRequest.AutomationElementMode = AutomationElementMode.Full;
                        cacheRequest.TreeFilter            = Automation.RawViewCondition;
                        cacheRequest.Push();
                        element = element.GetUpdatedCache(cacheRequest);
                    }

                    var           p = element.Cached;
                    var           b = p.BoundingRectangle;
                    ScreenElement parent;
                    try
                    {
                        parent = ScreenElement.fromAutomationElement(TreeWalker.RawViewWalker.GetParent(element, cacheRequest), cacheRequest);
                    }
                    catch (Exception)
                    {
                        parent = null;
                    }
                    var r = new ScreenElement()
                    {
                        classname = p.ClassName,
                        type      = p.ControlType.ProgrammaticName,
                        id        = p.AutomationId,
                        isControl = p.IsControlElement,
                        x         = b.X,
                        y         = b.Y,
                        width     = b.Width,
                        height    = b.Height,
                        // parent = parent,
                    };
                    if (cacheRequestMine)
                    {
                        cacheRequest.Pop();
                    }
                    return(r);
                }
                catch (Exception)
                {
                    return(null);
                }
            }
Beispiel #19
0
        private void DrawScreen()
        {
            ClearScreen();

            switch (currentScreen)
            {
            case 0:
                screenDisplay.sprite = gm.spriteDB.status_distance;
                string distance = gm.WorldMgr.CurrentDistance.ToString();
                string steps    = gm.WorldMgr.TotalSteps.ToString();
                ScreenElement.BuildTextBox("TextDistance", screenDisplay.transform, DFont.Regular)
                .SetText(distance).SetSize(31, 5).SetPosition(0, 10).SetAlignment(TextAnchor.UpperRight);
                ScreenElement.BuildTextBox("TextSteps", screenDisplay.transform, DFont.Regular)
                .SetText(steps).SetSize(31, 5).SetPosition(0, 26).SetAlignment(TextAnchor.UpperRight);
                break;

            case 1:
                screenDisplay.sprite = gm.spriteDB.status_level;
                string level   = gm.logicMgr.GetPlayerLevel().ToString();
                string spirits = gm.logicMgr.SpiritPower.ToString();
                ScreenElement.BuildTextBox("TextLevel", screenDisplay.transform, DFont.Regular)
                .SetText(level).SetSize(31, 5).SetPosition(0, 10).SetAlignment(TextAnchor.UpperRight);
                ScreenElement.BuildTextBox("TextSpirits", screenDisplay.transform, DFont.Regular)
                .SetText(spirits).SetSize(31, 5).SetPosition(0, 26).SetAlignment(TextAnchor.UpperRight);
                break;

            case 2:
                screenDisplay.sprite = gm.spriteDB.status_victories;
                float fVictoryPerc = gm.logicMgr.WinPercentage;
                int   iVictoryPerc = Mathf.RoundToInt(gm.logicMgr.WinPercentage * 100);
                //The victory percentage is never 100% or 0%, unless the player has won or lost every single battle they've played.
                if (iVictoryPerc == 100 && fVictoryPerc != 1f)
                {
                    iVictoryPerc = 99;
                }
                if (iVictoryPerc == 0 && fVictoryPerc != 0f)
                {
                    iVictoryPerc = 1;
                }

                string victoryPerc = iVictoryPerc.ToString();
                string winCount    = gm.logicMgr.TotalWins.ToString();
                ScreenElement.BuildTextBox("TextLevel", screenDisplay.transform, DFont.Regular)
                .SetText(victoryPerc).SetSize(24, 5).SetPosition(0, 10).SetAlignment(TextAnchor.UpperRight);
                ScreenElement.BuildTextBox("TextSpirits", screenDisplay.transform, DFont.Regular)
                .SetText(winCount).SetSize(31, 5).SetPosition(0, 26).SetAlignment(TextAnchor.UpperRight);
                break;

            case 3:
            case 4:
            case 5:
            case 6:
                int ddockNumber = currentScreen - 3;
                gm.GetDDockScreenElement(ddockNumber, screenDisplay.transform);
                break;
            }
        }
Beispiel #20
0
        /// <summary>
        /// Remove this building from the game grid
        /// </summary>
        /// <param name="building">The building to remove</param>
        /// <returns></returns>
        public bool DeleteElement(ScreenElement element)
        {
            if (!this.Exists(element))
            {
                Logger.Log(LogLevel.Warning, "Tried to remove non-existant element", string.Format("The campus manager was told to remove element {0} ({1}) from the game grid, but no such element exists.", element, element.Guid));
                return(false);
            }

            this.Remove(element);

            // Remove the element from the grid
            var elementIsoPosition = Geometry.ToIsometricGrid(element.Position);

            Building building = element as Building;

            if (building != null)
            {
                // Remove this building from the grid
                for (int y = 0; y < building.Footprint.Length; ++y)
                {
                    for (int x = 0; x < building.Footprint[y].Length; ++x)
                    {
                        if (building.Footprint[y][x])
                        {
                            var indexOffsets = building.FootprintIndexOffsets;
                            int gridX        = this.WorldIsoToGridX(elementIsoPosition.x + x - indexOffsets.x);
                            int gridY        = this.WorldIsoToGridY(elementIsoPosition.y + y - indexOffsets.y);

                            // Sanity checks before we remove the building
                            if (this.grid[gridY][gridX] != building.Guid)
                            {
                                Logger.Log(LogLevel.Error, "Removing a building from a corrupted grid location", string.Format("The grid location {0},{1} had Guid {2} set instead of {3}.", gridX, gridY, this.grid[gridY][gridX], building.Guid));
                            }

                            this.grid[gridY][gridX] = -1;
                        }
                    }
                }
            }
            else
            {
                // Remove this element from the grid
                int gridX = this.WorldIsoToGridX(elementIsoPosition.x);
                int gridY = this.WorldIsoToGridY(elementIsoPosition.y);

                // Sanity checks before we remove the element
                if (this.grid[gridY][gridX] != element.Guid)
                {
                    Logger.Log(LogLevel.Error, "Removing an element from a corrupted grid location", string.Format("The grid location {0},{1} had Guid {2} set instead of {3}.", gridX, gridY, this.grid[gridY][gridX], element.Guid));
                }

                this.grid[gridY][gridX] = -1;
            }

            return(true);
        }
Beispiel #21
0
        /// <summary>
        /// Adds a screen-element to the window and resizes the window if necessary.
        /// </summary>
        public void AddElement(ScreenElement element)
        {
            ElementList.Add(element);
            int _height = GetTotalElementHeight();

            if (_height > this.Size.Y)
            {
                this.Size.Y = _height;
            }
        }
Beispiel #22
0
 public override void StartApp()
 {
     for (int i = 0; i < 5; i++)
     {
         underscores[i] = ScreenElement.BuildRectangle($"Underscore{i}", screenDisplay.transform).SetSize(5, 1).SetPosition(2 + (6 * i), 25);
     }
     selectedInputDisplay = ScreenElement.BuildTextBox("Input", screenDisplay.transform, DFont.Big).SetSize(6, 8).SetPosition(14, 8);
     currentInputDisplay  = ScreenElement.BuildTextBox("CurrentCode", screenDisplay.transform, DFont.Big).SetSize(30, 8).SetPosition(2, 17);
     UpdateScreen();
 }
        /// <summary>
        /// Editor Screen constructor
        /// </summary>
        public VoxelEditorScreen(Game game, ScreenElement previousScreenElement, ContentManager content,
                                 GraphicsDevice graphicsDevice) :
            base(game.Window, previousScreenElement, graphicsDevice)
        {
            editorCamera.Initialize(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height);
            editorCamera.SetChaseTarget(Vector3.Zero);

            gridRenderer = new GridRenderer(graphicsDevice);
            gridRenderer.SetGridSize(10);
        }
Beispiel #24
0
        private void OpenViewDistance()
        {
            currentScreen = 2;
            //If the area chosen is the area the player is already in, the distance will not change. Otherwise, get the distance for the new area.

            int areaDist = (SelectedArea == originalArea) ? gm.WorldMgr.CurrentDistance : thisWorldData.areas[SelectedArea].distance;

            distanceScreen = ScreenElement.BuildSprite("DistanceScreen", screenDisplay.transform).SetSprite(gm.spriteDB.map_distanceScreen);
            ScreenElement.BuildTextBox("Distance", distanceScreen.transform, DFont.Regular)
            .SetText(areaDist.ToString()).SetSize(25, 5).SetPosition(6, 25).SetAlignment(TextAnchor.UpperRight);
        }
Beispiel #25
0
        private void Form1_Load(object sender, EventArgs e)
        {
            pictureBox1.BackColor = Color.DarkGray;

            Hook.GlobalEvents().MouseClick     += MouseClickAll;
            long          currTime              = new StartTime().getStartTime();
            long          timeSinceStartSession = currTime - startTime;
            ScreenElement structure             = ScreenElement.fromAutomationElement(ElementFromCursor());

            System.IO.File.AppendAllText(@"C:\Saif\Office\C#\Projects\MouseClick\file\" + startTime.ToString() + ".json", "{\"eventType\": \"mm\"" + ", \"mouseX\": " + Cursor.Position.X + ", \"mouseY\": " + Cursor.Position.Y + ", \"time\": " + timeSinceStartSession + ", \"relative\": true" + "}");
        }
 public void AddDisabled(string id, ScreenElement element)
 {
     if (!elements.ContainsKey(id))
     {
         elements.Add(id, element);
     }
     else
     {
         Disable(id);
     }
 }
Beispiel #27
0
        private IEnumerator PADisplayPattern()
        {
            gm.LockInput();

            keypad  = ScreenElement.BuildSprite("Keypad", Parent).SetSize(24, 24).Center().SetSprite(gm.spriteDB.jackpot_pad);
            keys[0] = ScreenElement.BuildSprite("Key Left", Parent).SetSize(8, 12).SetPosition(4, 10)
                      .SetSprite(gm.spriteDB.jackpot_keys[0]).SetTransparent(true).SetActive(false);
            keys[1] = ScreenElement.BuildSprite("Key Right", Parent).SetSize(8, 12).SetPosition(20, 10)
                      .SetSprite(gm.spriteDB.jackpot_keys[1]).SetTransparent(true).SetActive(false);
            keys[2] = ScreenElement.BuildSprite("Key Up", Parent).SetSize(12, 8).SetPosition(10, 4)
                      .SetSprite(gm.spriteDB.jackpot_keys[2]).SetTransparent(true).SetActive(false);
            keys[3] = ScreenElement.BuildSprite("Key Down", Parent).SetSize(12, 8).SetPosition(10, 20)
                      .SetSprite(gm.spriteDB.jackpot_keys[3]).SetTransparent(true).SetActive(false);

            SpriteBuilder hourglass = ScreenElement.BuildSprite("Hourglass", Parent).SetSprite(gm.spriteDB.hourglass);

            yield return(new WaitForSeconds(0.75f));

            hourglass.Dispose();

            for (int i = 0; i < pattern.Length; i++)
            {
                audioMgr.PlaySound(audioMgr.beepLow);
                keys[pattern[i]].SetActive(true);
                yield return(new WaitForSeconds(delay));

                keys[pattern[i]].SetActive(false);
            }

            //Black screen:
            RectangleBuilder rbBlackScreen = ScreenElement.BuildRectangle("BlackScreen0", Parent).SetSize(32, 32);
            SpriteBuilder    sbLoading     = ScreenElement.BuildSprite("Loading", Parent).SetSprite(gm.spriteDB.loading).PlaceOutside(Direction.Up);

            for (int i = 0; i < 64; i++)
            {
                sbLoading.Move(Direction.Down);
                yield return(new WaitForSeconds((delay * 2f) / 64));
            }
            rbBlackScreen.Dispose();
            sbLoading.Dispose();

            //Ready the player:
            keypad.Move(Direction.Down, 4);
            keys.Move(Direction.Down, 4);
            tbTime = ScreenElement.BuildTextBox("Time", screenDisplay.transform, DFont.Small)
                     .SetText("TIME").SetSize(18, 5).SetPosition(1, 1);
            tbTimeCount = ScreenElement.BuildTextBox("TimeCount", screenDisplay.transform, DFont.Small)
                          .SetText(timeRemaining.ToString()).SetSize(10, 5).SetPosition(22, 1);
            StartCoroutine(TimeCount());

            gm.UnlockInput();
        }
Beispiel #28
0
        private void timer_Tick(object sender, EventArgs e)
        {
            Thread th = new Thread(firstClick);

            th.Start();
            //firstClick();
            ScreenElement structure = ScreenElement.fromAutomationElement(ElementFromCursor());

            structureInCondition = structure;
            long currTime = new StartTime().getStartTime();
            long timeSinceStartSession = currTime - startTime;

            System.IO.File.AppendAllText(@"C:\Saif\Office\C#\Projects\MouseClick\file\" + startTime.ToString() + ".json", "\n{\"eventType\": \"mm\"" + ", \"mouseX\": " + Cursor.Position.X + ", \"mouseY\": " + Cursor.Position.Y + ", \"time\": " + timeSinceStartSession + ", \"relative\": true" + "}");
        }
        /// <summary>
        /// This is a scrubbing call when an element is being deleted.
        /// In case it has focus, make sure that power is handed down gracefully.
        ///
        /// Awkward power voids where a de-referenced element has focus is awkward.
        /// I know. Trust me.
        /// </summary>
        /// <param name="element">The element that is losing focus (if it actually has focus)</param>
        public void RemoveFocus(ScreenElement element)
        {
            if (element.Equals(this.screenFocus))
            {
                var parent = this.screenFocus.Parent;
                this.screenFocus.UnClicked(parent);
                this.screenFocus = parent;

                if (parent != null)
                {
                    parent.Clicked(Input.MousePosition, LeftOrRight.Neither);
                }
            }
        }
            public Screen(Screen OtherScreen)
            {
                Name         = OtherScreen.Name;
                Width        = OtherScreen.Width;
                Height       = OtherScreen.Height;
                ConfigByte   = OtherScreen.ConfigByte;
                WLConfigByte = OtherScreen.WLConfigByte;
                CharsetIndex = OtherScreen.CharsetIndex;
                OverrideMC1  = OtherScreen.OverrideMC1;
                OverrideMC2  = OtherScreen.OverrideMC2;

                foreach (ScreenElement element in OtherScreen.DisplayedElements)
                {
                    ScreenElement newElement = new ScreenElement(element);
                    DisplayedElements.Add(newElement);
                }
            }
Beispiel #31
0
 protected void PushScreenElement(ScreenElement element)
 {
     screenElements.Push(element);
 }
Beispiel #32
0
    static void Main()
    {
        // Setup playable area
        Console.Title = "Falling Rocks";
        Console.CursorVisible = false;
        Console.WindowHeight = boardHeight + 2;
        Console.BufferHeight = boardHeight + 2;
        Console.WindowWidth = boardWidth;
        Console.BufferWidth = boardWidth;

        // First draw
        Console.BackgroundColor = ConsoleColor.Black;
        Console.Clear();
        ClearBoard();
        DrawBoard();
        DrawGround();
        DrawScore();

        // Initialize screen elements
        ScreenElement dwarf = new ScreenElement("\x1B\x02\x1A", (byte)(boardWidth / 2), (byte)(boardHeight - 2));
        Enemy.lastID = maxRocks;		// Set lastID to the end of the array, on next spawn call the index will roll over
        for (int i = 0; i < maxRocks; i++)
        {
            rocks[i] = new Enemy();		// Fill array with dead elements
        }

        // Initialize clock
        Stopwatch timer = new Stopwatch();
        timer.Start();
        TimeSpan frameLast = new TimeSpan(0);
        TimeSpan frameThis = new TimeSpan();
        double lastSpawn = 0.0;		// Last time an enemy was spawned
        int lastSeeker = 0;			// Last score a seeker was spawned

        // Game loop
        ConsoleKeyInfo pressedKey;
        bool escapePressed = false;
        while (true)
        {
            frameThis = timer.Elapsed;

            // Process input
            if (Console.KeyAvailable)
            {
                pressedKey = Console.ReadKey(true);
                switch (pressedKey.Key)
                {
                    case ConsoleKey.LeftArrow:
                        dwarf.MoveLeft();
                        break;
                    case ConsoleKey.RightArrow:
                        dwarf.MoveRight();
                        break;
                    case ConsoleKey.Escape:
                        escapePressed = true;
                        break;
                    default:
                        break;
                }
                // Escape is used to terminate
                if (escapePressed)
                {
                    break;
                }
            }
            // Process enemies
            double elapsed = frameThis.TotalMilliseconds - frameLast.TotalMilliseconds;	// Calculate elapsed time
            if (frameThis.TotalMilliseconds > lastSpawn + (500 - frameLast.TotalMilliseconds * 0.0055))
            {												// Rocks spawn at an increasing rate,
                SpawnRock(frameThis.TotalMilliseconds);		// reaching peak at 90 seconds
                lastSpawn = frameThis.TotalMilliseconds;    // (spawning every tick, if possible)
            }
            // Seeker spawnrate peaks at 90 seconds, which theretically should mean regular intervals,
            // however enemy movement speed is out of phase (peaking at 60 seconds), meaning fewer
            // seekers up to 60 seconds and more seekers later.
            if (score - lastSeeker > (100 + frameLast.TotalMilliseconds / 225))
            {
                lastSeeker = score;
                SpawnSeeker(frameThis.TotalMilliseconds, (byte)(dwarf.Left + 1));
            }
            UpdateRocks(elapsed);	// Make 'em fall
            frameLast = frameThis;

            // Commit elements and render board
            dwarf.Draw(frameLast);   // Character is comitted last for collision detecion
            DrawBoard();
            DrawScore();
            ClearBoard();

            // Check alive state
            if (health < 1)
            {
                break;
            }
        }
        // Exit
        DrawEndscreen();	// Display final score; this will trigger when exiting with Escape
    }
	public abstract void Load (ScreenElement e, TemplateSettings settings);