예제 #1
0
        public override void Update(GameTime gameTime)
        {
            if (KeyMouseReader.KeyPressed(Keys.Escape))
            {
                NogardGame.PauseManager.Init();
            }

            ActiveMap.Update(gameTime);
        }
예제 #2
0
        private void UpdateGui(object sender, EventArgs e)
        {
            string message;

            while (_telnetHandler.InQueue.TryDequeue(out message))
            {
                if (message.StartsWith("<Sound>"))
                {
                    _soundHandler?.HandleSounds(message);
                }
                else if (message.StartsWith("<Map>"))
                {
                    if (_mapWindow != null && !_mapWindow.IsDisposed)
                    {
                        _mapWindow.Update(message);
                    }
                }
                else if (message.StartsWith("<Data>"))
                {
                    SaveFile(message);
                }
                else if (message.StartsWith("<FileValidation>"))
                {
                    ValidateAssets.Validate(message);
                }
                else
                {
                    List <ParsedMessage> parsedMessage = Parser.Parse(message);
                    myRichTextBox_MainText.AddFormatedText(parsedMessage);
                    ProcessTriggers(parsedMessage);

                    foreach (var item in parsedMessage)
                    {
                        _previousCommands.AddOnScreenWords(item.Message);
                    }
                }
            }

            if (myRichTextBox_MainText.Lines.Length > Settings.MaxLines)
            {
                myRichTextBox_MainText.BeginUpdate();

                myRichTextBox_MainText.SelectionStart  = 0;
                myRichTextBox_MainText.SelectionLength = myRichTextBox_MainText.GetFirstCharIndexFromLine(myRichTextBox_MainText.Lines.Length - Settings.MaxLines);
                myRichTextBox_MainText.SelectedText    = "";

                myRichTextBox_MainText.SelectionStart = myRichTextBox_MainText.Text.Length;
                myRichTextBox_MainText.ScrollToCaret();
                myRichTextBox_MainText.EndUpdate();
            }
        }
예제 #3
0
        private void UpdateGui(object sender, EventArgs e)
        {
            string message;

            while (_telnetHandler.InQueue.TryDequeue(out message))
            {
                if (message.StartsWith("<Sound>"))
                {
                    _soundHandler?.HandleSounds(message);
                }
                else if (message.StartsWith("<Map>"))
                {
                    if (_mapWindow != null && !_mapWindow.IsDisposed)
                    {
                        _mapWindow.Update(message);
                    }
                }
                else if (message.StartsWith("<Data>"))
                {
                    SaveFile(message);
                }
                else
                {
                    List <ParsedMessage> parsedMessage = Parser.Parse(message);
                    myRichTextBox_MainText.AddFormatedText(parsedMessage, _settings);
                    //myRichTextBox_MainText.AddFormatedText(message, _settings);
                }
            }

            if (myRichTextBox_MainText.Lines.Length > _settings.MaxLines)
            {
                myRichTextBox_MainText.BeginUpdate();

                myRichTextBox_MainText.SelectionStart  = 0;
                myRichTextBox_MainText.SelectionLength = myRichTextBox_MainText.GetFirstCharIndexFromLine(myRichTextBox_MainText.Lines.Length - _settings.MaxLines);
                myRichTextBox_MainText.SelectedText    = "";

                myRichTextBox_MainText.SelectionStart = myRichTextBox_MainText.Text.Length;
                myRichTextBox_MainText.ScrollToCaret();
                myRichTextBox_MainText.EndUpdate();
            }
        }
예제 #4
0
        /// <summary>
        /// Updates all the content within the gamestate that is changing over time.
        /// </summary>
        public override void Update()
        {
            base.Update();
            ((Layout.Textbox)layout.GetBox("timer")).text        = stopwatch.Elapsed.ToString(@"m\:ss\:f");
            ((Layout.Textbox)layout.GetBox("shotCounter")).text  = shots.ToString();
            ((Layout.Textbox)layout.GetBox("enemyCounter")).text = hits.ToString();
            ((Layout.Textbox)layout.GetBox("scoreCounter")).text = score.ToString();

            // Updating objects
            if (victory)
            {
                return;
            }
            map.Update();
            lock (entities)
            {
                foreach (Entity.Entity entity in entities)
                {
                    entity.Update();
                }
            }
        }
