|
@@ -126,13 +126,13 @@ namespace CommonAI.Zone.Instance
|
|
|
// this.path_terrain_area_gen = new ManhattanMapAreaGenerator(path_terrain_data.Data);
|
|
|
this.InitTerrain(data, spaceDivSize, out this.path_terrain_data, out this.path_finder, out this.path_terrain_area_gen);
|
|
|
this.mQuestAdapter = TemplateManager.Factory.CreateQuestAdapter(this);
|
|
|
- this.baseInit(data, gsData);
|
|
|
- }
|
|
|
+ this.baseInit(data, gsData);
|
|
|
+ }
|
|
|
|
|
|
- protected virtual void baseInit(ZoneEditor.SceneData data, GSCreateAreaData gsData)
|
|
|
- {
|
|
|
+ protected virtual void baseInit(ZoneEditor.SceneData data, GSCreateAreaData gsData)
|
|
|
+ {
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------
|
|
@@ -251,19 +251,19 @@ namespace CommonAI.Zone.Instance
|
|
|
mTasks.Enqueue(task);
|
|
|
}
|
|
|
|
|
|
- public string GetInfo()
|
|
|
- {
|
|
|
- if(this.mObjects == null)
|
|
|
- {
|
|
|
- return "对象:-1";
|
|
|
- }
|
|
|
-
|
|
|
- return "对象:" + AllObjectsCount + ", 单位:" + AllUnitsCount + ", 法术:" + AllSpellsCount + ", 道具:" + AllItemsCount + ", 玩家:" + AllPlayersCount;
|
|
|
- }
|
|
|
+ public string GetInfo()
|
|
|
+ {
|
|
|
+ if (this.mObjects == null)
|
|
|
+ {
|
|
|
+ return "对象:-1";
|
|
|
+ }
|
|
|
+
|
|
|
+ return "对象:" + AllObjectsCount + ", 单位:" + AllUnitsCount + ", 法术:" + AllSpellsCount + ", 道具:" + AllItemsCount + ", 玩家:" + AllPlayersCount;
|
|
|
+ }
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 【线程安全】增加时间任务
|
|
|
- /// </summary>
|
|
|
+ /// <summary>
|
|
|
+ /// 【线程安全】增加时间任务
|
|
|
+ /// </summary>
|
|
|
/// <param name="intervalMS"></param>
|
|
|
/// <param name="delayMS"></param>
|
|
|
/// <param name="repeat"></param>
|
|
@@ -288,11 +288,11 @@ namespace CommonAI.Zone.Instance
|
|
|
/// <param name="handler"></param>
|
|
|
public TimeTaskMS AddTimePeriodicMS(int intervalMS, TickHandler handler)
|
|
|
{
|
|
|
- if(intervalMS <= 0)
|
|
|
- {
|
|
|
- log.Error("增加定时任务异常:" + intervalMS);
|
|
|
- return null;
|
|
|
- }
|
|
|
+ if (intervalMS <= 0)
|
|
|
+ {
|
|
|
+ log.Error("增加定时任务异常:" + intervalMS);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
return mTimeTasks.AddTimePeriodicMS(intervalMS, handler);
|
|
|
}
|
|
|
|
|
@@ -327,21 +327,21 @@ namespace CommonAI.Zone.Instance
|
|
|
/// <param name="evt"></param>
|
|
|
public void queueObjectEvent(InstanceZoneObject obj, ObjectEvent evt, bool force = false)
|
|
|
{
|
|
|
- if(mSendingEvents == null)
|
|
|
- {
|
|
|
- if(mObjects == null)
|
|
|
- {
|
|
|
- log.Warn("queueObjectEvent exception1: " + this.GetSceneID() + ", mObjects null, " + this.UUID + ", " + evt.GetType()
|
|
|
+ if (mSendingEvents == null)
|
|
|
+ {
|
|
|
+ if (mObjects == null)
|
|
|
+ {
|
|
|
+ log.Warn("queueObjectEvent exception1: " + this.GetSceneID() + ", mObjects null, " + this.UUID + ", " + evt.GetType()
|
|
|
+ ", " + new StackTrace().ToString());
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- log.Warn("queueObjectEvent exception2: " + this.GetSceneID() + ", Players: " + this.AllPlayersCount + ", Items: "
|
|
|
- + this.AllItemsCount + ", Units: " + this.AllUnitsCount + ", " + this.UUID + ", " + evt.GetType() + ", " + new StackTrace().ToString());
|
|
|
- }
|
|
|
-
|
|
|
- return;
|
|
|
- }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ log.Warn("queueObjectEvent exception2: " + this.GetSceneID() + ", Players: " + this.AllPlayersCount + ", Items: "
|
|
|
+ + this.AllItemsCount + ", Units: " + this.AllUnitsCount + ", " + this.UUID + ", " + evt.GetType() + ", " + new StackTrace().ToString());
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
if (obj.ID == 0)
|
|
|
return;
|
|
@@ -819,22 +819,22 @@ namespace CommonAI.Zone.Instance
|
|
|
|
|
|
private long mAddUnitPrintTime = 0;
|
|
|
|
|
|
- public InstanceUnit AddUnit(UnitInfo info, string name, int force, int level, float x, float y, float direction,
|
|
|
+ public InstanceUnit AddUnit(UnitInfo info, string name, int force, int level, float x, float y, float direction,
|
|
|
out AddUnitEvent add, InstanceUnit summoner = null, String clientShowName = "", int gsFlag = 0, int alliesForce = 0, bool pointLv = false)
|
|
|
{
|
|
|
add = null;
|
|
|
- if (mObjects.UnitsCount >= mMaxUnitCount)
|
|
|
- {
|
|
|
- if(mAddUnitPrintTime < CommonLang.CUtils.localTimeMS)
|
|
|
+ if (mObjects.UnitsCount >= mMaxUnitCount)
|
|
|
+ {
|
|
|
+ if (mAddUnitPrintTime < CommonLang.CUtils.localTimeMS)
|
|
|
{
|
|
|
mAddUnitPrintTime = CommonLang.CUtils.localTimeMS + 3000;
|
|
|
log.Warn(string.Format("--Zone AddUnit to max: {0}, UUID: {1}, ID: {2} 单位数量:{3}", this.GetSceneID(), this.UUID, info.TemplateID, GetZoneUnitInfo()));
|
|
|
}
|
|
|
-
|
|
|
- return null;
|
|
|
- }
|
|
|
|
|
|
- if (mTryAddUnit != null && !mTryAddUnit.Invoke(info))
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mTryAddUnit != null && !mTryAddUnit.Invoke(info))
|
|
|
{
|
|
|
//log.Info(string.Format("Zone Unit TryAdd max: {0}, {1}, 单位数量:{2}", this.TerrainSrc.ID, info.TemplateID, mObjects.UnitsCount));
|
|
|
return null;
|
|
@@ -856,8 +856,8 @@ namespace CommonAI.Zone.Instance
|
|
|
if (unit is ISummonedUnit)
|
|
|
{
|
|
|
((ISummonedUnit)unit).SummonerUnit = summoner;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
unit.onAdded(this, pointLv);
|
|
@@ -908,7 +908,7 @@ namespace CommonAI.Zone.Instance
|
|
|
}
|
|
|
|
|
|
string finalStr = "";
|
|
|
- foreach(int unitID in mInfo.Keys)
|
|
|
+ foreach (int unitID in mInfo.Keys)
|
|
|
{
|
|
|
int count = mInfo.Get(unitID);
|
|
|
if (count < nMinNums)
|
|
@@ -923,16 +923,16 @@ namespace CommonAI.Zone.Instance
|
|
|
|
|
|
|
|
|
public InstanceItem AddItem(ItemTemplate template, string name, float x, float y, float direction, int force, string disPlayName,
|
|
|
- out AddItemEvent add, InstanceUnit creater,int from)
|
|
|
+ out AddItemEvent add, InstanceUnit creater, int from)
|
|
|
{
|
|
|
- add = null;
|
|
|
- if (mTryAddItem != null && !mTryAddItem.Invoke(template))
|
|
|
- {
|
|
|
- //log.Info(string.Format("Zone item TryAdd max: {0}, {1}", this.mSceneType, template.TemplateID));
|
|
|
- return null;
|
|
|
- }
|
|
|
+ add = null;
|
|
|
+ if (mTryAddItem != null && !mTryAddItem.Invoke(template))
|
|
|
+ {
|
|
|
+ //log.Info(string.Format("Zone item TryAdd max: {0}, {1}", this.mSceneType, template.TemplateID));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- InstanceItem ret = TemplateManager.Factory.CreateItem(this, template, name, force, creater, disPlayName,from);
|
|
|
+ InstanceItem ret = TemplateManager.Factory.CreateItem(this, template, name, force, creater, disPlayName, from);
|
|
|
ret.setPos(x, y);
|
|
|
if (ret.tryAdd(x, y, direction))
|
|
|
{
|
|
@@ -965,10 +965,10 @@ namespace CommonAI.Zone.Instance
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public InstanceItem AddItem(ItemTemplate template, string name, float x, float y, float direction, int force, string disPlayName, InstanceUnit creater,int from=0)
|
|
|
+ public InstanceItem AddItem(ItemTemplate template, string name, float x, float y, float direction, int force, string disPlayName, InstanceUnit creater, int from = 0)
|
|
|
{
|
|
|
AddItemEvent add;
|
|
|
- return AddItem(template, name, x, y, direction, force, disPlayName, out add, creater,from);
|
|
|
+ return AddItem(template, name, x, y, direction, force, disPlayName, out add, creater, from);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -997,12 +997,12 @@ namespace CommonAI.Zone.Instance
|
|
|
float startX,
|
|
|
float startY,
|
|
|
float direction,
|
|
|
- SpellChainLevelInfo chain = null,
|
|
|
+ SpellChainLevelInfo chain = null,
|
|
|
int actionIndex = -1,
|
|
|
int maxAffectUnit = 0,
|
|
|
- Dictionary<uint, InstanceUnit> damageList = null,
|
|
|
- int spellIndex = 0,
|
|
|
- JSGCreateSpellData createData = null)
|
|
|
+ Dictionary<uint, InstanceUnit> damageList = null,
|
|
|
+ int spellIndex = 0,
|
|
|
+ JSGCreateSpellData createData = null)
|
|
|
{
|
|
|
if (template != null && sender != null)
|
|
|
{
|
|
@@ -1053,23 +1053,23 @@ namespace CommonAI.Zone.Instance
|
|
|
// 创建实体单位
|
|
|
//InstanceSpell ret = new InstanceSpell(this, template, launch, launcher, sender, chainLevel);
|
|
|
InstanceSpell ret = TemplateManager.Factory.CreateSpell(this, template, launch, launcher, sender, fromSkillType, damageList, spellIndex, createData);
|
|
|
- //ret.Direction = direction;
|
|
|
- ret.BindActionIndex = actionIndex;
|
|
|
+ //ret.Direction = direction;
|
|
|
+ ret.BindActionIndex = actionIndex;
|
|
|
ret.MaxAffectUnit = (maxAffectUnit == 0) ? ret.Info.MaxAffectUnit : maxAffectUnit;
|
|
|
ret.faceTo(direction);
|
|
|
ret.setChainInfo(chain);
|
|
|
ret.setTargetPos(targetPos);
|
|
|
- ret.setTarget(target);
|
|
|
+ ret.setTarget(target);
|
|
|
|
|
|
- // 存入单位列表
|
|
|
- float xChanage, yChange;
|
|
|
- launch.GetXModify(launcher, out xChanage, out yChange);
|
|
|
- if (ret.tryAdd(startX + xChanage, startY + yChange, direction))
|
|
|
+ // 存入单位列表
|
|
|
+ float xChanage, yChange;
|
|
|
+ launch.GetXModify(launcher, out xChanage, out yChange);
|
|
|
+ if (ret.tryAdd(startX + xChanage, startY + yChange, direction))
|
|
|
{
|
|
|
- //System.Console.WriteLine("--AddSpell: " + ret.Info.ID + ", " + ret.ID);
|
|
|
- launcher.Virtual.DispatchSendSpellOverEvent(launch, template, ret.X, ret.Y);
|
|
|
+ //System.Console.WriteLine("--AddSpell: " + ret.Info.ID + ", " + ret.ID);
|
|
|
+ launcher.Virtual.DispatchSendSpellOverEvent(launch, template, ret.X, ret.Y);
|
|
|
|
|
|
- mObjects.AddObject(ret);
|
|
|
+ mObjects.AddObject(ret);
|
|
|
this.LastLaunchSpell = ret.Info;
|
|
|
ret.onAdded(this);
|
|
|
|
|
@@ -1102,11 +1102,11 @@ namespace CommonAI.Zone.Instance
|
|
|
if (mOnUnitRemoved != null)
|
|
|
mOnUnitRemoved.Invoke(this, unit);
|
|
|
}
|
|
|
- else if(obj is InstanceItem)
|
|
|
- {
|
|
|
- if (this.mOnItemRemoved != null)
|
|
|
- this.mOnItemRemoved.Invoke(this, (InstanceItem)obj);
|
|
|
- }
|
|
|
+ else if (obj is InstanceItem)
|
|
|
+ {
|
|
|
+ if (this.mOnItemRemoved != null)
|
|
|
+ this.mOnItemRemoved.Invoke(this, (InstanceItem)obj);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
if (obj.ClientVisible)
|
|
@@ -1144,7 +1144,7 @@ namespace CommonAI.Zone.Instance
|
|
|
public InstanceZoneObject RemoveSpellByLaunchIDAndSpellID(int launchId, int spellId)
|
|
|
{
|
|
|
InstanceSpell spell = mObjects.GetSpllByLanuchAndSpellId(launchId, spellId);
|
|
|
- if(spell != null && RemoveObject(spell))
|
|
|
+ if (spell != null && RemoveObject(spell))
|
|
|
{
|
|
|
return spell;
|
|
|
}
|
|
@@ -1153,10 +1153,10 @@ namespace CommonAI.Zone.Instance
|
|
|
|
|
|
|
|
|
public InstanceZoneObject RemoveItemByID(uint unitTemplateId)
|
|
|
- {
|
|
|
- InstanceItem obj = mObjects.GetItem(unitTemplateId);
|
|
|
- if (obj != null && RemoveObject(obj))
|
|
|
- {
|
|
|
+ {
|
|
|
+ InstanceItem obj = mObjects.GetItem(unitTemplateId);
|
|
|
+ if (obj != null && RemoveObject(obj))
|
|
|
+ {
|
|
|
Console.WriteLine("成功移除单位:" + unitTemplateId);
|
|
|
return obj;
|
|
|
}
|
|
@@ -1443,9 +1443,9 @@ namespace CommonAI.Zone.Instance
|
|
|
if (obj.mProcessDeadCallbackTime > 0)
|
|
|
{
|
|
|
log.Warn("单位多次回调死亡逻辑:" + this.GetSceneID() + ", " + this.UUID + ", " + obj.Info.ID + ", attackID:" +
|
|
|
- (attacker == null ? -1 : attacker.Info.ID) + ", UUID" + (attacker == null ? "null" : attacker.PlayerUUID) + ", " + CommonLang.TimeUtil.GetTimestampMS());
|
|
|
+ (attacker == null ? -1 : attacker.Info.ID) + ", UUID" + (attacker == null ? "null" : attacker.PlayerUUID) + ", " + obj.mProcessDeadCallbackTime);
|
|
|
}
|
|
|
- obj.mProcessDeadCallbackTime = CommonLang.CUtils.localTimeMS + 1000;
|
|
|
+ obj.mProcessDeadCallbackTime = CommonLang.CUtils.localTimeMS + 60000;
|
|
|
obj.mDeadTime = CommonLang.CUtils.localTimeMS;
|
|
|
|
|
|
statisticForceDead(obj);
|
|
@@ -1471,11 +1471,11 @@ namespace CommonAI.Zone.Instance
|
|
|
mOnUnitDead.Invoke(this, obj, attacker);
|
|
|
}
|
|
|
}
|
|
|
- catch(Exception e)
|
|
|
+ catch (Exception e)
|
|
|
{
|
|
|
log.Error("cb_unitDeadCallBackcatch: " + this.GetSceneID() + ", " + (obj == null ? -1 : obj.Info.ID) + ", " + (attacker == null ? -1 : attacker.Info.ID)
|
|
|
+ ",UUID: " + (obj == null ? "null" : obj.PlayerUUID) + ", " + (attacker == null ? "null" : attacker.PlayerUUID) + ", e: " + e);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
internal void cb_unitActivatedCallBack(InstanceUnit obj)
|
|
@@ -1685,10 +1685,10 @@ namespace CommonAI.Zone.Instance
|
|
|
/// <returns></returns>
|
|
|
public virtual bool IsAttackable(InstanceUnit src, InstanceUnit target, SkillTemplate.CastTarget expectTarget, AttackReason reason, ITemplateData weapon)
|
|
|
{
|
|
|
- if(src == null || target == null)
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ if (src == null || target == null)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
if (!IsVisibleAOI(src, target))
|
|
|
{
|
|
@@ -1909,7 +1909,7 @@ namespace CommonAI.Zone.Instance
|
|
|
uint targetUnitID = 0,
|
|
|
Vector2 targetPos = null, int actionIndex = -1, int maxAffectUnit = 0, float pointDir = 0)
|
|
|
{
|
|
|
- if(launch == null)
|
|
|
+ if (launch == null)
|
|
|
{
|
|
|
log.Error("单位释放技能异常: " + launcher.Info.ID + ", " + new StackTrace().ToString());
|
|
|
return;
|
|
@@ -1924,13 +1924,13 @@ namespace CommonAI.Zone.Instance
|
|
|
targetPos = (Vector2)targetPos.Clone();
|
|
|
}
|
|
|
SpellTemplate spell = Templates.getSpell(launch.SpellID);
|
|
|
- if(spell == null)
|
|
|
- {
|
|
|
- log.Error("unitLaunchSpell找不到法术模板:" + launcher.PlayerUUID + ", " + launch.SpellID + ", SN: " + launch.SerialNumber);
|
|
|
- return;
|
|
|
- }
|
|
|
- JSGCreateSpellData createData;
|
|
|
- if (spell != null && launch.Count > 0 && mFormula.TryLaunchSpell(launcher, launch, ref spell, out createData, ref startX, ref startY))
|
|
|
+ if (spell == null)
|
|
|
+ {
|
|
|
+ log.Error("unitLaunchSpell找不到法术模板:" + launcher.PlayerUUID + ", " + launch.SpellID + ", SN: " + launch.SerialNumber);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSGCreateSpellData createData;
|
|
|
+ if (spell != null && launch.Count > 0 && mFormula.TryLaunchSpell(launcher, launch, ref spell, out createData, ref startX, ref startY))
|
|
|
{
|
|
|
SpellChainLevelInfo chain = null;
|
|
|
if (launch.ChainLevel > 0)
|
|
@@ -2023,23 +2023,23 @@ namespace CommonAI.Zone.Instance
|
|
|
break;
|
|
|
case LaunchSpell.PosType.POS_TYPE_X:
|
|
|
{
|
|
|
- float startAngle = direction + launch.StartAngle;
|
|
|
- float[] interAngle = { launch.Angle, CMath.PI_F - launch.Angle, CMath.PI_F + launch.Angle, CMath.PI_F * 2 - launch.Angle };
|
|
|
- Dictionary<uint, InstanceUnit> damageList = (spell.HitIntervalMS <= 0 ? new Dictionary<uint, InstanceUnit>() : null);
|
|
|
-
|
|
|
- for (int i = 0; i < 4; i++)
|
|
|
- {
|
|
|
- AddSpell(fromSkillType, spell, launch, launcher, launcher, targetUnitID, targetPos,
|
|
|
- startX, startY, startAngle + interAngle[i], chain, actionIndex, maxAffectUnit, damageList);
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case LaunchSpell.PosType.POS_TYPE_RANDOM_DIRECTION:
|
|
|
+ float startAngle = direction + launch.StartAngle;
|
|
|
+ float[] interAngle = { launch.Angle, CMath.PI_F - launch.Angle, CMath.PI_F + launch.Angle, CMath.PI_F * 2 - launch.Angle };
|
|
|
+ Dictionary<uint, InstanceUnit> damageList = (spell.HitIntervalMS <= 0 ? new Dictionary<uint, InstanceUnit>() : null);
|
|
|
+
|
|
|
+ for (int i = 0; i < 4; i++)
|
|
|
+ {
|
|
|
+ AddSpell(fromSkillType, spell, launch, launcher, launcher, targetUnitID, targetPos,
|
|
|
+ startX, startY, startAngle + interAngle[i], chain, actionIndex, maxAffectUnit, damageList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case LaunchSpell.PosType.POS_TYPE_RANDOM_DIRECTION:
|
|
|
{
|
|
|
for (int i = 0; i < launch.Count; i++)
|
|
|
{
|
|
|
float d = (float)(random.NextDouble() * CMath.PI_MUL_2);
|
|
|
- AddSpell(fromSkillType, spell, launch, launcher,
|
|
|
+ AddSpell(fromSkillType, spell, launch, launcher,
|
|
|
launcher, targetUnitID, targetPos, startX,
|
|
|
startY, d, chain, actionIndex, maxAffectUnit);
|
|
|
}
|
|
@@ -2082,7 +2082,7 @@ namespace CommonAI.Zone.Instance
|
|
|
|
|
|
// 单位释放法术
|
|
|
public void spellLaunchSpell(
|
|
|
- XmdsSkillType fromSkillType,
|
|
|
+ XmdsSkillType fromSkillType,
|
|
|
InstanceSpell sender,
|
|
|
LaunchSpell launch,
|
|
|
float startX,
|
|
@@ -2127,7 +2127,7 @@ namespace CommonAI.Zone.Instance
|
|
|
for (int i = 0; i < launch.Count; i++)
|
|
|
{
|
|
|
AddSpell(fromSkillType, spell, launch, sender, sender.Launcher,
|
|
|
- targetUnitID, targetPos, startX, startY,
|
|
|
+ targetUnitID, targetPos, startX, startY,
|
|
|
startAngle + interAngle * i, chain, actionIndex, maxAffectUnit);
|
|
|
}
|
|
|
}
|
|
@@ -2138,26 +2138,26 @@ namespace CommonAI.Zone.Instance
|
|
|
float interAngle = CMath.PI_MUL_2 / launch.Count;
|
|
|
for (int i = 0; i < launch.Count; i++)
|
|
|
{
|
|
|
- AddSpell(fromSkillType, spell, launch, sender, sender.Launcher,
|
|
|
- targetUnitID, targetPos, startX, startY,
|
|
|
+ AddSpell(fromSkillType, spell, launch, sender, sender.Launcher,
|
|
|
+ targetUnitID, targetPos, startX, startY,
|
|
|
startAngle + interAngle * i, chain, actionIndex, maxAffectUnit);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
- case LaunchSpell.PosType.POS_TYPE_X:
|
|
|
- {
|
|
|
- float startAngle = direction + launch.StartAngle;
|
|
|
- float[] interAngle = { launch.Angle, CMath.PI_F - launch.Angle, CMath.PI_F + launch.Angle, CMath.PI_F * 2 - launch.Angle };
|
|
|
- Dictionary<uint, InstanceUnit> damageList = (spell.HitIntervalMS <= 0 ? new Dictionary<uint, InstanceUnit>() : null);
|
|
|
-
|
|
|
- for (int i = 0; i < launch.Count; i++)
|
|
|
- {
|
|
|
- AddSpell(fromSkillType, spell, launch, sender, sender.Launcher, targetUnitID,
|
|
|
- targetPos, startX, startY, startAngle + interAngle[i], chain, actionIndex, maxAffectUnit, damageList);
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case LaunchSpell.PosType.POS_TYPE_RANDOM_FOR_SPELL:
|
|
|
+ case LaunchSpell.PosType.POS_TYPE_X:
|
|
|
+ {
|
|
|
+ float startAngle = direction + launch.StartAngle;
|
|
|
+ float[] interAngle = { launch.Angle, CMath.PI_F - launch.Angle, CMath.PI_F + launch.Angle, CMath.PI_F * 2 - launch.Angle };
|
|
|
+ Dictionary<uint, InstanceUnit> damageList = (spell.HitIntervalMS <= 0 ? new Dictionary<uint, InstanceUnit>() : null);
|
|
|
+
|
|
|
+ for (int i = 0; i < launch.Count; i++)
|
|
|
+ {
|
|
|
+ AddSpell(fromSkillType, spell, launch, sender, sender.Launcher, targetUnitID,
|
|
|
+ targetPos, startX, startY, startAngle + interAngle[i], chain, actionIndex, maxAffectUnit, damageList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case LaunchSpell.PosType.POS_TYPE_RANDOM_FOR_SPELL:
|
|
|
launch_randomTypeSpell(fromSkillType, spell, sender, launch, chain, sender.Launcher, actionIndex);
|
|
|
break;
|
|
|
case LaunchSpell.PosType.POS_TYPE_MANY_CANNON:
|
|
@@ -2166,12 +2166,12 @@ namespace CommonAI.Zone.Instance
|
|
|
case LaunchSpell.PosType.POS_TYPE_RANDOM_POS:
|
|
|
launch_randomPosSpell(fromSkillType, spell, sender, launch, chain, sender.Launcher, actionIndex);
|
|
|
break;
|
|
|
- case LaunchSpell.PosType.POS_TYPE_RANDOM_DIRECTION:
|
|
|
+ case LaunchSpell.PosType.POS_TYPE_RANDOM_DIRECTION:
|
|
|
{
|
|
|
for (int i = 0; i < launch.Count; i++)
|
|
|
{
|
|
|
float d = (float)(random.NextDouble() * CMath.PI_MUL_2);
|
|
|
- AddSpell(fromSkillType, spell, launch, sender, sender.Launcher,
|
|
|
+ AddSpell(fromSkillType, spell, launch, sender, sender.Launcher,
|
|
|
targetUnitID, targetPos, startX, startY, d, chain, actionIndex, maxAffectUnit);
|
|
|
}
|
|
|
}
|
|
@@ -2182,7 +2182,7 @@ namespace CommonAI.Zone.Instance
|
|
|
SeekSpellAttackable(enemy_list, startX, startY, sender.Launcher, spell, launch, chain);
|
|
|
for (int i = 0; i < launch.Count && i < enemy_list.Count; i++)
|
|
|
{
|
|
|
- AddSpell(fromSkillType, spell, launch, sender, sender.Launcher,
|
|
|
+ AddSpell(fromSkillType, spell, launch, sender, sender.Launcher,
|
|
|
enemy_list[i].ID, targetPos, startX, startY, direction, chain, actionIndex, maxAffectUnit);
|
|
|
}
|
|
|
}
|
|
@@ -2190,7 +2190,7 @@ namespace CommonAI.Zone.Instance
|
|
|
case LaunchSpell.PosType.POS_TYPE_DEFAULT_SINGLE:
|
|
|
default:
|
|
|
{
|
|
|
- AddSpell(fromSkillType, spell, launch, sender, sender.Launcher,
|
|
|
+ AddSpell(fromSkillType, spell, launch, sender, sender.Launcher,
|
|
|
targetUnitID, targetPos, startX, startY, direction, chain, actionIndex, maxAffectUnit);
|
|
|
}
|
|
|
break;
|
|
@@ -2235,9 +2235,9 @@ namespace CommonAI.Zone.Instance
|
|
|
float startY = damage.Y;
|
|
|
|
|
|
SpellTemplate spell = Templates.getSpell(launch.SpellID);
|
|
|
- JSGCreateSpellData createData;
|
|
|
- if (spell != null && launch.Count > 0 && mFormula.TryLaunchSpell(attacker, launch, ref spell, out createData, ref startX, ref startY))
|
|
|
- {
|
|
|
+ JSGCreateSpellData createData;
|
|
|
+ if (spell != null && launch.Count > 0 && mFormula.TryLaunchSpell(attacker, launch, ref spell, out createData, ref startX, ref startY))
|
|
|
+ {
|
|
|
SpellChainLevelInfo chain = null;
|
|
|
if (source.FromSpellUnit != null && source.FromSpellUnit.ChainInfo != null)
|
|
|
{
|
|
@@ -2329,7 +2329,7 @@ namespace CommonAI.Zone.Instance
|
|
|
|
|
|
|
|
|
private void launch_randomTypeSpell(XmdsSkillType fromSkillType, SpellTemplate spell, InstanceZoneObject sender,
|
|
|
- LaunchSpell launch, SpellChainLevelInfo chain, InstanceUnit attacker, int serverExt = 0)
|
|
|
+ LaunchSpell launch, SpellChainLevelInfo chain, InstanceUnit attacker, int serverExt = 0)
|
|
|
{
|
|
|
using (var list = ListObjectPool<InstanceUnit>.AllocAutoRelease())
|
|
|
{
|
|
@@ -2350,7 +2350,7 @@ namespace CommonAI.Zone.Instance
|
|
|
attacker.Y,
|
|
|
launch.SeekingTargetRange,
|
|
|
list, attacker.AoiStatus);
|
|
|
-
|
|
|
+
|
|
|
int maxCount = launch.Count == 0 ? list.Count : Math.Min(launch.Count, list.Count);
|
|
|
for (int i = 0; i < maxCount; i++)
|
|
|
{
|
|
@@ -2368,36 +2368,36 @@ namespace CommonAI.Zone.Instance
|
|
|
private void launch_randomPosSpell(XmdsSkillType fromSkillType, SpellTemplate spell, InstanceZoneObject sender,
|
|
|
LaunchSpell launch, SpellChainLevelInfo chain, InstanceUnit attacker, int serverExt = 0)
|
|
|
{
|
|
|
- for (int i = 0; i < launch.Count; i++)
|
|
|
- {
|
|
|
- float x = (float)(random.NextDouble() * launch.SpellRange/2);
|
|
|
- float y = (float)(random.NextDouble() * launch.SpellRange/2);
|
|
|
- float d = (float)(random.NextDouble() * CMath.PI_MUL_2);
|
|
|
- int randX = random.Next() % 2 == 0 ? 1 : -1;
|
|
|
- int randY = random.Next() % 2 == 0 ? 1 : -1;
|
|
|
- AddSpell(fromSkillType, spell, launch, sender, attacker, 0, null,
|
|
|
- sender.X + x * randX, sender.Y + y * randY, d, chain, serverExt);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public InstanceSpell launch_ManyCannon(XmdsSkillType fromSkillType, SpellTemplate spell, InstanceZoneObject sender,
|
|
|
- LaunchSpell launch, SpellChainLevelInfo chain, InstanceUnit attacker, uint targetUnitID, int serverExt, JSGCreateSpellData createData)
|
|
|
- {
|
|
|
- //float angleOffset = targetUnitID == 0 ? launch.StartAngle / 3 : launch.StartAngle;
|
|
|
- float angleOffset = JSGModule.GetCurveStartAngleOffect(attacker, getUnit(targetUnitID), launch.StartAngle, spell.SeekingRange);
|
|
|
- float startAngle = CMath.OpitimizeRadians(attacker.Direction) + angleOffset;
|
|
|
- float launchX = attacker.X - (float)(1.0f * Math.Cos(attacker.Direction));
|
|
|
- float launchY = attacker.Y - (float)(1.0f * Math.Sin(attacker.Direction));
|
|
|
-
|
|
|
- Vector2 targetPos = JSGModule.GetCurveDefaultTargetPos(attacker, spell.SeekingRange);
|
|
|
- //System.Console.WriteLine("targetPos: " + targetPos.X + ", " + targetPos.Y);
|
|
|
-
|
|
|
- int totalCount = createData == null ? launch.Count : createData.mMaxSpellCount;
|
|
|
- return AddSpell(fromSkillType, spell, launch, sender, attacker, targetUnitID, targetPos,
|
|
|
- launchX, launchY, startAngle, chain, serverExt, 0, null, totalCount-1, createData);
|
|
|
- }
|
|
|
-
|
|
|
- public void spellSummonUnit(InstanceSpell summoner, SummonUnit summon)
|
|
|
+ for (int i = 0; i < launch.Count; i++)
|
|
|
+ {
|
|
|
+ float x = (float)(random.NextDouble() * launch.SpellRange / 2);
|
|
|
+ float y = (float)(random.NextDouble() * launch.SpellRange / 2);
|
|
|
+ float d = (float)(random.NextDouble() * CMath.PI_MUL_2);
|
|
|
+ int randX = random.Next() % 2 == 0 ? 1 : -1;
|
|
|
+ int randY = random.Next() % 2 == 0 ? 1 : -1;
|
|
|
+ AddSpell(fromSkillType, spell, launch, sender, attacker, 0, null,
|
|
|
+ sender.X + x * randX, sender.Y + y * randY, d, chain, serverExt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public InstanceSpell launch_ManyCannon(XmdsSkillType fromSkillType, SpellTemplate spell, InstanceZoneObject sender,
|
|
|
+ LaunchSpell launch, SpellChainLevelInfo chain, InstanceUnit attacker, uint targetUnitID, int serverExt, JSGCreateSpellData createData)
|
|
|
+ {
|
|
|
+ //float angleOffset = targetUnitID == 0 ? launch.StartAngle / 3 : launch.StartAngle;
|
|
|
+ float angleOffset = JSGModule.GetCurveStartAngleOffect(attacker, getUnit(targetUnitID), launch.StartAngle, spell.SeekingRange);
|
|
|
+ float startAngle = CMath.OpitimizeRadians(attacker.Direction) + angleOffset;
|
|
|
+ float launchX = attacker.X - (float)(1.0f * Math.Cos(attacker.Direction));
|
|
|
+ float launchY = attacker.Y - (float)(1.0f * Math.Sin(attacker.Direction));
|
|
|
+
|
|
|
+ Vector2 targetPos = JSGModule.GetCurveDefaultTargetPos(attacker, spell.SeekingRange);
|
|
|
+ //System.Console.WriteLine("targetPos: " + targetPos.X + ", " + targetPos.Y);
|
|
|
+
|
|
|
+ int totalCount = createData == null ? launch.Count : createData.mMaxSpellCount;
|
|
|
+ return AddSpell(fromSkillType, spell, launch, sender, attacker, targetUnitID, targetPos,
|
|
|
+ launchX, launchY, startAngle, chain, serverExt, 0, null, totalCount - 1, createData);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void spellSummonUnit(InstanceSpell summoner, SummonUnit summon)
|
|
|
{
|
|
|
float x = summoner.X;
|
|
|
float y = summoner.Y;
|
|
@@ -2447,7 +2447,7 @@ namespace CommonAI.Zone.Instance
|
|
|
{
|
|
|
unit = AddUnit(info, name, summoner.Launcher.Force, summon.UnitLevel, dx, dy, dr, summoner.Launcher);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (unit != null)
|
|
|
{
|
|
|
if (info.LifeTimeMS > 0)
|
|
@@ -2696,10 +2696,10 @@ namespace CommonAI.Zone.Instance
|
|
|
|
|
|
public InstanceFlag getFlag(string name)
|
|
|
{
|
|
|
- if(string.IsNullOrEmpty(name))
|
|
|
- {
|
|
|
- return null;
|
|
|
- }
|
|
|
+ if (string.IsNullOrEmpty(name))
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
return mFlags.Get(name);
|
|
|
}
|
|
|
|