123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- using CommonAI;
- using CommonAI.Data;
- using CommonAI.Zone.Instance;
- using System;
- using XmdsCommon.Message;
- using XmdsCommon.Plugin;
- using XmdsCommonServer.Plugin.Scene;
- using XmdsCommonServer.Plugin.Units;
- using XmdsCommonServer.XLS;
- using XmdsCommonServer.XLS.Data;
- namespace XmdsCommonServer.Plugin
- {
- public class XmdsVirtual_SummonUnit : XmdsVirtual
- {
- public XmdsVirtual_SummonUnit(XmdsInstanceSummonUnit unit) : base(unit)
- {
- }
- protected override void Init(bool pointLv)
- {
- if (this.mProp.LoadDataConfig == true)
- {
- InitMonsterData2(GetCurSceneType(), mUnit.Info.TemplateID);
- }
- InitVisibleData(mUnit as XmdsInstanceSummonUnit);
- }
- protected void InitMonsterData2(string _sceneType, int templateID)
- {
- // 读一行怪物数据
- String ss = _sceneType;
- if (ss == XLSMonsterDataLoader.DUNGEONHERO || ss == XLSMonsterDataLoader.DUNGEONELITE)
- ss = XLSMonsterDataLoader.DUNGEONNORMAL;
- MonsterData ma = XmdsDataMgr.GetInstance().GetMonsterData(ss, templateID, null, false);
- if (ma == null)
- {
- log.Warn("初始化召唤物属性,找不到单位:" + templateID);
- return;
- }
- XmdsUnitProp ret = (XmdsUnitProp)mProp.ServerData.Prop;
- //FateType=-1
- if (ma.FateType == UnitFateType.Random)
- {
- ret.fateType = (UnitFateType)(this.mUnit.RandomN.Next() % (int)UnitFateType.Five + 1);
- }
- else
- {
- ret.fateType = ma.FateType;
- }
- XmdsServerScene scene = this.mUnit.Parent as XmdsServerScene;
- SceneType sceneType = this.mUnit.GetSceneType();
- int lvl_monster = ma.Level;
- this.mUnit.Level = lvl_monster;
- this.mProp.ServerData.BaseInfo.UnitLv = lvl_monster;
- //等级转仙阶
- this.mProp.ServerData.BaseInfo.StateLv = (byte)(Math.Max(0, (lvl_monster - 70) / 10));
- if (ma.Fight_Type == 1)
- {
- MonsterProp prop = XmdsDataMgr.GetInstance().GetSingleMonsterProp(lvl_monster, ma.Type);
- initProp(prop, ma, ret);
- }
- else if (ma.Fight_Type == 2)
- {
- MonsterProp prop = XmdsDataMgr.GetInstance().GetMultipleMonsterProp(lvl_monster, ma.Type);
- initProp(prop, ma, ret);
- }
- else if (ma.Fight_Type == 4)
- {
- lvl_monster = ma.Level;
- MonsterProp prop = XmdsDataMgr.GetInstance().GetSingleMonsterProp(lvl_monster, ma.Type);
- initProp(prop, ma, ret);
- }
- else
- {
- OrigData oData = XmdsDataMgr.GetInstance().GetOrigData(lvl_monster);
- UserDefineConfig udc = XmdsDataMgr.GetInstance().GetUserDefineConfig(ma.Type);
- initProp2(ma, oData, udc, ret);
- }
- ret.BaseMaxHP = (int)(ret.BaseMaxHP * XmdsDataMgr.GetInstance().mMonsterDynamicLoader.Mon_Hp_Ratio);
- ret.BaseAttack = (int)(ret.BaseAttack * XmdsDataMgr.GetInstance().mMonsterDynamicLoader.Mon_Atk_Ratio);
- restoreMa2Ret(ret, ma);
- ret.HP = ret.BaseMaxHP;
- XmdsInstanceMonster unit = this.mUnit as XmdsInstanceMonster;
- if (unit != null)
- {
- unit.MonsterID = ma.ID;
- //警戒范围控制 :是否主动攻击.0否,1是.
- if (ma.isAttack == 0)
- {
- this.mUnit.Info.GuardRange = 0;
- this.mUnit.Info.GuardRangeGroup = 0;
- }
- }
- //edata.SenceType = GetCurSceneType();
- //edata.MonsterID = ma.ID;
- //edata.DisplayName = ma.Name;
- //edata.Title = ma.Title;
- //edata.Qcolor = (MonsterVisibleDataB2C.MonsterQcolor)ma.Qcolor;
- //edata.AttackType = (MonsterVisibleDataB2C.MonsterAttackType)ma.isAttack;
- //edata.Atype = (MonsterVisibleDataB2C.MonsterAtype)ma.Atype;
- //edata.MType = (MonsterVisibleDataB2C.MonsterType)ma.Type;
- //edata.hpPlies = (byte)ParseInt(mUnit.Info.UserTag, 1);
- this.mProp.ServerData.BaseInfo.name = ma.Name;
- this.mUnit.SetDiaplayerName(ma.Name);
- // 攻速初始化
- if (ret.AttackSpeed <= 0)
- {
- ret.AttackSpeed = GlobalData.DEFAULT_ATTACK_SPEED;
- }
- //mUnit.SetVisibleInfo(edata);
- //printMonsterData(ret, templateID);
- if (ret.MaxHP <= 0 || ret.MaxAttack <= 0 || ret.Defence <= 0)
- {
- log.Warn("召唤物属性错误:" + this.mUnit.Info.ID + ", 生命:" + ret.MaxHP +
- ", 攻击:" + ret.MaxAttack + ", 防御:" + ret.Defence);
- }
- }
- private void InitVisibleData(XmdsInstanceSummonUnit unit)
- {
- SummonUnitVisibleDataB2C data = new SummonUnitVisibleDataB2C();
- if (unit.SummonerUnit != null)
- {
- data.MasterObjID = unit.SummonerUnit.ID;
- }
- // 召唤的人物分身
- if(this.mInfo.ID == XmdsConstConfig.DEFAULT_PLAYER_TEMPLATE_ID)
- {
- data.AvatarList = this.mProp.ServerData.AvatarList;
- }
- mUnit.SetVisibleInfo(data);
- }
- public override string GetPlayerUUID()
- {
- InstanceUnit u = (mUnit as XmdsInstanceSummonUnit).SummonerUnit;
- if (u != null)
- {
- return ((u.Virtual) as XmdsVirtual).GetPlayerUUID();
- }
- return null;
- }
- public override int GetForceID()
- {
- InstanceUnit u = (mUnit as XmdsInstanceSummonUnit).SummonerUnit;
- if (u != null)
- {
- return ((u.Virtual) as XmdsVirtual).GetForceID();
- }
- return base.GetForceID();
- }
- public override string GetGuildID()
- {
- InstanceUnit u = (mUnit as XmdsInstanceSummonUnit).SummonerUnit;
- if (u != null)
- {
- return ((u.Virtual) as XmdsVirtual).GetGuildID();
- }
- return base.GetGuildID();
- }
- public override int GetServerID()
- {
- InstanceUnit u = (mUnit as XmdsInstanceSummonUnit).SummonerUnit;
- if (u != null)
- {
- return ((u.Virtual) as XmdsVirtual).GetServerID();
- }
- return base.GetServerID();
- }
- public override PKLevel GetCurPKLevel()
- {
- InstanceUnit u = (mUnit as XmdsInstanceSummonUnit).SummonerUnit;
- if (u != null)
- {
- return ((u.Virtual) as XmdsVirtual).GetCurPKLevel();
- }
- return base.GetCurPKLevel();
- }
- public override PKMode GetCurPKMode()
- {
- InstanceUnit u = (mUnit as XmdsInstanceSummonUnit).SummonerUnit;
- if (u != null)
- {
- return ((u.Virtual) as XmdsVirtual).GetCurPKMode();
- }
- return base.GetCurPKMode();
- }
- public override bool IsMember(XmdsVirtual target, PKMode mode, bool includeSelf, bool onlyForTeam = false)
- {
- if (includeSelf == true && this.mUnit == target.mUnit)
- {
- return true;
- }
- InstanceUnit u = (this.mUnit as XmdsInstanceSummonUnit).SummonerUnit;
- if (u != null)
- {
- XmdsVirtual zv = u.Virtual as XmdsVirtual;
- return zv.IsMember(target, mode, includeSelf);
- }
- return base.IsMember(target, mode, includeSelf);
- }
- public override void OnKillUnit(XmdsVirtual dead)
- {
- if (CalPKValue(dead) == true)
- {
- if (dead.IsPlayerUnit() &&
- dead.GetCurPKLevel() == PKLevel.White)
- {
- XmdsInstancePlayer zip = (mUnit as XmdsInstanceSummonUnit).SummonerUnit as XmdsInstancePlayer;
- if (zip != null)
- {
- (zip.Virtual as XmdsVirtual).OnKillUnit(dead);
- }
- }
- }
- }
- public override bool IsPlayerUnit()
- {
- bool ret = false;
- InstanceUnit u = (mUnit as XmdsInstanceSummonUnit).SummonerUnit;
- if (u != null && u is XmdsInstancePlayer)
- {
- ret = true;
- }
- return ret;
- }
- public override XmdsVirtual_Player GetPlayerUnit()
- {
- XmdsVirtual_Player ret = null;
- InstanceUnit u = (mUnit as XmdsInstanceSummonUnit).SummonerUnit;
- if (u != null && u is XmdsInstancePlayer)
- {
- ret = u.Virtual as XmdsVirtual_Player;
- }
- return ret;
- }
- protected override void CombatStateConnect(BattleStatus status, byte reason)
- {
- //影响主人.
- var v = GetPlayerUnit();
- if (v != null)
- {
- v.SetCombatState(status, reason);
- }
- }
- public override bool IsAttackable(XmdsVirtual attacker)
- {
- InstanceUnit u = (mUnit as XmdsInstanceSummonUnit).SummonerUnit;
- if (u != null)
- {
- return (u.Virtual as XmdsVirtual).IsAttackable(attacker);
- }
- return base.IsAttackable(attacker);
- }
- public override void OnHitOthter(XmdsVirtual target)
- {
- if (mHateSystem.ContainsID(target.mUnit.ID) == false)
- {
- mHateSystem.AddTarget(target);
- }
- var zv = GetPlayerUnit();
- if (zv != null)
- {
- zv.OnHitOthter(target);
- }
- }
- }
- }
|