rpgworldmodel-commits Mailing List for RPGWorldModel
Status: Inactive
Brought to you by:
deadwood_pl
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(12) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(7) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dea...@us...> - 2014-05-31 20:06:19
|
Revision: 27 http://sourceforge.net/p/rpgworldmodel/code/27 Author: deadwood_pl Date: 2014-05-31 20:06:12 +0000 (Sat, 31 May 2014) Log Message: ----------- another test Modified Paths: -------------- src/RPGWorldModel.Implementation/Clubs.cs Modified: src/RPGWorldModel.Implementation/Clubs.cs =================================================================== --- src/RPGWorldModel.Implementation/Clubs.cs 2014-05-31 18:41:04 UTC (rev 26) +++ src/RPGWorldModel.Implementation/Clubs.cs 2014-05-31 20:06:12 UTC (rev 27) @@ -4,6 +4,7 @@ using RPGWorldModel.Abstracts.Interfaces; using RPGWorldModel.Abstracts.Support.Damage; +// namespace RPGWorldModel.Implementation.Entities.Items.Clubs { /// <summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dea...@us...> - 2014-05-31 18:41:06
|
Revision: 26 http://sourceforge.net/p/rpgworldmodel/code/26 Author: deadwood_pl Date: 2014-05-31 18:41:04 +0000 (Sat, 31 May 2014) Log Message: ----------- test comment removed Modified Paths: -------------- src/RPGWorldModel.Implementation/Clubs.cs Modified: src/RPGWorldModel.Implementation/Clubs.cs =================================================================== --- src/RPGWorldModel.Implementation/Clubs.cs 2014-05-31 18:40:35 UTC (rev 25) +++ src/RPGWorldModel.Implementation/Clubs.cs 2014-05-31 18:41:04 UTC (rev 26) @@ -4,7 +4,6 @@ using RPGWorldModel.Abstracts.Interfaces; using RPGWorldModel.Abstracts.Support.Damage; -// comment namespace RPGWorldModel.Implementation.Entities.Items.Clubs { /// <summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dea...@us...> - 2014-05-31 18:40:40
|
Revision: 25 http://sourceforge.net/p/rpgworldmodel/code/25 Author: deadwood_pl Date: 2014-05-31 18:40:35 +0000 (Sat, 31 May 2014) Log Message: ----------- test comment Modified Paths: -------------- src/RPGWorldModel.Implementation/Clubs.cs Modified: src/RPGWorldModel.Implementation/Clubs.cs =================================================================== --- src/RPGWorldModel.Implementation/Clubs.cs 2014-05-27 19:24:23 UTC (rev 24) +++ src/RPGWorldModel.Implementation/Clubs.cs 2014-05-31 18:40:35 UTC (rev 25) @@ -4,6 +4,7 @@ using RPGWorldModel.Abstracts.Interfaces; using RPGWorldModel.Abstracts.Support.Damage; +// comment namespace RPGWorldModel.Implementation.Entities.Items.Clubs { /// <summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dea...@us...> - 2014-05-27 19:24:26
|
Revision: 24 http://sourceforge.net/p/rpgworldmodel/code/24 Author: deadwood_pl Date: 2014-05-27 19:24:23 +0000 (Tue, 27 May 2014) Log Message: ----------- clean up Modified Paths: -------------- src/RPGWorldModel.Implementation/Humans.cs Modified: src/RPGWorldModel.Implementation/Humans.cs =================================================================== --- src/RPGWorldModel.Implementation/Humans.cs 2014-05-27 19:23:41 UTC (rev 23) +++ src/RPGWorldModel.Implementation/Humans.cs 2014-05-27 19:24:23 UTC (rev 24) @@ -2,7 +2,6 @@ using RPGWorldModel.TopLevelImplementation.Entities.LiveEntities; using RPGWorldModel.Abstracts.Support.Damage; -// comment namespace RPGWorldModel.Implementation.Entities.LiveEntities.Humans { public class HumanSoldier : Human This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dea...@us...> - 2014-05-27 19:23:44
|
Revision: 23 http://sourceforge.net/p/rpgworldmodel/code/23 Author: deadwood_pl Date: 2014-05-27 19:23:41 +0000 (Tue, 27 May 2014) Log Message: ----------- clean up Modified Paths: -------------- src/RPGWorldModel.Implementation/Pants.cs Modified: src/RPGWorldModel.Implementation/Pants.cs =================================================================== --- src/RPGWorldModel.Implementation/Pants.cs 2014-05-27 18:05:31 UTC (rev 22) +++ src/RPGWorldModel.Implementation/Pants.cs 2014-05-27 19:23:41 UTC (rev 23) @@ -1,7 +1,6 @@ using System; using RPGWorldModel.TopLevelImplementation.Entities.Items; -// comment namespace RPGWorldModel.Implementation.Entities.Items.Pants { public class CottonPants : RPGWorldModel.TopLevelImplementation.Entities.Items.Pants This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dea...@us...> - 2014-05-27 18:05:35
|
Revision: 22 http://sourceforge.net/p/rpgworldmodel/code/22 Author: deadwood_pl Date: 2014-05-27 18:05:31 +0000 (Tue, 27 May 2014) Log Message: ----------- second test Modified Paths: -------------- src/RPGWorldModel.Implementation/Humans.cs Modified: src/RPGWorldModel.Implementation/Humans.cs =================================================================== --- src/RPGWorldModel.Implementation/Humans.cs 2014-05-27 18:03:01 UTC (rev 21) +++ src/RPGWorldModel.Implementation/Humans.cs 2014-05-27 18:05:31 UTC (rev 22) @@ -2,6 +2,7 @@ using RPGWorldModel.TopLevelImplementation.Entities.LiveEntities; using RPGWorldModel.Abstracts.Support.Damage; +// comment namespace RPGWorldModel.Implementation.Entities.LiveEntities.Humans { public class HumanSoldier : Human This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dea...@us...> - 2014-05-27 18:03:11
|
Revision: 21 http://sourceforge.net/p/rpgworldmodel/code/21 Author: deadwood_pl Date: 2014-05-27 18:03:01 +0000 (Tue, 27 May 2014) Log Message: ----------- ss Modified Paths: -------------- src/RPGWorldModel.Implementation/Pants.cs Modified: src/RPGWorldModel.Implementation/Pants.cs =================================================================== --- src/RPGWorldModel.Implementation/Pants.cs 2006-07-16 15:05:17 UTC (rev 20) +++ src/RPGWorldModel.Implementation/Pants.cs 2014-05-27 18:03:01 UTC (rev 21) @@ -1,6 +1,7 @@ using System; using RPGWorldModel.TopLevelImplementation.Entities.Items; +// comment namespace RPGWorldModel.Implementation.Entities.Items.Pants { public class CottonPants : RPGWorldModel.TopLevelImplementation.Entities.Items.Pants 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. |
From: <dea...@us...> - 2006-07-16 09:16:04
|
Revision: 19 Author: deadwood_pl Date: 2006-07-16 02:15:26 -0700 (Sun, 16 Jul 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=19&view=rev Log Message: ----------- Reorganization in namespaces connected with damage. Modified Paths: -------------- src/RPGWorldModel.Abstracts/Club.cs src/RPGWorldModel.Abstracts/IDamagable.cs src/RPGWorldModel.Abstracts/IDamageInflictor.cs src/RPGWorldModel.Abstracts/ILiveEntity.cs src/RPGWorldModel.Abstracts/INamedEntity.cs src/RPGWorldModel.Abstracts/Initializable.cs src/RPGWorldModel.Abstracts/Knife.cs src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj src/RPGWorldModel.Abstracts/Sword.cs src/RPGWorldModel.Abstracts/Weapon.cs src/RPGWorldModel.Implementation/Clubs.cs src/RPGWorldModel.Implementation/Knifes.cs src/RPGWorldModel.Implementation/Swords.cs src/test_applications/tester/Form1.cs Added Paths: ----------- src/RPGWorldModel.Abstracts/DamageDescriptor.cs src/RPGWorldModel.Abstracts/InflictedDamage.cs Modified: src/RPGWorldModel.Abstracts/Club.cs =================================================================== --- src/RPGWorldModel.Abstracts/Club.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/Club.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -2,6 +2,7 @@ using RPGWorldModel.Abstracts.Entities.Items; using RPGWorldModel.Abstracts.Support.Equipment; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.TopLevelImplementation.Entities.Items { Added: src/RPGWorldModel.Abstracts/DamageDescriptor.cs =================================================================== --- src/RPGWorldModel.Abstracts/DamageDescriptor.cs (rev 0) +++ src/RPGWorldModel.Abstracts/DamageDescriptor.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using RPGWorldModel.Abstracts.Support.Misc; + +namespace RPGWorldModel.Abstracts.Support.Damage +{ + /// <summary> + /// Dictionary of DamageDescriptor object indexed by type + /// </summary> + public class DamageDescriptorDictionary : Dictionary<Type, DamageDescriptor> + { + } + + public abstract class DamageDescriptor : Initializable + { + private short minDamage = 0; + public short MinDamage + { + get { return minDamage; } + set { minDamage = value; } + } + + private short maxDamage = 0; + public short MaxDamage + { + get { return maxDamage; } + set { maxDamage = value; } + } + + /* + * Base values + */ + + private short baseMinDamage = 0; + public short BaseMinDamage + { + get { return baseMinDamage; } + set { baseMinDamage = value; } + } + + private byte minDamageMargin = 0; + public byte MinDamageMargin + { + get { return minDamageMargin; } + set { minDamageMargin = value; } + } + + private short baseMaxDamage = 0; + public short BaseMaxDamage + { + get { return baseMaxDamage; } + set { baseMaxDamage = value; } + } + + private byte maxDamageMargin = 0; + public byte MaxDamageMargin + { + get { return maxDamageMargin; } + set { maxDamageMargin = value; } + } + + /// <summary> + /// Creates an instance of specified inflicted damage type + /// </summary> + /// <returns></returns> + public abstract InflictedDamage CreateInflictedDamage(); + } + + /* + * Concrete types of damage + */ + + public class DamageDescriptorPhysical : DamageDescriptor + { + public override InflictedDamage CreateInflictedDamage() + { + return new InflictedDamagePhysical(); + } + } + + public class DamageDescriptorFire : DamageDescriptor + { + public override InflictedDamage CreateInflictedDamage() + { + return new InflictedDamageFire(); + } + } +} \ No newline at end of file Modified: src/RPGWorldModel.Abstracts/IDamagable.cs =================================================================== --- src/RPGWorldModel.Abstracts/IDamagable.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/IDamagable.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using RPGWorldModel.Abstracts.Support.Misc; namespace RPGWorldModel.Abstracts.Interfaces { Modified: src/RPGWorldModel.Abstracts/IDamageInflictor.cs =================================================================== --- src/RPGWorldModel.Abstracts/IDamageInflictor.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/IDamageInflictor.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.Abstracts.Interfaces { @@ -17,148 +18,12 @@ /// Gets all types of inflicted damages along with values /// </summary> /// <returns></returns> - InflictedDamageResponse GetInflictedDamage(); + DamageInflictorInflictedDamageResponse GetInflictedDamage(); } - public abstract class DamageDescriptor : Initializable + public class DamageInflictorInflictedDamageResponse : InflictedDamageResponse { - private short minDamage = 0; - public short MinDamage - { - get { return minDamage; } - set { minDamage = value; } - } - - private short maxDamage = 0; - public short MaxDamage - { - get { return maxDamage; } - set { maxDamage = value; } - } - - /* - * Base values - */ - - private short baseMinDamage = 0; - public short BaseMinDamage - { - get { return baseMinDamage; } - set { baseMinDamage = value; } - } - - private byte minDamageMargin = 0; - public byte MinDamageMargin - { - get { return minDamageMargin; } - set { minDamageMargin = value; } - } - - private short baseMaxDamage = 0; - public short BaseMaxDamage - { - get { return baseMaxDamage; } - set { baseMaxDamage = value; } - } - - private byte maxDamageMargin = 0; - public byte MaxDamageMargin - { - get { return maxDamageMargin; } - set { maxDamageMargin = value; } - } - - /// <summary> - /// Creates an instance of specified inflicted damage type - /// </summary> - /// <returns></returns> - public abstract InflictedDamage CreateInflictedDamage(); } - /// <summary> - /// Dictionary of DamageDescriptor object indexed by type - /// </summary> - public class DamageDescriptorDictionary : Dictionary<Type, DamageDescriptor> - { - } - public class InflictedDamageResponse - { - protected InflictedDamageList inflictedDamages = new InflictedDamageList(); - - public void Add(InflictedDamage inflictedDamage) - { - inflictedDamages.Add(inflictedDamage); - } - - public IEnumerable<InflictedDamage> InflictedDamages - { - get { return inflictedDamages; } - } - } - - /// <summary> - /// Holds damage inflicted by an entity - /// </summary> - public abstract class InflictedDamage - { - private short minDamage = 0; - public virtual short MinDamage - { - get { return minDamage; } - } - - private short maxDamage = 0; - public virtual short MaxDamage - { - get { return maxDamage; } - } - - protected InflictedDamage() - { - } - - public virtual void SetDamage(short minDamage, short maxDamage) - { - if (minDamage > maxDamage) - throw new ArgumentException("minDamage must not be greater than maxDamage"); - - this.minDamage = minDamage; - this.maxDamage = maxDamage; - } - - - } - - public class InflictedDamageList : List<InflictedDamage> - { - } - - /* - * Concrete types of damage - */ - - public class DamageDescriptorPhysical : DamageDescriptor - { - public override InflictedDamage CreateInflictedDamage() - { - return new InflictedDamagePhysical(); - } - } - - public class InflictedDamagePhysical : InflictedDamage - { - } - - public class DamageDescriptorFire : DamageDescriptor - { - public override InflictedDamage CreateInflictedDamage() - { - return new InflictedDamageFire(); - } - } - - public class InflictedDamageFire : InflictedDamage - { - } } Modified: src/RPGWorldModel.Abstracts/ILiveEntity.cs =================================================================== --- src/RPGWorldModel.Abstracts/ILiveEntity.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/ILiveEntity.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using RPGWorldModel.Abstracts.Support.Misc; namespace RPGWorldModel.Abstracts.Interfaces { Modified: src/RPGWorldModel.Abstracts/INamedEntity.cs =================================================================== --- src/RPGWorldModel.Abstracts/INamedEntity.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/INamedEntity.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using RPGWorldModel.Abstracts.Support.Misc; namespace RPGWorldModel.Abstracts.Interfaces { Added: src/RPGWorldModel.Abstracts/InflictedDamage.cs =================================================================== --- src/RPGWorldModel.Abstracts/InflictedDamage.cs (rev 0) +++ src/RPGWorldModel.Abstracts/InflictedDamage.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; + +namespace RPGWorldModel.Abstracts.Support.Damage +{ + /// <summary> + /// Holds damage inflicted by an entity + /// </summary> + public abstract class InflictedDamage + { + private short minDamage = 0; + public virtual short MinDamage + { + get { return minDamage; } + } + + private short maxDamage = 0; + public virtual short MaxDamage + { + get { return maxDamage; } + } + + protected InflictedDamage() + { + } + + public virtual void SetDamage(short minDamage, short maxDamage) + { + if (minDamage > maxDamage) + throw new ArgumentException("minDamage must not be greater than maxDamage"); + + this.minDamage = minDamage; + this.maxDamage = maxDamage; + } + + + } + + public class InflictedDamageList : List<InflictedDamage> + { + } + + public class InflictedDamageDictionaty : Dictionary<Type, InflictedDamage> + { + } + + public class InflictedDamageResponse + { + protected InflictedDamageDictionaty inflictedDamages = new InflictedDamageDictionaty(); + + public virtual void Set(InflictedDamage inflictedDamage) + { + inflictedDamages[inflictedDamage.GetType()] = inflictedDamage; + } + + public virtual void Sum(InflictedDamage inflictedDamage) + { + InflictedDamage existing = inflictedDamages[inflictedDamage.GetType()]; + + if (existing == null) + Set(inflictedDamage); + else + { + existing.SetDamage( + (short)(existing.MinDamage + inflictedDamage.MinDamage), + (short)(existing.MaxDamage + inflictedDamage.MaxDamage)); + } + } + + public IEnumerable<InflictedDamage> InflictedDamages + { + get { return inflictedDamages.Values; } + } + } + + public class InflictedDamagePhysical : InflictedDamage + { + } + + public class InflictedDamageFire : InflictedDamage + { + } +} \ No newline at end of file Modified: src/RPGWorldModel.Abstracts/Initializable.cs =================================================================== --- src/RPGWorldModel.Abstracts/Initializable.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/Initializable.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace RPGWorldModel.Abstracts.Interfaces +namespace RPGWorldModel.Abstracts.Support.Misc { public class Initializable { Modified: src/RPGWorldModel.Abstracts/Knife.cs =================================================================== --- src/RPGWorldModel.Abstracts/Knife.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/Knife.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -2,6 +2,7 @@ using RPGWorldModel.Abstracts.Entities.Items; using RPGWorldModel.Abstracts.Support.Equipment; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.TopLevelImplementation.Entities.Items { Modified: src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj =================================================================== --- src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj 2006-07-16 09:15:26 UTC (rev 19) @@ -38,6 +38,7 @@ <Compile Include="Arachnid.cs" /> <Compile Include="Clothing.cs" /> <Compile Include="Club.cs" /> + <Compile Include="DamageDescriptor.cs" /> <Compile Include="EquipmentLocation.cs" /> <Compile Include="EquipmentSlot.cs" /> <Compile Include="GameEntity.cs" /> @@ -52,6 +53,7 @@ <Compile Include="IMagicEntity.cs" /> <Compile Include="INamedEntity.cs" /> <Compile Include="InAnimatedEntity.cs" /> + <Compile Include="InflictedDamage.cs" /> <Compile Include="Initializable.cs" /> <Compile Include="Item.cs" /> <Compile Include="Knife.cs" /> Modified: src/RPGWorldModel.Abstracts/Sword.cs =================================================================== --- src/RPGWorldModel.Abstracts/Sword.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/Sword.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -4,6 +4,7 @@ using RPGWorldModel.Abstracts.Interfaces; using RPGWorldModel.Abstracts.Entities.Items; using RPGWorldModel.Abstracts.Support.Equipment; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.TopLevelImplementation.Entities.Items { Modified: src/RPGWorldModel.Abstracts/Weapon.cs =================================================================== --- src/RPGWorldModel.Abstracts/Weapon.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/Weapon.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Text; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Misc; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.Abstracts.Entities.Items { @@ -47,9 +49,10 @@ /// Default implementation with all damages beeing changed by durability /// </summary> /// <returns></returns> - public virtual InflictedDamageResponse GetInflictedDamage() + public virtual DamageInflictorInflictedDamageResponse GetInflictedDamage() { - InflictedDamageResponse response = new InflictedDamageResponse(); + DamageInflictorInflictedDamageResponse response = + new DamageInflictorInflictedDamageResponse(); short min = 0; short max = 0; @@ -63,7 +66,7 @@ damage.SetDamage(min, max); - response.Add(damage); + response.Set(damage); } Modified: src/RPGWorldModel.Implementation/Clubs.cs =================================================================== --- src/RPGWorldModel.Implementation/Clubs.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Implementation/Clubs.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -2,6 +2,7 @@ using RPGWorldModel.Abstracts.Entities.Items; using RPGWorldModel.TopLevelImplementation.Entities.Items; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.Implementation.Entities.Items.Clubs { Modified: src/RPGWorldModel.Implementation/Knifes.cs =================================================================== --- src/RPGWorldModel.Implementation/Knifes.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Implementation/Knifes.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -2,6 +2,7 @@ using RPGWorldModel.Abstracts.Entities.Items; using RPGWorldModel.TopLevelImplementation.Entities.Items; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.Implementation.Entities.Items.Knifes { Modified: src/RPGWorldModel.Implementation/Swords.cs =================================================================== --- src/RPGWorldModel.Implementation/Swords.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Implementation/Swords.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -2,6 +2,7 @@ using RPGWorldModel.Abstracts.Entities.Items; using RPGWorldModel.TopLevelImplementation.Entities.Items; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.Implementation.Entities.Items.Swords { Modified: src/test_applications/tester/Form1.cs =================================================================== --- src/test_applications/tester/Form1.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/test_applications/tester/Form1.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -18,6 +18,7 @@ using RPGWorldModel.Implementation.Entities.Items.Pants; using RPGWorldModel.Implementation.Entities.Items.Clubs; using RPGWorldModel.Implementation.Entities.Items.Knifes; +using RPGWorldModel.Abstracts.Support.Damage; /* * This is a simple WinForms application for testing features added to the framework. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dea...@us...> - 2006-07-15 16:39:18
|
Revision: 18 Author: deadwood_pl Date: 2006-07-15 09:39:03 -0700 (Sat, 15 Jul 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=18&view=rev Log Message: ----------- Support for unequipping entities. Modified Paths: -------------- src/RPGWorldModel.Abstracts/Animal.cs src/RPGWorldModel.Abstracts/AnimatedEntity.cs src/RPGWorldModel.Abstracts/EquipmentSlot.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: src/RPGWorldModel.Abstracts/Animal.cs =================================================================== --- src/RPGWorldModel.Abstracts/Animal.cs 2006-07-15 13:38:17 UTC (rev 17) +++ src/RPGWorldModel.Abstracts/Animal.cs 2006-07-15 16:39:03 UTC (rev 18) @@ -32,6 +32,14 @@ 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-15 13:38:17 UTC (rev 17) +++ src/RPGWorldModel.Abstracts/AnimatedEntity.cs 2006-07-15 16:39:03 UTC (rev 18) @@ -23,6 +23,8 @@ public abstract EquipResponse Equip(EquipRequest request); + public abstract UnEquipResponse UnEquip(UnEquipRequest request); + public abstract void InitializeEquip(); #endregion Modified: src/RPGWorldModel.Abstracts/EquipmentSlot.cs =================================================================== --- src/RPGWorldModel.Abstracts/EquipmentSlot.cs 2006-07-15 13:38:17 UTC (rev 17) +++ src/RPGWorldModel.Abstracts/EquipmentSlot.cs 2006-07-15 16:39:03 UTC (rev 18) @@ -29,6 +29,11 @@ equippedEntities.Remove(equipable); } + public bool ContainsEquipable(IEquipable equipable) + { + return equippedEntities.Contains(equipable); + } + public abstract string SlotName { get; Modified: src/RPGWorldModel.Abstracts/Humanoid.cs =================================================================== --- src/RPGWorldModel.Abstracts/Humanoid.cs 2006-07-15 13:38:17 UTC (rev 17) +++ src/RPGWorldModel.Abstracts/Humanoid.cs 2006-07-15 16:39:03 UTC (rev 18) @@ -140,6 +140,35 @@ return response; } + public override UnEquipResponse UnEquip(UnEquipRequest request) + { + UnEquipResponse response = new UnEquipResponse(); + response.Status = UnEquipStatus.Undefined; + + EquipmentSlotList affectedSlots = new EquipmentSlotList(); + + foreach (EquipmentSlot slot in equipmentSlots) + { + if (slot.ContainsEquipable(request.RequestedEquipable)) + affectedSlots.Add(slot); + } + + if (affectedSlots.Count == 0) + { + // Not equipped + response.Status = UnEquipStatus.NotUnEquippedEquipableNotEquipped; + } + else + { + // Remove the equipable + foreach(EquipmentSlot slot in affectedSlots) + slot.RemoveEquipable(request.RequestedEquipable); + + response.Status = UnEquipStatus.UnEquipped; + } + + return response; + } } public abstract class HumanoidAdvanced : Humanoid Modified: src/RPGWorldModel.Abstracts/IEquip.cs =================================================================== --- src/RPGWorldModel.Abstracts/IEquip.cs 2006-07-15 13:38:17 UTC (rev 17) +++ src/RPGWorldModel.Abstracts/IEquip.cs 2006-07-15 16:39:03 UTC (rev 18) @@ -15,6 +15,9 @@ // Equip an entity EquipResponse Equip(EquipRequest request); + // UnEquip an entity + UnEquipResponse UnEquip(UnEquipRequest request); + // Initialized equip interface implementation void InitializeEquip(); } @@ -37,6 +40,16 @@ } } + public class UnEquipRequest + { + private IEquipable requestedEquipable = null; + public IEquipable RequestedEquipable + { + get { return requestedEquipable; } + set { requestedEquipable = value; } + } + } + /// <summary> /// A response to equip request /// </summary> @@ -59,6 +72,17 @@ } } + public class UnEquipResponse + { + private UnEquipStatus status = UnEquipStatus.Undefined; + + public UnEquipStatus Status + { + get { return status; } + set { status = value; } + } + } + public enum EquipStatus { Undefined, @@ -70,4 +94,12 @@ NotEquippedSlotNotPartOfEntity, NotEquippedNotAbleToEquipToAdditionalSlots } + + public enum UnEquipStatus + { + Undefined, + UnEquipped, + NotUnEquippedEquipableNotEquipped, + NotUnEquippedNotAbleToUnEquipAnyEntities + } } Modified: src/test_applications/tester/Form1.Designer.cs =================================================================== --- src/test_applications/tester/Form1.Designer.cs 2006-07-15 13:38:17 UTC (rev 17) +++ src/test_applications/tester/Form1.Designer.cs 2006-07-15 16:39:03 UTC (rev 18) @@ -59,6 +59,7 @@ this.btnItemRapair = new System.Windows.Forms.Button(); this.btnItemDamage = new System.Windows.Forms.Button(); this.tabPage3 = new System.Windows.Forms.TabPage(); + this.btnUnEquip = new System.Windows.Forms.Button(); this.label4 = new System.Windows.Forms.Label(); this.btnEquipaSelected = new System.Windows.Forms.Button(); this.lvAvailableItems = new System.Windows.Forms.ListView(); @@ -66,6 +67,7 @@ this.btnHumanCreate = new System.Windows.Forms.Button(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components); + this.label5 = new System.Windows.Forms.Label(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage2.SuspendLayout(); @@ -343,6 +345,8 @@ // // tabPage3 // + this.tabPage3.Controls.Add(this.label5); + this.tabPage3.Controls.Add(this.btnUnEquip); this.tabPage3.Controls.Add(this.label4); this.tabPage3.Controls.Add(this.btnEquipaSelected); this.tabPage3.Controls.Add(this.lvAvailableItems); @@ -356,6 +360,16 @@ this.tabPage3.Text = "Equip"; this.tabPage3.UseVisualStyleBackColor = true; // + // btnUnEquip + // + this.btnUnEquip.Location = new System.Drawing.Point(419, 342); + this.btnUnEquip.Name = "btnUnEquip"; + this.btnUnEquip.Size = new System.Drawing.Size(75, 23); + this.btnUnEquip.TabIndex = 6; + this.btnUnEquip.Text = "UnEquip"; + this.btnUnEquip.UseVisualStyleBackColor = true; + this.btnUnEquip.Click += new System.EventHandler(this.btnUnEquip_Click); + // // label4 // this.label4.AutoSize = true; @@ -419,6 +433,16 @@ // this.errorProvider1.ContainerControl = this; // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.label5.Location = new System.Drawing.Point(319, 312); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(157, 13); + this.label5.TabIndex = 7; + this.label5.Text = "Select item, click UnEquip"; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -480,6 +504,8 @@ private System.Windows.Forms.ListView lvAvailableItems; private System.Windows.Forms.Button btnEquipaSelected; private System.Windows.Forms.Label label4; + private System.Windows.Forms.Button btnUnEquip; + private System.Windows.Forms.Label label5; } } Modified: src/test_applications/tester/Form1.cs =================================================================== --- src/test_applications/tester/Form1.cs 2006-07-15 13:38:17 UTC (rev 17) +++ src/test_applications/tester/Form1.cs 2006-07-15 16:39:03 UTC (rev 18) @@ -543,11 +543,16 @@ if (equipTest == null) return; + EquipmentSlotTreeNode slotNode = tvEquipmentSlots.SelectedNode as EquipmentSlotTreeNode; + + if (slotNode == null) + return; + IEquipable selectedEquipable = (lvAvailableItems.SelectedItems[0] as EquipableListViewItem).Equipable; - + EquipmentSlot slot = - (tvEquipmentSlots.SelectedNode as EquipmentSlotTreeNode).Slot; + slotNode.Slot; EquipRequest request = new EquipRequest(); request.RequestedEquipable = selectedEquipable; @@ -575,6 +580,39 @@ refreshEquip(); } + + private void btnUnEquip_Click(object sender, EventArgs e) + { + if (tvEquipmentSlots.SelectedNode == null) + return; + + if (equipTest == null) + return; + + EquipableTreeNode equipableNode = (tvEquipmentSlots.SelectedNode as EquipableTreeNode); + + if (equipableNode == null) + return; + + UnEquipRequest request = new UnEquipRequest(); + request.RequestedEquipable = equipableNode.Equipable; + + UnEquipResponse response = equipTest.UnEquip(request); + + if (response.Status == UnEquipStatus.NotUnEquippedEquipableNotEquipped) + { + MessageBox.Show("Entity is not equipped"); + } + + if (response.Status == UnEquipStatus.UnEquipped) + { + // add to available + availableEquipable.Add(request.RequestedEquipable); + } + + refreshEquip(); + + } } public class EquipmentSlotTreeNode : TreeNode @@ -600,10 +638,31 @@ this.Text = slot.SlotName; foreach (IEquipable equipable in Slot.EquippedEntities) - this.Nodes.Add((equipable as INamedEntity).Name); + this.Nodes.Add(new EquipableTreeNode (equipable)); } } + public class EquipableTreeNode : TreeNode + { + private IEquipable equipable = null; + + public IEquipable Equipable + { + get { return equipable; } + set { equipable = value; } + } + + public EquipableTreeNode(IEquipable equipable) + { + if (equipable == null) + throw new ArgumentException("equipable must not be null", "equipable"); + + Equipable = equipable; + + this.Text = (equipable as INamedEntity).Name; + } + } + public class EquipableListViewItem : ListViewItem { private IEquipable equipable = null; 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-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-14 16:42:56
|
Revision: 15 Author: deadwood_pl Date: 2006-07-14 09:42:36 -0700 (Fri, 14 Jul 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=15&view=rev Log Message: ----------- More work on equipment. Support for multi-slot entites. Modified Paths: -------------- src/RPGWorldModel.Abstracts/EquipmentLocation.cs src/RPGWorldModel.Abstracts/EquipmentSlot.cs src/RPGWorldModel.Abstracts/Humanoid.cs src/RPGWorldModel.Abstracts/IEquip.cs src/RPGWorldModel.Abstracts/Sword.cs src/RPGWorldModel.Implementation/Swords.cs src/test_applications/tester/Form1.Designer.cs src/test_applications/tester/Form1.cs src/test_applications/tester/tester.csproj Modified: src/RPGWorldModel.Abstracts/EquipmentLocation.cs =================================================================== --- src/RPGWorldModel.Abstracts/EquipmentLocation.cs 2006-07-12 17:52:16 UTC (rev 14) +++ src/RPGWorldModel.Abstracts/EquipmentLocation.cs 2006-07-14 16:42:36 UTC (rev 15) @@ -46,6 +46,8 @@ { } + // Locations + public class EquipmentLocationLeftHand : EquipmentLocation { } @@ -61,4 +63,45 @@ public class EquipmentLocationWaist : EquipmentLocation { } + + public class EquipmentLocationHead : EquipmentLocation + { + } + + public class EquipmentLocationFace : EquipmentLocation + { + } + + public class EquipmentLocationTorso : EquipmentLocation + { + } + + public class EquipmentLocationLeftArm : EquipmentLocation + { + } + + public class EquipmentLocationRightArm : EquipmentLocation + { + } + + public class EquipmentLocationLeftLeg : EquipmentLocation + { + } + + public class EquipmentLocationRightLeg : EquipmentLocation + { + } + + public class EquipmentLocationLeftFoot : EquipmentLocation + { + } + + public class EquipmentLocationRightFoot : EquipmentLocation + { + } + + public class EquipmentLocationNeck : EquipmentLocation + { + } + } Modified: src/RPGWorldModel.Abstracts/EquipmentSlot.cs =================================================================== --- src/RPGWorldModel.Abstracts/EquipmentSlot.cs 2006-07-12 17:52:16 UTC (rev 14) +++ src/RPGWorldModel.Abstracts/EquipmentSlot.cs 2006-07-14 16:42:36 UTC (rev 15) @@ -12,21 +12,13 @@ get { return equippedEntities; } } - //TEST - protected EquipmentLocationList acceptableEquipmentLocations = new EquipmentLocationList(); - - public bool IsLocationAcceptable(EquipmentLocation location) + public int EquippedEntitiesCount { - foreach (EquipmentLocation acceptableLocation in acceptableEquipmentLocations) - { - if (acceptableLocation.GetType() == location.GetType()) - return true; - } - - return false; + get { return equippedEntities.Count; } } - // + public abstract bool IsLocationAcceptable(EquipmentLocation location); + public void AddEquipable(IEquipable equipable) { equippedEntities.Add(equipable); @@ -47,15 +39,21 @@ { } + // Slots + public class EquipmentSlotHead : EquipmentSlot { - public EquipmentSlotHead() + public override string SlotName { + get { return "Head"; } } - public override string SlotName + public override bool IsLocationAcceptable(EquipmentLocation location) { - get { return "Head"; } + if (location is EquipmentLocationHead) + return true; + else + return false; } } @@ -65,6 +63,14 @@ { get { return "Face"; } } + + public override bool IsLocationAcceptable(EquipmentLocation location) + { + if (location is EquipmentLocationFace) + return true; + else + return false; + } } public class EquipmentSlotNeck : EquipmentSlot @@ -73,6 +79,14 @@ { get { return "Neck"; } } + + public override bool IsLocationAcceptable(EquipmentLocation location) + { + if (location is EquipmentLocationNeck) + return true; + else + return false; + } } public class EquipmentSlotTorso : EquipmentSlot @@ -81,31 +95,45 @@ { get { return "Torso"; } } + + public override bool IsLocationAcceptable(EquipmentLocation location) + { + if (location is EquipmentLocationTorso) + return true; + else + return false; + } } public class EquipmentSlotWaist : EquipmentSlot { - public EquipmentSlotWaist() + public override string SlotName { - acceptableEquipmentLocations.Add(new EquipmentLocationWaist()); + get { return "Waist"; } } - public override string SlotName + public override bool IsLocationAcceptable(EquipmentLocation location) { - get { return "Waist"; } + if (location is EquipmentLocationWaist) + return true; + else + return false; } } public class EquipmentSlotBack : EquipmentSlot { - public EquipmentSlotBack() + public override string SlotName { - acceptableEquipmentLocations.Add(new EquipmentLocationBack()); + get { return "Back"; } } - public override string SlotName + public override bool IsLocationAcceptable(EquipmentLocation location) { - get { return "Back"; } + if (location is EquipmentLocationBack) + return true; + else + return false; } } @@ -115,6 +143,14 @@ { get { return "Left Arm"; } } + + public override bool IsLocationAcceptable(EquipmentLocation location) + { + if (location is EquipmentLocationLeftArm) + return true; + else + return false; + } } public class EquipmentSlotRightArm : EquipmentSlot @@ -123,31 +159,45 @@ { get { return "Right Arm"; } } + + public override bool IsLocationAcceptable(EquipmentLocation location) + { + if (location is EquipmentLocationRightArm) + return true; + else + return false; + } } public class EquipmentSlotLeftHand : EquipmentSlot { - public EquipmentSlotLeftHand() + public override string SlotName { - acceptableEquipmentLocations.Add(new EquipmentLocationLeftHand()); + get { return "Left Hand"; } } - public override string SlotName + public override bool IsLocationAcceptable(EquipmentLocation location) { - get { return "Left Hand"; } + if (location is EquipmentLocationLeftHand) + return true; + else + return false; } } public class EquipmentSlotRightHand : EquipmentSlot { - public EquipmentSlotRightHand() + public override string SlotName { - acceptableEquipmentLocations.Add(new EquipmentLocationRightHand()); + get { return "Right Hand"; } } - public override string SlotName + public override bool IsLocationAcceptable(EquipmentLocation location) { - get { return "Right Hand"; } + if (location is EquipmentLocationRightHand) + return true; + else + return false; } } @@ -157,6 +207,14 @@ { get { return "Left Leg"; } } + + public override bool IsLocationAcceptable(EquipmentLocation location) + { + if (location is EquipmentLocationLeftLeg) + return true; + else + return false; + } } public class EquipmentSlotRightLeg : EquipmentSlot @@ -165,6 +223,14 @@ { get { return "Right Leg"; } } + + public override bool IsLocationAcceptable(EquipmentLocation location) + { + if (location is EquipmentLocationRightLeg) + return true; + else + return false; + } } public class EquipmentSlotLeftFoot : EquipmentSlot @@ -173,6 +239,14 @@ { get { return "Left Foot"; } } + + public override bool IsLocationAcceptable(EquipmentLocation location) + { + if (location is EquipmentLocationLeftFoot) + return true; + else + return false; + } } public class EquipmentSlotRightFoot : EquipmentSlot @@ -181,5 +255,13 @@ { get { return "Right Foot"; } } + + public override bool IsLocationAcceptable(EquipmentLocation location) + { + if (location is EquipmentLocationRightFoot) + return true; + else + return false; + } } } \ No newline at end of file Modified: src/RPGWorldModel.Abstracts/Humanoid.cs =================================================================== --- src/RPGWorldModel.Abstracts/Humanoid.cs 2006-07-12 17:52:16 UTC (rev 14) +++ src/RPGWorldModel.Abstracts/Humanoid.cs 2006-07-14 16:42:36 UTC (rev 15) @@ -41,59 +41,102 @@ } #endregion - - + + public override EquipResponse Equip(EquipRequest request) { EquipResponse response = new EquipResponse(); - response.Status = EquipStatus.NotEquippedNotAbleToEquip; + response.Status = EquipStatus.Undefined; + response.AffectedSlot = null; + if (!equipmentSlots.Contains(request.RequestedSlot)) + { + response.Status = EquipStatus.NotEquippedSlotNotPartOfEntity; + response.AffectedSlot = request.RequestedSlot; + return response; + } - // Basic equip implementation for humanoids - foreach (EquipmentSlot slot in AvailableEquipmentSlots) + // Iterating over locations from equipable and trying to match them if open slots + + EquipmentSlotList selectedSlots = new EquipmentSlotList(); + bool initialSlotAccepting = false; + + foreach (EquipmentLocationDescriptor locationDescriptor in + request.RequestedEquipable.EquipmentLocationDescriptors) { - // Checking is slot is part of entity - if (slot == request.RequestedSlot) + initialSlotAccepting = false; + + // Checking if initial slot accepts any of the location + foreach (EquipmentLocation location in locationDescriptor.EquipmentLocations) + if (request.RequestedSlot.IsLocationAcceptable(location)) + { + initialSlotAccepting = true; + break; + } + + if (!initialSlotAccepting) { - // Checking is slot can accept any of the equipe locations for equipable + if (response.Status == EquipStatus.Undefined) + { + response.Status = EquipStatus.NotEquippedNotAbleToEquipToSlot; + response.AffectedSlot = request.RequestedSlot; + } - foreach (EquipmentLocationDescriptor locationDescriptor - in request.RequestedEquipable.EquipmentLocationDescriptors) + continue; + } + + // Initial is accepting, check other + selectedSlots.Clear(); + + foreach (EquipmentLocation location in locationDescriptor.EquipmentLocations) + { + foreach (EquipmentSlot slot in equipmentSlots) { - // TODO: multi-slot items support - if (locationDescriptor.EquipmentLocationsCount > 1) + // Can slot accept equipable + if (slot.IsLocationAcceptable(location)) { - break; + selectedSlots.Add(slot); + break; //NO OTHER LOCATION CAN ACCEPT } + } + } - if (locationDescriptor.EquipmentLocationsCount == 0) + if (selectedSlots.Count == locationDescriptor.EquipmentLocationsCount) + { + // Checking capacity + foreach (EquipmentSlot slot in selectedSlots) + { + // TEMP + if (slot.EquippedEntitiesCount > 0) { - break; //TODO : error + response.Status = EquipStatus.NotEquippedNoCapacityLeftInSlot; + response.AffectedSlot = slot; + break; } + } - 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.NotEquippedNoCapacityLeftInSlot) + { + // OK + response.Status = EquipStatus.Equipped; + response.AffectedSlot = request.RequestedSlot; - if (response.Status == EquipStatus.Equipped) - break; - + foreach (EquipmentSlot slot in selectedSlots) + slot.AddEquipable(request.RequestedEquipable); + + break; } - if (response.Status == EquipStatus.Equipped) - break; } + else + { + response.Status = EquipStatus.NotEquippedNotAbleToEquipToAdditionalSlots; + response.AffectedSlot = null; + } } - + return response; } Modified: src/RPGWorldModel.Abstracts/IEquip.cs =================================================================== --- src/RPGWorldModel.Abstracts/IEquip.cs 2006-07-12 17:52:16 UTC (rev 14) +++ src/RPGWorldModel.Abstracts/IEquip.cs 2006-07-14 16:42:36 UTC (rev 15) @@ -49,14 +49,25 @@ get { return status; } set { status = value; } } + + private EquipmentSlot affectedSlot = null; + + public EquipmentSlot AffectedSlot + { + get { return affectedSlot; } + set { affectedSlot = value; } + } } public enum EquipStatus { Undefined, Equipped, - NotEquippedNotAbleToEquip, + NotEquippedNotAbleToEquipToSlot, NotEquippedConflictingWithAlreadyEquippedEntity, NotEquippedNotAbleToEquipAnyEntities, // If and entity is not able to equipe any entities (e.g. animals) + NotEquippedNoCapacityLeftInSlot, + NotEquippedSlotNotPartOfEntity, + NotEquippedNotAbleToEquipToAdditionalSlots } } Modified: src/RPGWorldModel.Abstracts/Sword.cs =================================================================== --- src/RPGWorldModel.Abstracts/Sword.cs 2006-07-12 17:52:16 UTC (rev 14) +++ src/RPGWorldModel.Abstracts/Sword.cs 2006-07-14 16:42:36 UTC (rev 15) @@ -28,8 +28,8 @@ { if (!durability.IsInitialized) { - durability.BaseDurability = 1000; - durability.DurabilityMargin = 15; + durability.BaseDurability = 0; + durability.DurabilityMargin = 0; durability.IsInitialized = true; durability.RandomizationRequired = true; } @@ -47,10 +47,10 @@ { if (!damageDescriptor.IsInitialized && damageDescriptor is DamageDescriptorPhysical) { - damageDescriptor.BaseMinDamage = 30; - damageDescriptor.MinDamageMargin = 5; - damageDescriptor.BaseMaxDamage = 35; - damageDescriptor.MaxDamageMargin = 10; + damageDescriptor.BaseMinDamage = 0; + damageDescriptor.MinDamageMargin = 0; + damageDescriptor.BaseMaxDamage = 0; + damageDescriptor.MaxDamageMargin = 0; damageDescriptor.IsInitialized = true; damageDescriptor.RandomizationRequired = true; } @@ -83,4 +83,68 @@ } #endregion } + + public class TwoHandedSword : Sword + { + public TwoHandedSword() + { + } + + #region Initialization Overrides + + public override void InitializeNamedEntity() + { + if (!name.IsInitialized) + { + name.Value = "Two-Handed Sword"; + name.IsInitialized = true; + } + } + + 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(); + + // Building descriptors + EquipmentLocationDescriptor bothHands = new EquipmentLocationDescriptor(); + bothHands.AddEquipmentLocation(new EquipmentLocationLeftHand()); + bothHands.AddEquipmentLocation(new EquipmentLocationRightHand()); + equipmentLocationDescriptors.Add(bothHands); + + EquipmentLocationDescriptor back = new EquipmentLocationDescriptor(); + back.AddEquipmentLocation(new EquipmentLocationBack()); + equipmentLocationDescriptors.Add(back); + } + #endregion + } + } Modified: src/RPGWorldModel.Implementation/Swords.cs =================================================================== --- src/RPGWorldModel.Implementation/Swords.cs 2006-07-12 17:52:16 UTC (rev 14) +++ src/RPGWorldModel.Implementation/Swords.cs 2006-07-14 16:42:36 UTC (rev 15) @@ -76,4 +76,41 @@ #endregion } + + + /// <summary> + /// Bronze Two-Handed Sword + /// </summary> + public class BronzeTwoHandedSword : TwoHandedSword + { + public BronzeTwoHandedSword() + { + name.Value = "Bronze Two-Handed Sword"; + name.IsInitialized = true; + + durability.BaseDurability = 2000; + durability.DurabilityMargin = 20; + durability.IsInitialized = true; + durability.RandomizationRequired = true; + } + + #region Initialization Overrides + + public override void InitializeDamageInflictor() + { + DamageDescriptorPhysical damageDesc = new DamageDescriptorPhysical(); + damageDesc.BaseMaxDamage = 40; + 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/test_applications/tester/Form1.Designer.cs =================================================================== --- src/test_applications/tester/Form1.Designer.cs 2006-07-12 17:52:16 UTC (rev 14) +++ src/test_applications/tester/Form1.Designer.cs 2006-07-14 16:42:36 UTC (rev 15) @@ -380,6 +380,7 @@ // this.lvAvailableItems.HideSelection = false; this.lvAvailableItems.Location = new System.Drawing.Point(319, 176); + this.lvAvailableItems.MultiSelect = false; this.lvAvailableItems.Name = "lvAvailableItems"; this.lvAvailableItems.Size = new System.Drawing.Size(322, 97); this.lvAvailableItems.TabIndex = 3; Modified: src/test_applications/tester/Form1.cs =================================================================== --- src/test_applications/tester/Form1.cs 2006-07-12 17:52:16 UTC (rev 14) +++ src/test_applications/tester/Form1.cs 2006-07-14 16:42:36 UTC (rev 15) @@ -312,17 +312,32 @@ { if (equipable is Sword) { - g.FillRectangle(Brushes.Blue, x, y, 5, 100); - g.FillRectangle(Brushes.Blue, x - 10, y + 20, 25, 5); + int swordLength = 100; + Brush selectedBrush = Brushes.Gray; + + if (equipable is WoodenTrainingSword) + { + selectedBrush = Brushes.Brown; + swordLength = 80; + } + + if (equipable is BronzeTwoHandedSword) + { + selectedBrush = Brushes.DarkRed; + swordLength = 140; + } + + g.FillRectangle(selectedBrush, x, y, 5, swordLength); + g.FillRectangle(selectedBrush, x - 10, y + 20, 25, 5); Point[] points = new Point[3]; points[0].X = x; - points[0].Y = y + 100; + points[0].Y = y + swordLength; points[1].X = x + 2; - points[1].Y = y + 110; + points[1].Y = y + swordLength + 10; points[2].X = x+5; - points[2].Y = y + 100; - g.FillPolygon(Brushes.Blue, points); + points[2].Y = y + swordLength; + g.FillPolygon(selectedBrush, points); } } @@ -369,14 +384,20 @@ equipTest = new Human(); equipTest.InitializeEntity(); + availableEquipable.Clear(); + IronShortSword sword = new IronShortSword(); sword.InitializeEntity(); WoodenTrainingSword wSword = new WoodenTrainingSword(); wSword.InitializeEntity(); + BronzeTwoHandedSword bthSword = new BronzeTwoHandedSword(); + bthSword.InitializeEntity(); + availableEquipable.Add(sword); availableEquipable.Add(wSword); + availableEquipable.Add(bthSword); refreshEquip(); } @@ -433,6 +454,21 @@ if (response.Status == EquipStatus.Equipped) availableEquipable.Remove(selectedEquipable); + if (response.Status == EquipStatus.NotEquippedNoCapacityLeftInSlot) + { + MessageBox.Show("You cannot put more items into " + (response.AffectedSlot != null ? response.AffectedSlot.SlotName : "UNKNOWN")); + } + + if (response.Status == EquipStatus.NotEquippedNotAbleToEquipToSlot) + { + MessageBox.Show("You cannot put " + (selectedEquipable as INamedEntity).Name + " into " + (response.AffectedSlot != null ? response.AffectedSlot.SlotName : "UNKNOWN")); + } + + if (response.Status == EquipStatus.NotEquippedNotAbleToEquipToAdditionalSlots) + { + MessageBox.Show("You cannot put " + (selectedEquipable as INamedEntity).Name + " becuase of lack of capacity in other slots"); + } + refreshEquip(); } } Modified: src/test_applications/tester/tester.csproj =================================================================== --- src/test_applications/tester/tester.csproj 2006-07-12 17:52:16 UTC (rev 14) +++ src/test_applications/tester/tester.csproj 2006-07-14 16:42:36 UTC (rev 15) @@ -18,6 +18,7 @@ <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> + <UseVSHostingProcess>false</UseVSHostingProcess> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
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: <pos...@us...> - 2006-07-06 16:26:30
|
Revision: 12 Author: poserdev Date: 2006-07-06 09:26:23 -0700 (Thu, 06 Jul 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=12&view=rev Log Message: ----------- project files update Modified Paths: -------------- src/test_applications/ItemsViewer/ItemsViewer.csproj Modified: src/test_applications/ItemsViewer/ItemsViewer.csproj =================================================================== --- src/test_applications/ItemsViewer/ItemsViewer.csproj 2006-07-06 14:56:26 UTC (rev 11) +++ src/test_applications/ItemsViewer/ItemsViewer.csproj 2006-07-06 16:26:23 UTC (rev 12) @@ -52,12 +52,6 @@ <Compile Include="SceenObject.cs" /> <Compile Include="SwordObject.cs" /> </ItemGroup> - <ItemGroup> - <EmbeddedResource Include="Form1.resx"> - <SubType>Designer</SubType> - <DependentUpon>Form1.cs</DependentUpon> - </EmbeddedResource> - </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2006-07-06 14:56:39
|
Revision: 11 Author: poserdev Date: 2006-07-06 07:56:26 -0700 (Thu, 06 Jul 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=11&view=rev Log Message: ----------- Cool! Now we all can rotate/scale the object. Someone did a great job there :P Modified Paths: -------------- src/test_applications/ItemsViewer/Form1.Designer.cs src/test_applications/ItemsViewer/Form1.cs src/test_applications/ItemsViewer/ItemsViewer.csproj Added Paths: ----------- src/test_applications/ItemsViewer/Camera.cs Added: src/test_applications/ItemsViewer/Camera.cs =================================================================== --- src/test_applications/ItemsViewer/Camera.cs (rev 0) +++ src/test_applications/ItemsViewer/Camera.cs 2006-07-06 14:56:26 UTC (rev 11) @@ -0,0 +1,34 @@ +using System; + +namespace ItemsViewer +{ + public struct Camera + { + private int ZMax; + public int Z; + private int ZMin; + public float RotationY; + public float RotationX; + + public Camera(int zMax, int z, int zMin) + { + this.ZMax = zMax; + this.Z = z; + this.ZMin = zMin; + this.RotationY = 0; + this.RotationX = 0; + } + + public void ZoomIn() + { + if ((ZMin + 1) != Z) + Z--; + } + + public void ZoomOut() + { + if ((ZMax - 1) != Z) + Z++; + } + } +} \ No newline at end of file Modified: src/test_applications/ItemsViewer/Form1.Designer.cs =================================================================== --- src/test_applications/ItemsViewer/Form1.Designer.cs 2006-07-06 13:53:21 UTC (rev 10) +++ src/test_applications/ItemsViewer/Form1.Designer.cs 2006-07-06 14:56:26 UTC (rev 11) @@ -39,6 +39,7 @@ this.Name = "Form1"; this.Text = "Form1"; this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown); this.ResumeLayout(false); } Modified: src/test_applications/ItemsViewer/Form1.cs =================================================================== --- src/test_applications/ItemsViewer/Form1.cs 2006-07-06 13:53:21 UTC (rev 10) +++ src/test_applications/ItemsViewer/Form1.cs 2006-07-06 14:56:26 UTC (rev 11) @@ -17,6 +17,7 @@ { private Device m_Device; private SwordObject m_SceenObject; + private Camera m_Camera; public Form1() { @@ -32,11 +33,13 @@ { this.m_Device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, 1, 1, 100.0f); - this.m_Device.Transform.View = Matrix.LookAtLH(new Vector3(0, 0, 20), new Vector3(), + + this.m_Device.Transform.View = Matrix.LookAtLH(new Vector3(0, 0, this.m_Camera.Z), new Vector3(), new Vector3(0, 1, 0)); - this.m_Device.Transform.World = Matrix.RotationZ(Environment.TickCount / 1000.0f) * - Matrix.RotationY(Environment.TickCount / 1000.0f) * Matrix.Scaling(0.02f, 0.02f, 0.02f); + this.m_Device.Transform.World = Matrix.Scaling(0.02f, 0.02f, 0.02f) + * Matrix.RotationY(this.m_Camera.RotationY) * + Matrix.RotationX(this.m_Camera.RotationX); } private void InitializeGraphics() @@ -53,6 +56,8 @@ this.m_SceenObject = new SwordObject(this.m_Device); this.m_SceenObject.LoadMesh(@"Models\Base\Sword\sword.x"); + + this.m_Camera = new Camera(100, 10, 2); } private void Form1_Paint(object sender, PaintEventArgs e) @@ -81,11 +86,29 @@ void Form1_MouseWheel(object sender, MouseEventArgs e) { if (e.Delta > 0) + this.m_Camera.ZoomIn(); + else + this.m_Camera.ZoomOut(); + } + + private void Form1_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Left) { + this.m_Camera.RotationY += 0.05f; } - else + else if (e.KeyCode == Keys.Right) { + this.m_Camera.RotationY -= 0.05f; } + else if (e.KeyCode == Keys.Up) + { + this.m_Camera.RotationX += 0.05f; + } + else if (e.KeyCode == Keys.Down) + { + this.m_Camera.RotationX -= 0.05f; + } } } } \ No newline at end of file Modified: src/test_applications/ItemsViewer/ItemsViewer.csproj =================================================================== --- src/test_applications/ItemsViewer/ItemsViewer.csproj 2006-07-06 13:53:21 UTC (rev 10) +++ src/test_applications/ItemsViewer/ItemsViewer.csproj 2006-07-06 14:56:26 UTC (rev 11) @@ -39,6 +39,7 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="Camera.cs" /> <Compile Include="Form1.cs"> <SubType>Form</SubType> </Compile> @@ -51,6 +52,12 @@ <Compile Include="SceenObject.cs" /> <Compile Include="SwordObject.cs" /> </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Form1.resx"> + <SubType>Designer</SubType> + <DependentUpon>Form1.cs</DependentUpon> + </EmbeddedResource> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2006-07-06 13:53:44
|
Revision: 10 Author: poserdev Date: 2006-07-06 06:53:21 -0700 (Thu, 06 Jul 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=10&view=rev Log Message: ----------- Big reorganization in the application structure. Enabling object rotation/scaling in progress. Home I make it right from now :) Modified Paths: -------------- src/test_applications/ItemsViewer/App.config src/test_applications/ItemsViewer/ItemsViewer.csproj src/test_applications/ItemsViewer/Program.cs src/test_applications/ItemsViewer/Properties/AssemblyInfo.cs Added Paths: ----------- src/test_applications/ItemsViewer/Form1.Designer.cs src/test_applications/ItemsViewer/Form1.cs src/test_applications/ItemsViewer/SceenObject.cs src/test_applications/ItemsViewer/SwordObject.cs Removed Paths: ------------- src/test_applications/ItemsViewer/IModel.cs src/test_applications/ItemsViewer/Model.cs src/test_applications/ItemsViewer/OpenModelDialog.Designer.cs src/test_applications/ItemsViewer/OpenModelDialog.cs src/test_applications/ItemsViewer/Surface.cs src/test_applications/ItemsViewer/ViewController.cs src/test_applications/ItemsViewer/ViewState.cs Modified: src/test_applications/ItemsViewer/App.config =================================================================== --- src/test_applications/ItemsViewer/App.config 2006-07-03 20:23:33 UTC (rev 9) +++ src/test_applications/ItemsViewer/App.config 2006-07-06 13:53:21 UTC (rev 10) @@ -1,11 +1,3 @@ <?xml version="1.0" encoding="utf-8" ?> - <configuration> - <configSections> - <section name="models" type="System.Configuration.NameValueSectionHandler" /> - </configSections> - - <models> - <add key="Long Iron Sword" value="Models\sword.x" /> - </models> </configuration> \ No newline at end of file Added: src/test_applications/ItemsViewer/Form1.Designer.cs =================================================================== --- src/test_applications/ItemsViewer/Form1.Designer.cs (rev 0) +++ src/test_applications/ItemsViewer/Form1.Designer.cs 2006-07-06 13:53:21 UTC (rev 10) @@ -0,0 +1,49 @@ +namespace ItemsViewer +{ + partial class Form1 + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.SuspendLayout(); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(292, 273); + this.MinimumSize = new System.Drawing.Size(100, 100); + this.Name = "Form1"; + this.Text = "Form1"; + this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint); + this.ResumeLayout(false); + + } + + #endregion + } +} + Added: src/test_applications/ItemsViewer/Form1.cs =================================================================== --- src/test_applications/ItemsViewer/Form1.cs (rev 0) +++ src/test_applications/ItemsViewer/Form1.cs 2006-07-06 13:53:21 UTC (rev 10) @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +using Microsoft.DirectX; +using Microsoft.DirectX.Direct3D; + +using ItemsViewer.SceenObjects; + +namespace ItemsViewer +{ + public partial class Form1 : Form + { + private Device m_Device; + private SwordObject m_SceenObject; + + public Form1() + { + InitializeComponent(); + this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); + + this.MouseWheel += new MouseEventHandler(Form1_MouseWheel); + + InitializeGraphics(); + } + + private void SetupCamera() + { + this.m_Device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, + 1, 1, 100.0f); + this.m_Device.Transform.View = Matrix.LookAtLH(new Vector3(0, 0, 20), new Vector3(), + new Vector3(0, 1, 0)); + + this.m_Device.Transform.World = Matrix.RotationZ(Environment.TickCount / 1000.0f) * + Matrix.RotationY(Environment.TickCount / 1000.0f) * Matrix.Scaling(0.02f, 0.02f, 0.02f); + } + + private void InitializeGraphics() + { + PresentParameters parameters = new PresentParameters(); + parameters.Windowed = true; + parameters.SwapEffect = SwapEffect.Discard; + parameters.EnableAutoDepthStencil = true; + parameters.AutoDepthStencilFormat = DepthFormat.D16; + + this.m_Device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, parameters); + this.m_Device.RenderState.CullMode = Cull.None; + this.m_Device.RenderState.ZBufferEnable = true; + + this.m_SceenObject = new SwordObject(this.m_Device); + this.m_SceenObject.LoadMesh(@"Models\Base\Sword\sword.x"); + } + + private void Form1_Paint(object sender, PaintEventArgs e) + { + this.m_Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.CornflowerBlue, 1.0f, 0); + this.m_Device.RenderState.Ambient = Color.White; + + this.SetupCamera(); + + this.m_Device.BeginScene(); + + for (int i = 0; i < this.m_SceenObject.Materials.Length; i++) + { + this.m_Device.Material = this.m_SceenObject.Materials[i]; + this.m_Device.SetTexture(0, this.m_SceenObject.Textures[i]); + this.m_SceenObject.Mesh.DrawSubset(i); + } + + this.m_Device.EndScene(); + + this.m_Device.Present(); + this.Invalidate(); + } + + // Control over the sceen object zoom factor + void Form1_MouseWheel(object sender, MouseEventArgs e) + { + if (e.Delta > 0) + { + } + else + { + } + } + } +} \ No newline at end of file Deleted: src/test_applications/ItemsViewer/IModel.cs =================================================================== --- src/test_applications/ItemsViewer/IModel.cs 2006-07-03 20:23:33 UTC (rev 9) +++ src/test_applications/ItemsViewer/IModel.cs 2006-07-06 13:53:21 UTC (rev 10) @@ -1,24 +0,0 @@ -using System; - -using Microsoft.DirectX.Direct3D; - -namespace RPGWorldModel.ItemsViewer -{ - public interface IModel - { - Mesh Object - { - get; - } - - Material[] Materials - { - get; - } - - Texture[] Textures - { - get; - } - } -} Modified: src/test_applications/ItemsViewer/ItemsViewer.csproj =================================================================== --- src/test_applications/ItemsViewer/ItemsViewer.csproj 2006-07-03 20:23:33 UTC (rev 9) +++ src/test_applications/ItemsViewer/ItemsViewer.csproj 2006-07-06 13:53:21 UTC (rev 10) @@ -4,11 +4,11 @@ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.50727</ProductVersion> <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{57684296-F942-4797-8C0F-ADB151A02477}</ProjectGuid> + <ProjectGuid>{CA0D68AD-69C4-46D2-B09B-036D02ABA061}</ProjectGuid> <OutputType>WinExe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>RPGWorldModel.ItemsViewer</RootNamespace> - <AssemblyName>ModelViewer</AssemblyName> + <RootNamespace>ItemsViewer</RootNamespace> + <AssemblyName>ItemsViewer</AssemblyName> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -28,43 +28,28 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> - <Reference Include="Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> - <Private>False</Private> - </Reference> - <Reference Include="Microsoft.DirectX.Direct3D, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> - <Private>False</Private> - </Reference> - <Reference Include="Microsoft.DirectX.Direct3DX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> - <Private>False</Private> - </Reference> - <Reference Include="RPGWorldModel.Abstracts, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\..\RPGWorldModel.Abstracts\bin\Debug\RPGWorldModel.Abstracts.dll</HintPath> - </Reference> + <Reference Include="Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> + <Reference Include="Microsoft.DirectX.Direct3D, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> + <Reference Include="Microsoft.DirectX.Direct3DX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> <Reference Include="System" /> - <Reference Include="System.configuration" /> + <Reference Include="System.Data" /> + <Reference Include="System.Deployment" /> <Reference Include="System.Drawing" /> <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> - <Compile Include="IModel.cs" /> - <Compile Include="Model.cs" /> - <Compile Include="OpenModelDialog.cs"> + <Compile Include="Form1.cs"> <SubType>Form</SubType> </Compile> - <Compile Include="OpenModelDialog.Designer.cs"> - <DependentUpon>OpenModelDialog.cs</DependentUpon> + <Compile Include="Form1.Designer.cs"> + <DependentUpon>Form1.cs</DependentUpon> </Compile> - <Compile Include="Surface.cs"> - <SubType>Form</SubType> - </Compile> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="ViewController.cs" /> - <Compile Include="ViewState.cs" /> - </ItemGroup> - <ItemGroup> <None Include="App.config" /> + <Compile Include="SceenObject.cs" /> + <Compile Include="SwordObject.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Deleted: src/test_applications/ItemsViewer/Model.cs =================================================================== --- src/test_applications/ItemsViewer/Model.cs 2006-07-03 20:23:33 UTC (rev 9) +++ src/test_applications/ItemsViewer/Model.cs 2006-07-06 13:53:21 UTC (rev 10) @@ -1,69 +0,0 @@ -using System; -using System.IO; -using System.Windows.Forms; - -using Microsoft.DirectX; -using Microsoft.DirectX.Direct3D; - -namespace RPGWorldModel.ItemsViewer -{ - public class Model : IModel - { - private Mesh m_Object; - private Material[] m_Materials; - private Texture[] m_Textures; - - public Model(string source, Device device) - { - - - if (File.Exists(source)) - { - Directory.SetCurrentDirectory(Application.StartupPath + - Path.DirectorySeparatorChar + Path.GetDirectoryName(source)); - - // Load the model - ExtendedMaterial[] materials; - this.m_Object = Mesh.FromFile(System.IO.Path.GetFileName(source), MeshFlags.SystemMemory, device, out materials); - - this.m_Textures = new Texture[materials.Length]; - this.m_Materials = new Material[materials.Length]; - - for (int i = 0; i < materials.Length; i++) - { - this.m_Materials[i] = materials[i].Material3D; - this.m_Materials[i].Ambient = this.m_Materials[i].Diffuse; - this.m_Textures[i] = TextureLoader.FromFile(device, materials[i].TextureFilename); - } - } - } - - #region IModel Members - - public Mesh Object - { - get - { - return this.m_Object; - } - } - - public Material[] Materials - { - get - { - return this.m_Materials; - } - } - - public Texture[] Textures - { - get - { - return this.m_Textures; - } - } - - #endregion - } -} Deleted: src/test_applications/ItemsViewer/OpenModelDialog.Designer.cs =================================================================== --- src/test_applications/ItemsViewer/OpenModelDialog.Designer.cs 2006-07-03 20:23:33 UTC (rev 9) +++ src/test_applications/ItemsViewer/OpenModelDialog.Designer.cs 2006-07-06 13:53:21 UTC (rev 10) @@ -1,84 +0,0 @@ -namespace RPGWorldModel.ItemsViewer -{ - partial class OpenModelDialog - { - /// <summary> - /// Required designer variable. - /// </summary> - private System.ComponentModel.IContainer components = null; - - /// <summary> - /// Clean up any resources being used. - /// </summary> - /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// <summary> - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// </summary> - private void InitializeComponent() - { - this.m_List = new System.Windows.Forms.ListBox(); - this.m_Picture = new System.Windows.Forms.PictureBox(); - ((System.ComponentModel.ISupportInitialize)(this.m_Picture)).BeginInit(); - this.SuspendLayout(); - // - // m_List - // - this.m_List.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.m_List.Dock = System.Windows.Forms.DockStyle.Left; - this.m_List.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.m_List.IntegralHeight = false; - this.m_List.ItemHeight = 20; - this.m_List.Location = new System.Drawing.Point(0, 0); - this.m_List.Margin = new System.Windows.Forms.Padding(0); - this.m_List.Name = "m_List"; - this.m_List.ScrollAlwaysVisible = true; - this.m_List.Size = new System.Drawing.Size(400, 168); - this.m_List.TabIndex = 0; - this.m_List.DoubleClick += new System.EventHandler(this.m_List_DoubleClick); - this.m_List.SelectedIndexChanged += new System.EventHandler(this.m_List_SelectedIndexChanged); - // - // m_Picture - // - this.m_Picture.Dock = System.Windows.Forms.DockStyle.Fill; - this.m_Picture.Location = new System.Drawing.Point(400, 0); - this.m_Picture.Name = "m_Picture"; - this.m_Picture.Size = new System.Drawing.Size(194, 168); - this.m_Picture.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; - this.m_Picture.TabIndex = 1; - this.m_Picture.TabStop = false; - // - // OpenModelDialog - // - this.AutoSize = true; - this.ClientSize = new System.Drawing.Size(594, 168); - this.Controls.Add(this.m_Picture); - this.Controls.Add(this.m_List); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "OpenModelDialog"; - this.ShowIcon = false; - this.Text = "Model"; - ((System.ComponentModel.ISupportInitialize)(this.m_Picture)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.ListBox m_List; - private System.Windows.Forms.PictureBox m_Picture; - } -} \ No newline at end of file Deleted: src/test_applications/ItemsViewer/OpenModelDialog.cs =================================================================== --- src/test_applications/ItemsViewer/OpenModelDialog.cs 2006-07-03 20:23:33 UTC (rev 9) +++ src/test_applications/ItemsViewer/OpenModelDialog.cs 2006-07-06 13:53:21 UTC (rev 10) @@ -1,54 +0,0 @@ -using System; -using System.IO; -using System.Collections.Specialized; -using System.ComponentModel; -using System.Drawing; -using System.Windows.Forms; - -namespace RPGWorldModel.ItemsViewer -{ - public partial class OpenModelDialog : Form - { - private string m_SelectedModel; - private NameValueCollection m_Models; - - public OpenModelDialog(NameValueCollection models) - { - InitializeComponent(); - - this.m_Models = models; - - foreach (string key in this.m_Models.AllKeys) - this.m_List.Items.Add(key); - - this.m_List.SelectedIndex = -1; - } - - private void m_List_SelectedIndexChanged(object sender, EventArgs e) - { - string file = this.m_Models[this.m_List.SelectedItem.ToString()]; - // Load the model image - this.m_Picture.Load(Path.GetDirectoryName(file) + Path.DirectorySeparatorChar + - Path.GetFileNameWithoutExtension(file) + @".bmp"); - } - - private void m_List_DoubleClick(object sender, EventArgs e) - { - if (this.m_List.SelectedItem != null) - { - this.m_SelectedModel = this.m_List.SelectedItem.ToString(); - - this.DialogResult = DialogResult.OK; - this.Close(); - } - } - - public string SelectedModel - { - get - { - return this.m_SelectedModel; - } - } - } -} \ No newline at end of file Modified: src/test_applications/ItemsViewer/Program.cs =================================================================== --- src/test_applications/ItemsViewer/Program.cs 2006-07-03 20:23:33 UTC (rev 9) +++ src/test_applications/ItemsViewer/Program.cs 2006-07-06 13:53:21 UTC (rev 10) @@ -1,13 +1,20 @@ using System; +using System.Collections.Generic; +using System.Windows.Forms; -namespace RPGWorldModel.ItemsViewer +namespace ItemsViewer { static class Program { + /// <summary> + /// The main entry point for the application. + /// </summary> [STAThread] static void Main() { - ViewController view = new ViewController(); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); } } } \ No newline at end of file Modified: src/test_applications/ItemsViewer/Properties/AssemblyInfo.cs =================================================================== --- src/test_applications/ItemsViewer/Properties/AssemblyInfo.cs 2006-07-03 20:23:33 UTC (rev 9) +++ src/test_applications/ItemsViewer/Properties/AssemblyInfo.cs 2006-07-06 13:53:21 UTC (rev 10) @@ -5,11 +5,11 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("ModelViewer")] +[assembly: AssemblyTitle("ItemsViewer")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ModelViewer")] +[assembly: AssemblyProduct("ItemsViewer")] [assembly: AssemblyCopyright("Copyright © 2006")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -20,7 +20,7 @@ [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("2526b583-4d40-451f-b223-b66498fedb85")] +[assembly: Guid("ddbe5d05-3a77-4fe1-b4b0-108222295195")] // Version information for an assembly consists of the following four values: // Added: src/test_applications/ItemsViewer/SceenObject.cs =================================================================== --- src/test_applications/ItemsViewer/SceenObject.cs (rev 0) +++ src/test_applications/ItemsViewer/SceenObject.cs 2006-07-06 13:53:21 UTC (rev 10) @@ -0,0 +1,63 @@ +using System; +using System.IO; +using System.Drawing; +using System.Windows.Forms; + +using Microsoft.DirectX.Direct3D; + +namespace ItemsViewer.SceenObjects +{ + public class SceenObject + { + private Mesh m_Mesh; + private Material[] m_Materials; + private Texture[] m_Textures; + private Device m_Device; + + /// <summary> + /// Creates a new screen object + /// </summary> + public SceenObject(ref Device device) + { + this.m_Mesh = null; + this.m_Materials = null; + this.m_Textures = null; + this.m_Device = device; + } + + public virtual void LoadMesh(string source) + { + Directory.SetCurrentDirectory( + System.IO.Path.Combine(Application.StartupPath, System.IO.Path.GetDirectoryName(source))); + + ExtendedMaterial[] materials = null; + + this.m_Mesh = Mesh.FromFile(Path.GetFileName(source), MeshFlags.SystemMemory, this.m_Device, out materials); + + this.m_Textures = new Texture[materials.Length]; + this.m_Materials = new Material[materials.Length]; + + for (int i = 0; i < materials.Length; i++) + { + this.m_Materials[i] = materials[i].Material3D; + this.m_Materials[i].Ambient = this.m_Materials[i].Diffuse; + this.m_Textures[i] = TextureLoader.FromFile(this.m_Device, materials[i].TextureFilename); + } + } + + public Mesh Mesh + { + get { return this.m_Mesh; } + } + + public Texture[] Textures + { + get { return this.m_Textures; } + } + + public Material[] Materials + { + get { return this.m_Materials; } + } + } +} Deleted: src/test_applications/ItemsViewer/Surface.cs =================================================================== --- src/test_applications/ItemsViewer/Surface.cs 2006-07-03 20:23:33 UTC (rev 9) +++ src/test_applications/ItemsViewer/Surface.cs 2006-07-06 13:53:21 UTC (rev 10) @@ -1,126 +0,0 @@ -using System; - -using System.ComponentModel; -using System.Drawing; -using System.Windows.Forms; - -using Microsoft.DirectX; -using Microsoft.DirectX.Direct3D; - -namespace RPGWorldModel.ItemsViewer -{ - public sealed partial class Surface : Form - { - private Device m_RenderingDevice; - private IModel m_Model; - - public Surface() - { - this.SuspendLayout(); - - this.ClientSize = new System.Drawing.Size(800, 600); - this.ShowIcon = false; - this.KeyDown += new KeyEventHandler(Surface_KeyDown); - this.Paint += new PaintEventHandler(Surface_Paint); - - this.ResumeLayout(false); - - this.InitializeDevice(); - } - - void Surface_Paint(object sender, PaintEventArgs e) - { - this.RenderSceen(); - } - - float yAngle = 0.0f; - float xAngle = 0.0f; - - void Surface_KeyDown(object sender, KeyEventArgs e) - { - switch (e.KeyCode) - { - case(Keys.Left): - { - this.m_RenderingDevice.Transform.World = Matrix.RotationY((yAngle += 0.1f)); - this.RenderSceen(); - break; - } - case (Keys.Right): - { - this.m_RenderingDevice.Transform.World = Matrix.RotationY((yAngle -= 0.1f)); - this.RenderSceen(); - break; - } - case (Keys.Up): - { - this.m_RenderingDevice.Transform.World = Matrix.RotationX((xAngle += 0.1f)); - this.RenderSceen(); - break; - } - case (Keys.Down): - { - this.m_RenderingDevice.Transform.World = Matrix.RotationX((xAngle -= 0.1f)); - this.RenderSceen(); - break; - } - } - } - - private void InitializeDevice() - { - PresentParameters parameters = new PresentParameters(); - parameters.Windowed = true; - parameters.SwapEffect = SwapEffect.Discard; - - this.m_RenderingDevice = new Device(0, DeviceType.Hardware, - this, CreateFlags.SoftwareVertexProcessing, parameters); - - // Set metrices - this.m_RenderingDevice.Transform.View = Matrix.LookAtLH(new Vector3(0.0f, 0.0f, -100.0f), new Vector3(0.0f, 0.0f, 50.0f), new Vector3(0.0f, 1.0f, 0.0f)); - this.m_RenderingDevice.Transform.Projection = Matrix.PerspectiveFovLH((float)(Math.PI / 2), 1.0f, 1.0f, 100.0f); - } - - public void RenderSceen() - { - this.m_RenderingDevice.Clear(ClearFlags.Target, System.Drawing.Color.Black, 1.0f, 0); - this.m_RenderingDevice.BeginScene(); - - this.m_RenderingDevice.RenderState.Ambient = System.Drawing.Color.FromArgb(0x676766); - - for (int i = 0; i < this.m_Model.Materials.Length; i++) - { - this.m_RenderingDevice.Material = this.m_Model.Materials[i]; - this.m_RenderingDevice.SetTexture(0, this.m_Model.Textures[i]); - this.m_Model.Object.DrawSubset(i); - } - - this.m_RenderingDevice.EndScene(); - this.m_RenderingDevice.Present(); - } - - #region Public properties - - public Device RenderingDevice - { - get - { - return this.m_RenderingDevice; - } - } - - public IModel Model - { - get - { - return this.m_Model; - } - set - { - this.m_Model = value; - } - } - - #endregion - } -} \ No newline at end of file Added: src/test_applications/ItemsViewer/SwordObject.cs =================================================================== --- src/test_applications/ItemsViewer/SwordObject.cs (rev 0) +++ src/test_applications/ItemsViewer/SwordObject.cs 2006-07-06 13:53:21 UTC (rev 10) @@ -0,0 +1,13 @@ +using System; + +using Microsoft.DirectX.Direct3D; + +namespace ItemsViewer.SceenObjects +{ + public class SwordObject : SceenObject + { + public SwordObject(Device device) : base(ref device) + { + } + } +} Deleted: src/test_applications/ItemsViewer/ViewController.cs =================================================================== --- src/test_applications/ItemsViewer/ViewController.cs 2006-07-03 20:23:33 UTC (rev 9) +++ src/test_applications/ItemsViewer/ViewController.cs 2006-07-06 13:53:21 UTC (rev 10) @@ -1,54 +0,0 @@ -using System; -using System.IO; -using System.Configuration; -using System.Collections.Specialized; -using System.Windows.Forms; - -namespace RPGWorldModel.ItemsViewer -{ - public sealed class ViewController - { - private Surface m_View; - private Model m_Model; - - public ViewController() - { - this.m_View = new Surface(); - - if (this.LoadModel()) - { - this.m_View.Model = this.m_Model; - this.m_View.ShowDialog(); - } - } - - private bool LoadModel() - { - NameValueCollection models = (NameValueCollection)ConfigurationManager.GetSection("models"); - - if (models != null) - { - using (OpenModelDialog openModel = new OpenModelDialog(models)) - { - Directory.SetCurrentDirectory(Application.StartupPath); - - if (openModel.ShowDialog() == DialogResult.OK) - { - try - { - this.m_Model = new Model(models[openModel.SelectedModel], this.m_View.RenderingDevice); - } - catch - { - return false; - } - - return true; - } - } - } - - return false; - } - } -} Deleted: src/test_applications/ItemsViewer/ViewState.cs =================================================================== --- src/test_applications/ItemsViewer/ViewState.cs 2006-07-03 20:23:33 UTC (rev 9) +++ src/test_applications/ItemsViewer/ViewState.cs 2006-07-06 13:53:21 UTC (rev 10) @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace RPGWorldModel.ItemsViewer -{ - public struct ViewState - { - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dea...@us...> - 2006-07-03 20:23:49
|
Revision: 9 Author: deadwood_pl Date: 2006-07-03 13:23:33 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=9&view=rev Log Message: ----------- Remove IHandAllocator interface. Initial work on IEquipable interface implementation. Modified Paths: -------------- 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/RPGWorldModel.Abstracts/Weapon.cs Removed Paths: ------------- src/RPGWorldModel.Abstracts/IHandAllocator.cs Modified: src/RPGWorldModel.Abstracts/Humanoid.cs =================================================================== --- src/RPGWorldModel.Abstracts/Humanoid.cs 2006-06-26 15:10:32 UTC (rev 8) +++ src/RPGWorldModel.Abstracts/Humanoid.cs 2006-07-03 20:23:33 UTC (rev 9) @@ -28,6 +28,7 @@ equipmentSlots.Add(new EquipmentSlotNeck()); equipmentSlots.Add(new EquipmentSlotTorso()); equipmentSlots.Add(new EquipmentSlotBack()); + equipmentSlots.Add(new EquipmentSlotWaist()); equipmentSlots.Add(new EquipmentSlotLeftArm()); equipmentSlots.Add(new EquipmentSlotRightArm()); equipmentSlots.Add(new EquipmentSlotLeftHand()); Modified: src/RPGWorldModel.Abstracts/IEquip.cs =================================================================== --- src/RPGWorldModel.Abstracts/IEquip.cs 2006-06-26 15:10:32 UTC (rev 8) +++ src/RPGWorldModel.Abstracts/IEquip.cs 2006-07-03 20:23:33 UTC (rev 9) @@ -71,6 +71,10 @@ { } + public class EquipmentSlotWaist : EquipmentSlot + { + } + public class EquipmentSlotBack : EquipmentSlot { } Modified: src/RPGWorldModel.Abstracts/IEquipable.cs =================================================================== --- src/RPGWorldModel.Abstracts/IEquipable.cs 2006-06-26 15:10:32 UTC (rev 8) +++ src/RPGWorldModel.Abstracts/IEquipable.cs 2006-07-03 20:23:33 UTC (rev 9) @@ -6,9 +6,64 @@ { 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 + { + get { return equipmentLocationList; } + } + + 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 + { + } + } Deleted: src/RPGWorldModel.Abstracts/IHandAllocator.cs =================================================================== --- src/RPGWorldModel.Abstracts/IHandAllocator.cs 2006-06-26 15:10:32 UTC (rev 8) +++ src/RPGWorldModel.Abstracts/IHandAllocator.cs 2006-07-03 20:23:33 UTC (rev 9) @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace RPGWorldModel.Abstracts.Interfaces -{ - /// <summary> - /// Iterface for entities alocating entity hands - /// </summary> - public interface IHandAllocator - { - AllocatedHands Hands - { - get; - } - - void SetHandAllocation(HandAllocation newHandAllocation); - void InitializeHandAllocator(); - } - - public enum AllocatedHands - { - OneHand, - TwoHands - } - - public class HandAllocation : Initializable - { - private AllocatedHands allocatedHands = AllocatedHands.OneHand; - public AllocatedHands AllocatedHands - { - get { return allocatedHands; } - set { allocatedHands = value; } - } - } -} Modified: src/RPGWorldModel.Abstracts/Item.cs =================================================================== --- src/RPGWorldModel.Abstracts/Item.cs 2006-06-26 15:10:32 UTC (rev 8) +++ src/RPGWorldModel.Abstracts/Item.cs 2006-07-03 20:23:33 UTC (rev 9) @@ -12,6 +12,8 @@ { protected Durability durability = new Durability(); + protected EquipmentLocationDescriptorList equipmentLocationDescriptors = + new EquipmentLocationDescriptorList(); #region Initialize Overrides @@ -19,7 +21,8 @@ { base.InitializeEntity(); - // InitializeEquipable ? + InitializeEquipable(); + InitializeDamagable(); } @@ -34,6 +37,12 @@ #endregion + #region IEquipableMembers + + public abstract void InitializeEquipable(); + + #endregion + #region IDamagable Members public short MaxDurability Modified: src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj =================================================================== --- src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj 2006-06-26 15:10:32 UTC (rev 8) +++ src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj 2006-07-03 20:23:33 UTC (rev 9) @@ -44,7 +44,6 @@ <Compile Include="IDamageInflictor.cs" /> <Compile Include="IEquip.cs" /> <Compile Include="IEquipable.cs" /> - <Compile Include="IHandAllocator.cs" /> <Compile Include="ILiveEntity.cs" /> <Compile Include="IMagicEntity.cs" /> <Compile Include="INamedEntity.cs" /> Modified: src/RPGWorldModel.Abstracts/Sword.cs =================================================================== --- src/RPGWorldModel.Abstracts/Sword.cs 2006-06-26 15:10:32 UTC (rev 8) +++ src/RPGWorldModel.Abstracts/Sword.cs 2006-07-03 20:23:33 UTC (rev 9) @@ -23,15 +23,6 @@ } } - public override void InitializeHandAllocator() - { - if (!allocation.IsInitialized) - { - allocation.AllocatedHands = AllocatedHands.OneHand; - allocation.IsInitialized = true; - } - } - public override void InitializeDamagable() { if (!durability.IsInitialized) @@ -67,7 +58,28 @@ 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); + + EquipmentLocationDescriptor back = new EquipmentLocationDescriptor(); + back.AddEquipmentLocation(new EquipmentLocationBack()); + equipmentLocationDescriptors.Add(back); + } #endregion } } Modified: src/RPGWorldModel.Abstracts/Weapon.cs =================================================================== --- src/RPGWorldModel.Abstracts/Weapon.cs 2006-06-26 15:10:32 UTC (rev 8) +++ src/RPGWorldModel.Abstracts/Weapon.cs 2006-07-03 20:23:33 UTC (rev 9) @@ -5,9 +5,8 @@ namespace RPGWorldModel.Abstracts.Entities.Items { - public abstract class Weapon : Item, IHandAllocator, IDamageInflictor + public abstract class Weapon : Item, IDamageInflictor { - protected HandAllocation allocation = new HandAllocation(); protected DamageDescriptorDictionary damageDescriptors = new DamageDescriptorDictionary(); #region Initialize Overrides @@ -16,8 +15,6 @@ { base.InitializeEntity(); - InitializeHandAllocator(); - InitializeDamageInflictor(); } @@ -32,26 +29,6 @@ #endregion - - - #region IHandAllocator Members - - public AllocatedHands Hands - { - get { return allocation.AllocatedHands; } - } - - public abstract void InitializeHandAllocator(); - - public virtual void SetHandAllocation(HandAllocation newHandAllocation) - { - if (newHandAllocation == null) - throw new ArgumentException("newHandAllocation cannot be null", "newHandAllocation"); - - allocation = newHandAllocation; - } - #endregion - #region IDamageInflictor Members public abstract void InitializeDamageInflictor(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2006-06-26 15:10:57
|
Revision: 8 Author: poserdev Date: 2006-06-26 08:10:32 -0700 (Mon, 26 Jun 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=8&view=rev Log Message: ----------- Some more simple ItemsViewer implementation. It now work with the app config file. Models folder should by stored in the app startup path, like: ....\bin\Debug\Models. Some basic model rotation, but I really need to get some tutorials on DirectX transformations :D Modified Paths: -------------- src/test_applications/ItemsViewer/ItemsViewer.csproj src/test_applications/ItemsViewer/Program.cs src/test_applications/ItemsViewer/Surface.cs Added Paths: ----------- src/test_applications/ItemsViewer/App.config src/test_applications/ItemsViewer/IModel.cs src/test_applications/ItemsViewer/Model.cs src/test_applications/ItemsViewer/OpenModelDialog.Designer.cs src/test_applications/ItemsViewer/OpenModelDialog.cs src/test_applications/ItemsViewer/ViewController.cs src/test_applications/ItemsViewer/ViewState.cs Removed Paths: ------------- src/test_applications/ItemsViewer/Surface.Designer.cs src/test_applications/ItemsViewer/Surface.resx Added: src/test_applications/ItemsViewer/App.config =================================================================== --- src/test_applications/ItemsViewer/App.config (rev 0) +++ src/test_applications/ItemsViewer/App.config 2006-06-26 15:10:32 UTC (rev 8) @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8" ?> + +<configuration> + <configSections> + <section name="models" type="System.Configuration.NameValueSectionHandler" /> + </configSections> + + <models> + <add key="Long Iron Sword" value="Models\sword.x" /> + </models> +</configuration> \ No newline at end of file Added: src/test_applications/ItemsViewer/IModel.cs =================================================================== --- src/test_applications/ItemsViewer/IModel.cs (rev 0) +++ src/test_applications/ItemsViewer/IModel.cs 2006-06-26 15:10:32 UTC (rev 8) @@ -0,0 +1,24 @@ +using System; + +using Microsoft.DirectX.Direct3D; + +namespace RPGWorldModel.ItemsViewer +{ + public interface IModel + { + Mesh Object + { + get; + } + + Material[] Materials + { + get; + } + + Texture[] Textures + { + get; + } + } +} Modified: src/test_applications/ItemsViewer/ItemsViewer.csproj =================================================================== --- src/test_applications/ItemsViewer/ItemsViewer.csproj 2006-06-25 10:49:06 UTC (rev 7) +++ src/test_applications/ItemsViewer/ItemsViewer.csproj 2006-06-26 15:10:32 UTC (rev 8) @@ -7,7 +7,7 @@ <ProjectGuid>{57684296-F942-4797-8C0F-ADB151A02477}</ProjectGuid> <OutputType>WinExe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>ModelViewer</RootNamespace> + <RootNamespace>RPGWorldModel.ItemsViewer</RootNamespace> <AssemblyName>ModelViewer</AssemblyName> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> @@ -37,24 +37,35 @@ <Reference Include="Microsoft.DirectX.Direct3DX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> <Private>False</Private> </Reference> + <Reference Include="RPGWorldModel.Abstracts, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\RPGWorldModel.Abstracts\bin\Debug\RPGWorldModel.Abstracts.dll</HintPath> + </Reference> <Reference Include="System" /> + <Reference Include="System.configuration" /> <Reference Include="System.Drawing" /> <Reference Include="System.Windows.Forms" /> </ItemGroup> <ItemGroup> + <Compile Include="IModel.cs" /> + <Compile Include="Model.cs" /> + <Compile Include="OpenModelDialog.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="OpenModelDialog.Designer.cs"> + <DependentUpon>OpenModelDialog.cs</DependentUpon> + </Compile> <Compile Include="Surface.cs"> <SubType>Form</SubType> </Compile> - <Compile Include="Surface.Designer.cs"> - <DependentUpon>Surface.cs</DependentUpon> - </Compile> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> - <EmbeddedResource Include="Surface.resx"> - <SubType>Designer</SubType> - <DependentUpon>Surface.cs</DependentUpon> - </EmbeddedResource> + <Compile Include="ViewController.cs" /> + <Compile Include="ViewState.cs" /> </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. Added: src/test_applications/ItemsViewer/Model.cs =================================================================== --- src/test_applications/ItemsViewer/Model.cs (rev 0) +++ src/test_applications/ItemsViewer/Model.cs 2006-06-26 15:10:32 UTC (rev 8) @@ -0,0 +1,69 @@ +using System; +using System.IO; +using System.Windows.Forms; + +using Microsoft.DirectX; +using Microsoft.DirectX.Direct3D; + +namespace RPGWorldModel.ItemsViewer +{ + public class Model : IModel + { + private Mesh m_Object; + private Material[] m_Materials; + private Texture[] m_Textures; + + public Model(string source, Device device) + { + + + if (File.Exists(source)) + { + Directory.SetCurrentDirectory(Application.StartupPath + + Path.DirectorySeparatorChar + Path.GetDirectoryName(source)); + + // Load the model + ExtendedMaterial[] materials; + this.m_Object = Mesh.FromFile(System.IO.Path.GetFileName(source), MeshFlags.SystemMemory, device, out materials); + + this.m_Textures = new Texture[materials.Length]; + this.m_Materials = new Material[materials.Length]; + + for (int i = 0; i < materials.Length; i++) + { + this.m_Materials[i] = materials[i].Material3D; + this.m_Materials[i].Ambient = this.m_Materials[i].Diffuse; + this.m_Textures[i] = TextureLoader.FromFile(device, materials[i].TextureFilename); + } + } + } + + #region IModel Members + + public Mesh Object + { + get + { + return this.m_Object; + } + } + + public Material[] Materials + { + get + { + return this.m_Materials; + } + } + + public Texture[] Textures + { + get + { + return this.m_Textures; + } + } + + #endregion + } +} Added: src/test_applications/ItemsViewer/OpenModelDialog.Designer.cs =================================================================== --- src/test_applications/ItemsViewer/OpenModelDialog.Designer.cs (rev 0) +++ src/test_applications/ItemsViewer/OpenModelDialog.Designer.cs 2006-06-26 15:10:32 UTC (rev 8) @@ -0,0 +1,84 @@ +namespace RPGWorldModel.ItemsViewer +{ + partial class OpenModelDialog + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.m_List = new System.Windows.Forms.ListBox(); + this.m_Picture = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.m_Picture)).BeginInit(); + this.SuspendLayout(); + // + // m_List + // + this.m_List.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.m_List.Dock = System.Windows.Forms.DockStyle.Left; + this.m_List.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.m_List.IntegralHeight = false; + this.m_List.ItemHeight = 20; + this.m_List.Location = new System.Drawing.Point(0, 0); + this.m_List.Margin = new System.Windows.Forms.Padding(0); + this.m_List.Name = "m_List"; + this.m_List.ScrollAlwaysVisible = true; + this.m_List.Size = new System.Drawing.Size(400, 168); + this.m_List.TabIndex = 0; + this.m_List.DoubleClick += new System.EventHandler(this.m_List_DoubleClick); + this.m_List.SelectedIndexChanged += new System.EventHandler(this.m_List_SelectedIndexChanged); + // + // m_Picture + // + this.m_Picture.Dock = System.Windows.Forms.DockStyle.Fill; + this.m_Picture.Location = new System.Drawing.Point(400, 0); + this.m_Picture.Name = "m_Picture"; + this.m_Picture.Size = new System.Drawing.Size(194, 168); + this.m_Picture.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.m_Picture.TabIndex = 1; + this.m_Picture.TabStop = false; + // + // OpenModelDialog + // + this.AutoSize = true; + this.ClientSize = new System.Drawing.Size(594, 168); + this.Controls.Add(this.m_Picture); + this.Controls.Add(this.m_List); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "OpenModelDialog"; + this.ShowIcon = false; + this.Text = "Model"; + ((System.ComponentModel.ISupportInitialize)(this.m_Picture)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ListBox m_List; + private System.Windows.Forms.PictureBox m_Picture; + } +} \ No newline at end of file Added: src/test_applications/ItemsViewer/OpenModelDialog.cs =================================================================== --- src/test_applications/ItemsViewer/OpenModelDialog.cs (rev 0) +++ src/test_applications/ItemsViewer/OpenModelDialog.cs 2006-06-26 15:10:32 UTC (rev 8) @@ -0,0 +1,54 @@ +using System; +using System.IO; +using System.Collections.Specialized; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace RPGWorldModel.ItemsViewer +{ + public partial class OpenModelDialog : Form + { + private string m_SelectedModel; + private NameValueCollection m_Models; + + public OpenModelDialog(NameValueCollection models) + { + InitializeComponent(); + + this.m_Models = models; + + foreach (string key in this.m_Models.AllKeys) + this.m_List.Items.Add(key); + + this.m_List.SelectedIndex = -1; + } + + private void m_List_SelectedIndexChanged(object sender, EventArgs e) + { + string file = this.m_Models[this.m_List.SelectedItem.ToString()]; + // Load the model image + this.m_Picture.Load(Path.GetDirectoryName(file) + Path.DirectorySeparatorChar + + Path.GetFileNameWithoutExtension(file) + @".bmp"); + } + + private void m_List_DoubleClick(object sender, EventArgs e) + { + if (this.m_List.SelectedItem != null) + { + this.m_SelectedModel = this.m_List.SelectedItem.ToString(); + + this.DialogResult = DialogResult.OK; + this.Close(); + } + } + + public string SelectedModel + { + get + { + return this.m_SelectedModel; + } + } + } +} \ No newline at end of file Modified: src/test_applications/ItemsViewer/Program.cs =================================================================== --- src/test_applications/ItemsViewer/Program.cs 2006-06-25 10:49:06 UTC (rev 7) +++ src/test_applications/ItemsViewer/Program.cs 2006-06-26 15:10:32 UTC (rev 8) @@ -1,19 +1,13 @@ using System; -using System.Collections.Generic; -using System.Windows.Forms; -namespace ModelViewer +namespace RPGWorldModel.ItemsViewer { static class Program { - /// <summary> - /// The main entry point for the application. - /// </summary> [STAThread] static void Main() { - Surface surface = new Surface(); - surface.ShowDialog(); + ViewController view = new ViewController(); } } } \ No newline at end of file Deleted: src/test_applications/ItemsViewer/Surface.Designer.cs =================================================================== --- src/test_applications/ItemsViewer/Surface.Designer.cs 2006-06-25 10:49:06 UTC (rev 7) +++ src/test_applications/ItemsViewer/Surface.Designer.cs 2006-06-26 15:10:32 UTC (rev 8) @@ -1,51 +0,0 @@ -namespace ModelViewer -{ - partial class Surface - { - /// <summary> - /// Required designer variable. - /// </summary> - private System.ComponentModel.IContainer components = null; - - /// <summary> - /// Clean up any resources being used. - /// </summary> - /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// <summary> - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// </summary> - private void InitializeComponent() - { - this.SuspendLayout(); - // - // Surface - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(794, 568); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Name = "Surface"; - this.ShowIcon = false; - this.WindowState = System.Windows.Forms.FormWindowState.Maximized; - this.Load += new System.EventHandler(this.Surface_Load); - this.ResumeLayout(false); - - } - - #endregion - - } -} - Modified: src/test_applications/ItemsViewer/Surface.cs =================================================================== --- src/test_applications/ItemsViewer/Surface.cs 2006-06-25 10:49:06 UTC (rev 7) +++ src/test_applications/ItemsViewer/Surface.cs 2006-06-26 15:10:32 UTC (rev 8) @@ -7,37 +7,78 @@ using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; -namespace ModelViewer +namespace RPGWorldModel.ItemsViewer { - public partial class Surface : Form + public sealed partial class Surface : Form { - private Device m_RenderingDevice = null; - private PresentParameters m_DeviceParameters = null; - private Mesh m_SceenObjct = null; - private Material[] m_ObjectMaterials; - private Texture[] m_ObjectTextures; + private Device m_RenderingDevice; + private IModel m_Model; public Surface() { - InitializeComponent(); + this.SuspendLayout(); + + this.ClientSize = new System.Drawing.Size(800, 600); + this.ShowIcon = false; + this.KeyDown += new KeyEventHandler(Surface_KeyDown); + this.Paint += new PaintEventHandler(Surface_Paint); + + this.ResumeLayout(false); + + this.InitializeDevice(); } - private void SetMetrices() + void Surface_Paint(object sender, PaintEventArgs e) { - this.m_RenderingDevice.Transform.View = Matrix.LookAtLH(new Vector3(0.0f, 0.0f, -100.0f), - new Vector3(0.0f, 0.0f, 0.0f), - new Vector3(1.0f, 1.0f, 0.0f)); + this.RenderSceen(); + } - this.m_RenderingDevice.Transform.World = Matrix.Scaling(0.1f, 0.1f, 0.1f); - + float yAngle = 0.0f; + float xAngle = 0.0f; + + void Surface_KeyDown(object sender, KeyEventArgs e) + { + switch (e.KeyCode) + { + case(Keys.Left): + { + this.m_RenderingDevice.Transform.World = Matrix.RotationY((yAngle += 0.1f)); + this.RenderSceen(); + break; + } + case (Keys.Right): + { + this.m_RenderingDevice.Transform.World = Matrix.RotationY((yAngle -= 0.1f)); + this.RenderSceen(); + break; + } + case (Keys.Up): + { + this.m_RenderingDevice.Transform.World = Matrix.RotationX((xAngle += 0.1f)); + this.RenderSceen(); + break; + } + case (Keys.Down): + { + this.m_RenderingDevice.Transform.World = Matrix.RotationX((xAngle -= 0.1f)); + this.RenderSceen(); + break; + } + } + } + + private void InitializeDevice() + { + PresentParameters parameters = new PresentParameters(); + parameters.Windowed = true; + parameters.SwapEffect = SwapEffect.Discard; + + this.m_RenderingDevice = new Device(0, DeviceType.Hardware, + this, CreateFlags.SoftwareVertexProcessing, parameters); + + // Set metrices + this.m_RenderingDevice.Transform.View = Matrix.LookAtLH(new Vector3(0.0f, 0.0f, -100.0f), new Vector3(0.0f, 0.0f, 50.0f), new Vector3(0.0f, 1.0f, 0.0f)); this.m_RenderingDevice.Transform.Projection = Matrix.PerspectiveFovLH((float)(Math.PI / 2), 1.0f, 1.0f, 100.0f); - - this.m_RenderingDevice.Lights[0].Type = LightType.Directional; - this.m_RenderingDevice.Lights[0].Diffuse = System.Drawing.Color.Red; - this.m_RenderingDevice.Lights[0].Direction = new Vector3((float)Math.Cos(Environment.TickCount / 250.0f), 1.0f, (float)Math.Sin(Environment.TickCount / 250.0f)); - this.m_RenderingDevice.Lights[0].Direction = new Vector3(-1, 0, 0); - this.m_RenderingDevice.Lights[0].Enabled = true; - } public void RenderSceen() @@ -47,59 +88,39 @@ this.m_RenderingDevice.RenderState.Ambient = System.Drawing.Color.FromArgb(0x676766); - for (int i = 0; i < this.m_ObjectMaterials.Length; i++) + for (int i = 0; i < this.m_Model.Materials.Length; i++) { - this.m_RenderingDevice.Material = this.m_ObjectMaterials[i]; - this.m_RenderingDevice.SetTexture(0, this.m_ObjectTextures[i]); - this.m_SceenObjct.DrawSubset(i); + this.m_RenderingDevice.Material = this.m_Model.Materials[i]; + this.m_RenderingDevice.SetTexture(0, this.m_Model.Textures[i]); + this.m_Model.Object.DrawSubset(i); } this.m_RenderingDevice.EndScene(); this.m_RenderingDevice.Present(); } - private void Surface_Load(object sender, EventArgs e) + #region Public properties + + public Device RenderingDevice { - using (OpenFileDialog modelSource = new OpenFileDialog()) + get { - modelSource.Multiselect = false; - modelSource.Filter = "DirectX X Models (*.x)|*.x"; + return this.m_RenderingDevice; + } + } - if (modelSource.ShowDialog() == DialogResult.OK) - { - System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(modelSource.FileName)); - - this.m_DeviceParameters = new PresentParameters(); - this.m_DeviceParameters.Windowed = true; - this.m_DeviceParameters.SwapEffect = SwapEffect.Discard; - - this.m_RenderingDevice = new Device(0, DeviceType.Hardware, - this, CreateFlags.SoftwareVertexProcessing, this.m_DeviceParameters); - - ExtendedMaterial[] materials; - - this.m_SceenObjct = Mesh.FromFile(System.IO.Path.GetFileName(modelSource.FileName), MeshFlags.SystemMemory, this.m_RenderingDevice, out materials); - - this.m_ObjectTextures = new Texture[materials.Length]; - this.m_ObjectMaterials = new Material[materials.Length]; - - for (int i = 0; i < materials.Length; i++) - { - this.m_ObjectMaterials[i] = materials[i].Material3D; - this.m_ObjectMaterials[i].Ambient = this.m_ObjectMaterials[i].Diffuse; - this.m_ObjectTextures[i] = TextureLoader.FromFile(this.m_RenderingDevice, materials[i].TextureFilename); - } - - this.SetMetrices(); - - this.RenderSceen(); - } - else - { - MessageBox.Show("No model selected"); - this.Close(); - } + public IModel Model + { + get + { + return this.m_Model; } + set + { + this.m_Model = value; + } } + + #endregion } } \ No newline at end of file Deleted: src/test_applications/ItemsViewer/Surface.resx =================================================================== --- src/test_applications/ItemsViewer/Surface.resx 2006-06-25 10:49:06 UTC (rev 7) +++ src/test_applications/ItemsViewer/Surface.resx 2006-06-26 15:10:32 UTC (rev 8) @@ -1,120 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<root> - <!-- - Microsoft ResX Schema - - Version 2.0 - - The primary goals of this format is to allow a simple XML format - that is mostly human readable. The generation and parsing of the - various data types are done through the TypeConverter classes - associated with the data types. - - Example: - - ... ado.net/XML headers & schema ... - <resheader name="resmimetype">text/microsoft-resx</resheader> - <resheader name="version">2.0</resheader> - <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> - <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> - <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> - <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> - <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> - <value>[base64 mime encoded serialized .NET Framework object]</value> - </data> - <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> - <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> - <comment>This is a comment</comment> - </data> - - There are any number of "resheader" rows that contain simple - name/value pairs. - - Each data row contains a name, and value. The row also contains a - type or mimetype. Type corresponds to a .NET class that support - text/value conversion through the TypeConverter architecture. - Classes that don't support this are serialized and stored with the - mimetype set. - - The mimetype is used for serialized objects, and tells the - ResXResourceReader how to depersist the object. This is currently not - extensible. For a given mimetype the value must be set accordingly: - - Note - application/x-microsoft.net.object.binary.base64 is the format - that the ResXResourceWriter will generate, however the reader can - read any of the formats listed below. - - mimetype: application/x-microsoft.net.object.binary.base64 - value : The object must be serialized with - : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter - : and then encoded with base64 encoding. - - mimetype: application/x-microsoft.net.object.soap.base64 - value : The object must be serialized with - : System.Runtime.Serialization.Formatters.Soap.SoapFormatter - : and then encoded with base64 encoding. - - mimetype: application/x-microsoft.net.object.bytearray.base64 - value : The object must be serialized into a byte array - : using a System.ComponentModel.TypeConverter - : and then encoded with base64 encoding. - --> - <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> - <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> - <xsd:element name="root" msdata:IsDataSet="true"> - <xsd:complexType> - <xsd:choice maxOccurs="unbounded"> - <xsd:element name="metadata"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="value" type="xsd:string" minOccurs="0" /> - </xsd:sequence> - <xsd:attribute name="name" use="required" type="xsd:string" /> - <xsd:attribute name="type" type="xsd:string" /> - <xsd:attribute name="mimetype" type="xsd:string" /> - <xsd:attribute ref="xml:space" /> - </xsd:complexType> - </xsd:element> - <xsd:element name="assembly"> - <xsd:complexType> - <xsd:attribute name="alias" type="xsd:string" /> - <xsd:attribute name="name" type="xsd:string" /> - </xsd:complexType> - </xsd:element> - <xsd:element name="data"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> - <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> - <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> - <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> - <xsd:attribute ref="xml:space" /> - </xsd:complexType> - </xsd:element> - <xsd:element name="resheader"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string" use="required" /> - </xsd:complexType> - </xsd:element> - </xsd:choice> - </xsd:complexType> - </xsd:element> - </xsd:schema> - <resheader name="resmimetype"> - <value>text/microsoft-resx</value> - </resheader> - <resheader name="version"> - <value>2.0</value> - </resheader> - <resheader name="reader"> - <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> - </resheader> - <resheader name="writer"> - <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> - </resheader> -</root> \ No newline at end of file Added: src/test_applications/ItemsViewer/ViewController.cs =================================================================== --- src/test_applications/ItemsViewer/ViewController.cs (rev 0) +++ src/test_applications/ItemsViewer/ViewController.cs 2006-06-26 15:10:32 UTC (rev 8) @@ -0,0 +1,54 @@ +using System; +using System.IO; +using System.Configuration; +using System.Collections.Specialized; +using System.Windows.Forms; + +namespace RPGWorldModel.ItemsViewer +{ + public sealed class ViewController + { + private Surface m_View; + private Model m_Model; + + public ViewController() + { + this.m_View = new Surface(); + + if (this.LoadModel()) + { + this.m_View.Model = this.m_Model; + this.m_View.ShowDialog(); + } + } + + private bool LoadModel() + { + NameValueCollection models = (NameValueCollection)ConfigurationManager.GetSection("models"); + + if (models != null) + { + using (OpenModelDialog openModel = new OpenModelDialog(models)) + { + Directory.SetCurrentDirectory(Application.StartupPath); + + if (openModel.ShowDialog() == DialogResult.OK) + { + try + { + this.m_Model = new Model(models[openModel.SelectedModel], this.m_View.RenderingDevice); + } + catch + { + return false; + } + + return true; + } + } + } + + return false; + } + } +} Added: src/test_applications/ItemsViewer/ViewState.cs =================================================================== --- src/test_applications/ItemsViewer/ViewState.cs (rev 0) +++ src/test_applications/ItemsViewer/ViewState.cs 2006-06-26 15:10:32 UTC (rev 8) @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace RPGWorldModel.ItemsViewer +{ + public struct ViewState + { + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dea...@us...> - 2006-06-25 10:49:14
|
Revision: 7 Author: deadwood_pl Date: 2006-06-25 03:49:06 -0700 (Sun, 25 Jun 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=7&view=rev Log Message: ----------- bugfix ;) Modified Paths: -------------- src/test_applications/ItemsViewer/readme.html Modified: src/test_applications/ItemsViewer/readme.html =================================================================== --- src/test_applications/ItemsViewer/readme.html 2006-06-25 10:09:41 UTC (rev 6) +++ src/test_applications/ItemsViewer/readme.html 2006-06-25 10:49:06 UTC (rev 7) @@ -1,10 +1,10 @@ <html> <body> - <tt><h1>RPGWorldModel items viewer</h1></tt> + <tt><h1>RPGWorldModel Items viewer</h1></tt> <p>This application requires DirectX 9.0c installed. DirectX is available at this page : - <a href"http://www.microsoft.com/downloads">Microsoft Dowloads</a> + <a target="blank" href="http://www.microsoft.com/downloads">Microsoft Dowloads</a> under the DirectX Download Category. You can download the Microsoft DirectX SDK from there.<p/> <p>Please contact the project administrator for a set of medels to start working with this application.</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2006-06-25 10:09:51
|
Revision: 6 Author: poserdev Date: 2006-06-25 03:09:41 -0700 (Sun, 25 Jun 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=6&view=rev Log Message: ----------- Readme informations for the ItemsViewer. Added Paths: ----------- src/test_applications/ItemsViewer/readme.html Added: src/test_applications/ItemsViewer/readme.html =================================================================== --- src/test_applications/ItemsViewer/readme.html (rev 0) +++ src/test_applications/ItemsViewer/readme.html 2006-06-25 10:09:41 UTC (rev 6) @@ -0,0 +1,14 @@ +<html> + <body> + <tt><h1>RPGWorldModel items viewer</h1></tt> + + <p>This application requires DirectX 9.0c installed. + DirectX is available at this page : + <a href"http://www.microsoft.com/downloads">Microsoft Dowloads</a> + under the DirectX Download Category. You can download the Microsoft DirectX SDK from there.<p/> + + <p>Please contact the project administrator for a set of medels to start working with this application.</p> + + <b><tt>The RPGWorldModel team</tt></b> + </body> +</html> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |