/// <summary> /// Initializes a monster without a state but with health, inventory, location, armor, weapons, and location /// </summary> /// <param name="health"></param> /// <param name="inventory"></param> /// <param name="location"></param> /// <param name="armor"></param> /// <param name="weapon"></param> /// <param name="name"></param> /// <param name="description"></param> public Monster(int health, List <AbstractItem> inventory, Room location, AbstractArmor armor, AbstractWeapon weapon, string name, string description) : base(health, inventory, armor, weapon) { Location = location; Behavior = NpcBehavior.WARY; Description = description; Name = name; }
public void Initialize(ref AbstractArmor armor, AbstractArmor.ArmorType type) { SelectedArmor = armor; ArmorType = type; filter = true; base.Init(); }
/// <summary> /// Swaps current armor with new one and returns the old one. If the current armor is null, /// null is returned. /// /// Use this method when picking up new armor. /// </summary> /// <param name="newArmor">New armor.</param> /// <returns>Old armor or null if no armor was equipped.</returns> public AbstractArmor SwapArmor(AbstractArmor newArmor) { AbstractArmor oldArmor = Armor; Armor = newArmor; return(oldArmor); }
private Attribute CheckArmor(AbstractArmor armorPiece) { if (armorPiece == null) { return(new Attribute()); } return(armorPiece.Stats); }
/// <summary> /// Inserta una armadura en el inventorio /// </summary> /// <param name="a">Armadura a insertar</param> public void InsertArmor(AbstractArmor a) { if (Armors.ContainsKey(a.ItemName)) { Armors[a.ItemName].Second++; } else { Armors[a.ItemName] = new Tuple <AbstractArmor, int>(a, 1); } }
public override bool Equals(AbstractArmor other) { if (this.Name.Equals(other.Name) && other.GetType() == this.GetType()) { return true; } else { return false; } }
} // Set to true when the player consumes an agility potion public AbstractCreature(int health, List <AbstractItem> inventory, AbstractArmor armor, AbstractWeapon weapon) { Id = String.Format("CR{0}", creaturesCreated++); Health = health; MaxHealth = health; Inventory = inventory; Weapon = weapon; Armor = armor; Inventory.Add(Weapon); Inventory.Add(Armor); }
public AbstractActor() { RemoveStates = new Dictionary <string, Dictionary <string, AbstractState> >(); Stats = new Attribute(); MainHand = new AbstractWeapon(); Helmet = new AbstractArmor(); Body = new AbstractArmor(); Feet = new AbstractArmor(); Ring = new AbstractArmor(); Necklace = new AbstractArmor(); Job = new AbstractJob(); AbstractAbility aux = new AbstractAbility(); }
private void AddArmor(string name, ref AbstractArmor current, AbstractArmor.ArmorType armortype) { GUILayout.Label(name, EditorStyles.boldLabel); GUILayout.BeginHorizontal(); GUILayout.TextField(current.ItemName); if (GUILayout.Button("Select Armor")) { var window = EditorWindow.GetWindow <ArmorUI>(); window.Selected = true; window.Initialize(ref current, armortype); window.Show(); } GUILayout.EndHorizontal(); }
/// <summary> /// Retorna una lista de armor dado un tipo /// </summary> /// <param name="type"> Tipo de armor</param> /// <returns>lista de armors</returns> public List <Tuple <AbstractArmor, int> > TypeArmor(AbstractArmor.ArmorType type) { List <Tuple <AbstractArmor, int> > returnList = new List <Tuple <AbstractArmor, int> >(); foreach (string key in Armors.Keys) { AbstractArmor i = Armors[key].First; int cant = Armors[key].Second; if (i.Type == type) { returnList.Add(new Tuple <AbstractArmor, int>(i, cant)); } } return(returnList); }
public override void Execute() { if (!(Actor is AbstractPlayer)) { return; } AbstractPlayer player = (AbstractPlayer)Actor; MapBlock currentBlock = player.Position; if (currentBlock == null || currentBlock.Item == null) { throw new NoItemToPickUpException(player); } else if (currentBlock.Item is AbstractInventoryItem) { // normal item, just pick it up if (player.IsInventoryFull()) { throw new InventoryIsFullException(player); } player.AddItemToInventory((AbstractInventoryItem)(currentBlock.PickUpItem())); } else if (currentBlock.Item is AbstractWeapon) { // weapon AbstractWeapon oldWeapon = player.SwapWeapon((AbstractWeapon)(currentBlock.PickUpItem())); currentBlock.Item = oldWeapon; } else if (currentBlock.Item is AbstractArmor) { // armor AbstractArmor oldArmor = player.SwapArmor((AbstractArmor)(currentBlock.PickUpItem())); currentBlock.Item = oldArmor; } else { throw new PickUpUnknownItemException(player, currentBlock.Item); } }
} // modiferDict -> key: MemberName as string. Value: int modifier public Character(string name, string race, int str, int dex, int con, int intelligence, int wis, int cha, AbstractClass charClass, AbstractWeapon weapon, AbstractArmor armor, bool shield, int team, int level = 1) { Name = name; Race = race; Str = new Strength(str); Dex = new Dexterity(dex); Con = new Constitution(con); Int = new Intelligence(intelligence); Wis = new Wisdom(wis); Cha = new Charisma(cha); Class = new Fighter(level); EquippedArmor = armor; EquippedWeapon = weapon; ShieldEquipped = shield; CalculateHitPoints(); CalculateAC(); CalculateAttackBonus(); Team = team; }
public Armor() { Data = new AbstractArmor(); }
/// <summary> /// Renders armor as a path. /// <param name="armor">Armor to be rendered.</param> /// <param name="x">Top left corner x-coordinate of map block.</param> /// <param name="y">Top left corner y-coordinate of map block.</param> /// <param name="blockSize">Height and width of the block.</param> /// <returns>Armor rendered as path.</returns> private Path RenderArmor(AbstractArmor armor, double x, double y, double blockSize) { return(RenderPath(configuration.ArmorPath, x, y, blockSize / 3, Color.FromRgb(0, 0, 0), null)); }
void OnCollisionStay2D(Collision2D coll) { Pickup pickup = coll.gameObject.GetComponent <Pickup>(); if (pickup != null) { if (ProxyInput.GetInstance().A()) { if (pickup.Sound != null) { Audio audio = new Audio(pickup.name); audio.CreateAudioSource(pickup.Sound); audio.Source.Play(); Destroy(audio.gameobject, pickup.Sound.length + 0.5f); } if (pickup.ItemArmor.ItemName != "") { AbstractArmor armor = new AbstractArmor(); armor = pickup.ItemArmor; this.Items.InsertArmor(armor); } if (pickup.ItemWeapon.ItemName != "") { this.Items.InsertWeapon(pickup.ItemWeapon); } if (pickup.ItemUsable.ItemName != "") { this.Items.InsertUsable(pickup.ItemUsable); } Destroy(coll.gameObject); } } var obstacle = coll.gameObject.GetComponent <Obstacle>(); if (obstacle != null) { if (ProxyInput.GetInstance().A()) { if (obstacle.Sound != null) { Audio audio = new Audio(name); audio.CreateAudioSource(obstacle.Sound); audio.Source.Play(); Destroy(audio.gameobject, obstacle.Sound.length + 0.5f); } if (obstacle.Type == Constant.ObstacleType.Switchable) { obstacle.Switched = !obstacle.Switched; } else if (obstacle.Type == Constant.ObstacleType.Destroyable) { obstacle.hp -= Data.TotalDamage(); if (obstacle.hp <= 0) { Destroy(obstacle.gameObject); } } } } }
public Pickup() { ItemUsable = new AbstractUsable(); ItemArmor = new AbstractArmor(); ItemWeapon = new AbstractWeapon(); }
public void TestSerializeMaze() { int w = 4; int h = 4; Map map = MapGeneratorFactory.CreateSimpleMapGenerator().GenerateMap(w, h, IMapGeneratorConstants.NO_SEED); map.MapName = "Test map"; // add creatures to map Monster origMonster = new Monster("Test monster", map.Grid[0, 0], 4, 3654123, 87621235); map.AddCreature(origMonster); SimpleAIPlayer aiPlayer = new SimpleAIPlayer("Test player", map.Grid[3, 2]); map.AddCreature(aiPlayer); HumanPlayer hPlayer = new HumanPlayer("Příliš žluťoučký kůň úpěl ďábelské ódy", map.Grid[1, 3]) { BaseHitPoints = 98432156, BaseAttack = 112348, BaseDeffense = 41226987 }; map.AddCreature(hPlayer); // add items to map AbstractWeapon weapon = ItemFactory.CreateAxe(map.Grid[1, 3]); map.AddItem(weapon); AbstractArmor armor = ItemFactory.CreateLeatherArmor(map.Grid[1, 1]); map.AddItem(armor); AbstractInventoryItem item = new BasicItem("Příliš žluťoučký kůň úpěl ďábelské ódy.!?_/()':123456789<>&@{}[]", map.Grid[2, 2], 514) { UniqueId = 6284 }; map.AddItem(item); // serialize - deserialize IMapSerializer <byte[], byte[]> byteSerializer = new BinaryMapSerializer(); byte[] serializedMap = byteSerializer.Serialize(map); Map deserializedMap = byteSerializer.Deserialize(serializedMap); // check map Assert.AreEqual(map.MapName, deserializedMap.MapName, "Wrong map name!"); Assert.AreEqual(w, deserializedMap.Width, "Wrong width after deserialization!"); Assert.AreEqual(h, deserializedMap.Width, "Wrong height after deserialization!"); Assert.AreEqual(map.WinningBlock.X, deserializedMap.WinningBlock.X, "Wrong x coordinate of winning block!"); Assert.AreEqual(map.WinningBlock.Y, deserializedMap.WinningBlock.Y, "Wrong Y coordinate of winning block!"); // check map blocks for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { MapBlock origBlock = map.Grid[i, j]; MapBlock testedBlock = deserializedMap.Grid[i, j]; foreach (Direction dir in DirectionMethods.GetAllDirections()) { Assert.AreEqual(origBlock.EntranceInDirection(dir).IsOpen(), testedBlock.EntranceInDirection(dir).IsOpen(), $"Wrong entrance in direction {dir} in block [{i},{j}]."); } } } // check creatures Monster m = (Monster)deserializedMap.Grid[0, 0].Creature; CheckCreature(origMonster, m); SimpleAIPlayer p = (SimpleAIPlayer)deserializedMap.Grid[3, 2].Creature; CheckCreature(aiPlayer, p); HumanPlayer hp = (HumanPlayer)deserializedMap.Grid[1, 3].Creature; CheckCreature(hPlayer, hp); // check items AbstractWeapon weap = (AbstractWeapon)map.Grid[1, 3].Item; CheckItem(weap, weapon); AbstractArmor arm = (AbstractArmor)map.Grid[1, 1].Item; CheckItem(arm, armor); AbstractInventoryItem itm = (AbstractInventoryItem)map.Grid[2, 2].Item; CheckItem(item, itm); }
public Player(int health, List <AbstractItem> inventory, AbstractArmor armor, AbstractWeapon weapon) : base( health, inventory, armor, weapon) { }