예제 #1
0
파일: Effects.cs 프로젝트: quajak/StartGame
 private void RemoveEffect(MainGameWindow main)
 {
     main.Turn        -= Main_Turn;
     main.PlayerMoved -= Main_PlayerMoved;
     player.troop.statuses.Remove(this);
     main.UpdatePlayerView();
 }
예제 #2
0
파일: Effects.cs 프로젝트: quajak/StartGame
        public IceSpike(int Turns, Point point, Point SpawnPosition, Map map, MainGameWindow main) : base("Ice Spike", SpawnPosition, Resources.IceSpike, map, Turns, main, render: false)
        {
            //TODO: Do this for every single step of the animation
            int dX = SpawnPosition.X - point.X;
            int dY = SpawnPosition.Y - point.Y;

            if (Math.Abs(dX) > Math.Abs(dY))
            {
                if (dX < 0)
                {
                    Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                }
                else
                {
                    Image.RotateFlip(RotateFlipType.Rotate270FlipNone);
                }
            }
            else
            {
                if (dY < 0)
                {
                    Image.RotateFlip(RotateFlipType.Rotate180FlipNone);
                }
                else
                {
                }
            }

            Position = point; //So animation is created
        }
예제 #3
0
 public HumanPlayer(PlayerType Type, string Name, Map Map, Player[] Enemies, MainGameWindow window, int Money)
     : base(Type, Name, Map, Enemies, 0, 1, 1, 1, 1, 1, 10, constantMovementFunction: false)
 {
     main          = window;
     base.Money    = new Attribute(Money, "Money", "Coins");
     mana.RawValue = (int)mana.MaxValue();
 }
예제 #4
0
 public void Activate(Player Player, MainGameWindow Main, bool AllowAction)
 {
     allowAction = AllowAction;
     main        = Main;
     player      = Player;
     Render();
 }
예제 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="player"></param>
 /// <param name="mainGame">If set it is taken that the player is in battle</param>
 public void Activate(Player player, MainGameWindow mainGame)
 {
     InitializeComponent();
     this.player = player;
     items.AddRange(player.troop.Items);
     this.mainGame = mainGame;
 }
예제 #6
0
파일: Effects.cs 프로젝트: quajak/StartGame
        public static int IDcounter = 0; //The id of an effect is used to identify the render object it is linked to

        public Effect(string Name, Point Position, Bitmap Image, Map Map, int Turns, MainGameWindow main, bool Blocking = false, bool render = true) : base(Name + IDcounter.ToString(), Position, Image, Blocking, Map)
        {
            ID = IDcounter;
            IDcounter++;
            //DEBUG Test -- check that there is no race condition occuring and that names are being set correctly
            if (Name + ID.ToString() != base.Name)
            {
                throw new Exception("Setting of effect name went wrong!");
            }

            map = Map;
            map.entities.Add(this);

            lock (map.RenderController)
            {
                map.renderObjects.Add(new EntityRenderObject(this, new TeleportPointAnimation(new Point(0, 0), Position)));
            }
            if (render)
            {
                main.RenderMap();
            }
            turns      = Turns;
            this.main  = main;
            main.Turn += Main_Turn;
        }
예제 #7
0
파일: Effects.cs 프로젝트: quajak/StartGame
 public DebuffStatus(int Turns, int Strength, MainGameWindow main, Player player) : base("Debuff", Turns, player)
 {
     strength        = Strength;
     this.main       = main;
     this.main.Turn += Main_Turn;
     player.actionPoints.rawMaxValue -= strength;
     player.troop.statuses.Add(this);
     main.UpdatePlayerView();
 }
예제 #8
0
        public override void ManipulateMission(MainGameWindow mainGame, Mission.Mission mission)
        {
            int num = World.World.random.Next(10, 30);

            Point[] spawn = mainGame.map.DeterminSpawnPoint(num, SpawnType.randomLand).ToArray();
            foreach (var point in spawn)
            {
                mainGame.AddPlayer(new PlayerData.Players.Tree(point, mainGame.map));
            }
        }
예제 #9
0
        public void SimpleStart()
        {
            Initialise(out Map map, out List <Tree> trees, out HumanPlayer player);
            Assert.IsNotNull(player);
            MainGameWindow mainGame = new MainGameWindow(map, player, new DebugMission(), trees, 1, 1);

            Assert.IsNotNull(mainGame);
            Assert.IsNotNull(mainGame.humanPlayer);
            Assert.IsNotNull(mainGame.map);
            Assert.IsFalse(mainGame.dead);
        }
예제 #10
0
 /// <summary>
 /// 带参构造函数,传入一个MainGameWindow类,用于关联游戏窗口
 /// </summary>
 /// <param name="gameWindow">关联的游戏窗口</param>
 public SlideJigsawGame(MainGameWindow gameWindow)
 {
     Game       = new SlideJigsawMain(BlockCreatAction);
     GameWindow = gameWindow;
     GameWindow.ToggleDetector.Visibility = Visibility.Collapsed;
     GameWindow.SliderMinesSet.Visibility = Visibility.Collapsed;
     GameWindow.LabelProcess.Visibility   = Visibility.Collapsed;
     GameWindow.MaximumRows    = 10;
     GameWindow.MinimumRows    = 3;
     GameWindow.MaximumColumns = 10;
     GameWindow.MinimumColumns = 3;
     GameWindow.MinimumMines   = 0;
     GameWindow.KeyDown       += Window_KeyDown;
 }
 public TwoZeroFourEightGame(MainGameWindow gameWindow)
 {
     Game                                 = new TwoZeroFourEightMain(BlockCreateAction);
     GameWindow                           = gameWindow;
     GameWindow.KeyDown                  += Window_KeyDown;
     GameWindow.MaximumRows               = 6;
     GameWindow.MinimumRows               = 4;
     GameWindow.MaximumColumns            = 4;
     GameWindow.MinimumColumns            = 1;
     GameWindow.SliderMinesSet.Visibility = Visibility.Collapsed;
     GameWindow.LabelProcess.Visibility   = Visibility.Visible;
     GameWindow.ToggleDetector.Visibility = Visibility.Visible;
     GameWindow.ToggleDetector.Click     += ToggleDetector_Click;
 }
예제 #12
0
        public override void PlayTurn(MainGameWindow main, bool singleTurn)
        {
            //Decrease spell cooldown
            foreach (Spell spell in spells)
            {
                spell.coolDown = spell.coolDown == 0 ? 0 : spell.coolDown - 1;
            }

            //Panic if he has been hit or player is close and he is on low health
            if (troop.health.Value != lastHealth || (AIUtility.Distance(troop.Position, enemies[0].troop.Position) < 4 && troop.health.Value != troop.health.MaxValue().Value))
            {
                lastHealth = troop.health.Value;
                //If teleport spell is ready
                if (spells[1].Ready)
                {
                    //Find heighest free space
                    var HeightSorted = from field in map.map.Cast <MapTile>()
                                       where field.free
                                       where AIUtility.Distance(field.position, enemies[0].troop.Position) > 10
                                       orderby field.Height descending
                                       select field;
                    //Teleport
                    spells[1].Activate(new SpellInformation()
                    {
                        positions = new List <Point>()
                        {
                            troop.Position, HeightSorted.Take(1).ToList()[0].position
                        }, mage = this
                    });
                    return; //Finish turn
                }
                else
                {
                    main.WriteConsole("The wizard wimpers");
                    return;
                }
            }

            //Attack
            if (spells[0].Ready)
            {
                spells[0].Activate(new SpellInformation()
                {
                    positions = new List <Point> {
                        enemies[0].troop.Position
                    }, mage = this
                });
            }
        }
예제 #13
0
        public void CheckAllMissions()
        {
            List <Mission> missions = new List <Mission> {
                new BearMission(), new ElementalWizardFight(), new AttackCampMission(), new SpiderNestMission(), new BanditMission(), new DragonFight()
            };

            foreach (var mission in missions)
            {
                Initialise(out Map map, out List <Tree> trees, out HumanPlayer player);
                MainGameWindow mainGame = new MainGameWindow(map, player, new DebugMission(), trees, 1, 1);
                Assert.IsNotNull(mainGame);
                Assert.IsNotNull(mainGame.humanPlayer);
                Assert.IsNotNull(mainGame.map);
                Assert.IsFalse(mainGame.dead);
            }
        }
예제 #14
0
        private void StartGame()
        {
            w = new ManicDiggerGameWindow();
            if (maingamewindow == null)
            {
                //wasn't done in StartMenu().
                maingamewindow = new MainGameWindow(w);
            }
            maingamewindow.mywindow = w;

            w.d_MainWindow = maingamewindow;
            w.d_Exit       = exit;
            w.d_Audio      = audio;
            MakeGame();
            w.connectdata = connectdata;
            w.Run();
        }
