public void CheckEquipReq() { // create a training dummy TrainingDummy Dummy = new TrainingDummy(100, 0, 0); // knight should be able to use double slash try { Guinevere.Skillbar.Skills[0].Use(Dummy); Assert.IsTrue(true, "Knight should use the skill successfully."); } catch (SkillReqsNotMetException) { Assert.IsFalse(true, "Knight should meet skill requirements."); } // replace the knight's sword with a book and 2H it (lol) Guinevere.Inventory.AddItem(ItemDAO.CreateNewEquipmentItem("History Tome")); Guinevere.Equipment.Equip("MainHand", "History Tome"); Guinevere.Equipment.Toggle2H(); // try to use double slash, should fail because the book doesn't have a "sword" tag try { Guinevere.Skillbar.Skills[0].Use(Dummy); Assert.IsFalse(true, "Book should not meet the skill's Sword requirement."); } catch (SkillReqsNotMetException) { Assert.IsTrue(true, "Book should not meet the skill's Sword requirement."); } }
protected static bool TrainFirstAction(GoToLotSituation parent, GoToLotSituation.MeetUp meetUp) { try { NRaas.StoryProgression.Main.Situations.IncStat("First Action: Martial Train"); TrainingDummy choice = null; InteractionInstance interaction = parent.mSimB.InteractionQueue.GetCurrentInteraction(); if ((interaction != null) && (interaction.Target is TrainingDummy)) { choice = interaction.Target as TrainingDummy; meetUp.ForceSituationSpecificInteraction(choice, parent.mSimA, MartialArtsTrain.TrainSingleton, null, meetUp.OnSocialSucceeded, meetUp.OnSocialFailed, new InteractionPriority(InteractionPriorityLevel.UserDirected)); } else { List <TrainingDummy> choices = new List <TrainingDummy>(parent.mLot.GetObjects <TrainingDummy>(TestDummy)); if (choices.Count == 0) { return(false); } choice = RandomUtil.GetRandomObjectFromList(choices); meetUp.ForceSituationSpecificInteraction(choice, parent.mSimA, new MartialArtsTrain.Definition(parent.mSimB), null, meetUp.OnSocialSucceeded, meetUp.OnSocialFailed, new InteractionPriority(InteractionPriorityLevel.UserDirected)); } return(true); } catch (Exception e) { Common.Exception(parent.mSimA, parent.mSimB, e); return(false); } }
public void Check2HReq() { // create a training dummy TrainingDummy Dummy = new TrainingDummy(100, 0, 0); // knight should be able to use double slash try { Guinevere.Skillbar.Skills[0].Use(Dummy); Assert.IsTrue(true, "Knight should use the skill successfully."); } catch (SkillReqsNotMetException) { Assert.IsFalse(true, "Knight should meet skill requirements."); } // Toggle 2H off and try to use it again, should fail Guinevere.Equipment.Toggle2H(); try { Guinevere.Skillbar.Skills[0].Use(Dummy); Assert.IsFalse(true, "Knight should fail to use the skill successfully."); } catch (SkillReqsNotMetException) { Assert.IsTrue(true, "Knight should not meet the 2H requirements."); } }
public void UseAttackSkill() { // create a knight Character Guinevere = new Character("Guinevere", new Knight("F")); // attach the "double slash" skill directly to the character (not going through skillbar here) DoubleSlash knightSkill = new DoubleSlash(); knightSkill.SetUser(Guinevere); Assert.IsTrue(knightSkill.SkillTags.Contains("Attack"), "Double Slash should be an Attack skill"); // make a training dummy TrainingDummy dummy = new TrainingDummy(100, 10, 10); // knight uses skill to attack the dummy try { knightSkill.Use(dummy); Assert.IsTrue(true, "Attack skill should activate successfully."); } catch (Exception e) { Assert.IsFalse(true, e.Message); } }
public static Barracks GenerateBarracks(GenerationRandom genRan, Barracks barr, out BuildingVoxels vox, BuildingGenerationPlan plan) { vox = new BuildingVoxels(barr.Width, World.ChunkHeight, barr.Height); ChooseWallBounds(genRan, barr); BuildingGenerator.ConnectBoundingWall(vox, barr.BoundingWall, Voxel.stone); Tile[,] tileMap = new Tile[barr.Width, barr.Height]; BuildingGenerator.ChooseEntrancePoint(genRan, vox, barr, plan); BuildingGenerator.SetTiles(tileMap, 0, 0, barr.Width / 2, barr.Height - 1, Tile.STONE_FLOOR); BuildingGenerator.SetTiles(tileMap, barr.Width / 2, 0, barr.Width / 2 - 1, barr.Height - 1, Tile.DIRT); List <NPCJob> jobs = new List <NPCJob>(); for (int x = 2; x < barr.Height; x += 3) { Vector3 pos = new Vector3(barr.Width - 2, 0, x); float rotation = Vec2i.Angle(Vec2i.Forward, BuildingGenerator.GetWallPointDirection(barr, new Vec2i(barr.Width - 2, x))); TrainingDummy obj = new TrainingDummy().SetPosition(pos).SetRotation(rotation) as TrainingDummy; if (BuildingGenerator.AddObject(barr, vox, obj)) { jobs.Add(new NPCJobSoldier(barr)); } } WorkBuildingData wbd = new WorkBuildingData(jobs.ToArray()); barr.SetWorkBuildingData(wbd); barr.SetBuilding(tileMap); return(barr); }
//Todo : Weapon held public void HitDummy(int range) { IPooledEnumerable eable = m_Mobile.GetItemsInRange(range); foreach (Item item in eable) { if (item is TrainingDummy) { TrainingDummy dummy = (TrainingDummy)item; if (!dummy.Swinging) { if (MoveTo(item, false, 1)) { dummy.Use(m_Mobile, (BaseWeapon)m_Mobile.Weapon); // Repeat the animation m_Schedule.nextAct = DateTime.Now; break; } } } } eable.Free(); }
public void WithPosition(int x, int y) { ITileEntity sensor = new TrainingDummy(Vector.Zero, -1); sensor = sensor.WithPosition(new Vector(x, y)); Assert.That(sensor.Position, Is.EqualTo(new Vector(x, y))); }
public void WithPosition(int x, int y) { ITileEntity dummy = new TrainingDummy(Vector.Zero, -1); dummy = dummy.WithPosition(new Vector(x, y)); Assert.That(dummy.Position, Is.EqualTo(new Vector(x, y))); }
public static bool TestDummy(TrainingDummy dummy) { if (!dummy.InWorld) { return(false); } if (dummy.InUse) { return(false); } return(true); }
public override bool Test(Sim a, TrainingDummy target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (!base.Test(a, target, isAutonomous, ref greyedOutTooltipCallback)) { return false; } if (a.SkillManager.GetSkillLevel(SkillNames.MartialArts) >= 7) { return false; } return (SkillBasedCareerBooter.GetSkillBasedCareer(a, SkillNames.MartialArts) != null); }
protected override void Initialize() { base.Initialize(); map = new TileMap(this); camera = new Camera(GraphicsDevice.Viewport); camera.SetPosition(new Vector2(160, 160)); player = new Player(this); trainingDummy = new TrainingDummy(this, new Vector2(128, 64)); devConsole = new DevConsole(this); tempCrateRect = new Rectangle(64, 64, 32, 32); torchRect = new Rectangle(64, 32, 32, 32); tempChest = new Chest(this); }
public override bool Test(Sim a, TrainingDummy target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (!base.Test(a, target, isAutonomous, ref greyedOutTooltipCallback)) { return(false); } if (a.SkillManager.GetSkillLevel(SkillNames.MartialArts) >= 7) { return(false); } return(SkillBasedCareerBooter.GetSkillBasedCareer(a, SkillNames.MartialArts) != null); }
public void AttackSkillDamage() { // create a knight Character Guinevere = new Character("Guinevere", new Knight("F")); // attach the "double slash" skill directly to the character (not going through skillbar here) DoubleSlash knightSkill = new DoubleSlash(Guinevere); // make a training dummy TrainingDummy dummy = new TrainingDummy(100, 10, 10); // attack the dummy knightSkill.Use(dummy); // dummy HP should be lower Assert.IsTrue(dummy.HP.Current < dummy.HP.Max, "Dummy should have lost health."); }
public void LoadScene() { //==========MAP========== string text = File.ReadAllText("map.txt"); string[] split = text.Split('#'); int mapW = Convert.ToInt32(split[0].Split(',')[0]); int mapH = Convert.ToInt32(split[0].Split(',')[0]); int[] tileMap = new int[mapW * mapH]; int[] collisionMap = new int[mapW * mapH]; int[] depthMap = new int[mapW * mapH]; string[] tileMapTest = split[1].Split(','); tileMap = Array.ConvertAll(split[1].Split(','), int.Parse); collisionMap = Array.ConvertAll(split[2].Split(','), int.Parse); depthMap = Array.ConvertAll(split[3].Split(','), int.Parse); MapData mapData = new MapData() { Dimensions = new Vector2(mapW, mapH), TileMap = tileMap, CollisionMap = collisionMap, DepthMap = depthMap }; map = new Map(game, game.textureHandler.dungeonTileMapTexture, mapData); //========ENTITY======== int[] entityMap = Array.ConvertAll(split[4].Split(','), int.Parse); int idCounter = 2; for (int i = 0; i < entityMap.Length; i++) { if (entityMap[i] != 0) { int xPos = (i % mapW) * game.TileSize; int yPos = (i / mapW) * game.TileSize; switch (entityMap[i]) { case 1: player = new Player(this, new Vector2(xPos, yPos)); LiveEntities.Add(player); break; case 2: Torch torch = new Torch(this, new Vector2(xPos, yPos), idCounter); LiveEntities.Add(torch); idCounter++; break; case 3: TrainingDummy dummy = new TrainingDummy(this, new Vector2(xPos, yPos), idCounter); LiveEntities.Add(dummy); idCounter++; break; case 4: Chest chest = new Chest(this, new Vector2(xPos, yPos), idCounter); LiveEntities.Add(chest); idCounter++; break; } } } }
public void GetNpcIndex(int index) { var dummy = new TrainingDummy(Vector.Zero, index); Assert.That(dummy.NpcIndex, Is.EqualTo(index)); }
public override string GetInteractionName(Sim actor, TrainingDummy target, InteractionObjectPair iop) { return base.GetInteractionName(actor, target, new InteractionObjectPair(TrainingDummy.Train.Singleton, target)); }
static void Main(string[] args) { string buffer; string greeting; if (DateTime.Now.Hour < 12) { greeting = "Morning"; } else if (DateTime.Now.Hour < 5) { greeting = "Afternoon"; } else { greeting = "Evening"; } //Get Username Console.Write($"Good {greeting} adventurer! What is your name: "); string username = Console.ReadLine(); Player user = new Classes.Player(username); Console.Clear(); //Get Difficulty Level Console.WriteLine($"AH! Yes {user.name} glad to see you as always. Or is this our first meeting? . . ."); Console.WriteLine($"\t. . . no matter. As usual I will give you 10 gold and you will embark on an epic quest.\n"); Console.WriteLine($"What level of difficulty are you looking for this time?"); int selection; string[] difficulties = new string[] { "Easy", "Normal", "Hard", "Nightmare" }; for (int i = 0; i < 4; i++) { Console.WriteLine($"{(i + 1)}\t{difficulties[i]}"); } //Selection error catching while (true) { Console.Write("Selection: "); buffer = Console.ReadLine(); try { selection = Int32.Parse(buffer); } catch { buffer = string.Empty; selection = -1; } if (selection > 0 && selection < 5) { selection--; Console.WriteLine($"Ah, going with a(n) {difficulties[selection]} adventure. Good choice!"); break; } Console.WriteLine("\n\tInvalid Selection"); } Console.Clear(); Console.WriteLine($"Before you go {user.name}, make sure to get some gear.\n"); bool onward = true; while (onward) { Shop introShop = new Shop(user.level); introShop.Use(ref user); //Combat Tutorial Console.WriteLine("\nWould you like to train in combat against the dummy first?"); buffer = Console.ReadLine().ToLower(); if (buffer.Contains('y')) { Combat combat = new Combat(); TrainingDummy dummy = new TrainingDummy(); combat.Fight(ref user, dummy); } else { Console.WriteLine("I get it. Eager to start."); } //game loop while (user.health >= 1) { Difficulty difficulty = new Difficulty(0); //Load Difficulty possibly add difficulty change later also to allow biome change switch (difficulties[selection]) { case ("Easy"): { difficulty = new Difficulty(0); break; } case ("Normal"): { difficulty = new Difficulty(1); break; } case ("Hard"): { difficulty = new Difficulty(2); break; } case ("Nightmare"): { difficulty = new Difficulty(3); break; } default: break; } //Questing difficulty.Display(ref user); //Shop if (user.health > 0) { Shop shop = new Shop(user.level); shop.Use(ref user); } } Console.WriteLine("You have died your quest has ended."); Console.Write("Retry?(y/n): "); if (Console.ReadLine() == "n") { onward = false; } else { user = new Player(username); } } }
public override string GetInteractionName(Sim actor, TrainingDummy target, InteractionObjectPair iop) { return(base.GetInteractionName(actor, target, new InteractionObjectPair(TrainingDummy.Train.Singleton, target))); }
public void WriteRead() { var tiles = new Tile?[10, 10]; Main.tileFrameImportant[1] = true; var tile = new Tile { IsActive = true, BlockColor = 1, WallColor = 1, BlockId = 1, WallId = 1, Liquid = 255 }; for (var x = 0; x < 10; ++x) { for (var y = 0; y < 10; ++y) { tiles[x, y] = tile; } } var clipboard = new Clipboard(tiles); var items = new Item[40]; items[0] = new Item(1, 2, 3); var chest = new Chest(new Vector(0, 1), "Test", new Item[40]); var itemFrame = new ItemFrame(new Vector(3, 4), new Item(1, 2, 3)); var logicSensor = new LogicSensor(new Vector(2, 5), LogicSensorType.Day, true, 5); var sign = new Sign(new Vector(1, 0), "Test2"); var trainingDummy = new TrainingDummy(new Vector(4, 5), 21); clipboard.AddTileEntity(chest); clipboard.AddTileEntity(itemFrame); clipboard.AddTileEntity(logicSensor); clipboard.AddTileEntity(sign); clipboard.AddTileEntity(trainingDummy); var schematicFormat = new DefaultSchematicFormat(); Clipboard clipboard2; using (var stream = new MemoryStream()) { schematicFormat.Write(clipboard, stream); stream.Position = 0; clipboard2 = schematicFormat.Read(stream); Assert.That(clipboard2, Is.Not.Null); } for (var x = 0; x < 10; ++x) { for (var y = 0; y < 10; ++y) { Assert.That(clipboard2.GetTile(new Vector(x, y)), Is.EqualTo(tile)); } } foreach (var entity in clipboard2.GetTileEntities()) { if (entity is Chest chest2) { Assert.That(chest2.Position, Is.EqualTo(chest.Position)); Assert.That(chest2.Name, Is.EqualTo(chest.Name)); Assert.That(chest2.Items, Is.EquivalentTo(chest2.Items)); } else if (entity is ItemFrame itemFrame2) { Assert.That(itemFrame2.Position, Is.EqualTo(itemFrame.Position)); Assert.That(itemFrame2.Item, Is.EqualTo(itemFrame.Item)); } else if (entity is LogicSensor logicSensor2) { Assert.That(logicSensor2.Position, Is.EqualTo(logicSensor.Position)); Assert.That(logicSensor2.Type, Is.EqualTo(logicSensor.Type)); Assert.That(logicSensor2.IsEnabled, Is.EqualTo(logicSensor.IsEnabled)); Assert.That(logicSensor2.Data, Is.EqualTo(logicSensor.Data)); } else if (entity is Sign sign2) { Assert.That(sign2.Position, Is.EqualTo(sign.Position)); Assert.That(sign2.Text, Is.EqualTo(sign.Text)); } else if (entity is TrainingDummy trainingDummy2) { Assert.That(trainingDummy2.Position, Is.EqualTo(trainingDummy.Position)); Assert.That(trainingDummy2.NpcIndex, Is.EqualTo(trainingDummy.NpcIndex)); } } }
public void GetPosition(int x, int y) { var dummy = new TrainingDummy(new Vector(x, y), -1); Assert.That(dummy.Position, Is.EqualTo(new Vector(x, y))); }
public override bool Test(Sim a, TrainingDummy target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { return(true); }
public static void OnLeveled(Event e) { HasGuidEvent <SkillNames> skillEvent = e as HasGuidEvent <SkillNames>; if (skillEvent == null) { return; } if (skillEvent.Guid != SkillNames.MartialArts) { return; } Sim actor = e.Actor as Sim; if (actor == null) { return; } if (actor.InteractionQueue == null) { return; } InteractionInstance interaction = actor.InteractionQueue.GetCurrentInteraction(); if (interaction == null) { return; } TrainingDummy gameobj = interaction.Target as TrainingDummy; if (gameobj == null) { return; } Sim trainer = gameobj.OtherActor(actor); if (trainer == null) { return; } if (trainer.Household == actor.Household) { return; } float cash = GetPay(trainer); if (cash == 0) { return; } cash *= 2; Common.Notify("Bonus: " + cash); AddAccrued(actor, trainer, cash); }