Thread: [Rpgworldmodel-commits] SF.net SVN: rpgworldmodel: [13] doc
Status: Inactive
Brought to you by:
deadwood_pl
From: <dea...@us...> - 2006-07-09 14:48:35
|
Revision: 13 Author: deadwood_pl Date: 2006-07-09 07:48:10 -0700 (Sun, 09 Jul 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=13&view=rev Log Message: ----------- Basic work on IEquip implementation. Needed: how to bind equipment location with equipment slot. Modified Paths: -------------- doc/RPGWorldModel_model.zuml src/RPGWorldModel.Abstracts/AnimatedEntity.cs src/RPGWorldModel.Abstracts/Golbin.cs src/RPGWorldModel.Abstracts/Human.cs src/RPGWorldModel.Abstracts/Humanoid.cs src/RPGWorldModel.Abstracts/IEquip.cs src/test_applications/tester/Form1.Designer.cs src/test_applications/tester/Form1.cs Modified: doc/RPGWorldModel_model.zuml =================================================================== (Binary files differ) Modified: src/RPGWorldModel.Abstracts/AnimatedEntity.cs =================================================================== --- src/RPGWorldModel.Abstracts/AnimatedEntity.cs 2006-07-06 16:26:23 UTC (rev 12) +++ src/RPGWorldModel.Abstracts/AnimatedEntity.cs 2006-07-09 14:48:10 UTC (rev 13) @@ -15,9 +15,9 @@ protected EquipmentSlotList equipmentSlots = new EquipmentSlotList(); - public virtual EquipmentSlotList.Enumerator AvailableEquipmentSlots + public virtual IEnumerable<EquipmentSlot> AvailableEquipmentSlots { - get { return equipmentSlots.GetEnumerator(); } + get { return equipmentSlots; } } public abstract EquipResponse Equip(EquipRequest request); Modified: src/RPGWorldModel.Abstracts/Golbin.cs =================================================================== --- src/RPGWorldModel.Abstracts/Golbin.cs 2006-07-06 16:26:23 UTC (rev 12) +++ src/RPGWorldModel.Abstracts/Golbin.cs 2006-07-09 14:48:10 UTC (rev 13) @@ -38,13 +38,6 @@ randomizeMaxHealthPoints(); } - public override EquipResponse Equip(EquipRequest request) - { - EquipResponse response = new EquipResponse(); - response.Status = EquipStatus.Undefined; - return response; - } - #endregion Modified: src/RPGWorldModel.Abstracts/Human.cs =================================================================== --- src/RPGWorldModel.Abstracts/Human.cs 2006-07-06 16:26:23 UTC (rev 12) +++ src/RPGWorldModel.Abstracts/Human.cs 2006-07-09 14:48:10 UTC (rev 13) @@ -38,13 +38,6 @@ randomizeMaxHealthPoints(); } - public override EquipResponse Equip(EquipRequest request) - { - EquipResponse response = new EquipResponse(); - response.Status = EquipStatus.Undefined; - return response; - } - #endregion } } Modified: src/RPGWorldModel.Abstracts/Humanoid.cs =================================================================== --- src/RPGWorldModel.Abstracts/Humanoid.cs 2006-07-06 16:26:23 UTC (rev 12) +++ src/RPGWorldModel.Abstracts/Humanoid.cs 2006-07-09 14:48:10 UTC (rev 13) @@ -40,6 +40,20 @@ } #endregion + + + public override EquipResponse Equip(EquipRequest request) + { + // Basic equip implementation for humanoids + + // TEMP!!!!! + equipmentSlots[8].AddEquipable(request.RequestedEquipable); + + EquipResponse response = new EquipResponse(); + response.Status = EquipStatus.Equipped; + return response; + } + } public abstract class HumanoidAdvanced : Humanoid Modified: src/RPGWorldModel.Abstracts/IEquip.cs =================================================================== --- src/RPGWorldModel.Abstracts/IEquip.cs 2006-07-06 16:26:23 UTC (rev 12) +++ src/RPGWorldModel.Abstracts/IEquip.cs 2006-07-09 14:48:10 UTC (rev 13) @@ -6,7 +6,7 @@ { public interface IEquip { - EquipmentSlotList.Enumerator AvailableEquipmentSlots + IEnumerable<EquipmentSlot> AvailableEquipmentSlots { get; } @@ -20,11 +20,11 @@ public class EquipRequest { - private IEquipable requestEntity = null; - public IEquipable RequestEntity + private IEquipable requestedEquipable = null; + public IEquipable RequestedEquipable { - get { return requestEntity; } - set { requestEntity = value; } + get { return requestedEquipable; } + set { requestedEquipable = value; } } } @@ -35,20 +35,25 @@ public abstract class EquipmentSlot { protected EquipableList equippedEntities = new EquipableList(); - EquipableList.Enumerator EquippedEntities + public IEnumerable<IEquipable> EquippedEntities { - get { return equippedEntities.GetEnumerator(); } + get { return equippedEntities; } } - public void Add(IEquipable equipable) + public void AddEquipable(IEquipable equipable) { equippedEntities.Add(equipable); } - public void Remove(IEquipable equipable) + public void RemoveEquipable(IEquipable equipable) { equippedEntities.Remove(equipable); } + + public abstract string SlotName + { + get; + } } public class EquipmentSlotList : List<EquipmentSlot> @@ -57,58 +62,114 @@ 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"; } + } } /* Modified: src/test_applications/tester/Form1.Designer.cs =================================================================== --- src/test_applications/tester/Form1.Designer.cs 2006-07-06 16:26:23 UTC (rev 12) +++ src/test_applications/tester/Form1.Designer.cs 2006-07-09 14:48:10 UTC (rev 13) @@ -47,6 +47,7 @@ this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage(); + this.tbInflictedPhysicalDamage = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.tbItemName = new System.Windows.Forms.TextBox(); this.tbItemMaxDurability = new System.Windows.Forms.TextBox(); @@ -58,11 +59,18 @@ this.btnItemRapair = new System.Windows.Forms.Button(); this.btnItemDamage = new System.Windows.Forms.Button(); this.tabPage3 = new System.Windows.Forms.TabPage(); + 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.tbInflictedPhysicalDamage = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage2.SuspendLayout(); + this.tabPage3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit(); this.SuspendLayout(); // @@ -187,13 +195,16 @@ // // tabControl1 // + this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Controls.Add(this.tabPage3); this.tabControl1.Location = new System.Drawing.Point(12, 12); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(457, 334); + this.tabControl1.Size = new System.Drawing.Size(652, 394); this.tabControl1.TabIndex = 15; // // tabPage1 @@ -216,7 +227,7 @@ this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(449, 308); + this.tabPage1.Size = new System.Drawing.Size(644, 368); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "AnimatedEntities"; this.tabPage1.UseVisualStyleBackColor = true; @@ -237,11 +248,18 @@ this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(449, 308); + this.tabPage2.Size = new System.Drawing.Size(644, 368); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "Items"; this.tabPage2.UseVisualStyleBackColor = true; // + // tbInflictedPhysicalDamage + // + this.tbInflictedPhysicalDamage.Location = new System.Drawing.Point(332, 74); + this.tbInflictedPhysicalDamage.Name = "tbInflictedPhysicalDamage"; + this.tbInflictedPhysicalDamage.Size = new System.Drawing.Size(100, 20); + this.tbInflictedPhysicalDamage.TabIndex = 25; + // // label3 // this.label3.AutoSize = true; @@ -325,29 +343,86 @@ // // tabPage3 // + this.tabPage3.Controls.Add(this.label4); + this.tabPage3.Controls.Add(this.btnEquipaSelected); + this.tabPage3.Controls.Add(this.lvAvailableItems); + this.tabPage3.Controls.Add(this.tvEquipmentSlots); + this.tabPage3.Controls.Add(this.btnHumanCreate); + this.tabPage3.Controls.Add(this.pictureBox1); this.tabPage3.Location = new System.Drawing.Point(4, 22); this.tabPage3.Name = "tabPage3"; - this.tabPage3.Size = new System.Drawing.Size(449, 308); + this.tabPage3.Size = new System.Drawing.Size(644, 368); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "Equip"; this.tabPage3.UseVisualStyleBackColor = true; // + // btnEquipaSelected + // + this.btnEquipaSelected.Location = new System.Drawing.Point(319, 342); + this.btnEquipaSelected.Name = "btnEquipaSelected"; + this.btnEquipaSelected.Size = new System.Drawing.Size(75, 23); + this.btnEquipaSelected.TabIndex = 4; + this.btnEquipaSelected.Text = "Equip"; + this.btnEquipaSelected.UseVisualStyleBackColor = true; + this.btnEquipaSelected.Click += new System.EventHandler(this.btnEquipaSelected_Click); + // + // lvAvailableItems + // + this.lvAvailableItems.HideSelection = false; + this.lvAvailableItems.Location = new System.Drawing.Point(319, 176); + this.lvAvailableItems.Name = "lvAvailableItems"; + this.lvAvailableItems.Size = new System.Drawing.Size(322, 97); + this.lvAvailableItems.TabIndex = 3; + this.lvAvailableItems.UseCompatibleStateImageBehavior = false; + this.lvAvailableItems.View = System.Windows.Forms.View.List; + // + // tvEquipmentSlots + // + this.tvEquipmentSlots.HideSelection = false; + this.tvEquipmentSlots.Location = new System.Drawing.Point(319, 15); + this.tvEquipmentSlots.Name = "tvEquipmentSlots"; + this.tvEquipmentSlots.Size = new System.Drawing.Size(322, 155); + this.tvEquipmentSlots.TabIndex = 2; + this.tvEquipmentSlots.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvEquipmentSlots_AfterSelect); + // + // btnHumanCreate + // + this.btnHumanCreate.Location = new System.Drawing.Point(566, 342); + this.btnHumanCreate.Name = "btnHumanCreate"; + this.btnHumanCreate.Size = new System.Drawing.Size(75, 23); + this.btnHumanCreate.TabIndex = 1; + this.btnHumanCreate.Text = "Create"; + this.btnHumanCreate.UseVisualStyleBackColor = true; + this.btnHumanCreate.Click += new System.EventHandler(this.btnHumanCreate_Click); + // + // pictureBox1 + // + this.pictureBox1.Location = new System.Drawing.Point(13, 15); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(300, 300); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + // // errorProvider1 // this.errorProvider1.ContainerControl = this; // - // tbInflictedPhysicalDamage + // label4 // - this.tbInflictedPhysicalDamage.Location = new System.Drawing.Point(332, 74); - this.tbInflictedPhysicalDamage.Name = "tbInflictedPhysicalDamage"; - this.tbInflictedPhysicalDamage.Size = new System.Drawing.Size(100, 20); - this.tbInflictedPhysicalDamage.TabIndex = 25; + 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); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(481, 358); + this.ClientSize = new System.Drawing.Size(676, 418); this.Controls.Add(this.tabControl1); this.Name = "Form1"; this.Text = "Form1"; @@ -357,6 +432,9 @@ this.tabPage1.PerformLayout(); this.tabPage2.ResumeLayout(false); this.tabPage2.PerformLayout(); + this.tabPage3.ResumeLayout(false); + this.tabPage3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).EndInit(); this.ResumeLayout(false); @@ -395,6 +473,12 @@ private System.Windows.Forms.Button btnItemRapair; private System.Windows.Forms.Button btnItemDamage; private System.Windows.Forms.TextBox tbInflictedPhysicalDamage; + private System.Windows.Forms.Button btnHumanCreate; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.TreeView tvEquipmentSlots; + private System.Windows.Forms.ListView lvAvailableItems; + private System.Windows.Forms.Button btnEquipaSelected; + private System.Windows.Forms.Label label4; } } Modified: src/test_applications/tester/Form1.cs =================================================================== --- src/test_applications/tester/Form1.cs 2006-07-06 16:26:23 UTC (rev 12) +++ src/test_applications/tester/Form1.cs 2006-07-09 14:48:10 UTC (rev 13) @@ -25,10 +25,18 @@ { Random rand = new Random(); + // characters AnimatedEntity enemy = null; AnimatedEntity player = null; + + // item Item testItem = null; + // equip + Humanoid equipTest = null; + EquipmentSlot selectedSlot = null; + EquipableList availableEquipable = new EquipableList(); + public Form1() { InitializeComponent(); @@ -205,5 +213,278 @@ } } + + private void refreshEquipImage() + { + if (equipTest == null) + return; + + Bitmap bmp = new Bitmap(300, 300); + + Graphics g = Graphics.FromImage(bmp); + + g.DrawRectangle(Pens.Black, 0, 0, 299, 299); + + foreach (EquipmentSlot slot in equipTest.AvailableEquipmentSlots) + { + int x = 0, y = 0, w = 0, h = 0; + + if (slot is EquipmentSlotHead) + { + x = 80; y = 20; w = 40; h = 40; + } + + if (slot is EquipmentSlotFace) + { + x = 40; y = 25; w = 30; h = 30; + } + + if (slot is EquipmentSlotNeck) + { + x = 90; y = 65; w = 20; h = 20; + } + + if (slot is EquipmentSlotTorso) + { + x = 60; y = 90; w = 80; h = 80; + } + + if (slot is EquipmentSlotRightArm) + { + x = 35; y = 85; w = 20; h = 80; + } + + if (slot is EquipmentSlotLeftArm) + { + x = 145; y = 85; w = 20; h = 80; + } + + if (slot is EquipmentSlotRightHand) + { + x = 40; y = 170; w = 10; h = 30; + } + + if (slot is EquipmentSlotLeftHand) + { + x = 150; y = 170; w = 10; h = 30; + } + + + if (slot is EquipmentSlotWaist) + { + x = 60; y = 175; w = 80; h = 10; + } + + + if (slot is EquipmentSlotRightLeg) + { + x = 60; y = 190; w = 20; h = 80; + } + + if (slot is EquipmentSlotLeftLeg) + { + x = 120; y = 190; w = 20; h = 80; + } + + if (slot is EquipmentSlotRightFoot) + { + x = 60; y = 275; w = 20; h = 20; + } + + if (slot is EquipmentSlotLeftFoot) + { + x = 120; y = 275; w = 20; h = 20; + } + + if (slot is EquipmentSlotBack) + { + x = 190; y = 30; w = 60; h = 60; + } + + + if (slot == selectedSlot) + g.FillRectangle(Brushes.Black, x, y, w, h); + else + g.DrawRectangle(Pens.Black, x, y, w, h); + + foreach (IEquipable equipable in slot.EquippedEntities) + { + if (equipable is Sword) + { + g.FillRectangle(Brushes.Blue, x, y, 5, 100); + g.FillRectangle(Brushes.Blue, x - 10, y + 20, 25, 5); + + Point[] points = new Point[3]; + points[0].X = x; + points[0].Y = y + 100; + points[1].X = x + 2; + points[1].Y = y + 110; + points[2].X = x+5; + points[2].Y = y + 100; + g.FillPolygon(Brushes.Blue, points); + + } + } + } + + g.Dispose(); + + if (pictureBox1.Image != null) + pictureBox1.Image.Dispose(); + + pictureBox1.Image = bmp; + + } + + private void refreshEquipList() + { + if (equipTest == null) + return; + + tvEquipmentSlots.Nodes.Clear(); + TreeNode rootNode = tvEquipmentSlots.Nodes.Add("Slots"); + + foreach (EquipmentSlot slot in equipTest.AvailableEquipmentSlots) + { + rootNode.Nodes.Add(new EquipmentSlotTreeNode(slot)); + } + + tvEquipmentSlots.ExpandAll(); + } + + private void refreshAvailableItemsList() + { + lvAvailableItems.Clear(); + + foreach (IEquipable equipable in availableEquipable) + { + lvAvailableItems.Items.Add(new EquipableListViewItem(equipable)); + } + + } + + private void btnHumanCreate_Click(object sender, EventArgs e) + { + equipTest = new Human(); + equipTest.InitializeEntity(); + + IronShortSword sword = new IronShortSword(); + sword.InitializeEntity(); + + availableEquipable.Add(sword); + + refreshEquip(); + } + + private void refreshEquip() + { + // Drawing 'equipment slots' + refreshEquipImage(); + + refreshEquipList(); + + refreshAvailableItemsList(); + + } + + private void tvEquipmentSlots_AfterSelect(object sender, TreeViewEventArgs e) + { + EquipmentSlotTreeNode select = tvEquipmentSlots.SelectedNode as EquipmentSlotTreeNode; + + selectedSlot = null; + + if (select != null) + { + selectedSlot = select.Slot; + } + + refreshEquipImage(); + + } + + private void btnEquipaSelected_Click(object sender, EventArgs e) + { + if (lvAvailableItems.SelectedItems.Count != 1) + return; + + if (tvEquipmentSlots.SelectedNode == null) + return; + + if (equipTest == null) + return; + + IEquipable selectedEquipable = + (lvAvailableItems.SelectedItems[0] as EquipableListViewItem).Equipable; + + EquipmentSlot slot = + (tvEquipmentSlots.SelectedNode as EquipmentSlotTreeNode).Slot; + + EquipRequest request = new EquipRequest(); + request.RequestedEquipable = selectedEquipable; + + EquipResponse response = equipTest.Equip(request); + + if (response.Status == EquipStatus.Equipped) + availableEquipable.Remove(selectedEquipable); + + refreshEquip(); + } } + + public class EquipmentSlotTreeNode : TreeNode + { + private EquipmentSlot slot = null; + + public EquipmentSlot Slot + { + get { return slot; } + set { slot = value; } + } + + private EquipmentSlotTreeNode() + { + } + + public EquipmentSlotTreeNode(EquipmentSlot slot) + { + if (slot == null) + throw new ArgumentException("slot must not be null", "slot"); + + Slot = slot; + this.Text = slot.SlotName; + + foreach (IEquipable equipable in Slot.EquippedEntities) + this.Nodes.Add((equipable as INamedEntity).Name); + } + } + + public class EquipableListViewItem : ListViewItem + { + private IEquipable equipable = null; + + public IEquipable Equipable + { + get { return equipable; } + set { equipable = value; } + } + + private EquipableListViewItem() + { + } + + public EquipableListViewItem(IEquipable equipable) + { + if (equipable == null) + throw new ArgumentException("equipable must not be null", "equipable"); + + Equipable = equipable; + + if (Equipable is INamedEntity) + Text = (Equipable as INamedEntity).Name; + else + Text = "NOT NAMED"; + } + + } + } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dea...@us...> - 2006-07-14 18:48:54
|
Revision: 16 Author: deadwood_pl Date: 2006-07-14 11:19:50 -0700 (Fri, 14 Jul 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=16&view=rev Log Message: ----------- Added clothing for further equipment tests... oh and goblin is goblin not golbin :P Modified Paths: -------------- doc/RPGWorldModel_model.zuml src/RPGWorldModel.Abstracts/Item.cs src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj src/RPGWorldModel.Abstracts/Sword.cs src/RPGWorldModel.Implementation/RPGWorldModel.Implementation.csproj src/RPGWorldModel.Implementation/Swords.cs src/test_applications/tester/Form1.Designer.cs src/test_applications/tester/Form1.cs Added Paths: ----------- src/RPGWorldModel.Abstracts/Clothing.cs src/RPGWorldModel.Abstracts/Goblin.cs src/RPGWorldModel.Abstracts/Pants.cs src/RPGWorldModel.Abstracts/Shirt.cs src/RPGWorldModel.Implementation/Pants.cs src/RPGWorldModel.Implementation/Shirts.cs Removed Paths: ------------- src/RPGWorldModel.Abstracts/Golbin.cs Modified: doc/RPGWorldModel_model.zuml =================================================================== (Binary files differ) Added: src/RPGWorldModel.Abstracts/Clothing.cs =================================================================== --- src/RPGWorldModel.Abstracts/Clothing.cs (rev 0) +++ src/RPGWorldModel.Abstracts/Clothing.cs 2006-07-14 18:19:50 UTC (rev 16) @@ -0,0 +1,20 @@ +using System; + +namespace RPGWorldModel.Abstracts.Entities.Items +{ + public abstract class Clothing : Item + { + #region Initialize Overrides + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Unknown Clothing Entity"; + name.IsInitialized = true; + } + + base.InitializeNamedEntity(); + } + #endregion + } +} \ No newline at end of file Copied: src/RPGWorldModel.Abstracts/Goblin.cs (from rev 13, src/RPGWorldModel.Abstracts/Golbin.cs) =================================================================== --- src/RPGWorldModel.Abstracts/Goblin.cs (rev 0) +++ src/RPGWorldModel.Abstracts/Goblin.cs 2006-07-14 18:19:50 UTC (rev 16) @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Text; +using RPGWorldModel.Abstracts.Entities.LiveEntities; +using RPGWorldModel.Abstracts.Interfaces; + +namespace RPGWorldModel.TopLevelImplementation.Entities.LiveEntities +{ + public class Goblin : Humanoid + { + public Goblin() + { + } + + #region Initialize Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Goblin"; + name.IsInitialized = true; + } + } + + public override void InitializeLiveEntity() + { + if (!hp.IsInitialized) + { + // Base values for goblin + hp.BaseHP = 80; + hp.HPMargin = 20; + hp.IsInitialized = true; + hp.RandomizationRequired = true; + } + + if (hp.RandomizationRequired) + randomizeMaxHealthPoints(); + } + + #endregion + + + } +} Deleted: src/RPGWorldModel.Abstracts/Golbin.cs =================================================================== --- src/RPGWorldModel.Abstracts/Golbin.cs 2006-07-14 16:42:36 UTC (rev 15) +++ src/RPGWorldModel.Abstracts/Golbin.cs 2006-07-14 18:19:50 UTC (rev 16) @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using RPGWorldModel.Abstracts.Entities.LiveEntities; -using RPGWorldModel.Abstracts.Interfaces; - -namespace RPGWorldModel.TopLevelImplementation.Entities.LiveEntities -{ - public class Golbin : Humanoid - { - public Golbin() - { - } - - #region Initialize Overrides - - public override void InitializeNamedEntity() - { - if (!name.IsInitialized) - { - name.Value = "Goblin"; - name.IsInitialized = true; - } - } - - public override void InitializeLiveEntity() - { - if (!hp.IsInitialized) - { - // Base values for goblin - hp.BaseHP = 80; - hp.HPMargin = 20; - hp.IsInitialized = true; - hp.RandomizationRequired = true; - } - - if (hp.RandomizationRequired) - randomizeMaxHealthPoints(); - } - - #endregion - - - } -} Modified: src/RPGWorldModel.Abstracts/Item.cs =================================================================== --- src/RPGWorldModel.Abstracts/Item.cs 2006-07-14 16:42:36 UTC (rev 15) +++ src/RPGWorldModel.Abstracts/Item.cs 2006-07-14 18:19:50 UTC (rev 16) @@ -85,8 +85,20 @@ durability = newDurability; } - public abstract void InitializeDamagable(); + public virtual void InitializeDamagable() + { + if (!durability.IsInitialized) + { + durability.BaseDurability = 0; + durability.DurabilityMargin = 0; + durability.IsInitialized = true; + durability.RandomizationRequired = true; + } + if (durability.RandomizationRequired) + randomizeMaxDurability(); + } + public virtual short DamageByPoints(short damagePoints) { if (damagePoints < 0) Added: src/RPGWorldModel.Abstracts/Pants.cs =================================================================== --- src/RPGWorldModel.Abstracts/Pants.cs (rev 0) +++ src/RPGWorldModel.Abstracts/Pants.cs 2006-07-14 18:19:50 UTC (rev 16) @@ -0,0 +1,36 @@ +using System; +using RPGWorldModel.Abstracts.Entities.Items; +using RPGWorldModel.Abstracts.Support.Equipment; + +namespace RPGWorldModel.TopLevelImplementation.Entities.Items +{ + public class Pants : Clothing + { + #region Initialize Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Pants"; + name.IsInitialized = true; + } + + base.InitializeNamedEntity(); + } + + public override void InitializeEquipable() + { + equipmentLocationDescriptors.Clear(); + + // Building descriptors + EquipmentLocationDescriptor waistLegs = new EquipmentLocationDescriptor(); + waistLegs.AddEquipmentLocation(new EquipmentLocationLeftLeg()); + waistLegs.AddEquipmentLocation(new EquipmentLocationRightLeg()); + waistLegs.AddEquipmentLocation(new EquipmentLocationWaist()); + equipmentLocationDescriptors.Add(waistLegs); + } + + #endregion + } +} \ No newline at end of file Modified: src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj =================================================================== --- src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj 2006-07-14 16:42:36 UTC (rev 15) +++ src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj 2006-07-14 18:19:50 UTC (rev 16) @@ -36,10 +36,11 @@ <Compile Include="Animal.cs" /> <Compile Include="AnimatedEntity.cs" /> <Compile Include="Arachnid.cs" /> + <Compile Include="Clothing.cs" /> <Compile Include="EquipmentLocation.cs" /> <Compile Include="EquipmentSlot.cs" /> <Compile Include="GameEntity.cs" /> - <Compile Include="Golbin.cs" /> + <Compile Include="Goblin.cs" /> <Compile Include="Human.cs" /> <Compile Include="Humanoid.cs" /> <Compile Include="IDamagable.cs" /> @@ -53,7 +54,9 @@ <Compile Include="Initializable.cs" /> <Compile Include="Item.cs" /> <Compile Include="LiveEntity.cs" /> + <Compile Include="Pants.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Shirt.cs" /> <Compile Include="Spider.cs" /> <Compile Include="Sword.cs" /> <Compile Include="Weapon.cs" /> Added: src/RPGWorldModel.Abstracts/Shirt.cs =================================================================== --- src/RPGWorldModel.Abstracts/Shirt.cs (rev 0) +++ src/RPGWorldModel.Abstracts/Shirt.cs 2006-07-14 18:19:50 UTC (rev 16) @@ -0,0 +1,36 @@ +using System; +using RPGWorldModel.Abstracts.Entities.Items; +using RPGWorldModel.Abstracts.Support.Equipment; + +namespace RPGWorldModel.TopLevelImplementation.Entities.Items +{ + public class Shirt : Clothing + { + #region Initialize Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Shirt"; + name.IsInitialized = true; + } + + base.InitializeNamedEntity(); + } + + public override void InitializeEquipable() + { + equipmentLocationDescriptors.Clear(); + + // Building descriptors + EquipmentLocationDescriptor torsoArms = new EquipmentLocationDescriptor(); + torsoArms.AddEquipmentLocation(new EquipmentLocationLeftArm()); + torsoArms.AddEquipmentLocation(new EquipmentLocationRightArm()); + torsoArms.AddEquipmentLocation(new EquipmentLocationTorso()); + equipmentLocationDescriptors.Add(torsoArms); + } + + #endregion + } +} \ No newline at end of file Modified: src/RPGWorldModel.Abstracts/Sword.cs =================================================================== --- src/RPGWorldModel.Abstracts/Sword.cs 2006-07-14 16:42:36 UTC (rev 15) +++ src/RPGWorldModel.Abstracts/Sword.cs 2006-07-14 18:19:50 UTC (rev 16) @@ -9,10 +9,6 @@ { public class Sword : Weapon { - public Sword() - { - } - #region Initialization Overrides public override void InitializeNamedEntity() @@ -24,20 +20,6 @@ } } - public override void InitializeDamagable() - { - if (!durability.IsInitialized) - { - durability.BaseDurability = 0; - durability.DurabilityMargin = 0; - durability.IsInitialized = true; - durability.RandomizationRequired = true; - } - - if (durability.RandomizationRequired) - randomizeMaxDurability(); - } - public override void InitializeDamageInflictor() { // Preadding required descriptors @@ -86,10 +68,6 @@ public class TwoHandedSword : Sword { - public TwoHandedSword() - { - } - #region Initialization Overrides public override void InitializeNamedEntity() @@ -101,35 +79,6 @@ } } - public override void InitializeDamagable() - { - if (!durability.IsInitialized) - { - durability.BaseDurability = 0; - durability.DurabilityMargin = 0; - durability.IsInitialized = true; - durability.RandomizationRequired = true; - } - - if (durability.RandomizationRequired) - randomizeMaxDurability(); - } - - public override void InitializeDamageInflictor() - { - DamageDescriptorPhysical damageDesc = new DamageDescriptorPhysical(); - damageDesc.BaseMaxDamage = 0; - damageDesc.MaxDamageMargin = 0; - damageDesc.BaseMinDamage = 0; - damageDesc.MinDamageMargin = 0; - damageDesc.IsInitialized = true; - damageDesc.RandomizationRequired = true; - - addDamageDescriptorIfNotExisting(damageDesc); - - base.InitializeDamageInflictor(); - } - public override void InitializeEquipable() { equipmentLocationDescriptors.Clear(); Added: src/RPGWorldModel.Implementation/Pants.cs =================================================================== --- src/RPGWorldModel.Implementation/Pants.cs (rev 0) +++ src/RPGWorldModel.Implementation/Pants.cs 2006-07-14 18:19:50 UTC (rev 16) @@ -0,0 +1,36 @@ +using System; +using RPGWorldModel.TopLevelImplementation.Entities.Items; + +namespace RPGWorldModel.Implementation.Entities.Items.Pants +{ + public class CottonPants : RPGWorldModel.TopLevelImplementation.Entities.Items.Pants + { + #region Initialization Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Cotton Pants"; + name.IsInitialized = true; + } + + base.InitializeNamedEntity(); + } + + public override void InitializeDamagable() + { + if (!durability.IsInitialized) + { + durability.BaseDurability = 300; + durability.DurabilityMargin = 10; + durability.IsInitialized = true; + durability.RandomizationRequired = true; + } + + base.InitializeDamagable(); + } + + #endregion + } +} \ No newline at end of file Modified: src/RPGWorldModel.Implementation/RPGWorldModel.Implementation.csproj =================================================================== --- src/RPGWorldModel.Implementation/RPGWorldModel.Implementation.csproj 2006-07-14 16:42:36 UTC (rev 15) +++ src/RPGWorldModel.Implementation/RPGWorldModel.Implementation.csproj 2006-07-14 18:19:50 UTC (rev 16) @@ -33,7 +33,9 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="Pants.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Shirts.cs" /> <Compile Include="Swords.cs" /> </ItemGroup> <ItemGroup> Added: src/RPGWorldModel.Implementation/Shirts.cs =================================================================== --- src/RPGWorldModel.Implementation/Shirts.cs (rev 0) +++ src/RPGWorldModel.Implementation/Shirts.cs 2006-07-14 18:19:50 UTC (rev 16) @@ -0,0 +1,36 @@ +using System; +using RPGWorldModel.TopLevelImplementation.Entities.Items; + +namespace RPGWorldModel.Implementation.Entities.Items.Shirts +{ + public class CottonShirt : Shirt + { + #region Initialization Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Cotton Shirt"; + name.IsInitialized = true; + } + + base.InitializeNamedEntity(); + } + + public override void InitializeDamagable() + { + if (!durability.IsInitialized) + { + durability.BaseDurability = 350; + durability.DurabilityMargin = 15; + durability.IsInitialized = true; + durability.RandomizationRequired = true; + } + + base.InitializeDamagable(); + } + + #endregion + } +} \ No newline at end of file Modified: src/RPGWorldModel.Implementation/Swords.cs =================================================================== --- src/RPGWorldModel.Implementation/Swords.cs 2006-07-14 16:42:36 UTC (rev 15) +++ src/RPGWorldModel.Implementation/Swords.cs 2006-07-14 18:19:50 UTC (rev 16) @@ -10,19 +10,32 @@ /// </summary> public class WoodenTrainingSword : Sword { - public WoodenTrainingSword() + #region Initialization Overrides + + public override void InitializeNamedEntity() { - name.Value = "Wooden Training Sword"; - name.IsInitialized = true; + if (!name.IsInitialized) + { + name.Value = "Wooden Training Sword"; + name.IsInitialized = true; + } - durability.BaseDurability = 500; - durability.DurabilityMargin = 20; - durability.IsInitialized = true; - durability.RandomizationRequired = true; + base.InitializeNamedEntity(); } - #region Initialization Overrides + public override void InitializeDamagable() + { + if (!durability.IsInitialized) + { + durability.BaseDurability = 500; + durability.DurabilityMargin = 20; + durability.IsInitialized = true; + durability.RandomizationRequired = true; + } + base.InitializeDamagable(); + } + public override void InitializeDamageInflictor() { DamageDescriptorPhysical damageDesc = new DamageDescriptorPhysical(); @@ -46,19 +59,32 @@ /// </summary> public class IronShortSword : Sword { - public IronShortSword() + #region Initialization Overrides + + public override void InitializeNamedEntity() { - name.Value = "Iron Short Sword"; - name.IsInitialized = true; + if (!name.IsInitialized) + { + name.Value = "Iron Short Sword"; + name.IsInitialized = true; + } - durability.BaseDurability = 1100; - durability.DurabilityMargin = 15; - durability.IsInitialized = true; - durability.RandomizationRequired = true; + base.InitializeNamedEntity(); } - #region Initialization Overrides + public override void InitializeDamagable() + { + if (!durability.IsInitialized) + { + durability.BaseDurability = 1100; + durability.DurabilityMargin = 15; + durability.IsInitialized = true; + durability.RandomizationRequired = true; + } + base.InitializeDamagable(); + } + public override void InitializeDamageInflictor() { DamageDescriptorPhysical damageDesc = new DamageDescriptorPhysical(); @@ -83,19 +109,31 @@ /// </summary> public class BronzeTwoHandedSword : TwoHandedSword { - public BronzeTwoHandedSword() + #region Initialization Overrides + + public override void InitializeNamedEntity() { - name.Value = "Bronze Two-Handed Sword"; - name.IsInitialized = true; + if (!name.IsInitialized) + { + name.Value = "Bronze Two-Handed Sword"; + name.IsInitialized = true; + } - durability.BaseDurability = 2000; - durability.DurabilityMargin = 20; - durability.IsInitialized = true; - durability.RandomizationRequired = true; + base.InitializeNamedEntity(); } - #region Initialization Overrides + public override void InitializeDamagable() + { + if (!durability.IsInitialized) + { + durability.BaseDurability = 2000; + durability.DurabilityMargin = 20; + durability.IsInitialized = true; + durability.RandomizationRequired = true; + } + base.InitializeDamagable(); + } public override void InitializeDamageInflictor() { DamageDescriptorPhysical damageDesc = new DamageDescriptorPhysical(); Modified: src/test_applications/tester/Form1.Designer.cs =================================================================== --- src/test_applications/tester/Form1.Designer.cs 2006-07-14 16:42:36 UTC (rev 15) +++ src/test_applications/tester/Form1.Designer.cs 2006-07-14 18:19:50 UTC (rev 16) @@ -360,11 +360,11 @@ // 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.Location = new System.Drawing.Point(319, 288); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(395, 13); + this.label4.Size = new System.Drawing.Size(207, 13); this.label4.TabIndex = 5; - this.label4.Text = "Select slot(back,waist,left hand, right hand), select item, click Equip"; + this.label4.Text = "Select slot, select item, click Equip"; // // btnEquipaSelected // Modified: src/test_applications/tester/Form1.cs =================================================================== --- src/test_applications/tester/Form1.cs 2006-07-14 16:42:36 UTC (rev 15) +++ src/test_applications/tester/Form1.cs 2006-07-14 18:19:50 UTC (rev 16) @@ -14,6 +14,8 @@ using RPGWorldModel.TopLevelImplementation.Entities.LiveEntities; using RPGWorldModel.TopLevelImplementation.Entities.Items; using RPGWorldModel.Implementation.Entities.Items.Swords; +using RPGWorldModel.Implementation.Entities.Items.Shirts; +using RPGWorldModel.Implementation.Entities.Items.Pants; /* * This is a simple WinForms application for testing features added to the framework. @@ -81,7 +83,7 @@ switch (enemySelect) { case(0): - enemy = new Golbin(); + enemy = new Goblin(); break; case(1): enemy = new Human(); @@ -340,6 +342,49 @@ g.FillPolygon(selectedBrush, points); } + + if (equipable is Shirt) + { + if (slot is EquipmentSlotLeftArm) + { + x = 145; y = 85; w = 20; h = 80; + g.FillRectangle(Brushes.Wheat, x, y, w, h); + } + + if (slot is EquipmentSlotRightArm) + { + x = 35; y = 85; w = 20; h = 80; + g.FillRectangle(Brushes.Wheat, x, y, w, h); + } + + if (slot is EquipmentSlotTorso) + { + x = 60; y = 90; w = 80; h = 80; + g.FillRectangle(Brushes.Wheat, x, y, w, h); + } + } + + if (equipable is Pants) + { + if (slot is EquipmentSlotLeftLeg) + { + x = 120; y = 190; w = 20; h = 80; + g.FillRectangle(Brushes.LightGray, x, y, w, h); + } + + if (slot is EquipmentSlotRightLeg) + { + x = 60; y = 190; w = 20; h = 80; + g.FillRectangle(Brushes.LightGray, x, y, w, h); + } + + if (slot is EquipmentSlotWaist) + { + x = 60; y = 175; w = 80; h = 10; + g.FillRectangle(Brushes.LightGray, x, y, w, h); + } + + } } } @@ -395,9 +440,17 @@ BronzeTwoHandedSword bthSword = new BronzeTwoHandedSword(); bthSword.InitializeEntity(); + CottonPants cPants = new CottonPants(); + cPants.InitializeEntity(); + + CottonShirt cShirt = new CottonShirt(); + cShirt.InitializeEntity(); + availableEquipable.Add(sword); availableEquipable.Add(wSword); availableEquipable.Add(bthSword); + availableEquipable.Add(cPants); + availableEquipable.Add(cShirt); refreshEquip(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dea...@us...> - 2006-07-15 13:38:44
|
Revision: 17 Author: deadwood_pl Date: 2006-07-15 06:38:17 -0700 (Sat, 15 Jul 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=17&view=rev Log Message: ----------- Added clubs and knifes. Modified Paths: -------------- doc/RPGWorldModel_model.zuml src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj src/RPGWorldModel.Implementation/RPGWorldModel.Implementation.csproj src/test_applications/tester/Form1.cs Added Paths: ----------- doc/ReadeMe.txt src/RPGWorldModel.Abstracts/Club.cs src/RPGWorldModel.Abstracts/Knife.cs src/RPGWorldModel.Implementation/Clubs.cs src/RPGWorldModel.Implementation/Knifes.cs Modified: doc/RPGWorldModel_model.zuml =================================================================== (Binary files differ) Added: doc/ReadeMe.txt =================================================================== --- doc/ReadeMe.txt (rev 0) +++ doc/ReadeMe.txt 2006-07-15 13:38:17 UTC (rev 17) @@ -0,0 +1,2 @@ +In order to read RPGWorldModel_model.zuml you need 'Poseidon for UML'. +I use Community Edition from http://gentleware.com. \ No newline at end of file Added: src/RPGWorldModel.Abstracts/Club.cs =================================================================== --- src/RPGWorldModel.Abstracts/Club.cs (rev 0) +++ src/RPGWorldModel.Abstracts/Club.cs 2006-07-15 13:38:17 UTC (rev 17) @@ -0,0 +1,62 @@ +using System; +using RPGWorldModel.Abstracts.Entities.Items; +using RPGWorldModel.Abstracts.Support.Equipment; +using RPGWorldModel.Abstracts.Interfaces; + +namespace RPGWorldModel.TopLevelImplementation.Entities.Items +{ + public class Club : Weapon + { + #region Initialization Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Club"; + name.IsInitialized = true; + } + } + + public override void InitializeDamageInflictor() + { + // Preadding required descriptors + addDamageDescriptorIfNotExisting(new DamageDescriptorPhysical()); + + foreach (DamageDescriptor damageDescriptor in damageDescriptors.Values) + { + if (!damageDescriptor.IsInitialized && damageDescriptor is DamageDescriptorPhysical) + { + damageDescriptor.BaseMinDamage = 0; + damageDescriptor.MinDamageMargin = 0; + damageDescriptor.BaseMaxDamage = 0; + damageDescriptor.MaxDamageMargin = 0; + damageDescriptor.IsInitialized = true; + damageDescriptor.RandomizationRequired = true; + } + + if (damageDescriptor.RandomizationRequired) + randomizeDamageDescriptor(damageDescriptor); + } + } + + public override void InitializeEquipable() + { + equipmentLocationDescriptors.Clear(); + + // Building descriptors + EquipmentLocationDescriptor leftHand = new EquipmentLocationDescriptor(); + leftHand.AddEquipmentLocation(new EquipmentLocationLeftHand()); + equipmentLocationDescriptors.Add(leftHand); + + EquipmentLocationDescriptor rightHand = new EquipmentLocationDescriptor(); + rightHand.AddEquipmentLocation(new EquipmentLocationRightHand()); + equipmentLocationDescriptors.Add(rightHand); + + EquipmentLocationDescriptor waist = new EquipmentLocationDescriptor(); + waist.AddEquipmentLocation(new EquipmentLocationWaist()); + equipmentLocationDescriptors.Add(waist); + } + #endregion + } +} Added: src/RPGWorldModel.Abstracts/Knife.cs =================================================================== --- src/RPGWorldModel.Abstracts/Knife.cs (rev 0) +++ src/RPGWorldModel.Abstracts/Knife.cs 2006-07-15 13:38:17 UTC (rev 17) @@ -0,0 +1,62 @@ +using System; +using RPGWorldModel.Abstracts.Entities.Items; +using RPGWorldModel.Abstracts.Support.Equipment; +using RPGWorldModel.Abstracts.Interfaces; + +namespace RPGWorldModel.TopLevelImplementation.Entities.Items +{ + public class Knife : Weapon + { + #region Initialization Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Knife"; + name.IsInitialized = true; + } + } + + public override void InitializeDamageInflictor() + { + // Preadding required descriptors + addDamageDescriptorIfNotExisting(new DamageDescriptorPhysical()); + + foreach (DamageDescriptor damageDescriptor in damageDescriptors.Values) + { + if (!damageDescriptor.IsInitialized && damageDescriptor is DamageDescriptorPhysical) + { + damageDescriptor.BaseMinDamage = 0; + damageDescriptor.MinDamageMargin = 0; + damageDescriptor.BaseMaxDamage = 0; + damageDescriptor.MaxDamageMargin = 0; + damageDescriptor.IsInitialized = true; + damageDescriptor.RandomizationRequired = true; + } + + if (damageDescriptor.RandomizationRequired) + randomizeDamageDescriptor(damageDescriptor); + } + } + + public override void InitializeEquipable() + { + equipmentLocationDescriptors.Clear(); + + // Building descriptors + EquipmentLocationDescriptor leftHand = new EquipmentLocationDescriptor(); + leftHand.AddEquipmentLocation(new EquipmentLocationLeftHand()); + equipmentLocationDescriptors.Add(leftHand); + + EquipmentLocationDescriptor rightHand = new EquipmentLocationDescriptor(); + rightHand.AddEquipmentLocation(new EquipmentLocationRightHand()); + equipmentLocationDescriptors.Add(rightHand); + + EquipmentLocationDescriptor waist = new EquipmentLocationDescriptor(); + waist.AddEquipmentLocation(new EquipmentLocationWaist()); + equipmentLocationDescriptors.Add(waist); + } + #endregion + } +} Modified: src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj =================================================================== --- src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj 2006-07-14 18:19:50 UTC (rev 16) +++ src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj 2006-07-15 13:38:17 UTC (rev 17) @@ -37,6 +37,7 @@ <Compile Include="AnimatedEntity.cs" /> <Compile Include="Arachnid.cs" /> <Compile Include="Clothing.cs" /> + <Compile Include="Club.cs" /> <Compile Include="EquipmentLocation.cs" /> <Compile Include="EquipmentSlot.cs" /> <Compile Include="GameEntity.cs" /> @@ -53,6 +54,7 @@ <Compile Include="InAnimatedEntity.cs" /> <Compile Include="Initializable.cs" /> <Compile Include="Item.cs" /> + <Compile Include="Knife.cs" /> <Compile Include="LiveEntity.cs" /> <Compile Include="Pants.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> Added: src/RPGWorldModel.Implementation/Clubs.cs =================================================================== --- src/RPGWorldModel.Implementation/Clubs.cs (rev 0) +++ src/RPGWorldModel.Implementation/Clubs.cs 2006-07-15 13:38:17 UTC (rev 17) @@ -0,0 +1,56 @@ +using System; +using RPGWorldModel.Abstracts.Entities.Items; +using RPGWorldModel.TopLevelImplementation.Entities.Items; +using RPGWorldModel.Abstracts.Interfaces; + +namespace RPGWorldModel.Implementation.Entities.Items.Clubs +{ + /// <summary> + /// Wooden Club + /// </summary> + public class WoodenClub : Club + { + #region Initialization Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Wooden Club"; + name.IsInitialized = true; + } + + base.InitializeNamedEntity(); + } + + public override void InitializeDamagable() + { + if (!durability.IsInitialized) + { + durability.BaseDurability = 700; + durability.DurabilityMargin = 15; + durability.IsInitialized = true; + durability.RandomizationRequired = true; + } + + base.InitializeDamagable(); + } + + public override void InitializeDamageInflictor() + { + DamageDescriptorPhysical damageDesc = new DamageDescriptorPhysical(); + damageDesc.BaseMaxDamage = 15; + damageDesc.MaxDamageMargin = 20; + damageDesc.BaseMinDamage = 5; + damageDesc.MinDamageMargin = 10; + damageDesc.IsInitialized = true; + damageDesc.RandomizationRequired = true; + + addDamageDescriptorIfNotExisting(damageDesc); + + base.InitializeDamageInflictor(); + } + + #endregion + } +} \ No newline at end of file Added: src/RPGWorldModel.Implementation/Knifes.cs =================================================================== --- src/RPGWorldModel.Implementation/Knifes.cs (rev 0) +++ src/RPGWorldModel.Implementation/Knifes.cs 2006-07-15 13:38:17 UTC (rev 17) @@ -0,0 +1,56 @@ +using System; +using RPGWorldModel.Abstracts.Entities.Items; +using RPGWorldModel.TopLevelImplementation.Entities.Items; +using RPGWorldModel.Abstracts.Interfaces; + +namespace RPGWorldModel.Implementation.Entities.Items.Knifes +{ + /// <summary> + /// Flint Stone Knife + /// </summary> + public class FlintStoneKnife : Knife + { + #region Initialization Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Flint Stone Knife"; + name.IsInitialized = true; + } + + base.InitializeNamedEntity(); + } + + public override void InitializeDamagable() + { + if (!durability.IsInitialized) + { + durability.BaseDurability = 500; + durability.DurabilityMargin = 30; + durability.IsInitialized = true; + durability.RandomizationRequired = true; + } + + base.InitializeDamagable(); + } + + public override void InitializeDamageInflictor() + { + DamageDescriptorPhysical damageDesc = new DamageDescriptorPhysical(); + damageDesc.BaseMaxDamage = 10; + damageDesc.MaxDamageMargin = 10; + damageDesc.BaseMinDamage = 5; + damageDesc.MinDamageMargin = 10; + damageDesc.IsInitialized = true; + damageDesc.RandomizationRequired = true; + + addDamageDescriptorIfNotExisting(damageDesc); + + base.InitializeDamageInflictor(); + } + + #endregion + } +} \ No newline at end of file Modified: src/RPGWorldModel.Implementation/RPGWorldModel.Implementation.csproj =================================================================== --- src/RPGWorldModel.Implementation/RPGWorldModel.Implementation.csproj 2006-07-14 18:19:50 UTC (rev 16) +++ src/RPGWorldModel.Implementation/RPGWorldModel.Implementation.csproj 2006-07-15 13:38:17 UTC (rev 17) @@ -33,6 +33,8 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="Clubs.cs" /> + <Compile Include="Knifes.cs" /> <Compile Include="Pants.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Shirts.cs" /> Modified: src/test_applications/tester/Form1.cs =================================================================== --- src/test_applications/tester/Form1.cs 2006-07-14 18:19:50 UTC (rev 16) +++ src/test_applications/tester/Form1.cs 2006-07-15 13:38:17 UTC (rev 17) @@ -16,6 +16,8 @@ using RPGWorldModel.Implementation.Entities.Items.Swords; using RPGWorldModel.Implementation.Entities.Items.Shirts; using RPGWorldModel.Implementation.Entities.Items.Pants; +using RPGWorldModel.Implementation.Entities.Items.Clubs; +using RPGWorldModel.Implementation.Entities.Items.Knifes; /* * This is a simple WinForms application for testing features added to the framework. @@ -343,6 +345,47 @@ } + if (equipable is Knife) + { + int swordLength = 50; + Brush selectedBrush = Brushes.Gray; + + if (equipable is FlintStoneKnife) + { + selectedBrush = Brushes.Orange; + } + + g.FillRectangle(selectedBrush, x, y, 5, swordLength); + g.FillRectangle(selectedBrush, x + 5, y, 3, swordLength / 2); + + Point[] points = new Point[3]; + points[0].X = x; + points[0].Y = y + swordLength; + points[1].X = x; + points[1].Y = y + swordLength + 10; + points[2].X = x + 5; + points[2].Y = y + swordLength; + g.FillPolygon(selectedBrush, points); + + } + + if (equipable is Club) + { + int swordLength = 100; + Point[] points = new Point[4]; + points[0].X = x; + points[0].Y = y; + points[1].X = x-5; + points[1].Y = y + swordLength; + points[2].X = x + 10; + points[2].Y = y + swordLength; + points[3].X = x + 5; + points[3].Y = y; + + g.FillPolygon(Brushes.Brown, points); + + } + if (equipable is Shirt) { if (slot is EquipmentSlotLeftArm) @@ -446,11 +489,19 @@ CottonShirt cShirt = new CottonShirt(); cShirt.InitializeEntity(); + FlintStoneKnife fsKnife = new FlintStoneKnife(); + fsKnife.InitializeEntity(); + + WoodenClub wClub = new WoodenClub(); + wClub.InitializeEntity(); + availableEquipable.Add(sword); availableEquipable.Add(wSword); availableEquipable.Add(bthSword); availableEquipable.Add(cPants); availableEquipable.Add(cShirt); + availableEquipable.Add(fsKnife); + availableEquipable.Add(wClub); refreshEquip(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dea...@us...> - 2006-07-16 15:06:08
|
Revision: 20 Author: deadwood_pl Date: 2006-07-16 08:05:17 -0700 (Sun, 16 Jul 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=20&view=rev Log Message: ----------- Preparation for implementing IAttacker/IDefender interfaces. Modified Paths: -------------- doc/RPGWorldModel_model.zuml src/RPGWorldModel.Abstracts/Animal.cs src/RPGWorldModel.Abstracts/AnimatedEntity.cs src/RPGWorldModel.Abstracts/Arachnid.cs src/RPGWorldModel.Abstracts/Club.cs src/RPGWorldModel.Abstracts/Goblin.cs src/RPGWorldModel.Abstracts/Human.cs src/RPGWorldModel.Abstracts/Humanoid.cs src/RPGWorldModel.Abstracts/Knife.cs src/RPGWorldModel.Abstracts/LiveEntity.cs src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj src/RPGWorldModel.Abstracts/Spider.cs src/RPGWorldModel.Abstracts/Sword.cs src/RPGWorldModel.Abstracts/Weapon.cs src/RPGWorldModel.Implementation/RPGWorldModel.Implementation.csproj src/test_applications/tester/Form1.cs Added Paths: ----------- src/RPGWorldModel.Abstracts/IAttacker.cs src/RPGWorldModel.Abstracts/IDefender.cs src/RPGWorldModel.Implementation/Goblins.cs src/RPGWorldModel.Implementation/Humans.cs src/RPGWorldModel.Implementation/Spiders.cs Modified: doc/RPGWorldModel_model.zuml =================================================================== (Binary files differ) Modified: src/RPGWorldModel.Abstracts/Animal.cs =================================================================== --- src/RPGWorldModel.Abstracts/Animal.cs 2006-07-16 09:15:26 UTC (rev 19) +++ src/RPGWorldModel.Abstracts/Animal.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.Abstracts.Entities.LiveEntities { @@ -18,28 +19,6 @@ } } - public override void InitializeEquip() - { - // Animals by default have no equip abilities - equipmentSlots.Clear(); - } - - public override EquipResponse Equip(EquipRequest request) - { - // Animals by default have no equip abilities - EquipResponse response = new EquipResponse(); - response.Status = EquipStatus.NotEquippedNotAbleToEquipAnyEntities; - return response; - } - - public override UnEquipResponse UnEquip(UnEquipRequest request) - { - // Animals by default have no equip abilities - UnEquipResponse response = new UnEquipResponse(); - response.Status = UnEquipStatus.NotUnEquippedNotAbleToUnEquipAnyEntities; - return response; - } - #endregion } Modified: src/RPGWorldModel.Abstracts/AnimatedEntity.cs =================================================================== --- src/RPGWorldModel.Abstracts/AnimatedEntity.cs 2006-07-16 09:15:26 UTC (rev 19) +++ src/RPGWorldModel.Abstracts/AnimatedEntity.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -3,14 +3,12 @@ using System.Text; using RPGWorldModel.Abstracts.Interfaces; using RPGWorldModel.Abstracts.Support.Equipment; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.Abstracts.Entities { - public abstract class AnimatedEntity : GameEntity, IEquip + public abstract class AnimatedEntity : GameEntity, IDamageInflictor, IEquip, IAttacker, IDefender { - protected AnimatedEntity() - { - } #region IEquip Members @@ -21,14 +19,125 @@ get { return equipmentSlots; } } - public abstract EquipResponse Equip(EquipRequest request); + public virtual EquipResponse Equip(EquipRequest request) + { + // No equip abilities + EquipResponse response = new EquipResponse(); + response.Status = EquipStatus.NotEquippedNotAbleToEquipAnyEntities; + return response; + } - public abstract UnEquipResponse UnEquip(UnEquipRequest request); + public virtual UnEquipResponse UnEquip(UnEquipRequest request) + { + // No equip abilities + UnEquipResponse response = new UnEquipResponse(); + response.Status = UnEquipStatus.NotUnEquippedNotAbleToUnEquipAnyEntities; + return response; + } - public abstract void InitializeEquip(); + public virtual void InitializeEquip() + { + // No equip abilities + equipmentSlots.Clear(); + } #endregion + #region IAttacker Members + + public virtual AttackerInflictedDamageResponse GetAttackerInflictedDamage() + { + AttackerInflictedDamageResponse response = + new AttackerInflictedDamageResponse(); + + // Use damage decriptors from the entity itself + DamageInflictorInflictedDamageResponse responseDI = + new DamageInflictorInflictedDamageResponse(); + + foreach (InflictedDamage inflictedDamage in responseDI.InflictedDamages) + response.Set(inflictedDamage); + + return response; + } + + #endregion + + #region IDamageInflictor Members + + protected DamageDescriptorDictionary damageDescriptors = new DamageDescriptorDictionary(); + + protected virtual void addDamageDescriptorIfNotExisting(DamageDescriptor descriptor) + { + if (!damageDescriptors.ContainsKey(descriptor.GetType())) + AddDamage(descriptor); + } + + public virtual void InitializeDamageInflictor() + { + foreach (DamageDescriptor damageDescriptor in damageDescriptors.Values) + { + // Randomizing damage descriptors + if (damageDescriptor.RandomizationRequired) + randomizeDamageDescriptor(damageDescriptor); + } + } + + protected virtual void randomizeDamageDescriptor(DamageDescriptor descriptor) + { + descriptor.MinDamage = (short)basicRandomize(descriptor.BaseMinDamage, descriptor.MinDamageMargin); + descriptor.MaxDamage = (short)basicRandomize(descriptor.BaseMaxDamage, descriptor.MaxDamageMargin); + + // logic security check + if (descriptor.MinDamage > descriptor.MaxDamage) + { + short temp = descriptor.MinDamage; + descriptor.MinDamage = descriptor.MinDamage; + descriptor.MaxDamage = temp; + } + + } + + public virtual void AddDamage(DamageDescriptor descriptor) + { + damageDescriptors[descriptor.GetType()] = descriptor; + } + + public virtual void RemoveDamage(DamageDescriptor descriptor) + { + damageDescriptors.Remove(descriptor.GetType()); + } + + /// <summary> + /// Default implementation + /// </summary> + /// <returns></returns> + public virtual DamageInflictorInflictedDamageResponse GetInflictedDamage() + { + //TODO : affect damage by attributes? + + DamageInflictorInflictedDamageResponse response = + new DamageInflictorInflictedDamageResponse(); + + short min = 0; + short max = 0; + + foreach (DamageDescriptor damageDescriptor in damageDescriptors.Values) + { + InflictedDamage damage = damageDescriptor.CreateInflictedDamage(); + + min = (short)(damageDescriptor.MinDamage); + max = (short)(damageDescriptor.MaxDamage); + + damage.SetDamage(min, max); + + response.Set(damage); + } + + return response; + } + + #endregion + #region Initialize Overrides public override void InitializeEntity() @@ -36,6 +145,8 @@ base.InitializeEntity(); InitializeEquip(); + + InitializeDamageInflictor(); } public override void InitializeNamedEntity() Modified: src/RPGWorldModel.Abstracts/Arachnid.cs =================================================================== --- src/RPGWorldModel.Abstracts/Arachnid.cs 2006-07-16 09:15:26 UTC (rev 19) +++ src/RPGWorldModel.Abstracts/Arachnid.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -6,5 +6,17 @@ { public abstract class Arachnid : Animal { + #region Initialize Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Unknown Arachnid Entity"; + name.IsInitialized = true; + } + } + + #endregion } } Modified: src/RPGWorldModel.Abstracts/Club.cs =================================================================== --- src/RPGWorldModel.Abstracts/Club.cs 2006-07-16 09:15:26 UTC (rev 19) +++ src/RPGWorldModel.Abstracts/Club.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -19,28 +19,6 @@ } } - public override void InitializeDamageInflictor() - { - // Preadding required descriptors - addDamageDescriptorIfNotExisting(new DamageDescriptorPhysical()); - - foreach (DamageDescriptor damageDescriptor in damageDescriptors.Values) - { - if (!damageDescriptor.IsInitialized && damageDescriptor is DamageDescriptorPhysical) - { - damageDescriptor.BaseMinDamage = 0; - damageDescriptor.MinDamageMargin = 0; - damageDescriptor.BaseMaxDamage = 0; - damageDescriptor.MaxDamageMargin = 0; - damageDescriptor.IsInitialized = true; - damageDescriptor.RandomizationRequired = true; - } - - if (damageDescriptor.RandomizationRequired) - randomizeDamageDescriptor(damageDescriptor); - } - } - public override void InitializeEquipable() { equipmentLocationDescriptors.Clear(); Modified: src/RPGWorldModel.Abstracts/Goblin.cs =================================================================== --- src/RPGWorldModel.Abstracts/Goblin.cs 2006-07-16 09:15:26 UTC (rev 19) +++ src/RPGWorldModel.Abstracts/Goblin.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -3,14 +3,12 @@ using System.Text; using RPGWorldModel.Abstracts.Entities.LiveEntities; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.TopLevelImplementation.Entities.LiveEntities { public class Goblin : Humanoid { - public Goblin() - { - } #region Initialize Overrides @@ -27,17 +25,30 @@ { if (!hp.IsInitialized) { - // Base values for goblin - hp.BaseHP = 80; - hp.HPMargin = 20; + hp.BaseHP = 0; + hp.HPMargin = 0; hp.IsInitialized = true; hp.RandomizationRequired = true; } - if (hp.RandomizationRequired) - randomizeMaxHealthPoints(); + base.InitializeLiveEntity(); } + public override void InitializeDamageInflictor() + { + DamageDescriptor phy = new DamageDescriptorPhysical(); + phy.BaseMaxDamage = 0; + phy.BaseMinDamage = 0; + phy.MaxDamageMargin = 0; + phy.MinDamageMargin = 0; + phy.IsInitialized = true; + phy.RandomizationRequired = true; + + addDamageDescriptorIfNotExisting(phy); + + base.InitializeDamageInflictor(); + } + #endregion Modified: src/RPGWorldModel.Abstracts/Human.cs =================================================================== --- src/RPGWorldModel.Abstracts/Human.cs 2006-07-16 09:15:26 UTC (rev 19) +++ src/RPGWorldModel.Abstracts/Human.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -3,14 +3,12 @@ using System.Text; using RPGWorldModel.Abstracts.Entities.LiveEntities; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.TopLevelImplementation.Entities.LiveEntities { public class Human : HumanoidAdvanced { - public Human() - { - } #region Initialize Overrides @@ -27,17 +25,30 @@ { if (!hp.IsInitialized) { - // Base values for human - hp.BaseHP = 100; - hp.HPMargin = 30; + hp.BaseHP = 0; + hp.HPMargin = 0; hp.IsInitialized = true; hp.RandomizationRequired = true; } - if (hp.RandomizationRequired) - randomizeMaxHealthPoints(); + base.InitializeLiveEntity(); } + + public override void InitializeDamageInflictor() + { + DamageDescriptor phy = new DamageDescriptorPhysical(); + phy.BaseMaxDamage = 0; + phy.BaseMinDamage = 0; + phy.MaxDamageMargin = 0; + phy.MinDamageMargin = 0; + phy.IsInitialized = true; + phy.RandomizationRequired = true; + addDamageDescriptorIfNotExisting(phy); + + base.InitializeDamageInflictor(); + } + #endregion } } Modified: src/RPGWorldModel.Abstracts/Humanoid.cs =================================================================== --- src/RPGWorldModel.Abstracts/Humanoid.cs 2006-07-16 09:15:26 UTC (rev 19) +++ src/RPGWorldModel.Abstracts/Humanoid.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -3,6 +3,7 @@ using System.Text; using RPGWorldModel.Abstracts.Interfaces; using RPGWorldModel.Abstracts.Support.Equipment; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.Abstracts.Entities.LiveEntities { @@ -42,7 +43,6 @@ #endregion - public override EquipResponse Equip(EquipRequest request) { EquipResponse response = new EquipResponse(); @@ -169,6 +169,57 @@ return response; } + + public override AttackerInflictedDamageResponse GetAttackerInflictedDamage() + { + // VERY EARLY IMPLMEMENTATION + + AttackerInflictedDamageResponse response = + new AttackerInflictedDamageResponse(); + + // TEMP : check only equipment slots for IDamageInflitor entities + // TEMP : for now only items from left/right hand are counted + + // Find equipables used for attack + EquipableList usedEquipable = new EquipableList(); + + foreach (EquipmentSlot slot in equipmentSlots) + { + if ((slot is EquipmentSlotLeftHand) || + (slot is EquipmentSlotRightHand)) + { + foreach (IEquipable equipable in slot.EquippedEntities) + if (equipable is IDamageInflictor) + if (!usedEquipable.Contains(equipable)) + usedEquipable.Add(equipable); + } + } + + // Calculate final inflicted damage + + if (usedEquipable.Count > 0) + { + // TODO: use of entity attributes to modify the final result? + + foreach (IEquipable equipable in usedEquipable) + { + DamageInflictorInflictedDamageResponse responseDI = + (equipable as IDamageInflictor).GetInflictedDamage(); + + foreach (InflictedDamage inflictedDamage in responseDI.InflictedDamages) + response.Sum(inflictedDamage); + } + } + else + { + // From AnimatedEntity + response = base.GetAttackerInflictedDamage(); + } + + + + return response; + } } public abstract class HumanoidAdvanced : Humanoid Added: src/RPGWorldModel.Abstracts/IAttacker.cs =================================================================== --- src/RPGWorldModel.Abstracts/IAttacker.cs (rev 0) +++ src/RPGWorldModel.Abstracts/IAttacker.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -0,0 +1,23 @@ +using System; +using RPGWorldModel.Abstracts.Support.Damage; + +namespace RPGWorldModel.Abstracts.Interfaces +{ + /// <summary> + /// Interface for any entity that can attack another entity + /// </summary> + public interface IAttacker + { + /// <summary> + /// Returns the total inflicted damage by entity + /// </summary> + /// <returns></returns> + AttackerInflictedDamageResponse GetAttackerInflictedDamage(); + + // TODO : Get attack success/failure objects + } + + public class AttackerInflictedDamageResponse : InflictedDamageResponse + { + } +} \ No newline at end of file Added: src/RPGWorldModel.Abstracts/IDefender.cs =================================================================== --- src/RPGWorldModel.Abstracts/IDefender.cs (rev 0) +++ src/RPGWorldModel.Abstracts/IDefender.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -0,0 +1,11 @@ +using System; + +namespace RPGWorldModel.Abstracts.Interfaces +{ + /// <summary> + /// Interface for any entity that can defend (accept) and attack + /// </summary> + public interface IDefender + { + } +} \ No newline at end of file Modified: src/RPGWorldModel.Abstracts/Knife.cs =================================================================== --- src/RPGWorldModel.Abstracts/Knife.cs 2006-07-16 09:15:26 UTC (rev 19) +++ src/RPGWorldModel.Abstracts/Knife.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -19,28 +19,6 @@ } } - public override void InitializeDamageInflictor() - { - // Preadding required descriptors - addDamageDescriptorIfNotExisting(new DamageDescriptorPhysical()); - - foreach (DamageDescriptor damageDescriptor in damageDescriptors.Values) - { - if (!damageDescriptor.IsInitialized && damageDescriptor is DamageDescriptorPhysical) - { - damageDescriptor.BaseMinDamage = 0; - damageDescriptor.MinDamageMargin = 0; - damageDescriptor.BaseMaxDamage = 0; - damageDescriptor.MaxDamageMargin = 0; - damageDescriptor.IsInitialized = true; - damageDescriptor.RandomizationRequired = true; - } - - if (damageDescriptor.RandomizationRequired) - randomizeDamageDescriptor(damageDescriptor); - } - } - public override void InitializeEquipable() { equipmentLocationDescriptors.Clear(); Modified: src/RPGWorldModel.Abstracts/LiveEntity.cs =================================================================== --- src/RPGWorldModel.Abstracts/LiveEntity.cs 2006-07-16 09:15:26 UTC (rev 19) +++ src/RPGWorldModel.Abstracts/LiveEntity.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -10,12 +10,7 @@ /// </summary> public abstract class LiveEntity : AnimatedEntity, ILiveEntity { - protected HealthPoints hp = new HealthPoints(); - protected LiveEntity() - { - } - #region Initialize Overrides public override void InitializeEntity() @@ -38,6 +33,8 @@ #region ILiveEntity Members + protected HealthPoints hp = new HealthPoints(); + public short MaxHealthPoints { get { return hp.MaxHP; } @@ -71,8 +68,21 @@ hp.CurrentHP = hp.CurrentMaxHP = hp.MaxHP; } - public abstract void InitializeLiveEntity(); + public virtual void InitializeLiveEntity() + { + if (!hp.IsInitialized) + { + // Base values for spider + hp.BaseHP = 0; + hp.HPMargin = 0; + hp.IsInitialized = true; + hp.RandomizationRequired = true; + } + if (hp.RandomizationRequired) + randomizeMaxHealthPoints(); + } + public virtual void SetHealthPoints(HealthPoints newHealthPoints) { if (newHealthPoints == null) Modified: src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj =================================================================== --- src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj 2006-07-16 09:15:26 UTC (rev 19) +++ src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj 2006-07-16 15:05:17 UTC (rev 20) @@ -45,8 +45,10 @@ <Compile Include="Goblin.cs" /> <Compile Include="Human.cs" /> <Compile Include="Humanoid.cs" /> + <Compile Include="IAttacker.cs" /> <Compile Include="IDamagable.cs" /> <Compile Include="IDamageInflictor.cs" /> + <Compile Include="IDefender.cs" /> <Compile Include="IEquip.cs" /> <Compile Include="IEquipable.cs" /> <Compile Include="ILiveEntity.cs" /> Modified: src/RPGWorldModel.Abstracts/Spider.cs =================================================================== --- src/RPGWorldModel.Abstracts/Spider.cs 2006-07-16 09:15:26 UTC (rev 19) +++ src/RPGWorldModel.Abstracts/Spider.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -3,6 +3,7 @@ using System.Text; using RPGWorldModel.Abstracts.Entities.LiveEntities; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.TopLevelImplementation.Entities.LiveEntities { @@ -24,15 +25,30 @@ if (!hp.IsInitialized) { // Base values for spider - hp.BaseHP = 40; - hp.HPMargin = 10; + hp.BaseHP = 0; + hp.HPMargin = 0; hp.IsInitialized = true; hp.RandomizationRequired = true; } - if (hp.RandomizationRequired) - randomizeMaxHealthPoints(); + base.InitializeLiveEntity(); } + + public override void InitializeDamageInflictor() + { + DamageDescriptor phy = new DamageDescriptorPhysical(); + phy.BaseMaxDamage = 0; + phy.BaseMinDamage = 0; + phy.MaxDamageMargin = 0; + phy.MinDamageMargin = 0; + phy.IsInitialized = true; + phy.RandomizationRequired = true; + + addDamageDescriptorIfNotExisting(phy); + + base.InitializeDamageInflictor(); + } + #endregion } Modified: src/RPGWorldModel.Abstracts/Sword.cs =================================================================== --- src/RPGWorldModel.Abstracts/Sword.cs 2006-07-16 09:15:26 UTC (rev 19) +++ src/RPGWorldModel.Abstracts/Sword.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -21,28 +21,6 @@ } } - public override void InitializeDamageInflictor() - { - // Preadding required descriptors - addDamageDescriptorIfNotExisting(new DamageDescriptorPhysical()); - - foreach (DamageDescriptor damageDescriptor in damageDescriptors.Values) - { - if (!damageDescriptor.IsInitialized && damageDescriptor is DamageDescriptorPhysical) - { - damageDescriptor.BaseMinDamage = 0; - damageDescriptor.MinDamageMargin = 0; - damageDescriptor.BaseMaxDamage = 0; - damageDescriptor.MaxDamageMargin = 0; - damageDescriptor.IsInitialized = true; - damageDescriptor.RandomizationRequired = true; - } - - if (damageDescriptor.RandomizationRequired) - randomizeDamageDescriptor(damageDescriptor); - } - } - public override void InitializeEquipable() { equipmentLocationDescriptors.Clear(); Modified: src/RPGWorldModel.Abstracts/Weapon.cs =================================================================== --- src/RPGWorldModel.Abstracts/Weapon.cs 2006-07-16 09:15:26 UTC (rev 19) +++ src/RPGWorldModel.Abstracts/Weapon.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -33,7 +33,15 @@ #region IDamageInflictor Members - public abstract void InitializeDamageInflictor(); + public virtual void InitializeDamageInflictor() + { + foreach (DamageDescriptor damageDescriptor in damageDescriptors.Values) + { + // Randomizing damage descriptors + if (damageDescriptor.RandomizationRequired) + randomizeDamageDescriptor(damageDescriptor); + } + } public virtual void AddDamage(DamageDescriptor descriptor) { Added: src/RPGWorldModel.Implementation/Goblins.cs =================================================================== --- src/RPGWorldModel.Implementation/Goblins.cs (rev 0) +++ src/RPGWorldModel.Implementation/Goblins.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -0,0 +1,50 @@ +using System; +using RPGWorldModel.TopLevelImplementation.Entities.LiveEntities; +using RPGWorldModel.Abstracts.Support.Damage; + +namespace RPGWorldModel.Implementation.Entities.LiveEntities.Goblins +{ + public class GoblinWarrior : Goblin + { + + #region Initialize Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Goblin Warrior"; + name.IsInitialized = true; + } + } + + public override void InitializeLiveEntity() + { + if (!hp.IsInitialized) + { + hp.BaseHP = 80; + hp.HPMargin = 20; + hp.IsInitialized = true; + hp.RandomizationRequired = true; + } + + base.InitializeLiveEntity(); + } + + public override void InitializeDamageInflictor() + { + DamageDescriptor phy = new DamageDescriptorPhysical(); + phy.BaseMaxDamage = 10; + phy.BaseMinDamage = 5; + phy.MaxDamageMargin = 15; + phy.MinDamageMargin = 20; + phy.IsInitialized = true; + phy.RandomizationRequired = true; + + addDamageDescriptorIfNotExisting(phy); + + base.InitializeDamageInflictor(); + } + #endregion + } +} \ No newline at end of file Added: src/RPGWorldModel.Implementation/Humans.cs =================================================================== --- src/RPGWorldModel.Implementation/Humans.cs (rev 0) +++ src/RPGWorldModel.Implementation/Humans.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -0,0 +1,97 @@ +using System; +using RPGWorldModel.TopLevelImplementation.Entities.LiveEntities; +using RPGWorldModel.Abstracts.Support.Damage; + +namespace RPGWorldModel.Implementation.Entities.LiveEntities.Humans +{ + public class HumanSoldier : Human + { + #region Initialize Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Human Soldier"; + name.IsInitialized = true; + } + } + + public override void InitializeLiveEntity() + { + if (!hp.IsInitialized) + { + hp.BaseHP = 100; + hp.HPMargin = 30; + hp.IsInitialized = true; + hp.RandomizationRequired = true; + } + + base.InitializeLiveEntity(); + } + + public override void InitializeDamageInflictor() + { + DamageDescriptor phy = new DamageDescriptorPhysical(); + phy.BaseMaxDamage = 15; + phy.BaseMinDamage = 5; + phy.MaxDamageMargin = 10; + phy.MinDamageMargin = 10; + phy.IsInitialized = true; + phy.RandomizationRequired = true; + + addDamageDescriptorIfNotExisting(phy); + + base.InitializeDamageInflictor(); + } + + #endregion + } + + public class HumanPlayerCharacter : Human + { + #region Initialize Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Human Player Character"; + name.IsInitialized = true; + } + } + + public override void InitializeLiveEntity() + { + // TODO : based on stats, etc + if (!hp.IsInitialized) + { + hp.BaseHP = 100; + hp.HPMargin = 0; + hp.CurrentMaxHP = hp.CurrentHP = 100; + hp.IsInitialized = true; + hp.RandomizationRequired = false; + } + + base.InitializeLiveEntity(); + } + + public override void InitializeDamageInflictor() + { + // TODO : based on stats + DamageDescriptor phy = new DamageDescriptorPhysical(); + phy.BaseMaxDamage = 15; + phy.BaseMinDamage = 5; + phy.MaxDamageMargin = 0; + phy.MinDamageMargin = 0; + phy.IsInitialized = true; + phy.RandomizationRequired = false; + + addDamageDescriptorIfNotExisting(phy); + + base.InitializeDamageInflictor(); + } + + #endregion + } +} \ No newline at end of file Modified: src/RPGWorldModel.Implementation/RPGWorldModel.Implementation.csproj =================================================================== --- src/RPGWorldModel.Implementation/RPGWorldModel.Implementation.csproj 2006-07-16 09:15:26 UTC (rev 19) +++ src/RPGWorldModel.Implementation/RPGWorldModel.Implementation.csproj 2006-07-16 15:05:17 UTC (rev 20) @@ -34,10 +34,13 @@ </ItemGroup> <ItemGroup> <Compile Include="Clubs.cs" /> + <Compile Include="Goblins.cs" /> + <Compile Include="Humans.cs" /> <Compile Include="Knifes.cs" /> <Compile Include="Pants.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Shirts.cs" /> + <Compile Include="Spiders.cs" /> <Compile Include="Swords.cs" /> </ItemGroup> <ItemGroup> Added: src/RPGWorldModel.Implementation/Spiders.cs =================================================================== --- src/RPGWorldModel.Implementation/Spiders.cs (rev 0) +++ src/RPGWorldModel.Implementation/Spiders.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -0,0 +1,52 @@ +using System; +using RPGWorldModel.TopLevelImplementation.Entities.LiveEntities; +using RPGWorldModel.Abstracts.Support.Damage; + +namespace RPGWorldModel.Implementation.Entities.LiveEntities.Spiders +{ + public class SmallSpider : Spider + { + #region Initialize Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Small Spider"; + name.IsInitialized = true; + } + } + + public override void InitializeLiveEntity() + { + if (!hp.IsInitialized) + { + // Base values for spider + hp.BaseHP = 20; + hp.HPMargin = 10; + hp.IsInitialized = true; + hp.RandomizationRequired = true; + } + + base.InitializeLiveEntity(); + } + + public override void InitializeDamageInflictor() + { + DamageDescriptor phy = new DamageDescriptorPhysical(); + phy.BaseMaxDamage = 7; + phy.BaseMinDamage = 3; + phy.MaxDamageMargin = 20; + phy.MinDamageMargin = 10; + phy.IsInitialized = true; + phy.RandomizationRequired = true; + + addDamageDescriptorIfNotExisting(phy); + + base.InitializeDamageInflictor(); + } + + #endregion + + } +} \ No newline at end of file Modified: src/test_applications/tester/Form1.cs =================================================================== --- src/test_applications/tester/Form1.cs 2006-07-16 09:15:26 UTC (rev 19) +++ src/test_applications/tester/Form1.cs 2006-07-16 15:05:17 UTC (rev 20) @@ -19,6 +19,9 @@ using RPGWorldModel.Implementation.Entities.Items.Clubs; using RPGWorldModel.Implementation.Entities.Items.Knifes; using RPGWorldModel.Abstracts.Support.Damage; +using RPGWorldModel.Implementation.Entities.LiveEntities.Spiders; +using RPGWorldModel.Implementation.Entities.LiveEntities.Goblins; +using RPGWorldModel.Implementation.Entities.LiveEntities.Humans; /* * This is a simple WinForms application for testing features added to the framework. @@ -86,13 +89,13 @@ switch (enemySelect) { case(0): - enemy = new Goblin(); + enemy = new GoblinWarrior(); break; case(1): - enemy = new Human(); + enemy = new HumanSoldier(); break; case(2): - enemy = new Spider(); + enemy = new SmallSpider(); break; } @@ -100,7 +103,7 @@ - player = new Human(); + player = new HumanPlayerCharacter(); Name name = new Name(); name.Value = "Player"; name.IsInitialized = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |