110,536
社区成员
发帖
与我相关
我的任务
分享
[Serializable]
public class GameObject
{
/// <summary>
/// 所有怪物
/// </summary>
public WatchedList<Monster> Monsters;
/// <summary>
/// 所有资源
/// </summary>
public WatchedList<Resources> Resources;
/// <summary>
/// 所有动画
/// </summary>
public WatchedList<Animation> Animations;
/// <summary>
/// 所有武器
/// </summary>
public WatchedList<Weapon> Weapons;
/// <summary>
/// 所有子弹
/// </summary>
public WatchedList<Bullet> Bullets;
}
[Serializable]
public class WatchedList<T> : List<T>
{
public void Add(T item)
{
base.Add(item);
ObjectEvent(this, new ObjectEventArgs<T>(item, ObjectEventType.Add));
}
public bool Remove(T item)
{
if (base.Remove(item))
{
ObjectEvent(this, new ObjectEventArgs<T>(item, ObjectEventType.Del));
return true;
}
return false;
}
public event ObjectEventHandler<T> ObjectEvent;
public WatchedList(IEnumerable<T> collection)
: base(collection)
{
}
public WatchedList()
: base()
{
}
public WatchedList(int capacity)
: base(capacity)
{
}
}
[Serializable]
public class Bullet:ICloneable
{
[DescriptionAttribute("类型ID")
, CategoryAttribute("基本信息")]
public int TypeID { get; set; }
[DescriptionAttribute("武器名称")
, CategoryAttribute("基本信息")]
public String Name { get; set; }
}
<?xml version="1.0"?>
<GameObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Monsters>
<Monster>
<TypeID>1</TypeID>
<Name>新建怪物种类</Name>
<MonsProp>
<Level>0</Level>
<Life>0</Life>
<Def>0</Def>
<Atk>0</Atk>
<Agi>0</Agi>
<Weight>0</Weight>
<WalkSpeed>0</WalkSpeed>
<FlySpeed>0</FlySpeed>
</MonsProp>
<Items>
<WeaponID>0</WeaponID>
<FlightVehicleID>0</FlightVehicleID>
</Items>
</Monster>
</Monsters>
<Resources>
<Resources>
<ResID>1</ResID>
<Name>新建资源</Name>
</Resources>
</Resources>
<Animations>
<Animation>
<AniID>1</AniID>
<Name>新建动画</Name>
<NumX>0</NumX>
<NumY>0</NumY>
<NumFrame>0</NumFrame>
<PicWidth>0</PicWidth>
<PicHeight>0</PicHeight>
<PicX>0</PicX>
<PicY>0</PicY>
</Animation>
</Animations>
<Weapons>
<Weapon>
<TypeID>1</TypeID>
<Name>新建武器类型</Name>
<IcoName>BulletIco</IcoName>
<Bullets>
<TheBullet>
<BulletTypeID>1</BulletTypeID>
<Speed>
<X>300</X>
<Y>0</Y>
</Speed>
<Offset>
<X>0</X>
<Y>0</Y>
</Offset>
</TheBullet>
</Bullets>
<AutoCast>false</AutoCast>
<BulletAmount>-1</BulletAmount>
</Weapon>
</Weapons>
<Bullets />
</GameObject>