예제 #15
0
파일: Weapon.cs 프로젝트: quajak/StartGame
        public override void UseWeapon(Player player, MainGameWindow main)
        {
            Ammo ammo1 = GetSelectedAmmo();

            ammo1.Amount--;
            if (ammo1.Amount == 0)
            {
                ammo1.Selected.Keys.ToList().ForEach(w => {
                    ammo1.Deselect(w);
                    w.ammo.Remove(ammo1);
                });
                if (ammo.Count != 0)
                {
                    ammo[0].Select(this);
                }
            }
            ammo1.OnUse(player, main);
        }
예제 #16
0
파일: Effects.cs 프로젝트: quajak/StartGame
        private void Main_PlayerMoved(object sender, MainGameWindow.PlayerMovementData e)
        {
            MainGameWindow main = sender as MainGameWindow;

            if (e.player.Name == player.Name && e.goal.type.FType == FieldType.water)
            {
                Point start = e.start.position;
                foreach (var field in e.path)
                {
                    start = start.Add(field);
                    if (main.map.map.Get(start).type.FType == FieldType.water)
                    {
                        RemoveEffect(sender as MainGameWindow);
                        return;
                    }
                }
            }
        }
예제 #17
0
        private void RunMission(int difficulty, Mission.Mission selected, StartMission action = null)
        {
            World.Instance.campaign.mission = selected;
            MapBiome biome = new GrasslandMapBiome();

            if (mapBiomes.ContainsKey(World.Instance.worldMap[player.WorldPosition.X, player.WorldPosition.Y].type))
            {
                biome = mapBiomes[World.Instance.worldMap[player.WorldPosition.X, player.WorldPosition.Y].type];
            }
            Map map = World.Instance.campaign.GenerateMap(biome);

            player.map       = map;
            player.troop.Map = map;
            MainGameWindow mainGame = new MainGameWindow(map, player, selected, World.Instance.trees, difficulty, World.WORLD_DIFFICULTY);

            biome.ManipulateMission(mainGame, selected);
            mainGame.RenderMap(true, true, true);
            controller.Stop();
            mainGame.ShowDialog();
            if (action != null)
            {
                action.MissionEnded(mainGame.giveReward);
            }
            if (mainGame.dead)
            {
                //as player is dead campaign is over
                Close();
                return;
            }
            if (mainGame.giveReward)
            {
                //Now give reward
                MissionResult r = CampaignController.GenerateRewardAndHeal(player, mainGame, selected, player.vitality.Value, (player.level / 25d).Cut(0, 1), "Close");
                r.ShowDialog();
            }
            if (running)
            {
                controller.Start();
            }
            World.Instance.missionsCompleted++;
            World.Instance.actors.RemoveAll(p => (p is MissionWorldPlayer wp) && wp.WorldPosition == player.WorldPosition);
            World.Instance.GenerateNewMission();
            Render();
        }
예제 #18
0
        /// <summary>
        /// Alkalmazás indulásának eseménykezelője.
        /// </summary>
        private void App_Startup(object sender, StartupEventArgs e)
        {
            _dataAccess = new DBPersistence();

            _newGame = new NewGameWindow();

            _model = new TicTacToeGameModel(_dataAccess);
            //_model.GameWon += new EventHandler<GameWonEventArgs>(Model_GameWon);
            _model.NewGame();

            _viewModel           = new TicTacToeViewModel(_model);
            _viewModel.LoadGame += new EventHandler(ViewModel_LoadGame); // kezeljük a nézetmodell eseményeit
            _viewModel.SaveGame += new EventHandler(ViewModel_SaveGame);
            _viewModel.GameExit += new EventHandler(ViewModel_GameExit);
            _viewModel.NewGame  += new EventHandler(ViewModel_NewGame);
            _model.GameOver     += new EventHandler <GameOverEventArgs>(Model_GameOver);

            _window             = new MainGameWindow();
            _window.DataContext = _viewModel;
            _window.Show();
        }
