[Rpgworldmodel-commits] SF.net SVN: rpgworldmodel: [14] src/RPGWorldModel.Abstracts
Status: Inactive
Brought to you by:
deadwood_pl
From: <dea...@us...> - 2006-07-12 17:52:39
|
Revision: 14 Author: deadwood_pl Date: 2006-07-12 10:52:16 -0700 (Wed, 12 Jul 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=14&view=rev Log Message: ----------- More work on equipment. Still far from being acceptable at this stage. Modified Paths: -------------- src/RPGWorldModel.Abstracts/AnimatedEntity.cs src/RPGWorldModel.Abstracts/Humanoid.cs src/RPGWorldModel.Abstracts/IEquip.cs src/RPGWorldModel.Abstracts/IEquipable.cs src/RPGWorldModel.Abstracts/Item.cs src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj src/RPGWorldModel.Abstracts/Sword.cs src/test_applications/tester/Form1.Designer.cs src/test_applications/tester/Form1.cs Added Paths: ----------- src/RPGWorldModel.Abstracts/EquipmentLocation.cs src/RPGWorldModel.Abstracts/EquipmentSlot.cs Modified: src/RPGWorldModel.Abstracts/AnimatedEntity.cs =================================================================== --- src/RPGWorldModel.Abstracts/AnimatedEntity.cs 2006-07-09 14:48:10 UTC (rev 13) +++ src/RPGWorldModel.Abstracts/AnimatedEntity.cs 2006-07-12 17:52:16 UTC (rev 14) @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Equipment; namespace RPGWorldModel.Abstracts.Entities { Added: src/RPGWorldModel.Abstracts/EquipmentLocation.cs =================================================================== --- src/RPGWorldModel.Abstracts/EquipmentLocation.cs (rev 0) +++ src/RPGWorldModel.Abstracts/EquipmentLocation.cs 2006-07-12 17:52:16 UTC (rev 14) @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; + +namespace RPGWorldModel.Abstracts.Support.Equipment +{ + /// <summary> + /// Base for equipment location types + /// </summary> + public abstract class EquipmentLocation + { + } + + public class EquipmentLocationList : List<EquipmentLocation> + { + } + + public class EquipmentLocationDescriptor + { + protected EquipmentLocationList equipmentLocationList = new EquipmentLocationList(); + + public IEnumerable<EquipmentLocation> EquipmentLocations + { + get { return equipmentLocationList; } + } + + public int EquipmentLocationsCount + { + get { return equipmentLocationList.Count; } + } + + + + public void AddEquipmentLocation(EquipmentLocation location) + { + foreach (EquipmentLocation containedLocation in equipmentLocationList) + { + if (containedLocation.GetType() == location.GetType()) + return; + } + + equipmentLocationList.Add(location); + } + } + + public class EquipmentLocationDescriptorList : List<EquipmentLocationDescriptor> + { + } + + public class EquipmentLocationLeftHand : EquipmentLocation + { + } + + public class EquipmentLocationRightHand : EquipmentLocation + { + } + + public class EquipmentLocationBack : EquipmentLocation + { + } + + public class EquipmentLocationWaist : EquipmentLocation + { + } +} Added: src/RPGWorldModel.Abstracts/EquipmentSlot.cs =================================================================== --- src/RPGWorldModel.Abstracts/EquipmentSlot.cs (rev 0) +++ src/RPGWorldModel.Abstracts/EquipmentSlot.cs 2006-07-12 17:52:16 UTC (rev 14) @@ -0,0 +1,185 @@ +using System; +using System.Collections.Generic; +using RPGWorldModel.Abstracts.Interfaces; + +namespace RPGWorldModel.Abstracts.Support.Equipment +{ + public abstract class EquipmentSlot + { + protected EquipableList equippedEntities = new EquipableList(); + public IEnumerable<IEquipable> EquippedEntities + { + get { return equippedEntities; } + } + + //TEST + protected EquipmentLocationList acceptableEquipmentLocations = new EquipmentLocationList(); + + public bool IsLocationAcceptable(EquipmentLocation location) + { + foreach (EquipmentLocation acceptableLocation in acceptableEquipmentLocations) + { + if (acceptableLocation.GetType() == location.GetType()) + return true; + } + + return false; + } + // + + public void AddEquipable(IEquipable equipable) + { + equippedEntities.Add(equipable); + } + + public void RemoveEquipable(IEquipable equipable) + { + equippedEntities.Remove(equipable); + } + + public abstract string SlotName + { + get; + } + } + + public class EquipmentSlotList : List<EquipmentSlot> + { + } + + public class EquipmentSlotHead : EquipmentSlot + { + public EquipmentSlotHead() + { + } + + public override string SlotName + { + get { return "Head"; } + } + } + + public class EquipmentSlotFace : EquipmentSlot + { + public override string SlotName + { + get { return "Face"; } + } + } + + public class EquipmentSlotNeck : EquipmentSlot + { + public override string SlotName + { + get { return "Neck"; } + } + } + + public class EquipmentSlotTorso : EquipmentSlot + { + public override string SlotName + { + get { return "Torso"; } + } + } + + public class EquipmentSlotWaist : EquipmentSlot + { + public EquipmentSlotWaist() + { + acceptableEquipmentLocations.Add(new EquipmentLocationWaist()); + } + + public override string SlotName + { + get { return "Waist"; } + } + } + + public class EquipmentSlotBack : EquipmentSlot + { + public EquipmentSlotBack() + { + acceptableEquipmentLocations.Add(new EquipmentLocationBack()); + } + + public override string SlotName + { + get { return "Back"; } + } + } + + public class EquipmentSlotLeftArm : EquipmentSlot + { + public override string SlotName + { + get { return "Left Arm"; } + } + } + + public class EquipmentSlotRightArm : EquipmentSlot + { + public override string SlotName + { + get { return "Right Arm"; } + } + } + + public class EquipmentSlotLeftHand : EquipmentSlot + { + public EquipmentSlotLeftHand() + { + acceptableEquipmentLocations.Add(new EquipmentLocationLeftHand()); + } + + public override string SlotName + { + get { return "Left Hand"; } + } + } + + public class EquipmentSlotRightHand : EquipmentSlot + { + public EquipmentSlotRightHand() + { + acceptableEquipmentLocations.Add(new EquipmentLocationRightHand()); + } + + public override string SlotName + { + get { return "Right Hand"; } + } + } + + public class EquipmentSlotLeftLeg : EquipmentSlot + { + public override string SlotName + { + get { return "Left Leg"; } + } + } + + public class EquipmentSlotRightLeg : EquipmentSlot + { + public override string SlotName + { + get { return "Right Leg"; } + } + } + + public class EquipmentSlotLeftFoot : EquipmentSlot + { + public override string SlotName + { + get { return "Left Foot"; } + } + } + + public class EquipmentSlotRightFoot : EquipmentSlot + { + public override string SlotName + { + get { return "Right Foot"; } + } + } +} \ No newline at end of file Modified: src/RPGWorldModel.Abstracts/Humanoid.cs =================================================================== --- src/RPGWorldModel.Abstracts/Humanoid.cs 2006-07-09 14:48:10 UTC (rev 13) +++ src/RPGWorldModel.Abstracts/Humanoid.cs 2006-07-12 17:52:16 UTC (rev 14) @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Equipment; namespace RPGWorldModel.Abstracts.Entities.LiveEntities { @@ -44,13 +45,55 @@ public override EquipResponse Equip(EquipRequest request) { + EquipResponse response = new EquipResponse(); + response.Status = EquipStatus.NotEquippedNotAbleToEquip; + + // Basic equip implementation for humanoids + foreach (EquipmentSlot slot in AvailableEquipmentSlots) + { + // Checking is slot is part of entity + if (slot == request.RequestedSlot) + { + // Checking is slot can accept any of the equipe locations for equipable + + foreach (EquipmentLocationDescriptor locationDescriptor + in request.RequestedEquipable.EquipmentLocationDescriptors) + { + // TODO: multi-slot items support + if (locationDescriptor.EquipmentLocationsCount > 1) + { + break; + } + + if (locationDescriptor.EquipmentLocationsCount == 0) + { + break; //TODO : error + } + + if (locationDescriptor.EquipmentLocationsCount == 1) + { + foreach (EquipmentLocation location in locationDescriptor.EquipmentLocations) + if (slot.IsLocationAcceptable(location)) + { + slot.AddEquipable(request.RequestedEquipable); + response.Status = EquipStatus.Equipped; + break; + } + } + + if (response.Status == EquipStatus.Equipped) + break; + + } + + if (response.Status == EquipStatus.Equipped) + break; + + } + } + - // TEMP!!!!! - equipmentSlots[8].AddEquipable(request.RequestedEquipable); - - EquipResponse response = new EquipResponse(); - response.Status = EquipStatus.Equipped; return response; } Modified: src/RPGWorldModel.Abstracts/IEquip.cs =================================================================== --- src/RPGWorldModel.Abstracts/IEquip.cs 2006-07-09 14:48:10 UTC (rev 13) +++ src/RPGWorldModel.Abstracts/IEquip.cs 2006-07-12 17:52:16 UTC (rev 14) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using RPGWorldModel.Abstracts.Support.Equipment; namespace RPGWorldModel.Abstracts.Interfaces { @@ -26,156 +27,16 @@ get { return requestedEquipable; } set { requestedEquipable = value; } } - } - /* - * Basic equipment slots start - */ + private EquipmentSlot requestedSlot = null; - public abstract class EquipmentSlot - { - protected EquipableList equippedEntities = new EquipableList(); - public IEnumerable<IEquipable> EquippedEntities + public EquipmentSlot RequestedSlot { - get { return equippedEntities; } + get { return requestedSlot; } + set { requestedSlot = value; } } - - public void AddEquipable(IEquipable equipable) - { - equippedEntities.Add(equipable); - } - - public void RemoveEquipable(IEquipable equipable) - { - equippedEntities.Remove(equipable); - } - - public abstract string SlotName - { - get; - } } - public class EquipmentSlotList : List<EquipmentSlot> - { - } - - public class EquipmentSlotHead : EquipmentSlot - { - public override string SlotName - { - get { return "Head"; } - } - } - - public class EquipmentSlotFace : EquipmentSlot - { - public override string SlotName - { - get { return "Face"; } - } - } - - public class EquipmentSlotNeck : EquipmentSlot - { - public override string SlotName - { - get { return "Neck"; } - } - } - - public class EquipmentSlotTorso : EquipmentSlot - { - public override string SlotName - { - get { return "Torso"; } - } - } - - public class EquipmentSlotWaist : EquipmentSlot - { - public override string SlotName - { - get { return "Waist"; } - } - } - - public class EquipmentSlotBack : EquipmentSlot - { - public override string SlotName - { - get { return "Back"; } - } - } - - public class EquipmentSlotLeftArm : EquipmentSlot - { - public override string SlotName - { - get { return "Left Arm"; } - } - } - - public class EquipmentSlotRightArm : EquipmentSlot - { - public override string SlotName - { - get { return "Right Arm"; } - } - } - - public class EquipmentSlotLeftHand : EquipmentSlot - { - public override string SlotName - { - get { return "Left Hand"; } - } - } - - public class EquipmentSlotRightHand : EquipmentSlot - { - public override string SlotName - { - get { return "Right Hand"; } - } - } - - public class EquipmentSlotLeftLeg : EquipmentSlot - { - public override string SlotName - { - get { return "Left Leg"; } - } - } - - public class EquipmentSlotRightLeg : EquipmentSlot - { - public override string SlotName - { - get { return "Right Leg"; } - } - } - - public class EquipmentSlotLeftFoot : EquipmentSlot - { - public override string SlotName - { - get { return "Left Foot"; } - } - } - - public class EquipmentSlotRightFoot : EquipmentSlot - { - public override string SlotName - { - get { return "Right Foot"; } - } - } - - /* - * Basic equipment slots end - */ - /// <summary> /// A response to equip request /// </summary> Modified: src/RPGWorldModel.Abstracts/IEquipable.cs =================================================================== --- src/RPGWorldModel.Abstracts/IEquipable.cs 2006-07-09 14:48:10 UTC (rev 13) +++ src/RPGWorldModel.Abstracts/IEquipable.cs 2006-07-12 17:52:16 UTC (rev 14) @@ -1,69 +1,21 @@ using System; using System.Collections.Generic; using System.Text; +using RPGWorldModel.Abstracts.Support.Equipment; namespace RPGWorldModel.Abstracts.Interfaces { public interface IEquipable { - void InitializeEquipable(); - } - - public class EquipableList : List<IEquipable> - { - } - - - /* - * Equipment location - maps to equipement slot - */ - public abstract class EquipmentLocation - { - } - - public class EquipmentLocationList : List<EquipmentLocation> - { - } - - public class EquipmentLocationDescriptor - { - protected EquipmentLocationList equipmentLocationList = new EquipmentLocationList(); - - public IEnumerable<EquipmentLocation> EquipmentLocations + IEnumerable<EquipmentLocationDescriptor> EquipmentLocationDescriptors { - get { return equipmentLocationList; } + get; } - public void AddEquipmentLocation(EquipmentLocation location) - { - foreach (EquipmentLocation containedLocation in equipmentLocationList) - { - if (containedLocation.GetType() == location.GetType()) - return; - } - - equipmentLocationList.Add(location); - } + void InitializeEquipable(); } - public class EquipmentLocationDescriptorList : List<EquipmentLocationDescriptor> + public class EquipableList : List<IEquipable> { } - - public class EquipmentLocationLeftHand : EquipmentLocation - { - } - - public class EquipmentLocationRightHand : EquipmentLocation - { - } - - public class EquipmentLocationBack : EquipmentLocation - { - } - - public class EquipmentLocationWaist : EquipmentLocation - { - } - } Modified: src/RPGWorldModel.Abstracts/Item.cs =================================================================== --- src/RPGWorldModel.Abstracts/Item.cs 2006-07-09 14:48:10 UTC (rev 13) +++ src/RPGWorldModel.Abstracts/Item.cs 2006-07-12 17:52:16 UTC (rev 14) @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Equipment; namespace RPGWorldModel.Abstracts.Entities.Items { @@ -39,6 +40,11 @@ #region IEquipableMembers + public virtual IEnumerable<EquipmentLocationDescriptor> EquipmentLocationDescriptors + { + get { return equipmentLocationDescriptors; } + } + public abstract void InitializeEquipable(); #endregion Modified: src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj =================================================================== --- src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj 2006-07-09 14:48:10 UTC (rev 13) +++ src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj 2006-07-12 17:52:16 UTC (rev 14) @@ -36,6 +36,8 @@ <Compile Include="Animal.cs" /> <Compile Include="AnimatedEntity.cs" /> <Compile Include="Arachnid.cs" /> + <Compile Include="EquipmentLocation.cs" /> + <Compile Include="EquipmentSlot.cs" /> <Compile Include="GameEntity.cs" /> <Compile Include="Golbin.cs" /> <Compile Include="Human.cs" /> Modified: src/RPGWorldModel.Abstracts/Sword.cs =================================================================== --- src/RPGWorldModel.Abstracts/Sword.cs 2006-07-09 14:48:10 UTC (rev 13) +++ src/RPGWorldModel.Abstracts/Sword.cs 2006-07-12 17:52:16 UTC (rev 14) @@ -3,6 +3,7 @@ using System.Text; using RPGWorldModel.Abstracts.Interfaces; using RPGWorldModel.Abstracts.Entities.Items; +using RPGWorldModel.Abstracts.Support.Equipment; namespace RPGWorldModel.TopLevelImplementation.Entities.Items { Modified: src/test_applications/tester/Form1.Designer.cs =================================================================== --- src/test_applications/tester/Form1.Designer.cs 2006-07-09 14:48:10 UTC (rev 13) +++ src/test_applications/tester/Form1.Designer.cs 2006-07-12 17:52:16 UTC (rev 14) @@ -59,13 +59,13 @@ this.btnItemRapair = new System.Windows.Forms.Button(); this.btnItemDamage = new System.Windows.Forms.Button(); this.tabPage3 = new System.Windows.Forms.TabPage(); + this.label4 = new System.Windows.Forms.Label(); this.btnEquipaSelected = new System.Windows.Forms.Button(); this.lvAvailableItems = new System.Windows.Forms.ListView(); this.tvEquipmentSlots = new System.Windows.Forms.TreeView(); this.btnHumanCreate = new System.Windows.Forms.Button(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components); - this.label4 = new System.Windows.Forms.Label(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage2.SuspendLayout(); @@ -356,6 +356,16 @@ this.tabPage3.Text = "Equip"; this.tabPage3.UseVisualStyleBackColor = true; // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.label4.Location = new System.Drawing.Point(253, 318); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(395, 13); + this.label4.TabIndex = 5; + this.label4.Text = "Select slot(back,waist,left hand, right hand), select item, click Equip"; + // // btnEquipaSelected // this.btnEquipaSelected.Location = new System.Drawing.Point(319, 342); @@ -408,16 +418,6 @@ // this.errorProvider1.ContainerControl = this; // - // label4 - // - this.label4.AutoSize = true; - this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.label4.Location = new System.Drawing.Point(320, 280); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(243, 13); - this.label4.TabIndex = 5; - this.label4.Text = "Select Left Hand, select item, click Equip"; - // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); Modified: src/test_applications/tester/Form1.cs =================================================================== --- src/test_applications/tester/Form1.cs 2006-07-09 14:48:10 UTC (rev 13) +++ src/test_applications/tester/Form1.cs 2006-07-12 17:52:16 UTC (rev 14) @@ -10,6 +10,7 @@ using RPGWorldModel.Abstracts.Entities; using RPGWorldModel.Abstracts.Entities.Items; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Equipment; using RPGWorldModel.TopLevelImplementation.Entities.LiveEntities; using RPGWorldModel.TopLevelImplementation.Entities.Items; using RPGWorldModel.Implementation.Entities.Items.Swords; @@ -371,7 +372,11 @@ IronShortSword sword = new IronShortSword(); sword.InitializeEntity(); + WoodenTrainingSword wSword = new WoodenTrainingSword(); + wSword.InitializeEntity(); + availableEquipable.Add(sword); + availableEquipable.Add(wSword); refreshEquip(); } @@ -421,6 +426,7 @@ EquipRequest request = new EquipRequest(); request.RequestedEquipable = selectedEquipable; + request.RequestedSlot = slot; EquipResponse response = equipTest.Equip(request); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |