Пример #1
0
        static void Main(string[] args)
        {
            Terminal.Open();
            Terminal.Set(string.Format("window.title='{0}'", "SharpSnake"));
            Terminal.Refresh();

            var consoleScreen = new ConsoleScreen(36, 28);
            var context       = new StateContext(consoleScreen, new Settings());
            var stateStack    = new StateStack(context);

            stateStack.RegisterState <MenuState>(StateId.Menu);
            stateStack.RegisterState <OptionsState>(StateId.Options);
            stateStack.RegisterState <PlayState>(StateId.Play);
            stateStack.RegisterState <GameOverState>(StateId.GameOver);
            stateStack.RegisterState <PauseState>(StateId.Pause);

            // Initial state
            stateStack.PushState(StateId.Menu);

            while (!stateStack.Empty)
            {
                stateStack.HandleInput();
                stateStack.Update();

                consoleScreen.Clear();
                stateStack.Draw();
                consoleScreen.Display();

                System.Threading.Thread.Sleep(16);
            }

            Terminal.Close();
        }
Пример #2
0
		public override void OnStart(ConsoleScreen screen) {

			base.OnStart(screen);

			Application.logMessageReceived += this.OnLog;

		}
Пример #3
0
 private static void AddConsoleLog(string log)
 {
     if (PreloaderUI.Instantiated)
     {
         ConsoleScreen.Log(log);
     }
 }
Пример #4
0
        public static void Start(Database.Database db)
        {
            var userAccessLoop = true;

            while (userAccessLoop)
            {
                Console.Title = "UpWork";
                ConsoleScreen.PrintMenu(ConsoleScreen.UserAccess, ConsoleColor.DarkGreen);

                var userAccess = (UserAccessEnum)ConsoleScreen.Input(ConsoleScreen.UserAccess.Count);

                Console.Clear();

                switch (userAccess)
                {
                case UserAccessEnum.Login:
                {
                    LoginSide(db);
                    break;
                }

                case UserAccessEnum.Register:
                {
                    RegisterSide(db);
                    break;
                }

                case UserAccessEnum.Exit:
                {
                    userAccessLoop = false;
                    break;
                }
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Called when the DrawableGameComponent needs to be drawn. Override this method with
        /// component-specific drawing code.
        /// </summary>
        /// <param name="gameTime">Time passed since the last call to Draw.</param>
        public virtual void Draw(TickCount gameTime)
        {
            // Update the FPS
            _fps.Update(gameTime);

            // Clear the screen
            _game.RenderWindow.Clear(DrawingManager.BackgroundColor);

            // Draw the active non-console screen
            var ancs = ActiveNonConsoleScreen;

            if (ancs != null)
            {
                ancs.Draw(gameTime);
            }

            // Draw the console
            var cs = ConsoleScreen;

            if (ShowConsole && cs != null)
            {
                cs.Draw(gameTime);
            }

            // Draw the console
            if (ShowConsole && ConsoleScreen != null)
            {
                ConsoleScreen.Draw(gameTime);
            }
        }
Пример #6
0
    public void OnRealTimeMessageReceived(bool isReliable, string senderId, byte[] data)
    {
        ConsoleScreen.Log("OnRealTimeMessageReceived");
        OnlineMessage message = deserializeMessage(data);

        if (!playerOneDecided)
        {
            ConsoleScreen.Log("OnRealTimeMessageReceived - decide p1");
            GlobalGameManager.amIPlayerOne = PlayGamesPlatform.Instance.RealTime.GetSelf().ParticipantId.Equals(message.participantIdPlayerOne);
            CurrentState = GlobalGameManager.amIPlayerOne ? State.MY_TURN : State.WAIT;
        }
        else
        {
            ReceiveShoot(message.unitIndex, message.force);
        }
        //switch (CurrentState)
        //{
        //    case State.WAIT:

        //        break;
        //    case State.MY_TURN:
        //        Debug.Log("OnRealTimeMessageReceived - mensaje en mi turno? WTF!!");
        //        break;
        //    default:
        //        Debug.Log("OnRealTimeMessageReceived - WTF!!");
        //        break;
        //}
    }
Пример #7
0
		public override void OnStart(ConsoleScreen screen) {

			base.OnStart(screen);

			this.alpha = this.alpha;

		}
Пример #8
0
    private void Item_OnSelected(EventItem item, bool state)
    {
        if (item == _lastSelected)
        {
            _lastSelected = null;
        }
        else if (_selected != item)
        {
            _lastSelected    = _selected;
            _selected        = item;
            selectionChanged = true;

            ConsoleScreen.Log("SELECT", item.NameText.text);

            if (_lastSelected != null)
            {
                _lastSelected.Selected = false;
            }

            StartCoroutine(_MaintainScroll());
        }
        else if (_selected == item && OnItemSelected != null)
        {
            OnItemSelected(_selected);
        }
    }
Пример #9
0
 protected void AddConsoleLog(string log)
 {
     if (PreloaderUI.Instantiated)
     {
         ConsoleScreen.Log(log);
     }
 }
Пример #10
0
        public GameLoop(int width, int height)
        {
            _height = height;
            _width  = width;

            _consoleScreen = new ConsoleScreen();
        }
Пример #11
0
        static void Withdraw(Bank bank)
        {
            while (true)
            {
                var screen = new ConsoleScreen("Withdraw");
                screen.AddText("Enter the details", TextJustification.Center);
                var account = screen.AddInput("Account Number: ", Validate.AsAccount(bank));
                var amount  = screen.AddInput("Amount: $", Validate.Money());

                if (!screen.Show())
                {
                    return;
                }
                else if (amount.Response <= account.Response.Balance)
                {
                    bank.Transact(account.Response, -amount.Response);
                    ShowSuccess(account.Response);

                    return;
                }
                else if (!ConsoleScreen.ShowConfirmation("You're too broke", "The selected account's balance is too low.", "Would you like to try again (y/n)? ", ConsoleColor.Black, ConsoleColor.Red))
                {
                    return;
                }
            }
        }
Пример #12
0
        public static string InputExperience()
        {
            Console.Clear();
            Console.WriteLine("Experience:");
            ConsoleScreen.PrintMenu(FileHelper.Experiences, ConsoleColor.Blue);

            return(FileHelper.Experiences[ConsoleScreen.Input(FileHelper.Experiences.Count) - 1]);
        }
Пример #13
0
 private void GoToSelection()
 {
     if (_selectedButton != null)
     {
         ConsoleScreen.Log("GO TO", AppData.Events[_selectedButton.transform.GetSiblingIndex()].Name);
         AppManager.SwitchToEventScreen(AppData.Events[_selectedButton.transform.GetSiblingIndex()]);
     }
 }
Пример #14
0
        public static string InputSalary()
        {
            Console.Clear();
            Console.WriteLine("Salary: ");
            ConsoleScreen.PrintMenu(FileHelper.Salaries, ConsoleColor.Blue);

            return(FileHelper.Salaries[ConsoleScreen.Input(FileHelper.Salaries.Count) - 1]);
        }
Пример #15
0
 public override void Draw(Sprite sprite)
 {
     foreach (var pixel in sprite)
     {
         pixel.Draw(this);
     }
     ConsoleScreen.Draw(sprite.X + sprite.Width, sprite.Y, sprite.Color, () => Console.Write(sprite));
 }
Пример #16
0
 /// <summary>
 /// Creates a new console game manager
 /// </summary>
 /// <param name="width">Screen width</param>
 /// <param name="height">Screen height</param>
 /// <param name="firstScene">First scene</param>
 public ConsoleGame(
     int width,
     int height,
     ISceneBase firstScene
     ) : base(firstScene)
 {
     Screen = new ConsoleScreen(width, height);
 }
Пример #17
0
        public static string InputEducation()
        {
            Console.Clear();
            Console.WriteLine("Education:");
            ConsoleScreen.PrintMenu(FileHelper.Educations, ConsoleColor.Blue);

            return(FileHelper.Educations[ConsoleScreen.Input(FileHelper.Educations.Count) - 1]);
        }
Пример #18
0
        static void Main(string[] args)
        {
            var   screen = new ConsoleScreen();
            var   keypad = new ConsoleKeyPad();
            Kiosk kiosk  = new Kiosk(screen, keypad);

            kiosk.Run();
        }
Пример #19
0
        static void Main(string[] args)
        {
            var screen = new ConsoleScreen();
            var keypad = new ConsoleKeyPad();
            ATM atm    = new ATM(screen, keypad);

            atm.Start();
        }
Пример #20
0
 /// <summary>
 /// Creates a new console game manager
 /// </summary>
 /// <param name="width">Screen width</param>
 /// <param name="height">Screen height</param>
 /// <param name="firstScene">First scene</param>
 public ConsoleGame(
     int width,
     int height,
     ISceneBase firstScene
 )
     : base(firstScene)
 {
     Screen = new ConsoleScreen(width, height);
 }
Пример #21
0
    //*****************************************************************************
    // What happens after a shoot is performed?
    //*****************************************************************************
    public IEnumerator managePostShoot(string _shootBy, int unitIndex, Vector3 outPower)
    {
        ConsoleScreen.Log("shoot " + outPower);
        //get who is did the shoot
        //if we had a goal after the shoot was done and just before the round change, leave the process to other controllers.

        timeLeft = 15;


        float t = 0;

        while (t < timeStepToAdvanceRound)
        {
            t += Time.deltaTime;
            if (goalHappened)
            {
                yield break;
            }
            yield return(0);
        }

        //we had a simple shoot with no goal result
        if (t >= timeStepToAdvanceRound)
        {
            //add to round counters
            switch (_shootBy)
            {
            case "Player":
                if (powerUpTurnoExtra == true)
                {
                    round             = 1;
                    powerUpTurnoExtra = false;
                }
                else
                {
                    round = 2;
                } break;

            case "Player_2":
                round = 1;
                break;

            case "Opponent":
                round = 1;
                break;
            }

            //TODO-REE Online
            if (gameMode == 2)
            {
                SoccerRealTimeMultiplayerListener.Instance.SendShoot(unitIndex, outPower);
            }

            roundTurnManager(); //cycle again between players
        }
    }
Пример #22
0
 public static void Main(string[] args)
 {
     if (args.Length > 0 && args[0] == "test")
     {
         TestClass.Test();
         return;
     }
     new Game().Run();
     ConsoleScreen.Clear();
 }
Пример #23
0
        public static SkillLevelEnum InputSkillLevel()
        {
            Console.WriteLine("Level: ");
            while (true)
            {
                ConsoleScreen.PrintMenu(ConsoleScreen.SkillLevels, ConsoleColor.Blue);

                return((SkillLevelEnum)(ConsoleScreen.Input(ConsoleScreen.SkillLevels.Count)));
            }
        }
Пример #24
0
        private static void LoginSide(Database.Database db)
        {
            var loginLoop = true;

            while (loginLoop)
            {
                Console.Title = "Login";
                Console.WriteLine("Username: "******"Username can not be empty!");

                Console.WriteLine("Password: "******"Password can not be empty!");

                Console.Clear();

                var credentials = new Credentials()
                {
                    Username = username, Password = password
                };

                try
                {
                    var loggedUser = UpWork.UserAccess.UserAccess.Login(credentials, db.Users);

                    if (loggedUser is Worker worker)
                    {
                        WorkerSide.Start(worker, db);
                    }
                    else if (loggedUser is Entities.Employer employer)
                    {
                        EmployerSide.Start(employer, db);
                    }
                    break;
                }
                catch (Exception e) when(e is DatabaseException)
                {
                    LoggerPublisher.OnLogError($"There is no user associated this username -> {username}");
                }
                catch (Exception e)
                {
                    LoggerPublisher.OnLogError(e.Message);
                }

                if (ConsoleScreen.DisplayMessageBox("Error", "Do yo want try again?",
                                                    MessageBoxButtons.YesNo, MessageBoxIcon.Error)
                    == DialogResult.No)
                {
                    loginLoop = false;
                }
                Console.Clear();
            }
        }
Пример #25
0
        static bool IsValidLoginAccount(string name, string pw)
        {
            const string loginFile = "login.txt";

            if (!File.Exists(loginFile))
            {
                ConsoleScreen.ShowError("Bad Config", "login.txt file could not be found. Please place into the program directory.");
                Environment.Exit(-1);
            }

            return(File.ReadLines(loginFile).Contains(name + "|" + pw)); // No salts & hashes here
        }
Пример #26
0
        static void SearchForAccount(Bank bank)
        {
            var screen = new ConsoleScreen("Search an account");

            screen.AddText("Enter account details to search", TextJustification.Center);

            var account = screen.AddInput("Account number:", Validate.AsAccount(bank));

            if (screen.Show())
            {
                ShowSuccess(account.Response);
            }
        }
Пример #27
0
        static void Main(string[] args)
        {
            var screen = new ConsoleScreen();
            var keypad = new ConsoleKeyPad();

            var atm = new Atm(screen, keypad);

            if (atm.Start())
            {
                screen.WriteLine("Logged in");
                atm.Menu();
            }
        }
Пример #28
0
 public static IList <T2> Handle <T1, T2>(Func <T1, IList <T2>, IList <T2> > func, T1 data, IList <T2> data2)
 {
     try
     {
         return(func.Invoke(data, data2));
     }
     catch (Exception e)
     {
         LoggerPublisher.OnLogError(e.Message);
         ConsoleScreen.Clear();
         return(null);
     }
 }
Пример #29
0
        /// <summary>
        /// Draw the menu at the given screen position.
        /// </summary>
        /// <param name="screen">The screen to draw on</param>
        /// <param name="left">Position along X-axis in columns</param>
        /// <param name="top">Position along Y-axis in rows</param>
        public void Draw(ConsoleScreen screen, int left, int top)
        {
            for (int i = 0; i < Items.Count; i++)
            {
                if (Items[i] == SelectedItem)
                {
                    screen.SetColor(PaletteColor.Highlight);
                    screen.Draw(">", left, top + i);
                }

                Items[i].Draw(screen, left + 2, top + i);
            }
        }
Пример #30
0
        /// <summary>
        /// Handles the drawing part of the scene
        /// </summary>
        /// <param name="game">Game manager</param>
        public void Draw(Game game)
        {
            // Game is a generic class, so make sure to convert it to ConsoleGame
            ConsoleGame consoleGame = (ConsoleGame)game;
            // ConsoleGame has a screen to draw whereas Game doesn't
            ConsoleScreen consoleScreen = consoleGame.Screen;

            // Clears the whole screen
            consoleScreen.Clear();
            // Draw the gameover text
            consoleScreen.DrawText(3, 7, "    Your pet left you!\nTake better care next time!");
            // When we're done drawing everything we needed, updates the screen
            consoleScreen.Show();
        }
Пример #31
0
        public override void Draw(Sprite sprite)
        {
            var xc = sprite.X + sprite.Width / 2;
            var yc = sprite.Y - sprite.Height / 2;

            foreach (var pixel in sprite)
            {
                var xn  = xc + (pixel.X - xc) * Math.Cos(sprite.Angle) + (pixel.Y - yc) * Math.Sin(sprite.Angle);
                var yn  = yc - (pixel.X - xc) * Math.Sin(sprite.Angle) + (pixel.Y - yc) * Math.Cos(sprite.Angle);
                var rep = pixel.Clone();
                rep.Set(xn, yn);
                rep.Draw(this);
            }
            ConsoleScreen.Draw(sprite.X + sprite.Width, sprite.Y, sprite.Color, () => Console.Write(sprite));
        }
Пример #32
0
 //Link up hard coded markers
 public void LinkMarkers()
 {
     for (int i = 0; i < MapImage.transform.childCount; i++)
     {
         Button markerButton = MapImage.transform.GetChild(i).GetComponent <Button>();
         markerButton.onClick.AddListener(delegate()
         {
             EventButton.gameObject.SetActive(true);
             Text text = EventButton.GetComponentInChildren <Text>();
             text.text = AppData.Events[markerButton.transform.GetSiblingIndex()].Name;
             ConsoleScreen.Log("SELECT", AppData.Events[markerButton.transform.GetSiblingIndex()].Name);
             _selectedButton = markerButton;
         });
     }
 }
Пример #33
0
        static void CreateNewAccount(Bank bank)
        {
            var screen    = new ConsoleScreen(Art.AsHeader("Create a new account", Art.Hello));
            var firstName = screen.AddInput("First Name: ", Validate.Name());
            var lastName  = screen.AddInput("Last Name: ", Validate.Name());
            var address   = screen.AddInput("Address: ", Validate.AsString(3));
            var phone     = screen.AddInput("Phone: ", Validate.NumberBetween(0, 99_9999_9999));
            var email     = screen.AddInput("Email: ", Validate.Email());

            screen.Show();

            if (ConsoleScreen.ShowConfirmation("Confirm new account", "Are you sure you would like to create this account?"))
            {
                var account = bank.CreateAccount(firstName.Response, lastName.Response, address.Response, email.Response, phone.Response);
                ConsoleScreen.ShowMessage("Account Created", $"Created new account with ID {account.ID}.");
            }
        }
		public void SetScreen(ConsoleScreen screen) {

			this.screen = screen;
			this.UpdateQueue();

		}
		public void SetScreen(ConsoleScreen screen) {

			this.screen = screen;

		}