예제 #5
0
		public static void Main(string[] args) {

			//Inicjalizacja okna
			window = new RenderWindow(new VideoMode(1280, 720, 32), "Praca inzynierska", Styles.Close);
			window.Closed += (o, e) => window.Close();
			window.KeyPressed += (o, e) => { if ( e.Code == Keyboard.Key.Escape ) { window.Close(); } };
			origWindowSize = window.Size;

			DisplayTitle();

			WriteLine("Title displayed!");

			//inicjalizacja mapy
			WriteLine("Start map creating!");
			const int mapSize = 50;
			map = new Map.Map(mapSize, new MapSeed((int)(mapSize / 5.0), (int)(mapSize / 10.0), (int)(mapSize / 15.0)));

			window.MouseMoved += map.Map_MouseMoved;
			window.MouseWheelScrolled += map.Map_MouseWheelScrolled;
			WriteLine("Map created!");

			WriteLine("Start creating GUI!");
			//Tworzenie GUI
			gui = new GUI() { new Button {
											   Name = "Close Button",
											   IsActive = true,
											   ButtonTexture = new Sprite(NormalButtonTexture),
											   ButtonText = new Text("Zamknij!", font) {
																						   CharacterSize = 20,
																						   Color = Color.Black
																					   },
											   Position = new Vector2f(20, window.Size.Y - 60),
											   MouseButtonPressedHandler = (s, e) => {
																			   if ( Mouse.IsButtonPressed(Mouse.Button.Left) ) window.Close();
																		   }
										   },
								new BuildButton() {
													  Name = "Build Button",
													  IsActive = true,
													  ButtonTexture = new Sprite(NormalButtonTexture),
													  ButtonText = new Text("Buduj", font) {
																							   CharacterSize = 20,
																							   Color = Color.Black
																						   },
													  Position = new Vector2f(20, window.Size.Y - 120)
												  }
							};

			window.KeyPressed += gui.Window_KeyPressed;
			window.KeyReleased += gui.Window_KeyReleased;
			window.MouseButtonPressed += gui.Window_MouseButtonPressed;
			window.MouseButtonReleased += gui.Window_MouseButtonReleased;
			window.MouseMoved += gui.Window_MouseMoved;
			window.MouseWheelScrolled += gui.Window_MouseWheelScrolled;
			WriteLine("GUI created!");

			WriteLine("Start creating colony!");
			Colony colony = new Colony(map, window);
			map.UpdateTime += colony.UpdateTime;
			colony.AddColonist(new Men() {
											 Name = "Adam",
											 MoveSpeed = 5,
											 Location = map[10, 20],
											 TextureSelected = new Sprite(MenTextureSelected),
											 TextureNotSelected = new Sprite(MenTexture),
											 IsSelected = false,
											 HP = new FuzzyHP(50f) {
																	   MaxHP = 50f
																   },
											 Strength = 5f,
											 Mining = 3f,
											 Constructing = 4f,
											 Accuracy = 4.5f,
										 });
			colony.AddConstruct(new Construct(2, 3, map[3, 3], Color.Magenta) {
																				  MaxConstructPoints = 200
																			  });

			WriteLine("Colony created!");
			
			/*WriteLine("Start creating path!");
			WriteLine("Searching for start and end point!");
			//tymczasowe sprawdzenie wyznaczanie sciezki
			IList<MapField> path;
		    MapField start = null,
		             stop  = null;

            //Wyszukanie pierwszego dostepnego pola
            foreach ( MapField field in map.Where(field => field.IsAvaliable) ) {
	            start = field;
	            break;
            }

            //wyszukanie ostatniego dostepnego pola
            foreach ( MapField field in map.Reverse().Where(field => field.IsAvaliable) ) {
	            stop = field;
	            break;
            }
			WriteLine("Sstart and end point found!");

			try { //próba wyznaczenia sciezki miedzy wyznaczonymi polami
                path = PathFinding.AStar(start, stop, PathFinding.Metric.EuclideanDistance);
			} catch ( FieldNotAvaliableException ) {
				WriteLine($"Texture [{start.MapPosition.X}, {start.MapPosition.Y}] is avaliable = {start.IsAvaliable}");
                WriteLine($"Texture [{stop.MapPosition.X}, {stop.MapPosition.Y}] is avaliable = {stop.IsAvaliable}");
                WriteLine("But path between this field dose not exists!");
				path = null;
			}
			WriteLine("Path created!");*/

			WriteLine("Start creating herd!");
			MapField mapField;
			int center = map.Size / 2;
			do {
				int x = rand.Next(center - center / 2, center + center / 2);
				int y = rand.Next(center - center / 2, center + center / 2);
				mapField = map[x, y];
			} while ( !mapField.IsAvaliable );
			WriteLine($"Start from - {mapField}");

			Herd herd = new Herd(mapField, 5);

			map.UpdateTime += herd.UpdateTime;
			foreach ( Animal animal in herd ) { map.UpdateTime += animal.UpdateTime; }
			WriteLine("Herd created!");

			time.Start();

            //Główna petla gry
            while ( window.IsOpen ) {
				window.DispatchEvents();
				window.Clear();

				time.Stop();

				map.Update(time.Elapsed);

				time.Restart();

				window.Draw(map);

				/*if ( path != null ) {
					foreach ( Sprite val in path.Select(field => new Sprite(SelectedTexture) {
																	 Position = field.ScreenPosition
																 }) ) {
						window.Draw(val);
					}
				}*/

				window.Draw(colony);

	            window.Draw(herd);
	            //window.Draw(an);

				window.Draw(gui);

				window.Display();
			}
		}