/// <summary> /// Get the current renderer to draw the game /// </summary> public void Draw() { GuiEnvironment.GetRenderer().RenderWindow(); MetaHandler.ShowPanels(); // IA - Make the panel visible // IA - Single Player Mode only. if (_gameStates.Peek() == GameState.SinglePlayerMode) { MetaHandler.DisplayHungerInformation(); // IA - Show the hunger level progress bar and messages MetaHandler.DisplayTimer(); // IA - Make the timer visible MetaHandler.DisplayGameLevel(); // IA - Display the game level MetaHandler.DisplayAmmunitionLevel(_player.Weapon); // IA - Display info about amminutions (type and amount) MetaHandler.DisplayEnemiesInfo(SpawnedEnemies, EnemiesToBeRemoved); // IA - Display how many enemies have been destroyed. MetaHandler.DrawFoodField(GetPlayer().Inventory); } // IA - Only display the worth of minerals while the game runs. if (_gameStates.Peek() == GameState.SinglePlayerMode) { MetaHandler.DisplayRate(GetPlayer().Inventory.GetTotalValue(), GetPlayer().Inventory); } // IA - Two Players Mode only. if (_gameStates.Peek() == GameState.TwoPlayerMode) { MetaHandler.DisplayTwoPlayersInstructions(); MetaHandler.DisplaySinglePlayerWeaponInfo(_player, "Player 1", 15); MetaHandler.DisplaySinglePlayerWeaponInfo(_player2, "Player 2", 85); MetaHandler.DisplayRate(_player.Inventory.GetTotalValue(), _player.Inventory, "PLAYER 1", -190, Color.Wheat); MetaHandler.DisplayRate(_player2.Inventory.GetTotalValue(), _player2.Inventory, "PLAYER 2", 10, Color.Yellow); } }
public void ImpingAintEasy() { new AutoLevel(Util.Data.AutoLevel.GetSequence()); MetaHandler.DoChecks(); //#TODO rewrite MetaHandler with BehaviorSharp Behaviors.MainBehavior.Root.Tick(); }
public static void CarryIsNull() { if (Autoplay._byPassLoadedCheck) { Autoplay.Carry = MetaHandler.AllyHeroes.FirstOrDefault( hero => !hero.IsMe && !hero.InFountain() && !MetaHandler.HasSmite(hero)); return; } Autoplay.BotLanePos.To3D().WalkAround(); if (Autoplay.Bot.Distance(Autoplay.BotLanePos) < 1000) { if (Environment.TickCount - Autoplay._loaded > 60000 && !MetaHandler.ShouldSupportTopLane) { Autoplay.Carry = MetaHandler.AllyHeroes.FirstOrDefault( hero => !hero.IsMe && hero.Distance(Autoplay.Bot.Position) < 4500 && !MetaHandler.HasSmite(hero)); } if (Environment.TickCount - Autoplay._loaded > 60000 && MetaHandler.ShouldSupportTopLane) { Autoplay.Carry = MetaHandler.AllyHeroes.FirstOrDefault( hero => !hero.IsMe && hero.Distance(Autoplay.TopLanePos) < 4500 && !MetaHandler.HasSmite(hero)); } } }
/// <summary> /// Starts the bot asynchronously. /// </summary> public async Task Start() { Console.WriteLine("Fetching meta repositories..."); if (Directory.Exists("git")) { FileHelper.NormalizeAttributes("git"); Directory.Delete("git", true); } Meta = new MetaHandler(Settings.Meta); Commands = new Dictionary <string, Func <BotCommand, Task> >(); Directory.CreateDirectory(PluginsFolder); Console.WriteLine("Loading plugins."); Plugins = new PluginLoader <IBotPlugin>(); foreach (IBotPlugin plugin in Plugins.Load(PluginsFolder)) { plugin.Load(this); } Console.WriteLine("Reloading meta."); Meta.Reload(); if (Settings.Chat.Discord.Enabled) { DiscordConnection = new DiscordConnection(); DiscordConnection.Configure(this, Settings.Chat.Discord); Connections.Add(DiscordConnection); Console.WriteLine("Beginning asynchronous Discord connection."); _ = DiscordConnection.ConnectAsync(); } Console.WriteLine("Setting up command system."); RegisterCommands(typeof(Bot).Assembly); Console.WriteLine("Successful startup."); await Task.Delay(-1); }
private static void Obj_AI_Base_OnIssueOrder(Obj_AI_Base sender, GameObjectIssueOrderEventArgs args) { if (sender == null || !sender.IsValid || !sender.IsMe) { return; } if (args.Order == GameObjectOrder.MoveTo) { if (Environment.TickCount - LastMove < Menu.Item("MovementDelay").GetValue <Slider>().Value&& Menu.Item("MovementEnabled").GetValue <bool>()) { args.Process = false; return; } if (ObjectHandler.Get <Obj_AI_Turret>().Any(t => t.IsEnemy && t.Distance(args.TargetPosition) < 800) && MetaHandler.CountNearbyAllyMinions( ObjectHandler.Get <Obj_AI_Turret>() .FirstOrDefault(t => t.IsEnemy && t.Distance(args.TargetPosition) < 800), 800) <= 2) { args.Process = false; return; } LastMove = Environment.TickCount; } if (args.Target == null) { return; } if (args.Target.IsEnemy && args.Target is Obj_AI_Hero && sender.UnderTurret(true) && (args.Order == GameObjectOrder.AutoAttack || args.Order == GameObjectOrder.AttackUnit)) { args.Process = false; } }
public static bool IsBotSafe() { var map = Constants.Map; if (map != null && map.Type == Utility.Map.MapType.HowlingAbyss) { return(true); } if (Variables.TookRecallDecision) { return(false); } if (Heroes.Me.InFountain()) { return((Heroes.Me.Health > Heroes.Me.MaxHealth * 0.9f) && (Heroes.Me.Mana > Heroes.Me.MaxMana * 0.8f)); } if (Heroes.Me.Mana < Heroes.Me.MaxMana * Constants.LowManaRatio) { return(Heroes.Me.Health > Heroes.Me.MaxHealth * Constants.LowHealthIfLowManaRatio && !Heroes.Me.IsRecalling() && !(Heroes.Me.Gold > Randoms.NeededGoldToBack && !MetaHandler.HasSixItems())); } return((Heroes.Me.Health > Heroes.Me.MaxHealth * Constants.LowHealthRatio) && !Heroes.Me.IsRecalling() && !(Heroes.Me.Gold > Randoms.NeededGoldToBack && !MetaHandler.HasSixItems())); }
/// <summary> /// Deploys the weapon. /// </summary> /// <param name="attackDirection">Attack direction.</param> public void DeployWeapon(AttackDirection attackDirection) //JY- player uses weapon { if (_weapon != null) { _weapon.Attack(_location, attackDirection); } MetaHandler.DisplayAmmunitionLevel(_weapon); }
/// <summary> /// Performs minerals-to-food transactions and updates the energy level progress bar accordingly. /// </summary> /// <param name="inventory">Inventory.</param> /// <param name="convertedAmount">Converted amount.</param> public static void PurchaseFood(Inventory inventory, int convertedAmount) { _foodPurchased = convertedAmount; // store the amount for conversion to energy inventory.DeductPointsForFood(convertedAmount); double validPercentage = FoodConvertableToEnergy(); MetaHandler.IncreaseEnergy(validPercentage); }
/// <summary> /// Performs minerals-to-food transactions using only the player's balance /// </summary> /// <param name="convertedAmount">Converted amount.</param> public static void PurchaseFoodFromBalance(int convertedAmount) { GetMineralValue(); // int foodKGAvailable = 0; if (convertedAmount <= _balance) { _balance -= convertedAmount; } double validPercentage = FoodConvertableToEnergy(); MetaHandler.IncreaseEnergy(validPercentage); }
public String get_skin_meta() { String meta_text = ""; if (File.Exists(filebank_folder + "/meta/meta.xml")) { MetaHandler Meta = new MetaHandler(filebank_folder + "/meta/meta.xml"); //Setting metas meta_text += Meta.get("author") + ";"; meta_text += Meta.get("version") + ";"; meta_text += Meta.get("name") + ";"; meta_text += Meta.get("texidfix"); } return(meta_text); }
public void set_skin_meta(String author, String version, String name, String texidfix) { if (!File.Exists(filebank_folder + "/meta/meta.xml")) { if (!Directory.Exists(filebank_folder + "/meta/")) { Directory.CreateDirectory(filebank_folder + "/meta/"); } File.Copy("mmsl_config/meta/Default_Meta.xml", filebank_folder + "/meta/meta.xml", true); } MetaHandler Meta = new MetaHandler(filebank_folder + "/meta/meta.xml"); Meta.set("author", author); Meta.set("version", version); Meta.set("name", name); Meta.set("texidfix", texidfix); library.set_changed_status(fullname, cspslot, "changed"); }
public static void UnderTurret() { var turret = MetaHandler.EnemyTurrets.FirstOrDefault(t => t.Distance(Autoplay.Bot.Position) < 1200); if (Autoplay._overrideAttackUnitAction && !Autoplay._tookRecallDecision) { Autoplay.Bot.IssueOrder(GameObjectOrder.MoveTo, Autoplay._safepos.To3D()); } if (!Autoplay.Bot.UnderTurret(true)) { Autoplay._overrideAttackUnitAction = false; } if (Autoplay.Bot.UnderTurret(true) && MetaHandler.NearbyAllyMinions(turret, 750) > 2 && Autoplay.IsBotSafe() && !Autoplay._tookRecallDecision) { if (turret.Distance(Autoplay.Bot.Position) < Autoplay.Bot.AttackRange && !Autoplay._overrideAttackUnitAction) { Autoplay.Bot.IssueOrder(GameObjectOrder.AttackUnit, turret); } } else { if (TargetSelector.GetTarget(Autoplay.Bot.AttackRange, TargetSelector.DamageType.Physical) != null) { var target = TargetSelector.GetTarget(Autoplay.Bot.AttackRange, TargetSelector.DamageType.Physical); if (target != null && target.IsValid && !target.IsDead && Autoplay.IsBotSafe() && !target.UnderTurret(true) && !Autoplay._overrideAttackUnitAction && !Autoplay._tookRecallDecision) { Autoplay.Bot.IssueOrder(GameObjectOrder.AttackUnit, target); } } } if (Autoplay.Bot.UnderTurret(true) && MetaHandler.NearbyAllyMinions(turret, 750) < 2) { Autoplay._safepos.X = (Autoplay.Bot.Position.X + Autoplay._safe); Autoplay._safepos.Y = (Autoplay.Bot.Position.Y + Autoplay._safe); PluginBase.Orbwalker.SetOrbwalkingPoint(Autoplay._safepos.To3D()); } }
public static void NoCarryFound() { if (Autoplay.TempCarry == null || Autoplay.TempCarry.IsDead || Autoplay.TempCarry.InFountain()) { Autoplay.TempCarry = MetaHandler.AllyHeroes.FirstOrDefault( hero => !hero.IsMe && !hero.InFountain() && !hero.IsDead && !MetaHandler.HasSmite(hero)); if (MetaHandler.AllyHeroes.FirstOrDefault( hero => !hero.IsMe && !hero.InFountain() && !hero.IsDead && !MetaHandler.HasSmite(hero)) == null && MetaHandler.AllyHeroes.FirstOrDefault( hero => !hero.IsMe && !hero.InFountain() && !hero.IsDead) != null) { //well f**k, let's follow the jungler -sighs- Autoplay.TempCarry = MetaHandler.AllyHeroes.FirstOrDefault( hero => !hero.IsMe && !hero.InFountain() && !hero.IsDead); } } if (Autoplay.TempCarry != null) { Console.WriteLine("Carry not found, following: " + Autoplay.TempCarry.ChampionName); Autoplay._frontline.X = Autoplay.TempCarry.Position.X + Autoplay._chosen; Autoplay._frontline.Y = Autoplay.TempCarry.Position.Y + Autoplay._chosen; if ( !(Autoplay.TempCarry.UnderTurret(true) && MetaHandler.NearbyAllyMinions(Autoplay.TempCarry, 400) < 2) && Autoplay.IsBotSafe()) { if (Autoplay.Bot.Distance(Autoplay._frontline) > 550) { Autoplay.TempCarry.WalkAround(); } } } }
public static void CarryIsDead() { if (Autoplay.TempCarry == null || Autoplay.TempCarry.IsDead || Autoplay.TempCarry.InFountain()) { if ( MetaHandler.AllyHeroes.FirstOrDefault( hero => !hero.IsMe && !hero.InFountain() && !hero.IsDead && !MetaHandler.HasSmite(hero)) != null) { Autoplay.TempCarry = MetaHandler.AllyHeroes.FirstOrDefault( hero => !hero.IsMe && !hero.InFountain() && !hero.IsDead && !MetaHandler.HasSmite(hero)); } if ( MetaHandler.AllyHeroes.FirstOrDefault( hero => !hero.IsMe && !hero.InFountain() && !hero.IsDead && !MetaHandler.HasSmite(hero)) == null && MetaHandler.AllyHeroes.FirstOrDefault( hero => !hero.IsMe && !hero.InFountain() && !hero.IsDead) != null) { //well f**k, let's follow the jungler -sighs- Autoplay.TempCarry = MetaHandler.AllyHeroes.FirstOrDefault( hero => !hero.IsMe && !hero.InFountain() && !hero.IsDead); } if (!MetaHandler.AllyHeroes.Any(hero => !hero.IsMe && !hero.IsDead)) //everyone is dead { if (!Autoplay.Bot.InFountain()) { Autoplay.NearestAllyTurret = MetaHandler.AllyTurrets.FirstOrDefault(); if (Autoplay.NearestAllyTurret != null) { Autoplay._saferecall.X = Autoplay.NearestAllyTurret.Position.X + Autoplay._safe; Autoplay._saferecall.Y = Autoplay.NearestAllyTurret.Position.Y; Autoplay._tookRecallDecision = true; if (Autoplay.Bot.Position.Distance(Autoplay._saferecall.To3D()) < 200) { Autoplay.Bot.Spellbook.CastSpell(SpellSlot.Recall); } else { Autoplay.Bot.IssueOrder(GameObjectOrder.MoveTo, Autoplay._saferecall.To3D()); } } } } } if (Autoplay.TempCarry != null) { Console.WriteLine("Autoplay.Carry dead or afk, following: " + Autoplay.TempCarry.ChampionName); Autoplay._frontline.X = Autoplay.TempCarry.Position.X + Autoplay._chosen; Autoplay._frontline.Y = Autoplay.TempCarry.Position.Y + Autoplay._chosen; if ( !(Autoplay.TempCarry.UnderTurret(true) && MetaHandler.NearbyAllyMinions(Autoplay.TempCarry, 400) < 2) && Autoplay.IsBotSafe()) { if (Autoplay.TempCarry.Distance(Autoplay.Bot) > 550) { Autoplay.TempCarry.WalkAround(); } } } }
/// <summary> /// This method returns the amount of energy in percentages needed to reach the full energy level of 100%. /// </summary> /// <returns>The gap of energy between the player's current level in percentages, and 100%.</returns> public static int EnergyNeededInPercentage() { int max = 100 - MetaHandler.GetEnergyLevel(); // IA - Current energy levels in % + what the player purchased. return(max); }
/// <summary> /// Update the game based on events, objects and other things /// </summary> public void Update() { randomhit++; //spawn rate - jeremy if (randomhit >= 200) { Init(); randomhit = 0; } // JY- detect projectile hits, projectile and enemies will be deleted foreach (Entity e in Objects) { if (e is Projectile) { if (_twoplayer) { if (_player.PlayerHitbyProjectile((Projectile)e)) { _gameStates.Push(GameState.PlayerTwoWins); ControlGameState(); } else if (_player2.PlayerHitbyProjectile((Projectile)e)) { _gameStates.Push(GameState.PlayerOneWins); ControlGameState(); } } else { if (_player.PlayerHitbyProjectile((Projectile)e)) { _gameStates.Push(GameState.SinglePlayerEndGame); ControlGameState(); } } if (SpawnedEnemies.Count > 0) { foreach (Enemy _e in SpawnedEnemies) { if (((Projectile)e).CheckObjectHit(_world, _e)) { ProjectilesToBeRemoved.Add((Projectile)e); } if (_e.CheckHit((Projectile)e)) { EnemiesToBeRemoved.Add(_e); } } } else if (((Projectile)e).CheckObjectHit(_world, _enemy)) { ProjectilesToBeRemoved.Add((Projectile)e); } } //JY- detect enemies hitting players else if (e is Enemy) { if (_twoplayer) { if (_player.PlayerHitbyEnemy((Enemy)e)) { _gameStates.Push(GameState.PlayerTwoWins); //_player.PlayerHitbyEnemy((Enemy)e) = !_player.PlayerHitbyEnemy((Enemy)e); ControlGameState(); } else if (_player2.PlayerHitbyEnemy((Enemy)e)) { _gameStates.Push(GameState.PlayerOneWins); ControlGameState(); } } else { if (_player.PlayerHitbyEnemy((Enemy)e)) { _gameStates.Push(GameState.SinglePlayerEndGame); ControlGameState(); } } } } foreach (Projectile p in ProjectilesToBeRemoved) { Objects.Remove(p); } foreach (Enemy en in EnemiesToBeRemoved) { if (SpawnedEnemies.Contains(en)) { SpawnedEnemies.Remove(en); } Objects.Remove(en); } foreach (Entity obj in Objects) { obj.Update(); } //PLAYER 1 MINE/BUILD ROCKS INPUT //mine rocks/minerals right // IA - Rewritten the mining logic for the single player if (SwinGame.KeyDown(KeyCode.FKey)) { int x = _player.Location.X; int y = _player.Location.Y; if (SwinGame.KeyReleased(KeyCode.DKey)) { x += 1; } else if (SwinGame.KeyReleased(KeyCode.SKey)) { y += 1; } else if (SwinGame.KeyReleased(KeyCode.AKey)) { x -= 1; } else if (SwinGame.KeyReleased(KeyCode.WKey)) { y -= 1; } try { if (_world.Map[x, y].Type == TileType.Rock && x != 0 && y != 0 && x != 52 && y != 36) { _world.Map[x, y].Type = TileType.Air; if (_world.Map[x, y].Mineral != null) { GetPlayer().Inventory.AddItem(_world.Map[x, y].Mineral); } } } catch (Exception e) { // IA - in case of an exception, force the reassignment of x and y using the player's location. x = _player.Location.X; y = _player.Location.Y; } } //build rock right if (SwinGame.KeyDown(KeyCode.DKey) && SwinGame.KeyDown(KeyCode.GKey)) { //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y)); GetEnvironment(); int x = (_player.Location.X + 1); int y = (_player.Location.Y); Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y)); if (f == null) { Tile tile = _world.Map[x, y]; if (tile.Type == TileType.Air) { _world.Map[x, y] = new Tile(TileType.Rock); } } } //build rock left if (SwinGame.KeyDown(KeyCode.AKey) && SwinGame.KeyDown(KeyCode.GKey)) { //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y)); GetEnvironment(); int x = (_player.Location.X - 1); int y = (_player.Location.Y); Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y)); if (f == null) { Tile tile = _world.Map[x, y]; if (tile.Type == TileType.Air) { _world.Map[x, y] = new Tile(TileType.Rock); } } } //build rock up if (SwinGame.KeyDown(KeyCode.WKey) && SwinGame.KeyDown(KeyCode.GKey)) { //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y)); GetEnvironment(); int x = (_player.Location.X); int y = (_player.Location.Y - 1); Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y)); if (f == null) { Tile tile = _world.Map[x, y]; if (tile.Type == TileType.Air) { _world.Map[x, y] = new Tile(TileType.Rock); } } } //build rock down if (SwinGame.KeyDown(KeyCode.SKey) && SwinGame.KeyDown(KeyCode.GKey)) { //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y)); GetEnvironment(); int x = (_player.Location.X); int y = (_player.Location.Y + 1); Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y)); if (f == null) { Tile tile = _world.Map[x, y]; if (tile.Type == TileType.Air) { _world.Map[x, y] = new Tile(TileType.Rock); } } } if (_twoplayer == true) { //PLAYER 2 MINE/BUILD ROCKS INPUT //mine rocks/minerals right if (SwinGame.KeyDown(KeyCode.KKey)) { int i = _player2.Location.X; int j = _player2.Location.Y; if (SwinGame.KeyReleased(KeyCode.RightKey)) { i += 1; } else if (SwinGame.KeyReleased(KeyCode.DownKey)) { j += 1; } else if (SwinGame.KeyReleased(KeyCode.LeftKey)) { i -= 1; } else if (SwinGame.KeyReleased(KeyCode.UpKey)) { j -= 1; } try { if (_world.Map[i, j].Type == TileType.Rock && i != 0 && j != 0 && i != 52 && j != 36) { _world.Map[i, j].Type = TileType.Air; if (_world.Map[i, j].Mineral != null) { _player2.Inventory.AddItem(_world.Map[i, j].Mineral); } } } catch (Exception e) { // IA - in case of an exception, force the reassignment of x and y using the player's location. i = _player2.Location.X; j = _player2.Location.Y; } } //build rock right if (SwinGame.KeyDown(KeyCode.RightKey) && SwinGame.KeyDown(KeyCode.LKey)) { //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y)); GetEnvironment(); int x = (_player2.Location.X + 1); int y = (_player2.Location.Y); Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y)); if (f == null) { Tile tile = _world.Map[x, y]; if (tile.Type == TileType.Air) { _world.Map[x, y] = new Tile(TileType.Rock); } } } //build rock left if (SwinGame.KeyDown(KeyCode.LeftKey) && SwinGame.KeyDown(KeyCode.LKey)) { //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y)); GetEnvironment(); int x = (_player2.Location.X - 1); int y = (_player2.Location.Y); Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y)); if (f == null) { Tile tile = _world.Map[x, y]; if (tile.Type == TileType.Air) { _world.Map[x, y] = new Tile(TileType.Rock); } } } //build rock up if (SwinGame.KeyDown(KeyCode.UpKey) && SwinGame.KeyDown(KeyCode.LKey)) { //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y)); GetEnvironment(); int x = (_player2.Location.X); int y = (_player2.Location.Y - 1); Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y)); if (f == null) { Tile tile = _world.Map[x, y]; if (tile.Type == TileType.Air) { _world.Map[x, y] = new Tile(TileType.Rock); } } } //build rock down if (SwinGame.KeyDown(KeyCode.DownKey) && SwinGame.KeyDown(KeyCode.LKey)) { //GetEnvironment ().HandleGuiEvent (GuiEvent.MouseRight, new Location (_player.Location.X+1, _player.Location.Y)); GetEnvironment(); int x = (_player2.Location.X); int y = (_player2.Location.Y + 1); Frame f = GuiEnvironment.GetRenderer().GetActiveFrame(new Location(x, y)); if (f == null) { Tile tile = _world.Map[x, y]; if (tile.Type == TileType.Air) { _world.Map[x, y] = new Tile(TileType.Rock); } } } } if (SwinGame.KeyDown(KeyCode.EscapeKey)) { Environment.Exit(0); } //PLAYER 1 KEY MOVEMENT/WEAPON INPUT //changes player input using keyboard - jeremy //Allowed player to attack, //else if if used so that the player can spam attack and move at the same time - Jonathan // buy weapon if (SwinGame.KeyDown(KeyCode.VKey) && SwinGame.KeyDown(KeyCode.WKey)) { if (_player.Weapon != null && _player.Weapon.Ammunition > 0) { _player.DeployWeapon(AttackDirection.Up); Objects.Add(_player.Weapon.Projectile); } } else if (SwinGame.KeyDown(KeyCode.WKey) && _world.Map[_player.Location.X, _player.Location.Y - 1].Type != TileType.Rock && _player.Location.Y - 1 != 0) { _player.Location.Y -= 1; } if (SwinGame.KeyDown(KeyCode.VKey) && SwinGame.KeyDown(KeyCode.SKey)) { if (_player.Weapon != null && _player.Weapon.Ammunition > 0) { _player.DeployWeapon(AttackDirection.Down); Objects.Add(_player.Weapon.Projectile); } } else if (SwinGame.KeyDown(KeyCode.SKey) && _world.Map[_player.Location.X, _player.Location.Y + 1].Type != TileType.Rock && _player.Location.Y + 1 != 36) { _player.Location.Y += 1; } if (SwinGame.KeyDown(KeyCode.VKey) && SwinGame.KeyDown(KeyCode.AKey)) { if (_player.Weapon != null && _player.Weapon.Ammunition > 0) { _player.DeployWeapon(AttackDirection.Left); Objects.Add(_player.Weapon.Projectile); } } else if (SwinGame.KeyDown(KeyCode.AKey) && _world.Map[_player.Location.X - 1, _player.Location.Y].Type != TileType.Rock && _player.Location.X - 1 != 0) { _player.Location.X -= 1; } if (SwinGame.KeyDown(KeyCode.VKey) && SwinGame.KeyDown(KeyCode.DKey)) { if (_player.Weapon != null && _player.Weapon.Ammunition > 0) { _player.DeployWeapon(AttackDirection.Right); Objects.Add(_player.Weapon.Projectile); } } else if (SwinGame.KeyDown(KeyCode.DKey) && _world.Map[_player.Location.X + 1, _player.Location.Y].Type != TileType.Rock && _player.Location.X + 1 != 52) { _player.Location.X += 1; } if (SwinGame.KeyTyped(KeyCode.BKey) && !SwinGame.KeyDown(KeyCode.LeftShiftKey)) { if (GetPlayer().Inventory.GetMineralPoints() >= 20) { if (_player.Weapon == null) { _player.BuyWeapon(_player.Location, WeaponType.Normal); } if (_player.Weapon.Type == WeaponType.Super) { _player.BuyWeapon(_player.Location, WeaponType.Normal); } _player.Weapon.Ammunition += 30; // Objects.Add(_player.Weapon); _player.Inventory.DeductMineralPoints(WeaponType.Normal); } } if (SwinGame.KeyTyped(KeyCode.BKey) && SwinGame.KeyDown(KeyCode.LeftShiftKey)) { if (GetPlayer().Inventory.GetMineralPoints() >= 30) { if (_player.Weapon == null) { _player.BuyWeapon(_player.Location, WeaponType.Super); } if (_player.Weapon.Type == WeaponType.Normal) { _player.BuyWeapon(_player.Location, WeaponType.Super); } _player.Weapon.Ammunition += 30; // Objects.Add(_player.Weapon); _player.Inventory.DeductMineralPoints(WeaponType.Super); } } if (_twoplayer == true) { //PLAYER 2 MOVEMENT/WEAPON KEY INPUT if (SwinGame.KeyDown(KeyCode.OKey) && SwinGame.KeyDown(KeyCode.UpKey)) { if (_player2.Weapon != null && _player2.Weapon.Ammunition > 0) { _player2.DeployWeapon(AttackDirection.Up); Objects.Add(_player2.Weapon.Projectile); } } else if (SwinGame.KeyDown(KeyCode.UpKey) && _world.Map[_player2.Location.X, _player2.Location.Y - 1].Type != TileType.Rock && _player2.Location.Y - 1 != 0) { _player2.Location.Y -= 1; } if (SwinGame.KeyDown(KeyCode.OKey) && SwinGame.KeyDown(KeyCode.DownKey)) { if (_player2.Weapon != null && _player2.Weapon.Ammunition > 0) { _player2.DeployWeapon(AttackDirection.Down); Objects.Add(_player2.Weapon.Projectile); } } else if (SwinGame.KeyDown(KeyCode.DownKey) && _world.Map[_player2.Location.X, _player2.Location.Y + 1].Type != TileType.Rock && _player2.Location.Y + 1 != 36) { _player2.Location.Y += 1; } if (SwinGame.KeyDown(KeyCode.OKey) && SwinGame.KeyDown(KeyCode.LeftKey)) { if (_player2.Weapon != null && _player2.Weapon.Ammunition > 0) { _player2.DeployWeapon(AttackDirection.Left); Objects.Add(_player2.Weapon.Projectile); } } else if (SwinGame.KeyDown(KeyCode.LeftKey) && _world.Map[_player2.Location.X - 1, _player2.Location.Y].Type != TileType.Rock && _player2.Location.X - 1 != 0) { _player2.Location.X -= 1; } if (SwinGame.KeyDown(KeyCode.OKey) && SwinGame.KeyDown(KeyCode.RightKey)) { if (_player2.Weapon != null && _player2.Weapon.Ammunition > 0) { _player2.DeployWeapon(AttackDirection.Right); Objects.Add(_player2.Weapon.Projectile); } } else if (SwinGame.KeyDown(KeyCode.RightKey) && _world.Map[_player2.Location.X + 1, _player2.Location.Y].Type != TileType.Rock && _player2.Location.X + 1 != 52) { _player2.Location.X += 1; } // Player 2 buys a weapon if (SwinGame.KeyTyped(KeyCode.PKey) && !SwinGame.KeyDown(KeyCode.JKey)) { if (_player2.Inventory.GetMineralPoints() >= 20) { if (_player2.Weapon == null) { _player2.BuyWeapon(_player.Location, WeaponType.Normal); } if (_player2.Weapon.Type == WeaponType.Super) { _player2.BuyWeapon(_player.Location, WeaponType.Normal); } _player2.Weapon.Ammunition += 20; // Objects.Add(_player.Weapon); _player2.Inventory.DeductMineralPoints(WeaponType.Normal); } } if (SwinGame.KeyTyped(KeyCode.PKey) && SwinGame.KeyDown(KeyCode.JKey)) { if (_player2.Inventory.GetMineralPoints() >= 30) { if (_player2.Weapon == null) { _player2.BuyWeapon(_player.Location, WeaponType.Super); } if (_player2.Weapon.Type == WeaponType.Normal) { _player2.BuyWeapon(_player.Location, WeaponType.Super); } _player2.Weapon.Ammunition += 40; // Objects.Add(_player.Weapon); _player2.Inventory.DeductMineralPoints(WeaponType.Super); } } } // Accept the spawning of minerals on demand - Useful for demonstration purposes only (to make it easier to collect mineral points, buy food, weapons, etc.) // if (SwinGame.KeyTyped(KeyCode.EKey)) // { // GetWorld().PutMinerals(); // } // IA - After computing everything, determine when/if the level should be increased. ControlLevels(); MetaHandler.DisplayFoodExchange(GetPlayer().Inventory); // IA - End the game when the player's energy level reaches 0. if (MetaHandler.GetEnergyLevel() == 0) { EndGame("you_died"); } }
public void EndGame(string status) { SwinGame.PlayMusic(GameResources.GameMusic("main_menu_music")); bool proceed = false; // IA - Reset minerals, game levels, food purchased and energy levels. Food.SetBalance(0); Food.ResetFoodPurchased(); Food.ResetMineralValue(); Food.ResetEnergyValue(); MetaHandler.ResetEnergyLevels(); MetaHandler.SetFoodMessage("Hit Space to enter amount."); MetaHandler.ResetAmmunitionMessage1(); MetaHandler.ResetAmmunitionMessage2(); GameLevel.SetLevel(1); EnemiesToBeRemoved.Clear(); GetPlayer().DestroyWeapon(); // IA - Clear the input field from the Food Exchange Center if (Input.ReadingText()) { Input.EndReadingText(); } GetPlayer().Inventory.ClearInventory(); if (_twoplayer == true) { _player2.Inventory.ClearInventory(); _player2.DestroyWeapon(); } while (!proceed) { SwinGame.ClearScreen(Color.White); SwinGame.DrawBitmap(GameResources.GameImage(status), 0, 0); SwinGame.ProcessEvents(); if (SwinGame.MouseClicked(MouseButton.LeftButton)) { if (_twoplayer == true) { _player2.Location.X = 45; _player2.Location.Y = 30; } proceed = true; initdone = false; initdone2 = false; initPlayer2 = false; _twoplayer = false; firstGame = false; } SwinGame.RefreshScreen(60); } SwinGame.ClearScreen(Color.White); _gameStates.Push(GameState.ViewingMainMenu); ControlGameState(); }
public void ImpingAintEasy() { MetaHandler.DoChecks(); //#TODO rewrite MetaHandler with BehaviorSharp Behaviors.MainBehavior.Root.Tick(); }