예제 #19
0
 /// <summary>
 /// 带参构造函数,传入一个MainGameWindow类,用于关联游戏窗口
 /// </summary>
 /// <param name="gameWindow">关联的游戏窗口</param>
 public MinesweeperGame(MainGameWindow gameWindow)
 {
     Game       = new MinesweeperMain(BlockCreateAction);
     GameWindow = gameWindow;
     GameWindow.ToggleDetector.Visibility = Visibility.Visible;
     GameWindow.SliderMinesSet.Visibility = Visibility.Visible;
     GameWindow.LabelProcess.Visibility   = Visibility.Visible;
     GameWindow.MaximumRows                     = 18;
     GameWindow.MinimumRows                     = 6;
     GameWindow.MaximumColumns                  = 30;
     GameWindow.MinimumColumns                  = 6;
     GameWindow.MinimumMines                    = 5;
     GameWindow.ToggleDetector.Click           += ToggleDetector_Click;
     GameWindow.AllowDrop                       = true;
     GameWindow.DragEnter                      += GameWindow_DragEnter;
     GameWindow.DragLeave                      += GameWindow_DragLeave;
     GameWindow.BorderGamePanelCover.AllowDrop  = true;
     GameWindow.BorderGamePanelCover.DragEnter += BorderGamePanelCover_DragEnter;
     GameWindow.BorderGamePanelCover.DragLeave += BorderGamePanelCover_DragLeave;
     GameWindow.BorderGamePanelCover.Drop      += BorderGamePanelCover_Drop;
 }
예제 #20
0
        public override void PlayTurn(MainGameWindow main, bool singleTurn)
        {
            turn = turn == 0 ? 0 : turn - 1;
            if (turn == 0 && numSpawned < maxSpawned)
            {
                //Find the position for the new spider to spawn
                Point pos = new Point(-1, -1);
                foreach (MapTile tile in map.map[troop.Position.X, troop.Position.Y].neighbours.rawMaptiles)
                {
                    //Check if empty and not water
                    if (tile.type.type != MapTileTypeEnum.deepWater || tile.type.type != MapTileTypeEnum.shallowWater && !map.troops.Exists(t => t.Position.X == tile.position.X && t.Position.Y == tile.position.Y))
                    {
                        pos = tile.position;
                        break;
                    }
                }

                if (pos.X == -1) // No space available wait for next turn
                {
                    return;
                }

                //Spawn a new spider
                numSpawned++;
                WarriorSpiderAI spider = new WarriorSpiderAI(PlayerType.computer, "Spider Spawn " + numSpawned, map, main.players.ToArray());
                spider.troop = new Troop("Spider Spawn " + numSpawned, new Weapon(1 + difficulty / 5 + round / 2,
                                                                                  BaseAttackType.melee, BaseDamageType.sharp, 1, "Fangs", 1, false), Resources.spiderWarrior, 0, map, spider, 25)
                {
                    Position = pos
                };

                main.AddPlayer(spider);

                turn = 5 - (difficulty / 2);
            }
        }
예제 #21
0
파일: Effects.cs 프로젝트: quajak/StartGame
        private void Main_Turn(object sender, MainGameWindow.TurnData e)
        {
            MainGameWindow main = sender as MainGameWindow;

            if (e.active.Name != player.Name)
            {
                return;
            }

            //Handle turn countdown
            if (turns == null)
            {
                return;
            }

            turns--;
            if (turns == 0)
            {
                player.actionPoints.rawMaxValue += strength;
                player.troop.statuses.Remove(this);
                main.UpdatePlayerView();
                this.main.Turn -= Main_Turn;
            }
        }
예제 #22
0
파일: Effects.cs 프로젝트: quajak/StartGame
        private void Main_Turn(object sender, MainGameWindow.TurnData e)
        {
            MainGameWindow main = sender as MainGameWindow;

            if (e.active.Name != player.Name)
            {
                return;
            }

            //Do effect
            main.DamagePlayer(damage, DamageType.fire, player);

            //Handle turn countdown
            if (turns == null)
            {
                return;
            }

            turns--;
            if (turns == 0)
            {
                RemoveEffect(main);
            }
        }
예제 #23
0
파일: Effects.cs 프로젝트: quajak/StartGame
        public Fire(int Turns, int Damage, Point Position, Point SpawnPosition, Map Map, MainGameWindow main) : base("Fire", SpawnPosition, Resources.Fire, Map, Turns, main, render: false)
        {
            //Can it actually exist?
            if (Map.map.Get(Position).type.FType == FieldType.water)
            {
                //Destroy it
                BaseDelete();
                Delete();
                return;
            }

            //Set position to actual position - to create effect that the mage created the fireball
            this.Position = Position;
            main.RenderMap();

            damage = Damage;
            this.main.PlayerMoved += Main_PlayerMoved;

            //Check if put on position of entity
            List <Troop> f = Map.troops.Where(t => t.Position == Position).ToList();

            if (f.Count != 0)
            {
                Player player     = main.players.First(p => p.troop == f[0]);
                string playerName = player.Name;
                main.WriteConsole($"{playerName} has been put on fire!");
                f[0].statuses.Add(new FireStatus(turns + 2, damage, main, player));
                if (playerName == main.humanPlayer.Name)
                {
                    main.UpdatePlayerView();
                }
            }
        }
