public override BtResult Execute() { int buffId = m_dataBase.GetData <int>((int)eAIParam.INT_BUFF_ID); CCreature buff = CCreatureMgr.Get(buffId); if (buff != null) { //float dis2 = Collide.GetDis2(buff.GetPos(), m_creature.GetPos()); //if (dis2 < 1.0f) //{ // return BtResult.Ended; //} //else //{ // m_curTime += FSPParam.clientFrameMsTime; // if (m_curTime >= 30 * FSPParam.clientFrameMsTime) // { // m_curTime = 0; // Vector2 target = buff.GetPos(); // m_creature.GoTo(target); // } // return BtResult.Running; //} } else { m_curTime = 0; return(BtResult.Ended); } return(BtResult.Ended); }
public static void OnChangeLv(CCreature obj, int newV, int oldV) { if (newV == oldV) { return; } // 逻辑层 obj.UpdateProp(); int maxHp = obj.GetPropNum(eCreatureProp.Hp); // 主角升级才回满血 //if (obj.IsMaster()) //{ // obj.SetPropNum(eCreatureProp.CurHp, maxHp); //} // 表现层 obj.UpdateVO_ShowHeadLv(); obj.UpdateVO_ShowHeadHp(); obj.UpdateUI_Lv(); if (oldV != 0 && obj.IsMaster()) { if (obj.m_vCreature != null) { CEffectMgr.Create(21160, obj.m_vCreature.GetEnt(), "origin"); } } }
public void UpdateVO_ShowBuffEffect(CCreature cc, bool bAdd, int effectId, int effectPoint, int uid) { if (cc == null) { return; } //if(bAdd) // 添加时,没有同种BUFF则创建特效,有则不创建 //{ // BuffBase buffBase = cc.GetBuffByCsvId(m_buffData.id); // if (buffBase != null) // return; //} //else // 移除时,没有同种BUFF则销毁特效,有同种BUFF则不销毁 //{ // BuffBase buffBase = cc.GetBuffByCsvId(m_buffData.id); // if (buffBase != null) // return; //} if (cc.m_vCreature == null) { return; } CmdFspBuff buff = new CmdFspBuff(); buff.bAdd = bAdd; buff.effectId = effectId; buff.bindType = effectPoint; buff.color = m_buffData.hitColor; cc.m_vCreature.PushCommand(buff); }
public static void OnChangeCurExp(CCreature obj, int newV, int oldV) { // 逻辑层 // 到达满级时,不再执行 if (newV == oldV && newV != 0) { return; } // 通过当前总经验值获取等级。 PlayerExpCsv playerCsv = CsvManager.Inst.GetCsv <PlayerExpCsv>((int)eAllCSV.eAC_PlayerExp); int lv = playerCsv.GetLevelByExp(newV); if (lv >= playerCsv.m_maxLv.Level) // 已满级 { int maxExp = playerCsv.GetMaxExpByLv(lv); obj.SetPropNum(eCreatureProp.CurExp, maxExp); obj.SetPropNum(eCreatureProp.Exp, maxExp); } else { int maxExp = playerCsv.GetMaxExpByLv(lv + 1); // 下一级所需经验 obj.SetPropNum(eCreatureProp.Exp, maxExp); } obj.SetPropNum(eCreatureProp.Lv, lv); // 表现层 obj.UpdateUI_Exp(); }
/// <summary> /// 更新充能技能 /// </summary> private void UpdateChargeSkill(CCreature m_caster, int hurtVal) { if (m_caster == null || m_caster.m_cmdFspSendSkill == null) { return; } CSkillInfo cInfo = m_caster.GetSkillByIndex(m_caster.m_cmdFspSendSkill.m_skillIndex); if (cInfo == null) { return; } // 如果施法者,当前是放的蓄能大招,则不进行充能 if (cInfo.GetCDType() == (int)eSkillCdType.Charge) { return; } foreach (KeyValuePair <int, CSkillInfo> item in m_caster.m_dicSkill) { CSkillInfo info = item.Value; if (info.GetCDType() == (int)eSkillCdType.Charge) { info.AddCharge(hurtVal); // 更新界面 m_caster.UpdateUI_Charge(info.GetSkillIndex(), info.GetChargePct()); } } }
/// <summary> /// 是否同阵营 /// </summary> /// <param name="target"></param> /// <returns></returns> public bool bCamp(CCreature target) { if (GetUid() == target.GetUid()) { return(true); } return(false); if (IsPlayer() && target.IsMonster()) // 玩家对怪物 { return(false); } //else if (IsPartner() && target.IsMonster()) //{ // return false; //} else if (IsMonster() && target.IsPlayer()) // 怪物对玩家 { return(false); } else if (IsNpc() && target.IsMonster()) // 坐骑对怪物 { return(false); } return(true); }
public override void Destory() { m_destroy = true; CFrameTimeMgr.Inst.RemoveEvent(m_skillLifeEventHid); //Debug.Log("destory skill:" + m_skillInfo.name); SetLogicEnable(true); CCreature cc = GetCaster(); if (cc != null) { cc.PushCommand(CmdFspStopMove.Inst); // 如果在释放技能时,操作了移动,技能释放结束修改方向 //if (cc.m_cmdFspMove != null) // cc.SetDir(GetCaster().m_cmdFspMove.m_dir); } // 销毁表现层 if (m_vSkill != null) { m_vSkill.Destory(); m_vSkill = null; } }
public int GetTarget(int lookDis) { int targetUid = 0; FixedPoint m_minDis2 = new FixedPoint(999999); List <long> list = CCreatureMgr.GetCreatureList(); for (int i = 0; i < list.Count; i++) { CCreature cc = CCreatureMgr.Get(list[i]); FixedPoint abDis2 = FPCollide.GetDis2(GetPos(), cc.GetPos()); if (abDis2 > new FixedPoint(lookDis * lookDis)) { continue; } if (cc.IsDie() || cc.GetUid() == GetUid()) { continue; } if (abDis2 < new FixedPoint(lookDis * lookDis)) // 如果目标在视线范围内 { if (abDis2 < m_minDis2) { m_minDis2 = abDis2; targetUid = (int)cc.GetUid(); } } } return(targetUid); }
/// <summary> /// m_logicSkillEnabled用于控制技能的保护状态 /// 也用于BUFF去设置技能是否可用 /// </summary> public void SetLogicEnable(bool bTrue) { CCreature cc = GetCaster(); if (cc == null) { return; } cc.m_logicSkillEnabled = bTrue; // 不能移动的技能,才需要设置逻辑是否移动,常规的MOBA技能释放 // 比如机枪,就可以边走边释放,就不设置逻辑是否移动 if (m_skillInfo.bRota) { cc.m_logicSkillRotationEnabled = !bTrue; } if (!m_skillInfo.bMove) { cc.PushCommand(CmdFspStopMove.Inst); cc.SetLogicMoveEnabled(bTrue); // 释放技能不能移动时 VBase v = cc.m_vCreature; if (v != null) { v.SetMove(bTrue); } } // 重置遥感,一般在按下移动,并技能释放完之后,还需继续移动 if (bTrue) { cc.UpdateUI_ResetJoyStick(true); } }
public override void Launch() { //base.Launch(); //Debug.Log("近战击中,计算伤害"); // 检测,播放受击动作 Vector2d pos = CCreatureMgr.Get(m_curSkillCmd.m_casterUid).GetPos(); Vector2d dir = m_curSkillCmd.m_dir; List <long> list = CCreatureMgr.GetCreatureList(); for (int i = 0; i < list.Count; i++) { CCreature creature = CCreatureMgr.Get(list[i]); if (GetCaster().bCamp(creature) || creature.IsDie()) { continue; } Vector2d focusPos = creature.GetPos(); FPSector sec = new FPSector(); sec.pos = pos; sec.dir = dir; sec.angle = new FixedPoint(m_skillInfo.width); sec.r = new FixedPoint(m_skillInfo.length); if (FPCollide.bSectorInside(sec, focusPos)) { //Debug.Log("近战检测:" + item.GetUid()); //OnHit(creature, i++); OnCasterAddBuff(GetCaster(), creature); } } }
public static bool SendSkill(CCreature m_creature, BtDatabase m_dataBase, bool bDown = false) { int targetUid = m_dataBase.GetData <int>((int)eAIParam.INT_TARGET_UID); if (targetUid == m_creature.GetUid()) { return(false); } CCreature targetCc = CCreatureMgr.Get(targetUid); if (targetCc != null) { Vector2d dir = (targetCc.GetPos() - m_creature.GetPos()); dir.Normalize(); //if (dir == Vector2.zero) //{ // dir = m_creature.GetDir(); //} int selectSkillUid = m_dataBase.GetData <int>((int)eAIParam.INT_SELECT_SKILL_INDEX); CSkillInfo skillInfo = m_creature.GetSkillByIndex(selectSkillUid); CmdFspSendSkill cmd = new CmdFspSendSkill(); cmd.m_casterUid = (int)m_creature.GetUid(); cmd.m_skillIndex = selectSkillUid; if (skillInfo.m_skillInfo.selectTargetType == (int)eSelectTargetType.Self) { } else if (skillInfo.m_skillInfo.selectTargetType == (int)eSelectTargetType.Dir || skillInfo.m_skillInfo.selectTargetType == (int)eSelectTargetType.SectorDir) { cmd.m_dir = dir; } else if (skillInfo.m_skillInfo.selectTargetType == (int)eSelectTargetType.Pos) { cmd.m_dir = dir; cmd.m_endPos = targetCc.GetPos(); } cmd.m_bDown = bDown; if (m_creature.m_aiType == eAIType.Player) { m_creature.SendFspCmd(cmd); } else { m_creature.PushCommand(cmd); } // 进入公共CD m_dataBase.SetData <int>((int)eAIParam.INT_SKILL_INTERVAL, GetSkillCastCd(m_creature, m_dataBase)); // 清空当前发送的技能 m_dataBase.SetData <int>((int)eAIParam.INT_SELECT_SKILL_INDEX, -1); return(true); } return(false); }
/// <summary> /// 常规情况的CD,combo时,缩短CD间隔 /// </summary> public static int GetSkillCastCd(CCreature creature, BtDatabase baseData) { // 连招状态,取最小间隔 //if (baseData.GetData<bool>(BOOL_COMBO_STATE)) // return INT_HARD_CAST_SKILL_INTERVAL; //return INT_HARD_CAST_SKILL_INTERVAL / 2; int curInterval = INT_NORMAL_CAST_SKILL_INTERVAL; switch (creature.m_ai.m_level) { case eAILevel.NEWBIE: curInterval = INT_NEWBIE_CAST_SKILL_INTERVAL; break; case eAILevel.EASY: curInterval = INT_EASY_CAST_SKILL_INTERVAL; break; case eAILevel.NORMAL: curInterval = INT_NORMAL_CAST_SKILL_INTERVAL; break; case eAILevel.HARD: curInterval = INT_HARD_CAST_SKILL_INTERVAL; break; } return(curInterval); }
public override void Update(float fTime, float fDTime) { float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); Vector2 moveVec = new Vector2(h, v); if (moveVec != Vector2.zero) { JoyStickModule ctr = (JoyStickModule)LayoutMgr.Inst.GetLogicModule(LogicModuleIndex.eLM_PanelJoyStick); ctr.OnMove(false, moveVec); m_bMove = true; } else { if (m_bMove) { JoyStickModule ctr = (JoyStickModule)LayoutMgr.Inst.GetLogicModule(LogicModuleIndex.eLM_PanelJoyStick); ctr.OnMove(true, moveVec); m_bMove = false; } } if (Input.GetKey(KeyCode.Alpha7)) { m_ai = !m_ai; CCreature cc = CCreatureMgr.GetMaster(); cc.StartAi(m_ai); } }
private void UpdateBuff(CCreature rec) { BuffBase buff = rec.GetStateBuff(eBuffState.sleep); if (buff != null) { CBuffMgr.Destroy(buff.m_uid); } }
private void ResetSkill(CCreature rec) { rec.m_logicSkillEnabled = true; //CCreature ride = rec.GetRide(); //if (ride != null) //{ // ride.m_logicSkillEnabled = true; //} }
private void SetStopSkill(CCreature rec) { rec.m_logicSkillEnabled = false; //CCreature ride = rec.GetRide(); //if (ride != null) //{ // ride.m_logicSkillEnabled = false; //} }
public bool LineTest2(CMap map, CCreature cc, int x1, int y1, int x2, int y2, ref Vector2 lastPos) { //Profiler.BeginSample("LineTest2"); int dx = x2 - x1; int dy = y2 - y1; int ux = (dx > 0) ? 1 : -1; //x的增量方向,取或-1 int uy = (dy > 0) ? 1 : -1; //y的增量方向,取或-1 int x = x1, y = y1, eps; //eps为累加误差 //算法问题需要向增量方向在+1 x2 += ux; y2 += uy; eps = 0; dx = Mathf.Abs(dx); dy = Mathf.Abs(dy); if (dx > dy) { for (x = x1; x != x2; x += ux) { if (!map.CanArrive(cc, x, y)) { //Profiler.EndSample(); return(false); } lastPos.x = x; lastPos.y = y; //mpaths.Add(new Vector2(x, y)); eps += dy; if ((eps << 1) >= dx) { y += uy; eps -= dx; } } } else { for (y = y1; y != y2; y += uy) { if (!map.CanArrive(cc, x, y)) { //Profiler.EndSample(); return(false); } lastPos.x = x; lastPos.y = y; eps += dx; if ((eps << 1) >= dy) { x += ux; eps -= dy; } } } //Profiler.EndSample(); return(true); }
public override BtResult Execute() { GetSkillDis(); if (m_skillDis == 0) { AIParam.SendSkill(m_creature, m_dataBase); return(BtResult.Ended); } // 1.实时获取当前选择的技能和目标计算 当前的移动位置 // 2.如果到达,即可结束 int targetUid = m_dataBase.GetData <int>((int)eAIParam.INT_TARGET_UID); CCreature targetCC = CCreatureMgr.Get(targetUid); if (targetCC != null) { FixedPoint dis2 = FPCollide.GetDis2(targetCC.GetPos(), m_creature.GetPos()); if (dis2 < new FixedPoint(m_skillDis * m_skillDis)) { return(BtResult.Ended); } else { // 一秒执行一次 m_curTime += FSPParam.clientFrameMsTime; if (m_curTime >= 30 * FSPParam.clientFrameMsTime) { m_curTime = 0; //Vector2 pPos = targetCC.GetPos(); //m_creature.GoTo(pPos); Vector2d dir = targetCC.GetPos() - m_creature.GetPos(); Vector2d target = m_creature.GetPos() + dir.normalized * new FixedPoint(m_skillDis); Vector2d endPos = CMapMgr.m_map.GetRandomPos(target.x.value, target.y.value, 3, m_creature.m_aiType).ToVector2d(); //Vector2d pPos = targetCC.GetPos(); CmdFspAutoMove cmd = new CmdFspAutoMove(); cmd.m_pos = endPos; if (m_creature.m_aiType == eAIType.Player) { m_creature.SendFspCmd(cmd); } else { m_creature.PushCommand(cmd); } } return(BtResult.Running); } } return(BtResult.Ended); }
public void OnCreateHitBuff(CCreature foeCc) { for (int i = 0; i < m_buffList.Count; i++) { BuffBase buff = m_buffList[i]; if (buff.GetBuffType() == eBuffType.hitCreate) { ((Buff12)buff).CreateBuff(foeCc); } } }
/// <summary> /// 1.支持玩家身上的BUFF /// 2.支持创建基于位置的触发器BUFF /// </summary> public static void AddBuff(CCreature caster, CCreature receiver, int[] buffList, Vector2d startPos, Vector2d skillPos, Vector2d dir, int skillIndex = 0, object obj = null) { for (int i = 0; i < buffList.Length; i++) { if (buffList[i] == 0) { continue; } AddBuff(caster, receiver, buffList[i], startPos, skillPos, dir, skillIndex, obj); } }
public void UpdateUI_Master(CCreature cc) { if (!IsMaster()) { return; } //JoyStickModule js = (JoyStickModule)LayoutMgr.Inst.GetLogicModule(LogicModuleIndex.eLM_PanelJoyStick); //js.SetMaster(cc); //cc.UpdateUI_Skill(); //js.InitCd(); }
public void SetHUD(eHUDType type, string text, CCreature cc) { if (cc == null || cc.m_vCreature == null) { return; } VBase vObj = cc.m_vCreature; Vector3 pos = vObj.GetEnt().GetPos() + Vector3.up * vObj.m_baseInfo.m_headHeight; m_ui.SetHUD(type, text, GUIManager.GetUIPos(pos)); }
public override void Init() { base.Init(); CCreature cast = m_caster; if (cast != null) { int len = GetVal1(); Vector2d target = cast.GetPos() + m_skillDir * len; cast.SetPos(target, true); } }
public FSMMgr(CCreature creature) { StopMoveState stop = new StopMoveState(creature); MoveState move = new MoveState(creature); AutoMoveState autoMove = new AutoMoveState(creature); Add((int)StateID.eFspStopMove, stop); Add((int)StateID.eFspMove, move); Add((int)StateID.eFspAutoMove, autoMove); ChangeState((int)StateID.eFspStopMove, CmdFspStopMove.Inst); }
public void OnHitTarget() { FixedPoint m_minDis2 = new FixedPoint(999999); CCreature target = null; List <long> list = CCreatureMgr.GetCreatureList(); for (int i = 0; i < list.Count; i++) { CCreature creature = CCreatureMgr.Get(list[i]); if (m_listHited != null && m_listHited.Contains((int)list[i])) { continue; } if (m_caster == creature || m_caster.bCamp(creature) || creature.IsDie() || creature == m_rec) { continue; } FixedPoint abDis2 = FPCollide.GetDis2(m_rec.GetPos(), creature.GetPos()); if (abDis2 < new FixedPoint(m_triggerData.Length * m_triggerData.Length)) { if (abDis2 < m_minDis2) { target = creature; m_minDis2 = abDis2; } } } if (target != null) { if (m_listHited == null) { m_listHited = new List <int>(); } Debug.Log("添加单位:" + target.GetUid()); m_listHited.Add((int)target.GetUid()); OnHitAddBuff(m_caster, target, m_listHited); VTrigger vTri = GetVTrigger(); if (vTri != null && m_rec != null && m_rec.GetVObject() != null) { Vector3 sh = m_rec.GetVObject().GetHitHeight(); Vector3 th = target.GetVObject().GetHitHeight(); vTri.SetLineStartPos(GetPos().ToVector3() + sh); vTri.SetLineTargetPos(target.GetPos().ToVector3() + th); } } else { Destory(); } }
// 创建玩家身上的特效,非技能情况,比如升级,吃F爆点等等,不需要逻辑控制生命周期的 // bindPos = SBindPont.eBindType public void UpdateVO_ShowEffect_One(CCreature cc, int effect, int bindPos) { if (cc == null || cc.m_vCreature == null) { return; } CmdUIHead cmd = new CmdUIHead(); cmd.type = 11; cmd.effectId = effect; cmd.effectBindPos = bindPos; cc.m_vCreature.PushCommand(cmd); }
public void CreateBuff(CCreature foe) { // format is "buffid1_chance2_buffid2_chance2" int[] data = m_buffData.listParam; for (int i = 0; i < data.Length; i += 2) { int chance = data[i + 1]; //int pct = GameManager.Inst.m_clientRand.Next(0, 100); //if(pct < chance) //{ // int buffId = data[i]; // SkillBase.AddBuff(m_caster, foe, buffId, m_startPos, m_skillPos, m_skillDir, -1); //} } }
public static void SendSkill(CCreature m_creature, BtDatabase m_dataBase) { int selectSkillUid = m_dataBase.GetData <int>((int)eAIParam.INT_SELECT_SKILL_INDEX); CmdFspSendSkill cmd = new CmdFspSendSkill(); cmd.m_casterUid = (int)m_creature.GetUid(); cmd.m_skillIndex = selectSkillUid; cmd.m_bDown = false; m_creature.PushCommand(cmd); // 进入公共CD m_dataBase.SetData <int>((int)eAIParam.INT_SKILL_INTERVAL, GetSkillCastCd(m_creature, m_dataBase)); // 清空当前发送的技能 m_dataBase.SetData <int>((int)eAIParam.INT_SELECT_SKILL_INDEX, 0); }
/// <summary> /// 触发器触发BUFF /// </summary> public void OnHitAddBuff(CCreature caster, CCreature receiver, object obj = null) { // 给自己加 int[] selfBuffList = m_triggerData.selfBuffList; SkillBase.AddBuff(caster, receiver, selfBuffList, GetPos(), GetPos(), GetDir(), m_skillIndex, obj); // 给目标加 int[] targetBuffList = m_triggerData.targetBuffList; SkillBase.AddBuff(caster, receiver, targetBuffList, GetPos(), GetPos(), GetDir(), m_skillIndex, obj); if (m_triggerData.bBullet) // 如果是子弹,碰撞就调用父类的销毁 { base.Destory(); } }
public void SetStopMove(CCreature rec) { if (rec == null) { return; } rec.SetLogicMoveEnabled(false); rec.PushCommand(CmdFspStopMove.Inst); //CCreature ride = rec.GetRide(); //if (ride != null) //{ // ride.m_logicMoveEnabled = false; // ride.PushCommand(CmdFspStopMove.Inst); // ride.StopAutoMove(); //} }