123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using CommonLang;
- using CommonAI.Zone.Helper;
- namespace CommonAI.Zone.Instance
- {
- /// <summary>
- /// 代理用类
- /// </summary>
- partial class InstanceZone
- {
- private InstanceUnit mLastAddedUnit;
- private InstanceUnit mLastActivatedUnit;
- private InstanceUnit mLastRebirthUnit;
- private InstanceUnit mLastHittedUnit;
- private InstanceUnit mLastAttackUnit;
- private InstanceUnit mLastKilledUnit;
- private InstanceItem mLastCreatedInstanceItem;
- private InstanceItem mLastUnitGotInstanceItem;
- private ItemTemplate mLastUnitGotItem;
- private ItemTemplate mLastUnitLostItem;
- private ItemTemplate mLastUnitUseItem;
- private BuffTemplate mLastUnitGotBuff;
- private InstanceUnit mLastPickingItemUnit;
- private InstanceItem mLastPickingItem;
- private InstanceUnit mLastPickableUnit;
- private InstanceUnit mLastLaunchSkillUnit;
- private SkillTemplate mLastLaunchSkill;
- private SpellTemplate mLastLaunchSpell;
- private ZoneServer.SendMessageR2B mLastRecvMessageR2B;
- private ZoneServer.SendMessageB2R mLastSentMessageB2R;
- //当前场景类型
- protected CommonAI.Data.SceneType mSceneType;
- public InstanceUnit LastAddedUnit
- {
- get { return mLastAddedUnit; }
- private set { if (value != null) mLastAddedUnit = value; }
- }
- public InstanceUnit LastActivatedUnit
- {
- get { return mLastActivatedUnit; }
- private set { if (value != null) mLastActivatedUnit = value; }
- }
- public InstanceUnit LastRebirthUnit
- {
- get { return mLastRebirthUnit; }
- private set { if (value != null) mLastRebirthUnit = value; }
- }
- public InstanceUnit LastHittedUnit
- {
- get { return mLastHittedUnit; }
- private set { if (value != null) mLastHittedUnit = value; }
- }
- public InstanceUnit LastAttackUnit
- {
- get { return mLastAttackUnit; }
- private set { if (value != null) mLastAttackUnit = value; }
- }
- public InstanceUnit LastKilledUnit
- {
- get { return mLastKilledUnit; }
- private set { if (value != null) mLastKilledUnit = value; }
- }
- public InstanceItem LastCreatedInstanceItem
- {
- get { return mLastCreatedInstanceItem; }
- private set { if (value != null) mLastCreatedInstanceItem = value; }
- }
- public InstanceItem LastUnitGotInstanceItem
- {
- get { return mLastUnitGotInstanceItem; }
- private set { if (value != null) mLastUnitGotInstanceItem = value; }
- }
- public ItemTemplate LastUnitGotInventoryItem
- {
- get { return mLastUnitGotItem; }
- private set { if (value != null) mLastUnitGotItem = value; }
- }
- public ItemTemplate LastUnitLostInventoryItem
- {
- get { return mLastUnitLostItem; }
- private set { if (value != null) mLastUnitLostItem = value; }
- }
- public ItemTemplate LastUnitUseItem
- {
- get { return mLastUnitUseItem; }
- private set { if (value != null) mLastUnitUseItem = value; }
- }
- public BuffTemplate LastUnitGotBuff
- {
- get { return mLastUnitGotBuff; }
- private set { if (value != null) mLastUnitGotBuff = value; }
- }
- public InstanceUnit LastPickingItemUnit
- {
- get { return mLastPickingItemUnit; }
- private set { if (value != null) mLastPickingItemUnit = value; }
- }
- public InstanceItem LastPickingItem
- {
- get { return mLastPickingItem; }
- private set { if (value != null) mLastPickingItem = value; }
- }
- public InstanceUnit LastPickableUnit
- {
- get { return mLastPickableUnit; }
- private set { if (value != null) mLastPickableUnit = value; }
- }
-
- public InstanceUnit LastLaunchSkillUnit
- {
- get { return mLastLaunchSkillUnit; }
- private set { if (value != null) mLastLaunchSkillUnit = value; }
- }
- public SkillTemplate LastLaunchSkill
- {
- get { return mLastLaunchSkill; }
- private set { if (value != null) mLastLaunchSkill = value; }
- }
- public SpellTemplate LastLaunchSpell
- {
- get { return mLastLaunchSpell; }
- private set { if (value != null) mLastLaunchSpell = value; }
- }
- public ZoneServer.SendMessageR2B LastRecvMessageR2B
- {
- get { return mLastRecvMessageR2B; }
- private set { if (value != null) mLastRecvMessageR2B = value; }
- }
- public ZoneServer.SendMessageB2R LastSentMessageB2R
- {
- get { return mLastSentMessageB2R; }
- private set { if (value != null) mLastSentMessageB2R = value; }
- }
- private void beginEventsRecord()
- {
- // mLastAddedUnit = null;
- // mLastActivatedUnit = null;
- // mLastRebirthUnit = null;
- // mLastHittedUnit = null;
- // mLastAttackUnit = null;
- // mLastKilledUnit = null;
- //
- // mLastCreatedInstanceItem = null;
- // mLastUnitGotInstanceItem = null;
- //
- // mLastUnitGotItem = null;
- // mLastUnitLostItem = null;
- // mLastUnitUseItem = null;
- // mLastUnitGotBuff = null;
- //
- // mLastPickingItemUnit = null;
- // mLastPickingItem = null;
- // mLastPickableUnit = null;
- //
- // mLastLaunchSkillUnit = null;
- // mLastLaunchSkill = null;
- // mLastLaunchSpell = null;
- //
- // mLastRecvMessageR2B = null;
- // mLastSentMessageB2R = null;
- }
- private HashMap<int, int> mForceTotalDead = new HashMap<int, int>();
- public int GetTotalForceDead(byte force)
- {
- int ret = 0;
- mForceTotalDead.TryGetValue(force, out ret);
- return ret;
- }
- private void statisticForceDead(InstanceUnit unit)
- {
- int ret = 0;
- mForceTotalDead.TryGetValue(unit.Force, out ret);
- ret += 1;
- mForceTotalDead[unit.Force] = ret;
- }
- #region LUA_API
- public int get_total_width()
- {
- return TotalWidth;
- }
- public int get_total_height()
- {
- return TotalHeight;
- }
- public int get_grid_cell_w()
- {
- return GridCellW;
- }
- public int get_grid_cell_h()
- {
- return GridCellH;
- }
- public int get_x_count()
- {
- return XCount;
- }
- public int get_y_count()
- {
- return YCount;
- }
- public ulong get_tick()
- {
- return Tick;
- }
- public long get_pass_time_ms()
- {
- return PassTimeMS;
- }
- public Random get_random()
- {
- return RandomN;
- }
- public bool is_attribute(string key)
- {
- return IsAttribute(key);
- }
- public void set_attribute(string key, object value)
- {
- SetAttribute(key, value);
- }
- public object get_attribute(string key)
- {
- return GetAttribute(key);
- }
- public InstanceUnit get_edit_unit(string name)
- {
- return GetEditUnit(name);
- }
- public InstanceFlag get_edit_flag(string name)
- {
- return GetEditFlag(name);
- }
- //public TimeTaskMS add_time_task_ms(int interval, int delay, int repeat, TickHandler handler)
- //{
- // return AddTimeTask(interval, delay, repeat, handler);
- //}
- //public TimeTaskMS add_time_delay_ms(int delay, TickHandler handler)
- //{
- // return AddTimeDelayMS(delay, handler);
- //}
- //public TimeTaskMS add_time_periodic_ms(int interval, TickHandler handler)
- //{
- // return AddTimePeriodicMS(interval, handler);
- //}
- public void do_client_script(string filename)
- {
- DoClientScript(filename);
- }
- public bool send_script_command(string reason)
- {
- return SendScriptCommand(reason);
- }
- public bool send_game_over(int force, string reason)
- {
- return GameOver(force, reason);
- }
- public InstanceUnit add_unit(int templateID, string name, byte force, int level, float x, float y, float direction)
- {
- return AddUnit(templateID, name, force, level, x, y, direction, false);
- }
- public InstanceItem add_item(int templateID, string name, byte force, float x, float y)
- {
- ItemTemplate info = Templates.getItem(templateID);
- if (info != null)
- {
- return AddItem(info, name, x, y, CMath.RandomAngle(RandomN), force, name, null,0);
- }
- return null;
- }
- public InstanceUnit GetEditUnit(string name)
- {
- return getUnitByName(name);
- }
- public InstanceFlag GetEditFlag(string name)
- {
- return getFlag(name);
- }
- public void DoClientScript(string filename)
- {
- DoScriptEvent evt = new DoScriptEvent(filename);
- queueEvent(evt);
- }
- public bool SendScriptCommand(string reason)
- {
- queueEvent(new ScriptCommandEvent(reason));
- return true;
- }
- public bool GameOver(int force, string reason)
- {
- queueEvent(new GameOverEvent(force, reason));
- return true;
- }
- [Obsolete]
- public List<InstanceUnit> GetAllUnits()
- {
- return new List<InstanceUnit>(this.AllUnits);
- }
- public void GetAllUnits(List<InstanceUnit> ret)
- {
- ret.AddRange(this.AllUnits);
- }
- public int GetAllUnitsCount()
- {
- return this.AllUnitsCount;
- }
- [Obsolete]
- public List<InstanceUnit> GetForceUnits(byte force)
- {
- List<InstanceUnit> ret = new List<InstanceUnit>(this.AllUnitsCount);
- foreach (InstanceUnit u in this.AllUnits)
- {
- if (u.Force == force)
- {
- ret.Add(u);
- }
- }
- return ret;
- }
- public void GetForceUnits(byte force, List<InstanceUnit> ret)
- {
- foreach (InstanceUnit u in this.AllUnits)
- {
- if (u.Force == force)
- {
- ret.Add(u);
- }
- }
- }
- public int GetForceUnitsCount(byte force)
- {
- int Count = 0;
- foreach (InstanceUnit u in this.AllUnits)
- {
- if (u.Force == force)
- {
- Count++;
- }
- }
- return Count;
- }
- public CommonAI.Data.SceneType SceneType
- {
- get { return mSceneType; }
- }
- #endregion
- }
- }
|