Esempio n. 1
0
        public ResultsScreen(Game game, int gamePlayResult)
            : base(game)
        {
            _gui = new GUI(new Vector2(GraphicsDevice.Viewport.Height / 500f));
            _gui.Add(CreateMainTitle(game));
            _gui.Add(CreateMessage(gamePlayResult));
            _gui.Add(CreateBackButton(game));

            _music = Game.Content.Load<Song>("Audio/Music/credits.wav");

#if ANDROID && !DEBUG
            UpdateHighScore(gamePlayResult);
#endif
        }
Esempio n. 2
0
        internal static void Initialize()
        {
            Binding.Load("bindings.txt");
            Command.Add(new Command("addmacro", AddMacro));
            Command.Add(new Command("clear", Clear));
            Command.Add(new Command("help", Help));
            Command.Add(new Command("macro", Macro));
            Command.Add(new Command("netsend", NetSend));
            Command.Add(new Command("repeat", Repeat));
            Command.Add(new Command("say", Say));
            GUI.Initialize(Game);
            GUI.Add(ConsoleForm = new ConsoleForm());
            GameHooks.OnInitialize();

            ProjNames = new string[Main.instance.Get("projectileTexture").Length];
            dynamic temp = Projectile.New();

            for (int i = 0; i < ProjNames.Length; i++)
            {
                temp.SetDefaults(i);
                ProjNames[i] = temp.name;
            }
            if (File.Exists("startup.macro"))
            {
                Command.Execute("m startup");
            }
        }
Esempio n. 3
0
 static void Main(string[] args)
 {
     Console.ForegroundColor = ConsoleColor.White;
     // t.Draw(10, 40, ConsoleColor.Gray);
     One.Set(0, 10, "░░1░░", ConsoleColor.Gray);
     GUI.Add(One);
     GUI.CalculateOnStart();
     for (;;)
     {
         MousePos = new Point(System.Windows.Forms.Control.MousePosition.X / (Console.LargestWindowWidth / 24), System.Windows.Forms.Control.MousePosition.Y / (Console.LargestWindowHeight / 7));
         if (One.Pressed(MousePos))
         {
             Console.Write("1");
         }
         //   Console.Clear();
     }
 }
