123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- 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
- {
- /// <summary>
- /// 客户端用于监听场景行为的监听器
- /// </summary>
- 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--
- /// <summary>
- /// 扩展以及公式
- /// </summary>
- abstract public IFormula Formula { get; }
- /// <summary>
- /// 创建场景
- /// </summary>
- /// <param name="templates"></param>
- /// <param name="listener"></param>
- /// <param name="data"></param>
- /// <returns></returns>
- 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);
- }
- /// <summary>
- /// 创建法术
- /// </summary>
- /// <param name="zone"></param>
- /// <param name="data"></param>
- /// <param name="launch"></param>
- /// <param name="launcher"></param>
- /// <param name="sender"></param>
- /// <returns></returns>
- public virtual InstanceSpell CreateSpell(InstanceZone zone, SpellTemplate data, LaunchSpell launch, InstanceUnit launcher, InstanceZoneObject sender,
- XmdsSkillType fromSkillType, Dictionary<uint, InstanceUnit> damageList, int manyCannonMax, JSGCreateSpellData createData)
- {
- return new InstanceSpell(zone, data, launch, launcher, sender, damageList, fromSkillType, manyCannonMax, createData);
- }
- /// <summary>
- /// 创建物品
- /// </summary>
- /// <param name="zone"></param>
- /// <param name="item"></param>
- /// <param name="name"></param>
- /// <param name="force"></param>
- /// <param name="creater"></param>
- /// <returns></returns>
- 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);
- }
- /// <summary>
- /// 创建单位
- /// </summary>
- /// <param name="zone"></param>
- /// <param name="info"></param>
- /// <param name="name"></param>
- /// <param name="force"></param>
- /// <param name="level"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 创建单位仇恨系统
- /// </summary>
- /// <param name="owner"></param>
- /// <returns></returns>
- public virtual HateSystem CreateHateSystem(InstanceUnit owner)
- {
- return new SimpleHateSystem(owner);
- }
- /// <summary>
- /// 创建任务事件接口
- /// </summary>
- /// <param name="zone"></param>
- /// <returns></returns>
- public abstract IQuestAdapter CreateQuestAdapter(InstanceZone zone);
- public virtual IVirtualUnit CreateUnitVirtual(InstanceUnit owner)
- {
- return null;
- }
- #endregion
- //-------------------------------------------------------------------------------------------------------------------------------
- #region --Client--
- /// <summary>
- /// 创建客户端显示名称规则
- /// </summary>
- /// <param name="info"></param>
- /// <param name="syncInfo"></param>
- /// <returns></returns>
- public virtual string ToClientDisplayName(UnitInfo info, SyncUnitInfo syncInfo)
- {
- return info.Name;
- }
- /// <summary>
- /// 创建客户端代理场景
- /// </summary>
- /// <param name="templates"></param>
- /// <param name="listener"></param>
- /// <returns></returns>
- 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();
- }
- //---------------------------------------------------------------------------------------------
- //---------------------------------------------------------------------------------------------
- }
|