예제 #24
0
        static void Main(string[] args)
        {
            var game = new MainGameWindow();

            game.Run();
        }
예제 #25
0
 public override void Initialise(MainGameWindow main)
 {
     spells.ForEach(s => s.Initialise(main, map));
     lastHealth = troop.health.Value;
 }
예제 #26
0
 public virtual void ManipulateMission(MainGameWindow mainGame, Mission.Mission mission)
 {
 }
예제 #27
0
        public override void PlayTurn(MainGameWindow main, bool SingleTurn)
        {
            DistanceGraphCreator distanceGraph = new DistanceGraphCreator(this, troop.Position.X, troop.Position.Y, map, false);
            Thread path = new Thread(distanceGraph.CreateGraph);

            path.Start();
            path.Join();

            int damageDealt = 0;
            int dodged      = 0;

            while (actionPoints.Value > 0)
            {
                Point playerPos = enemies[0].troop.Position;

                //Check if it can attack player
                int playerDistance = AIUtility.Distance(playerPos, troop.Position);
                if (playerDistance <= troop.activeWeapon.range &&
                    troop.activeWeapon.Attacks() > 0)
                {
                    //Attack
                    var(damage, killed, hit) = main.Attack(this, enemies[0]);
                    damageDealt += damage;
                    if (!hit)
                    {
                        dodged++;
                    }

                    if (killed)
                    {
                        map.overlayObjects.Add(new OverlayText(enemies[0].troop.Position.X * MapCreator.fieldSize, enemies[0].troop.Position.Y * MapCreator.fieldSize, Color.Red, $"-{damageDealt}"));
                        main.PlayerDied($"You have been killed by {Name}!");
                        break;
                    }
                    actionPoints.RawValue--;
                    troop.activeWeapon.UseWeapon(enemies[0], main);
                    main.RenderMap();
                    continue;
                }
                else if (troop.weapons.Exists(t => t.range >= playerDistance && t.Attacks() > 0))
                {
                    //Change weapon
                    Weapon best = troop.weapons.FindAll(t => t.range >= playerDistance)
                                  .Aggregate((t1, t2) => t1.range > t2.range ? t1 : t2);
                    troop.activeWeapon = best;
                    continue;
                }

                Point closestField = new Point(-1, -1);
                try
                {
                    // Try finding closer field to player
                    closestField = AIUtility.FindClosestField(distanceGraph, playerPos, movementPoints.Value, map,
                                                              (List <(Point point, double cost, double height)> list) => {
                        list.Sort((o1, o2) => {
                            double diffCost   = o1.cost - o2.cost;
                            double heightDiff = o1.height - o2.height;
                            if (Math.Abs(diffCost) >= 1)     //assume that using the weapon costs 1 action point
                            {
                                return(diffCost < 0 ? -1 : 1);
                            }
                            else if (heightDiff != 0)
                            {
                                return(diffCost < 0 ? -1 : 1);
                            }
                            return(0);
                        });
                        return(list.First().point);
                    });
                }
예제 #28
0
파일: Effects.cs 프로젝트: quajak/StartGame
 public LightningBolt(int Turns, Point point, Map map, MainGameWindow main) : base("LightningBolt", point, Resources.LightningBolt, map, Turns, main, render: false)
 {
 }
예제 #29
0
파일: Effects.cs 프로젝트: quajak/StartGame
 public EarthQuakeField(int Turns, Point point, Map map, MainGameWindow main) : base("EarthQuakeField", point, Resources.EarthQuake, map, Turns, main, render: false)
 {
 }
예제 #30
0
파일: Effects.cs 프로젝트: quajak/StartGame
 /// <summary>
 ///
 /// </summary>
 /// <param name="Turns"></param>
 /// <param name="Damage"></param>
 /// <param name="main"></param>
 /// <param name="affected">The player who was affected</param>
 public FireStatus(int?Turns, int Damage, MainGameWindow main, Player affected) : base("Fire", Turns, affected)
 {
     main.Turn        += Main_Turn;
     main.PlayerMoved += Main_PlayerMoved;
     damage            = Damage;
 }