using System; using CommonLang; using CommonLang.IO; using CommonAI.Zone.Instance; using CommonAI.Zone.Formula; using CommonAI.Zone.Helper; using CommonAI.Zone.ZoneEditor; using CommonLang.Xml; using CommonAI.ZoneClient; using CommonAI.Zone.Simple; using CommonAI.Data; using System.Collections.Generic; namespace CommonAI.Zone { /// /// 客户端用于监听场景行为的监听器 /// public interface InstanceZoneListener { void onEventHandler(Event e); bool CheckDropItem(); } public abstract class InstanceZoneFactory { protected InstanceZoneFactory() { InitData(); } public virtual Random CreateRandom(int seed) { return new Random(seed); } //------------------------------------------------------------------------------------------------------------------------------- #region --Host-- /// /// 扩展以及公式 /// abstract public IFormula Formula { get; } /// /// 创建场景 /// /// /// /// /// public virtual EditorScene CreateEditorScene(TemplateManager templates, InstanceZoneListener listener, SceneData data, GSCreateAreaData gsData, string bindGameSrvId) { return new EditorScene(templates, listener, data, gsData, 9, DateTime.Now.Millisecond); } /// /// 创建法术 /// /// /// /// /// /// /// public virtual InstanceSpell CreateSpell(InstanceZone zone, SpellTemplate data, LaunchSpell launch, InstanceUnit launcher, InstanceZoneObject sender, XmdsSkillType fromSkillType, Dictionary damageList, int manyCannonMax, JSGCreateSpellData createData) { return new InstanceSpell(zone, data, launch, launcher, sender, damageList, fromSkillType, manyCannonMax, createData); } /// /// 创建物品 /// /// /// /// /// /// /// public virtual InstanceItem CreateItem(InstanceZone zone, ItemTemplate item, string name, int force, InstanceUnit creater, string disPlayName,int from) { return new InstanceItem(zone, item, name, force, creater, disPlayName,from); } /// /// 创建单位 /// /// /// /// /// /// /// public virtual InstanceUnit CreateUnit(InstanceZone zone, UnitInfo info, string name, int force, int alliesForce, int level) { InstanceUnit ret = null; if (info.UType == UnitInfo.UnitType.TYPE_PLAYER) { ret = new InstancePlayer(zone, info, name, force, level, alliesForce); } else if (info.UType == UnitInfo.UnitType.TYPE_PET) { ret = new InstancePet(zone, info, name, force, level); } else if (info.UType == UnitInfo.UnitType.TYPE_SUMMON) { ret = new InstanceSummon(zone, info, name, force, level); } else if (info.UType == UnitInfo.UnitType.TYPE_BUILDING) { ret = new InstanceBuilding(zone, info, name, force, level); } else if (info.UType == UnitInfo.UnitType.TYPE_MANUAL) { ret = new InstanceManual(zone, info, name, force, level); } else if (info.UType == UnitInfo.UnitType.TYPE_TRIGGER) { ret = new InstanceTriggerUnit(zone, info, name, force, level); } else if (info.UType == UnitInfo.UnitType.TYPE_NEUTRALITY) { ret = new InstanceNature(zone, info, name, force, level); } else { ret = new InstanceGuard(zone, info, name, force, level); } return ret; } /// /// 创建单位仇恨系统 /// /// /// public virtual HateSystem CreateHateSystem(InstanceUnit owner) { return new SimpleHateSystem(owner); } /// /// 创建任务事件接口 /// /// /// public abstract IQuestAdapter CreateQuestAdapter(InstanceZone zone); public virtual IVirtualUnit CreateUnitVirtual(InstanceUnit owner) { return null; } #endregion //------------------------------------------------------------------------------------------------------------------------------- #region --Client-- /// /// 创建客户端显示名称规则 /// /// /// /// public virtual string ToClientDisplayName(UnitInfo info, SyncUnitInfo syncInfo) { return info.Name; } /// /// 创建客户端代理场景 /// /// /// /// public virtual ZoneLayer CreateClientZoneLayer(EditorTemplates templates, ILayerClient listener) { return new ZoneLayer(templates, listener); } public virtual ZoneSpell CreateClientSpell(ZoneLayer parent, SpellTemplate info, SyncSpellInfo syn, AddSpellEvent add = null) { return new ZoneSpell(info, syn, parent, add); } public virtual ZoneItem CreateClientItem(ZoneLayer parent, ItemTemplate info, SyncItemInfo syn, AddItemEvent add = null) { return new ZoneItem(info, syn, parent, add); } public virtual ZoneUnit CreateClientUnit(ZoneLayer parent, UnitInfo info, SyncUnitInfo syn, AddUnitEvent add = null) { return new ZoneUnit(info, syn, parent, add); } public virtual ZoneActor CreateClientActor(ZoneLayer parent, UnitInfo info, LockActorEvent add) { return new ZoneActor(info, add, parent); } public virtual IVirtualClientUnit CreateClientUnitVirtual(ZoneClient.ZoneUnit owner) { return null; } #endregion //------------------------------------------------------------------------------------------------------------------------------- #region --Data-- public abstract ICommonConfig CreateCommonCFG(); public abstract IUnitProperties CreateUnitProperties(); public abstract ISkillProperties CreateSkillProperties(); public abstract ISpellProperties CreateSpellProperties(); public abstract IBuffProperties CreateBuffProperties(); public abstract IItemProperties CreateItemProperties(); public abstract IUnitTriggerProperties CreateTriggerProperties(); public abstract ISceneProperties CreateSceneProperties(); public abstract IAttackProperties CreateAttackProperties(); public Type ExtConfigType { get; private set; } public Type ScenePropertiesType { get; private set; } public Type UnitPropertiesType { get; private set; } public Type BuffPropertiesType { get; private set; } public Type ItemPropertiesType { get; private set; } public Type SkillPropertiesType { get; private set; } public Type SpellPropertiesType { get; private set; } public Type UnitTriggerPropertiesType { get; private set; } private void InitData() { ExtConfigType = CreateCommonCFG().GetType(); UnitPropertiesType = CreateUnitProperties().GetType(); SkillPropertiesType = CreateSkillProperties().GetType(); SpellPropertiesType = CreateSpellProperties().GetType(); BuffPropertiesType = CreateBuffProperties().GetType(); ItemPropertiesType = CreateItemProperties().GetType(); UnitTriggerPropertiesType = CreateTriggerProperties().GetType(); ScenePropertiesType = CreateSceneProperties().GetType(); } #endregion //------------------------------------------------------------------------------------------------------------------------------- } //--------------------------------------------------------------------------------------------- public interface ICommonConfig { void init(); } public interface IUnitProperties : ICloneable, IExternalizable { } public interface ISkillProperties : ICloneable, IExternalizable { XmdsSkillType GetSkillType(); // 多段式存储 int GetSkillUseTimes(); // 获取技能可使用次数 int GetSkillAddTimeInterval(); // 获取技能增加使用次数时间间隔 } public interface ISpellProperties : ICloneable, IExternalizable { } public interface IBuffProperties : ICloneable, IExternalizable { } public interface IItemProperties : ICloneable, IExternalizable { } public interface IUnitTriggerProperties : ICloneable, IExternalizable { } public interface ISceneProperties : ICloneable, IExternalizable { void OnInit(InstanceZone owner); //0-不允许自动战斗,1-允许自动战斗,2-通过后自动站点,3-进入默认自动战斗 byte GetAutoFightFlag(); } public interface IAttackProperties : ICloneable, IExternalizable { int GetAttackID(); } //--------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------- }