Esempio n. 4
0
        public static void Main(string[] args)
        {
#if TEST
            PerformanceTests(25, 200, @"PerformanceTest.txt");
            QualityTests(25, 20, 10, @"QualityTest.txt");

            return;
#endif
            //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();

#if DEBUG
            WriteLine("Title displayed!");

            //inicjalizacja mapy
            WriteLine("Start map creating!");
#endif
            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;
#if DEBUG
            WriteLine("Map created!");

            WriteLine("Start creating GUI!");
#endif
            //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 (e.Button == Mouse.Button.Left)
                        {
                            window.Close();
                        }
                    }
                },
                new BuildButton(font, window)
                {
                    Name          = "Build wall",
                    IsActive      = true,
                    ButtonTexture = new Sprite(NormalButtonTexture),
                    ButtonText    = new Text("Mur", font)
                    {
                        CharacterSize = 20,
                        Color         = Color.Black
                    },
                    Position = new Vector2f(20, window.Size.Y - 120),
                    MouseButtonPressedHandler = (s, e) => {
                        if (e.Button == Mouse.Button.Left)
                        {
                            construct       = string.Empty;
                            constructSprite = null;
                            foreach (Men selectedMen in SelectedMens)
                            {
                                selectedMen.IsSelected = false;
                            }
                            SelectedMens.Clear();

                            construct       = "WALL";
                            constructSprite = new Sprite(WallTexturePlanned);
                            WasClicked      = true;
                        }
                    }
                },
                new BuildButton(font, window)
                {
                    Name          = "Build bed",
                    IsActive      = true,
                    ButtonTexture = new Sprite(NormalButtonTexture),
                    ButtonText    = new Text("Łóżko", font)
                    {
                        CharacterSize = 20,
                        Color         = Color.Black
                    },
                    Position = new Vector2f(150, window.Size.Y - 120),
                    MouseButtonPressedHandler = (s, e) => {
                        if (e.Button == Mouse.Button.Left)
                        {
                            construct       = string.Empty;
                            constructSprite = null;
                            foreach (Men selectedMen in SelectedMens)
                            {
                                selectedMen.IsSelected = false;
                            }
                            SelectedMens.Clear();

                            construct       = "BED";
                            constructSprite = new Sprite(BedTexturePlanned);
                            WasClicked      = true;
                        }
                    }
                },
                new BuildButton(font, window)
                {
                    Name          = "Build table",
                    IsActive      = true,
                    ButtonTexture = new Sprite(NormalButtonTexture),
                    ButtonText    = new Text("Stół", font)
                    {
                        CharacterSize = 20,
                        Color         = Color.Black
                    },
                    Position = new Vector2f(150, window.Size.Y - 60),
                    MouseButtonPressedHandler = (s, e) => {
                        if (e.Button == Mouse.Button.Left)
                        {
                            construct       = string.Empty;
                            constructSprite = null;
                            foreach (Men selectedMen in SelectedMens)
                            {
                                selectedMen.IsSelected = false;
                            }
                            SelectedMens.Clear();

                            construct       = "TABLE";
                            constructSprite = new Sprite(TableTexturePlanned);
                            WasClicked      = true;
                        }
                    }
                },
                new Button {
                    Name          = "Attack Button",
                    IsActive      = true,
                    ButtonTexture = new Sprite(NormalButtonTexture),
                    ButtonText    = new Text("Atakuj!", font)
                    {
                        CharacterSize = 20,
                        Color         = Color.Black
                    },
                    Position = new Vector2f(280, window.Size.Y - 120),
                    MouseButtonPressedHandler = (s, e) => {
                        if (e.Button == Mouse.Button.Left && SelectedMens.Count != 0)
                        {
                            construct       = string.Empty;
                            constructSprite = null;
                            Men beeing;

                            try {
                                beeing = (Men)(map.GetMapFieldUnderCursor(window)
                                               .OnField
                                               .First(b => b.GetType() == typeof(Men)));
                            } catch (InvalidOperationException) {
                                return;
                            }

                            foreach (Men men in SelectedMens)
                            {
                                men.Job = ((Men)beeing).AttackThis;
                            }
                        }
                    }
                },
                new Button {
                    Name          = "Clear Button",
                    IsActive      = true,
                    ButtonTexture = new Sprite(NormalButtonTexture),
                    ButtonText    = new Text("Anuluj", font)
                    {
                        CharacterSize = 20,
                        Color         = Color.Black
                    },
                    Position = new Vector2f(280, window.Size.Y - 60),
                    MouseButtonPressedHandler = (s, e) => {
                        if (e.Button == Mouse.Button.Left)
                        {
                            construct       = string.Empty;
                            constructSprite = null;
                            foreach (Men selectedMen in SelectedMens)
                            {
                                selectedMen.IsSelected = false;
                            }
                            SelectedMens.Clear();
                        }
                    }
                },
            };

            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;
#if DEBUG
            WriteLine("GUI created!");

            WriteLine("Start creating colony!");
#endif
            Colony colony = new Colony(map[10, 20], map, window);
            map.UpdateTimeEvent += colony.UpdateTime;
            colony.AddColonist(new Men()
            {
                Name         = "Adam",
                MoveSpeed    = 5,
                IsSelected   = false,
                HP           = new FuzzyHP(50f, 50f),
                Laziness     = new FuzzyLaziness(2.5f),
                RestF        = new FuzzyRest(10f),
                Strength     = 5f,
                Morale       = new FuzzyMorale(5f),
                Mining       = 3f,
                Constructing = 4f,
            });
            colony.AddColonist(new Men()
            {
                Name         = "Adam",
                MoveSpeed    = 5,
                IsSelected   = false,
                HP           = new FuzzyHP(50f, 50f),
                Laziness     = new FuzzyLaziness(5f),
                RestF        = new FuzzyRest(8f),
                Strength     = 5f,
                Morale       = new FuzzyMorale(5f),
                Mining       = 10f,
                Constructing = 4f,
            });
            colony.AddColonist(new Men()
            {
                Name         = "Adam",
                MoveSpeed    = 5,
                IsSelected   = false,
                HP           = new FuzzyHP(50f, 50f),
                Laziness     = new FuzzyLaziness(7f),
                RestF        = new FuzzyRest(3f),
                Strength     = 7f,
                Morale       = new FuzzyMorale(5f),
                Mining       = 3f,
                Constructing = 4f,
            });
            window.MouseButtonPressed += (sender, eventArgs) => {
                if (eventArgs.Button == Mouse.Button.Left && construct != string.Empty && !WasClicked)
                {
                    MapField field = map.GetMapFieldUnderCursor(window);
                    if (field != null && field.IsAvaliable)
                    {
                        try {
                            Construct c;
                            if (construct == "BED")
                            {
                                c = new Bed(1, 1, field, Color.Blue)
                                {
                                    MaxConstructPoints = 200,
                                    Name = "bed"
                                }
                            }
                            ;
                            else if (construct == "WALL")
                            {
                                c = new Construct(1, 1, field, new Color(158, 158, 158))
                                {
                                    MaxConstructPoints = 350,
                                    Name = "bed"
                                }
                            }
                            ;
                            else if (construct == "TABLE")
                            {
                                c = new Construct(2, 2, field, new Color(60, 60, 0))
                                {
                                    MaxConstructPoints = 250,
                                    Name = "bed"
                                }
                            }
                            ;
                            else
                            {
                                throw new ArgumentException();
                            }

                            colony.AddConstruct(c);
                        } catch {
                            // ignored
                        }
                    }
                }
            };

            window.MouseButtonReleased += (sender, eventArgs) => {
                if (eventArgs.Button == Mouse.Button.Left)
                {
                    foreach (Beeing beeing in map.GetMapFieldUnderCursor(window).OnField)
                    {
                        if (beeing is Men colonist && colonist.Colony != null)
                        {
                            if (colonist.IsSelected)
                            {
                                SelectedMens.Remove(colonist);
                                colonist.IsSelected = false;
                            }
                            else
                            {
                                SelectedMens.Add(colonist);
                                colonist.IsSelected = true;
                            }
                        }
                    }
                }
            };
#if DEBUG
            WriteLine("Colony created!");
#endif
            Besiegers besigers = new Besiegers(map, colony);
            map.UpdateTimeEvent += besigers.UpdateTime;
#if DEBUG
            WriteLine("Start creating besigers!");

            WriteLine("Besigers created!");

            WriteLine("Start creating herd!");
#endif
            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);
#if DEBUG
            WriteLine($"Start from - {mapField}");
#endif
            Herd herd = new Herd(mapField, 5);

            map.UpdateTimeEvent += herd.UpdateTime;
            foreach (Animal animal in herd)
            {
                map.UpdateTimeEvent += animal.UpdateTime;
            }
#if DEBUG
            WriteLine("Herd created!");
#endif
            gui.Add(new ColonySurface(colony, font, window)
            {
                IsActive = true,
            });

            time.Start();

            //Główna petla gry
            while (window.IsOpen && colony.Colonist.Count > 0)
            {
                window.DispatchEvents();
                WasClicked = false;
                window.Clear();

                time.Stop();

                map.Update(time.Elapsed);

                time.Restart();

                window.Draw(map);

                if (construct != string.Empty)
                {
                    MapField field = map.GetMapFieldUnderCursor(window);
                    if (field != null)
                    {
                        constructSprite.Position = field.ScreenPosition;
                        window.Draw(constructSprite);
                    }
                }

                window.Draw(herd);

                window.Draw(besigers);

                window.Draw(colony);

                window.Draw(gui);

                window.Display();

                GC.Collect();
            }

            if (window.IsOpen)
            {
                window.Close();
            }
        }