private string GetProp(uint id, string prop) { string content = ""; Mogo.Game.EntityParent e = null; if (!MogoWorld.Entities.TryGetValue(id, out e)) { return(content); } if (e.IntAttrs.ContainsKey(prop)) { return(prop + ": " + e.IntAttrs[prop]); } if (e.DoubleAttrs.ContainsKey(prop)) { return(prop + ": " + e.DoubleAttrs[prop]); } if (e.StringAttrs.ContainsKey(prop)) { return(prop + ": " + e.StringAttrs[prop]); } if (e.ObjectAttrs.ContainsKey(prop)) { return(prop + ": object"); } return(content); }
private UIFilledSprite m_fsInfoBillboardAnger; // 怒气条 public PlayerHead(uint id, Transform trans ,Action<PlayerHead, uint,Transform,EntityParent> OnFinished,EntityParent self, bool showBlood, HeadBloodColor bloodColor = HeadBloodColor.Red, bool showAnger = false) { AssetCacheMgr.GetUIInstance("InfoBillboard.prefab", (prefab, guid, go) => { m_billboard = (GameObject)go; m_billboard.name = id.ToString(); m_goBillboardBlood = m_billboard.transform.FindChild("InfoBillboardBlood").gameObject; m_goBillboardAnger = m_billboard.transform.FindChild("InfoBillboardAnger").gameObject; ShowBillboardBlood(showBlood); SetBillboardBloodColor(bloodColor); ShowBillboardAnger(showAnger); blood = m_billboard.transform.FindChild("InfoBillboardBlood/InfoBillboardBloodFG").GetComponentInChildren<UIFilledSprite>(); name = m_billboard.transform.FindChild("InfoBillboardName").GetComponentInChildren<UILabel>(); tong = m_billboard.transform.FindChild("InfoBillboardTong").GetComponentInChildren<UILabel>(); testInfo = m_billboard.transform.FindChild("InfoBillboardTestInfo").GetComponentsInChildren<UILabel>(true)[0]; bar = m_billboard.transform.FindChild("InfoBillboardBlood/InfoBillboardBloodFG").GetComponentInChildren<UIFilledSprite>(); bg = m_billboard.transform.FindChild("InfoBillboardBlood/InfoBillboardBloodBG0").GetComponentInChildren<UISprite>(); m_bloodAnim = m_billboard.transform.FindChild("InfoBillboardBlood").GetComponentsInChildren<MogoBloodAnim>(true)[0]; m_fsInfoBillboardAnger = m_billboard.transform.FindChild("InfoBillboardAnger/InfoBillboardAngerFG").GetComponentInChildren<UIFilledSprite>(); OnFinished(this,id,trans,self); }); }
private string GetInfo(uint id) { string content = ""; Mogo.Game.EntityParent e = null; if (!MogoWorld.Entities.TryGetValue(id, out e)) { return(content); } content += "id: " + e.ID + " "; content += "hp: " + e.curHp + " "; content += "max hp: " + e.hp + " "; content += "state: " + e.CurrentMotionState + " "; content += "stiff: " + e.stiff + " "; content += "hit air: " + e.hitAir + " "; content += "knockdown: " + e.knockDown + " "; content += "curr skill: " + e.currSpellID + " "; content += "curr hitAction: " + e.currHitAction + " "; if (e.animator) { content += "curr act: " + e.animator.GetInteger("Action") + " "; } else { content += "curr act: not animator"; } content += "state flag: " + e.stateFlag + " "; content += "skill act name: " + e.skillActName + " "; return(content); }
public override bool Proc(EntityParent theOwner) { //查找目标,记录到blackBoard //Mogo.Util.LoggerHelper.Debug("AI:" + "AOI"); bool rnt = theOwner.ProcAOI(m_iSearchChance); return rnt; }
// 状态处理 public void Process(EntityParent theOwner, params Object[] args) { // LoggerHelper.Debug("process prepare state"); if (args.Length != 1) { LoggerHelper.Error("error spell id"); return; } int skillID = (int)(args[0]); // 技能释放准备相关动作 // 比如 旋转角色, 朝向, 自动靠近目标等 // 目前先跳过 if (skillID > 2) { // ActorParent actorParent = theOwner.transform.gameObject.GetComponent<ActorParent>(); // actorParent.SwitchToIdle(); } // 回调函数, 切换到 idle theOwner.AddCallbackInFrames<EntityParent, int>( (_theOwner, _skillID) => { _theOwner.TriggerUniqEvent(Events.FSMMotionEvent.OnPrepareEnd, _skillID); }, theOwner, skillID ); }
// 离开状态 public void Exit(EntityParent theOwner, params Object[] args) { if (theOwner is EntityDummy) { theOwner.ApplyRootMotion(false); } }
public BuffManager(EntityParent theOwner) { m_theOwner = theOwner; clientBuffs = new Dictionary<int, ClientBuff>(); EventDispatcher.AddEventListener(Events.OtherEvent.SecondPast, CountDownSkillBuffTime); timer = TimerHeap.AddTimer(500, 100, UpdateBuff); }
// 进入该状态 public void Enter(EntityParent theOwner, params Object[] args) { theOwner.CurrentMotionState = MotionState.HIT; if (theOwner is EntityDummy) { theOwner.ApplyRootMotion(true); } }
// 进入该状态 public void Enter(EntityParent theOwner, params System.Object[] args) { theOwner.CurrentMotionState = MotionState.WALKING; if (theOwner is EntityMyself) { theOwner.animator.speed = theOwner.moveSpeedRate * theOwner.gearMoveSpeedRate; } }
public BattleManager(EntityParent _owner, SkillManager _skillManager) { theOwner = _owner; skillManager = _skillManager; theOwner.AddUniqEventListener<int>(Events.FSMMotionEvent.OnPrepareEnd, OnPrepareEnd); theOwner.AddUniqEventListener<int>(Events.FSMMotionEvent.OnAttackingEnd, OnAttackingEnd); theOwner.AddUniqEventListener<int>(Events.FSMMotionEvent.OnHitAnimEnd, OnHitAnimEnd); theOwner.AddUniqEventListener(Events.FSMMotionEvent.OnRollEnd, OnRollEnd); EventDispatcher.AddEventListener<int, uint, uint, List<int>>(Events.FSMMotionEvent.OnHit, OnHit); }
// 状态处理 public void Process(EntityParent theOwner, params Object[] args) { LoggerHelper.Debug("process roll state"); // 播放动画 if (theOwner.animator != null) { theOwner.animator.SetInteger("Action", 30); theOwner.AddCallbackInFrames((t) => { t.animator.SetInteger("Action", -30); }, theOwner); } }
public override bool Proc(EntityParent theOwner) { bool rnt = theOwner.ProcChooseCastPoint(m_iSkillId); if (rnt == true) { //Mogo.Util.LoggerHelper.Debug("AI:" + "ChooseCastPoint:true"); } else { //Mogo.Util.LoggerHelper.Debug("AI:" + "ChooseCastPoint:false"); } return rnt; }
protected void AllRepeat() { if (MogoWorld.Entities == null) return; if (MogoWorld.Entities.Count == 0) return; bool hasFound = false; int hitActionID = -1; EntityParent theOwner = new EntityParent(); Transform theOwnerTransform = null; foreach (var entityData in MogoWorld.Entities) { List<int> skillIDs = new List<int>(); if (entityData.Value is EntityMonster) skillIDs = (entityData.Value as EntityMonster).MonsterData.skillIds; if (entityData.Value is EntityMercenary) skillIDs = (entityData.Value as EntityMercenary).MonsterData.skillIds; if (entityData.Value is EntityDummy) skillIDs = (entityData.Value as EntityDummy).MonsterData.skillIds; if (skillIDs.Contains(checkSkillActionID)) { theOwner = entityData.Value; theOwnerTransform = entityData.Value.Transform; hitActionID = checkSkillActionID; hasFound = true; break; } } if (!hasFound) return; List<Transform> hitContainers = GetHitContainers(theOwnerTransform, hitActionID); if (hitContainers.Count > 0) { AttackContainers(theOwner, hitActionID, hitContainers); } }
// public override void ChangeStatus(EntityParent theOwner, string newState, params Object[] args) { if (theOwner.CurrentMotionState == newState && newState != MotionState.ATTACKING) { return; } if (theFSM.ContainsKey(newState) == false) { LoggerHelper.Error("error state in Motion FSM."); return; } theFSM[theOwner.CurrentMotionState].Exit(theOwner, args); theFSM[newState].Enter(theOwner, args); theFSM[newState].Process(theOwner, args); }
// 状态处理 public void Process(EntityParent theOwner, params Object[] args) { int action = ActionConstants.DIE; theOwner.ApplyRootMotion(true); string actName = theOwner.CurrActStateName(); if (actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT_AIR]) || actName.EndsWith("getup")) { action = ActionConstants.DIE_KNOCK_DOWN; theOwner.SetAction(action); } else if (actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT_GROUND]) || actName.EndsWith("knockout")) { action = ActionConstants.DIE; theOwner.SetAction(action); } else { int hitActionID = (int)(args[0]); List<int> deadAction = null; if (SkillAction.dataMap.ContainsKey(hitActionID)) { deadAction = SkillAction.dataMap[hitActionID].deadAction; } action = ActionConstants.DIE; if (deadAction == null || deadAction.Count == 0) { action = ActionConstants.DIE; } else { action = Utils.Choice<int>(deadAction); } theOwner.SetAction(action); } theOwner.SetSpeed(0); EventDispatcher.TriggerEvent(Events.LogicSoundEvent.OnHitYelling, theOwner as EntityParent, action); if (theOwner is EntityMyself && theOwner.motor) { theOwner.motor.enableStick = false; } //theOwner.AddCallbackInFrames<int>(theOwner.SetAction, 0); }
public override bool Proc(EntityParent theOwner) { EntityParent enemy = theOwner.GetTargetEntity(); if (enemy == null || enemy.curHp <= 0) { theOwner.blackBoard.enemyId = 0; } if (theOwner.blackBoard.enemyId != 0) { //Mogo.Util.LoggerHelper.Debug("AI:" + "HasFightTarget:" + "true"); } else { //Mogo.Util.LoggerHelper.Debug("AI:" + "HasFightTarget:" + "false"); } return theOwner.blackBoard.enemyId != 0; }
// 离开状态 public void Exit(EntityParent theOwner, params System.Object[] args) { theOwner.ApplyRootMotion(true); theOwner.SetSpeed(1); if (theOwner is EntityMonster) { theOwner.motor.SetExrtaSpeed(0); theOwner.motor.isMovingToTarget = false; return; } if (theOwner is EntityDummy) { theOwner.ApplyRootMotion(false); } if (theOwner is EntityMyself) { theOwner.animator.speed = 1; } }
// 状态处理 public void Process(EntityParent theOwner, params System.Object[] args) { MogoMotor theMotor = theOwner.motor; if (theOwner is EntityMonster || (theOwner is EntityPlayer && !(theOwner is EntityMyself))) { theOwner.ApplyRootMotion(false); theOwner.SetSpeed(1); theMotor.SetSpeed(0.4f); //服务器没有同步其他玩家的速度,这里暂时硬编码处理, //待确定其他玩家与怪物移动位移的控制方案再修改(程序控制还是动作位移) if (theOwner.speed == 0) { theMotor.SetExrtaSpeed(6); } else { theMotor.SetExrtaSpeed(theOwner.speed); } return; } else if (theOwner is EntityDummy || theOwner is EntityMercenary) { theOwner.ApplyRootMotion(false); //theOwner.SetSpeed(1); theMotor.SetSpeed(0.4f * theOwner.aiRate); theMotor.SetExrtaSpeed(theOwner.GetIntAttr("speed") * 0.01f * theOwner.blackBoard.speedFactor * theOwner.aiRate); } else { theOwner.ApplyRootMotion(true); // theOwner.SetSpeed(1); theMotor.SetSpeed(0.4f); } theMotor.isMovable = true; }
// 状态处理 public void Process(EntityParent theOwner, params Object[] args) { // 播放 idle 动画 if (theOwner == null) { return; } if (theOwner.CanMove() && theOwner.motor != null) { theOwner.motor.enableStick = true; } MogoMotor theMotor = theOwner.motor; if (theOwner is EntityMonster) { theOwner.ApplyRootMotion(false); } // 设置 速度 if (theMotor != null) { theMotor.SetSpeed(0.0f); } //theMotor.SetExrtaSpeed(0f); if (theOwner.charging) { return; } if (theOwner is EntityPlayer && MogoWorld.inCity) { theOwner.SetAction(-1); } else { theOwner.SetAction(0); } theOwner.SetActionByStateFlagInIdleState(); }
public BattleManager(EntityParent _owner, SkillManager _skillManager) { theOwner = _owner; skillManager = _skillManager; }
protected void AttackContainers(EntityParent theOwner, int hitActionID, List<Transform> hitContainers) { foreach (Transform target in hitContainers) { if (!Container.containers.ContainsKey(target)) continue; if (!Container.containers[target].triggleEnable) continue; if ((theOwner is EntityMyself && Container.containers[target].isMyselfAttackable) || (theOwner is EntityMercenary && theOwner.ID == MogoWorld.theLittleGuyID && Container.containers[target].isLittelGuyAttackable) || (theOwner is EntityMercenary && theOwner.ID != MogoWorld.theLittleGuyID && Container.containers[target].isMercenarayAttackable) || (theOwner is EntityDummy && Container.containers[target].isDummyAttackable)) Container.containers[target].OnDeath(hitActionID); } }
public override bool ProcFollowOwner() { //SetIntAttr("speed", 500); EntityParent enemy = MogoWorld.thePlayer; if (enemy == null) { return(false); } if (enemy.Transform == null) { LoggerHelper.Error("enemy.Transform == null"); return(false); } else if (Transform == null) { LoggerHelper.Error("Transform == null"); return(false); } int distance = 200; int curdistance = (int)(Vector3.Distance(Transform.position, enemy.Transform.position) * 100); if (curdistance > 1000) { RemoveTarget(); this.Transform.GetComponent <NavMeshAgent>().enabled = false; this.Transform.position = MogoWorld.thePlayer.Transform.position + new Vector3(0, 0, 1); this.Transform.GetComponent <NavMeshAgent>().enabled = true; return(true); } if (curdistance < 250) { return(false); } if (distance >= curdistance) { StopMove(); return(false); } else { blackBoard.navTargetDistance = (uint)distance; blackBoard.movePoint = enemy.Transform.position; } float tmpDis = Vector3.Distance(Transform.position, new Vector3(blackBoard.movePoint.x, Transform.position.y, blackBoard.movePoint.z)); if (tmpDis < 1.0f) { StopMove(); return(false); } motor.CancleLookAtTarget(); if (!MoveToByNav(blackBoard.movePoint, (int)blackBoard.navTargetDistance)) { return(false); } return(true); }
// 离开状态 public void Exit(EntityParent theOwner, params Object[] args) { }
public void FaceToTarget(EntityParent targetEntity) { Vector3 target = targetEntity.Transform.position; Transform.LookAt(new Vector3(target.x, Transform.position.y, target.z)); }
// 状态处理 public void Process(EntityParent theOwner, params Object[] args) { if (theOwner == null || theOwner.Transform == null) return; if (theOwner.IsDeath()) return; if (args.Length < 2) { LoggerHelper.Error("error skill id"); return; } int hitActionID = (int)(args[0]); uint attackID = (uint)(args[1]); EntityParent attacker = null; if (MogoWorld.Entities.ContainsKey(attackID)) { attacker = MogoWorld.Entities[attackID]; } if (attackID == MogoWorld.thePlayer.ID) { attacker = MogoWorld.thePlayer; } if (theOwner.motor != null) { theOwner.motor.enableStick = false; } //if (attacker == null) //{//没有受击者 // return; //} List<int> hitAction = SkillAction.dataMap[hitActionID].hitAction; if (hitAction == null || hitAction.Count == 0) { return; } int action = Utils.Choice<int>(hitAction); if (action == ActionConstants.HIT) { HitActionRule(theOwner, action, hitActionID); return; } if (!(theOwner is EntityPlayer)) { if (((theOwner is EntityMonster) && theOwner.GetIntAttr("notTurn") == 0) || theOwner is EntityDummy) { if (theOwner.motor == null) { return; } if (attacker != null && attacker.Transform != null) { theOwner.motor.SetTargetToLookAt(attacker.Transform.position); } } } else { if (theOwner.Transform == null) { return; } theOwner.preQuaternion = theOwner.Transform.localRotation; if (attacker != null && attacker.Transform != null) theOwner.motor.SetTargetToLookAt(attacker.Transform.position); } HitActionRule(theOwner, action, hitActionID); }
private void HitActionRule(EntityParent theOwner, int act, int hitActionID) { int action = act; string actName = theOwner.CurrActStateName(); if (actName.EndsWith(PlayerActionNames.names[ActionConstants.KNOCK_DOWN])) {//击飞状态,受非浮空打击,一直倒地 action = ActionConstants.KNOCK_DOWN; return; } if (actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT_AIR])) {//浮空受击 action = ActionConstants.HIT_AIR; } else if (actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT_GROUND]) || actName.EndsWith("knockout")) { action = ActionConstants.HIT_GROUND; } else if ((theOwner is EntityMyself) && (action == ActionConstants.HIT_AIR || action == ActionConstants.KNOCK_DOWN)) { int random = Mogo.Util.RandomHelper.GetRandomInt(0, 100); if (random <= 70) {//主角受到倒地状态影响时,只有30%机会成功,否则变成普通受击 By.铭 action = ActionConstants.HIT; } } theOwner.SetAction(action); EventDispatcher.TriggerEvent(Events.LogicSoundEvent.OnHitYelling, theOwner as EntityParent, action); // 回调函数, 切换到 idle TimerHeap.AddTimer<EntityParent, int>(100, 0, (_theOwner, _hitAct) => { if (_theOwner == null) { return; } if (_theOwner.motor != null) { _theOwner.motor.CancleLookAtTarget(); } //_theOwner.TriggerUniqEvent<int>(Events.FSMMotionEvent.OnHitAnimEnd, _hitAct); if (_theOwner is EntityMyself) { _theOwner.SetSpeed(0); _theOwner.motor.SetSpeed(0); } }, theOwner, hitActionID ); }
//---------------------------------------AI Condition相关begin------------------------------------------------ public override bool ProcInSkillRange(int skillBagIndex) { if (m_monsterData.skillIds.Count < skillBagIndex || skillBagIndex <= 0) { return(false); } skillBagIndex--; if (blackBoard.enemyId == 0) { return(false); } int skillId = m_monsterData.skillIds[skillBagIndex]; if (!SkillData.dataMap.ContainsKey(skillId)) { return(false); } EntityParent enemy = GetTargetEntity(); if (enemy == null) { return(false); } bool rnt = false; if (!SkillData.dataMap.ContainsKey(skillId)) { return(false); } TargetRangeType targetRangeType = 0; SkillData tmpSkillData = SkillData.dataMap[skillId]; //逐个skillaction来判断是否等于TargetRangeType.WorldRange foreach (var tmpSkillActionId in tmpSkillData.skillAction) { if (SkillAction.dataMap[tmpSkillActionId].targetRangeType == (int)TargetRangeType.WorldRange) { targetRangeType = TargetRangeType.WorldRange; } } if (targetRangeType == TargetRangeType.WorldRange) { rnt = skillManager.IsInSkillRange(skillId, blackBoard.enemyId); } else { int skillRange = GetSkillRange(skillId); int distance = skillRange; float entityRadius = enemy.MonsterData.scaleRadius; if (entityRadius <= 0.1f) { entityRadius = (float)enemy.GetIntAttr("scaleRadius"); } int curdistance = (int)(Vector3.Distance(Transform.position, enemy.Transform.position) * 100 - entityRadius); if (distance >= curdistance) { rnt = true; //if (isLittleGuy) // Mogo.Util.LoggerHelper.Error("IsInSkillRange:true" + distance + " " + entityRadius + " " + curdistance); } else { rnt = false; //if (isLittleGuy) // Mogo.Util.LoggerHelper.Error("IsInSkillRange:false" + distance + " " + entityRadius + " " + curdistance); } } return(rnt); }
public virtual float MoveAround() { EntityParent enemy = GetTargetEntity(); if (enemy == null) { //返回出生点 ////Debug.Log("blackBoard.enemyId <= 0"); return(0.0f); } //速度衰减 blackBoard.speedFactor = DummyLookOnParam.SPEED_FACTOR_MODE_2_3; float tarAngle = Mogo.Util.RandomHelper.GetRandomFloat(DummyLookOnParam.PER_ANGLE * 0.5f, DummyLookOnParam.PER_ANGLE * 1.5f); float halfTarAngle = tarAngle / 2; Vector3 n = (enemy.Transform.position - Transform.position).normalized; float xie = Mathf.Sqrt(n.x * n.x + n.z * n.z); float hudu = Mathf.Asin(n.z / xie); float angle = hudu / Mathf.PI * 180.0f; if (enemy.Transform.position.x > Transform.position.x && enemy.Transform.position.z > Transform.position.z) { angle = 270 - angle; } else if (enemy.Transform.position.x < Transform.position.x && enemy.Transform.position.z > Transform.position.z) { angle = 90 + angle; } else if (enemy.Transform.position.x < Transform.position.x && enemy.Transform.position.z < Transform.position.z) { angle = 90 + angle; } else if (enemy.Transform.position.x > Transform.position.x && Transform.position.z > enemy.Transform.position.z) { angle = -90 - angle; } if (blackBoard.LookOn_Mode == 2) { angle = angle + (90.0f + halfTarAngle); } else//blackBoard.LookOn_Mode == 3 { angle = angle - (90.0f + halfTarAngle); } float time = 0.0f; float r = Vector3.Distance(enemy.Transform.position, Transform.position); float len = (float)Mathf.Sin(halfTarAngle * Mathf.PI / 180.0f) * r * 2; time = len / (GetIntAttr("speed") * 0.01f * blackBoard.speedFactor); ////Debug.Log("time:" + time + " len:" + len + " speed:" + (GetIntAttr("speed") / 100.0f) + " r:" + r + " sin:" + (float)Mathf.Sin(halfTarAngle * Mathf.PI / 180.0f)); motor.SetTargetToLookAt(enemy.Transform); MoveToByAngle(angle, time, false); return(time); }
public bool GetMovePointStraight(int skillRange) { // Debug.LogError("GetMovePointStraight"); EntityParent enemy = GetTargetEntity(); Container enemyTrap = GetTargetContainer(); if (enemy == null && enemyTrap == null) { return(false); } if (enemy != null) { if (enemy.Transform == null) { Debug.LogError("enemy.Transform == null"); } else if (Transform == null) { Debug.LogError("Transform == null"); } int distance = skillRange; float entityRadius = enemy.MonsterData.scaleRadius; if (entityRadius <= 0.1f) { entityRadius = (float)enemy.GetIntAttr("scaleRadius"); } int curdistance = (int)(Vector3.Distance(Transform.position, enemy.Transform.position) * 100 - entityRadius); if (distance >= curdistance)// || curdistance-distance < 0.1f { StopMove(); return(false); } else { blackBoard.navTargetDistance = (uint)skillRange + (uint)entityRadius; blackBoard.movePoint = enemy.Transform.position; } float tmpDis = Vector3.Distance(Transform.position, new Vector3(blackBoard.movePoint.x, Transform.position.y, blackBoard.movePoint.z)); if (tmpDis < 1.0f) { StopMove(); return(false); } return(true); } else if (enemyTrap != null) { if (enemyTrap.transform == null) { Debug.LogError("enemy.Transform == null"); } else if (Transform == null) { Debug.LogError("Transform == null"); } int distance = skillRange; int curdistance = (int)(Vector3.Distance(Transform.position, enemyTrap.transform.position) * 100); if (distance >= curdistance)// || curdistance-distance < 0.1f { StopMove(); return(false); } else { blackBoard.navTargetDistance = (uint)skillRange; blackBoard.movePoint = enemyTrap.transform.position; } float tmpDis = Vector3.Distance(Transform.position, new Vector3(blackBoard.movePoint.x, Transform.position.y, blackBoard.movePoint.z)); if (tmpDis < 1.0f) { StopMove(); return(false); } return(true); } else { return(false); } }
public virtual bool ProcAOI(int searchChance) { EntityParent littleGuy = GetMercenaryEntity(); //检测是否需要清除仇恨,例如entity不存在或者死亡 //此方法只提供给怪物用,雇佣兵用ProcMercenaryAOI //把距离满足条件的活物对手加入仇恨列表 if (!blackBoard.HasHatred(MogoWorld.thePlayer.ID) && !MogoWorld.thePlayer.IsDeath()) { int tmpDis = (int)(Vector3.Distance(Transform.position, MogoWorld.thePlayer.Transform.position) * 100); //Debug.LogError("m_currentSee:" + m_currentSee); if (tmpDis < m_currentSee) { //发现新目标,在距离内,加入仇恨列表 blackBoard.EditHatred(MogoWorld.thePlayer.ID, 1); //通知其他同出生点的伙伴们也把新目标加入仇恨列表 EventDispatcher.TriggerEvent(Events.AIEvent.WarnOtherSpawnPointEntities, ID, (byte)Mogo.Game.AIWarnEvent.DiscoverSomeOne, MogoWorld.thePlayer.ID, spawnPointCfgId); //Debug.LogError("thePlayer closed!!!!!!!!!!!!"); } } if (littleGuy != null && !blackBoard.HasHatred(littleGuy.ID) && !littleGuy.IsDeath()) { int tmpDis = (int)(Vector3.Distance(Transform.position, littleGuy.Transform.position) * 100); if (tmpDis < m_currentSee) { //发现新目标,在距离内,加入仇恨列表 blackBoard.EditHatred(littleGuy.ID, 1); EventDispatcher.TriggerEvent(Events.AIEvent.WarnOtherSpawnPointEntities, ID, Mogo.Game.AIWarnEvent.DiscoverSomeOne, littleGuy.ID, spawnPointCfgId); } } //取一个作为目标,暂时没随机 if (blackBoard.mHatred.Count > 0) { foreach (KeyValuePair <uint, int> v in blackBoard.mHatred) { if (v.Value <= 0) { continue; } blackBoard.enemyId = v.Key; if (v.Key == MogoWorld.thePlayer.ID) { //Debug.LogError(" see thePlayer !!!!!!!!!!!!"); if (!NotTurn()) { motor.SetTargetToLookAt(MogoWorld.thePlayer.Transform); } } else if (littleGuy != null && v.Key == littleGuy.ID) { if (!NotTurn()) { motor.SetTargetToLookAt(littleGuy.Transform); } } break; } } if (blackBoard.enemyId == 0) { return(false); } else { return(true); } }
// 为去除警告暂时屏蔽以下代码 //private int lastSkillId = 0; public MercenaryBattleManager(EntityParent _theOwner, SkillManager _skillManager) : base(_theOwner, _skillManager) { }
public MonsterBattleManager(EntityParent _theOwner, SkillManager _skillManager) : base(_theOwner, _skillManager) { }
private void HitRule(EntityParent theOwner, int act, int hitActionID) { int action = act; HitState h = null; if (!HitState.dataMap.TryGetValue(theOwner.hitStateID, out h)) {//如果没有配置,用回原来接口 HitActionRule(theOwner, action, hitActionID); return; } string actName = theOwner.CurrActStateName(); if (theOwner.currSpellID != -1) { action = h.GetSkillAct(action); } else if (actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT])) { action = h.GetHitAct(action); } else if(actName.EndsWith(PlayerActionNames.names[ActionConstants.PUSH])) { action = h.GetPushAct(action); } else if(actName.EndsWith(PlayerActionNames.names[ActionConstants.KNOCK_DOWN])) { action = h.GetKnockDownAct(action); } else if(actName.EndsWith(PlayerActionNames.names[ActionConstants.HIT_AIR])) { action = h.GetHitAirAct(action); } else if (actName.EndsWith("knockout")) { action = h.GetKnockOutAct(action); } else if (actName.EndsWith("getup")) { action = h.GetGetUpAct(action); } else if (theOwner.animator.GetInteger("Action") == ActionConstants.REVIVE) { action = h.GetReviveAct(action); } else //(theOwner.CurrentMotionState == MotionState.IDLE) { action = h.GetIdleAct(action); } if (action != 0) { theOwner.SetAction(action); } // 回调函数, 切换到 idle theOwner.AddCallbackInFrames<EntityParent, int>( (_theOwner, _hitAct) => { _theOwner.motor.CancleLookAtTarget(); _theOwner.TriggerUniqEvent<int>(Events.FSMMotionEvent.OnHitAnimEnd, _hitAct); if (_theOwner is EntityMyself) { _theOwner.SetSpeed(0); _theOwner.motor.SetSpeed(0); } }, theOwner, hitActionID ); }
// Flush Blood public void FlushBossBlood(EntityParent boss, int bossBlood) { //Mogo.Util.LoggerHelper.Error("FlushBossBlood boss hp: " + boss.hp); // if (boss is EntityMercenary) // Mogo.Util.LoggerHelper.Error("FlushBossBlood boss hpBase: " + (boss as EntityMercenary).MonsterData.hpBase); // Mogo.Util.LoggerHelper.Error("FlushBossBlood boss curHp: " + boss.curHp); if (bossBlood == 0 && hasShowBossBlood) { // MainUIViewManager.Instance.ShowBossTarget(false); return; } if (!hasShowBossBlood && boss.MonsterData.hpShow != null && boss.MonsterData.hpShow.Count >= 3) SetBossMessageInit(boss, boss.MonsterData.hpShow[2]); int currentBloodCount = bossBlood / defaultBlood; int currentBloodOdd = bossBlood % defaultBlood; float currentBloodRate = 0; if (currentBloodOdd != 0) { currentBloodCount += 1; currentBloodRate = (float)currentBloodOdd / defaultBlood; } else { if (bossBlood != boss.hp) currentBloodCount += 1; currentBloodOdd = defaultBlood; currentBloodRate = 1; } MainUIViewManager.Instance.SetBossTargetBlood(currentBloodRate, (currentBloodCount - 1) % 5); }
public override bool Proc(EntityParent theOwner) { foreach (IBehaviorTreeNode _node in children) { if (!_node.Proc(theOwner)) { return false; } } return true; }
/// <summary> /// 由子数实现 /// </summary> /// <returns></returns> public virtual bool Proc(EntityParent theOwner) { return true; }
public void SetBossMessageInit(EntityParent boss, int bloodNum) { hasShowBossBlood = true; // Mogo.Util.LoggerHelper.Debug("Init boss hp: " + boss.hp); // if (boss is EntityMercenary) // Mogo.Util.LoggerHelper.Debug("Init boss hpBase: " + (boss as EntityMercenary).MonsterData.hpBase); // Mogo.Util.LoggerHelper.Debug("Init boss curHp: " + boss.curHp); MainUIViewManager.Instance.SetBossTargetName(boss.name, boss.MonsterData.monsterType); MainUIViewManager.Instance.SetBossTargetFace(boss.HeadIcon, boss.MonsterData.monsterType); MainUIViewManager.Instance.SetBossTargetLevel(boss.level, boss.MonsterData.monsterType); // 处理血 defaultBloodCount = bloodNum; defaultBlood = (int)boss.MonsterData.hpBase / bloodNum; if (defaultBlood == 0) LoggerHelper.Error("defaultBlood == 0: " + boss.ID + " " + boss.GameObject.name); int currentBloodCount = (int)boss.curHp / defaultBlood; int sumOdd = (int)boss.curHp - defaultBloodCount * defaultBlood; int currentBloodOdd = (int)boss.curHp % defaultBlood; float currentBloodRate = 0; if (sumOdd > 0) // 血量有极少量余数 { currentBloodRate = (float)(boss.curHp - (defaultBloodCount - 1) * defaultBlood) / defaultBlood; } else // 已经扣血 { if (currentBloodCount == 0) { currentBloodCount = 1; currentBloodRate = (float)currentBloodOdd / defaultBlood; } else if (currentBloodOdd != 0) { currentBloodCount += 1; currentBloodRate = (float)currentBloodOdd / defaultBlood; } else { currentBloodOdd = defaultBlood; currentBloodRate = 1; } } MainUIViewManager.Instance.ShowBossTarget(true, 4 - (currentBloodCount - 1) % 5, boss.MonsterData.monsterType); MainUIViewManager.Instance.SetBossTargetBlood(currentBloodRate >= 1 ? 1 : currentBloodRate, (currentBloodCount - 1) % 5); }
public PlayerBattleManager(EntityParent _owner, SkillManager _skillManager) : base(_owner, _skillManager) { theOwner = _owner; skillManager = _skillManager; }
public void SetPlayerMessageInit(EntityParent player, int i) { switch (i) { case 1: MainUIViewManager.Instance.SetMember1Name(player.name); MainUIViewManager.Instance.SetMember1Level(player.level); MainUIViewManager.Instance.SetMember1Blood((int)(player.curHp * 100 / player.hp)); MainUIViewManager.Instance.ShowMember1(true); break; case 2: MainUIViewManager.Instance.SetMember2Name(player.name); MainUIViewManager.Instance.SetMember2Level(player.level); MainUIViewManager.Instance.SetMember2Blood((int)(player.curHp * 100 / player.hp)); MainUIViewManager.Instance.ShowMember2(true); break; case 3: MainUIViewManager.Instance.SetMember3Name(player.name); MainUIViewManager.Instance.SetMember3Level(player.level); MainUIViewManager.Instance.SetMember3Blood((int)(player.curHp * 100 / player.hp)); MainUIViewManager.Instance.ShowMember3(true); break; default: Debug.LogError("Are You Kidding Me ?"); break; } }
public override float MoveAround() { if (IsMonster()) { return(base.MoveAround()); } //是雇佣兵或者pvp EntityParent enemy = GetTargetEntity(); if (enemy == null) { //返回出生点 //Mogo.Util.LoggerHelper.Debug("blackBoard.enemyId <= 0"); return(0.0f); } //速度衰减 blackBoard.speedFactor = DummyLookOnParam.SPEED_FACTOR_MODE_2_3; float tarAngle = Mogo.Util.RandomHelper.GetRandomFloat(DummyLookOnParam.PER_ANGLE * 0.5f, DummyLookOnParam.PER_ANGLE * 1.5f); tarAngle *= 2; float halfTarAngle = tarAngle / 2; Vector3 n = (enemy.Transform.position - Transform.position).normalized; float xie = Mathf.Sqrt(n.x * n.x + n.z * n.z); float hudu = Mathf.Asin(n.z / xie); float angle = hudu / Mathf.PI * 180.0f; if (enemy.Transform.position.x > Transform.position.x && enemy.Transform.position.z > Transform.position.z) { angle = 270 - angle; } else if (enemy.Transform.position.x < Transform.position.x && enemy.Transform.position.z > Transform.position.z) { angle = 90 + angle; } else if (enemy.Transform.position.x < Transform.position.x && enemy.Transform.position.z < Transform.position.z) { angle = 90 + angle; } else if (enemy.Transform.position.x > Transform.position.x && Transform.position.z > enemy.Transform.position.z) { angle = -90 - angle; } if (blackBoard.LookOn_Mode == 2) { angle = angle + (90.0f + halfTarAngle); } else//blackBoard.LookOn_Mode == 3 { angle = angle - (90.0f + halfTarAngle); } float time = 0.0f; float r = Vector3.Distance(enemy.Transform.position, Transform.position); float len = (float)Mathf.Sin(halfTarAngle * Mathf.PI / 180.0f) * r * 2; time = len / (GetIntAttr("speed") * 0.01f * blackBoard.speedFactor); motor.CancleLookAtTarget(); MoveToByAngle(angle, time, true); return(time); }
public bool Proc(EntityParent theOwner) { return root.Proc(theOwner); }
// 进入该状态 public void Enter(EntityParent theOwner, params Object[] args) { // LoggerHelper.Debug("enter prepare state"); theOwner.CurrentMotionState = MotionState.PREPARING; }
public virtual bool Proc(EntityParent theOwner) { return child.Proc(theOwner) ; }
public virtual void ProcLookOn() { EntityParent enemy = GetTargetEntity(); if (enemy == null) { Debug.Log("ProcLookOn enemy null"); return; } float curdistance = Vector3.Distance(Transform.position, enemy.Transform.position); if (curdistance >= blackBoard.LookOn_DistanceMax) { //不能远离了,把远离左右移动概率填0 只能接近,冲锋 blackBoard.LookOn_ModePercent[1] = 0; blackBoard.LookOn_ModePercent[2] = 0; blackBoard.LookOn_ModePercent[3] = 0; blackBoard.LookOn_ModePercent[4] = 0; } if (curdistance <= blackBoard.LookOn_DistanceMin) { //不能接近了,把接近和冲锋概率填0 blackBoard.LookOn_ModePercent[0] = 0; blackBoard.LookOn_ModePercent[5] = 0; } /* * if (ProcLastLookOnModeIs(4)) * { //上次使用了休息这次不用休息了 * blackBoard.LookOn_ModePercent[4] = 0; * Debug.LogError("c:" + blackBoard.LookOn_ModePercent[4]); * } */ int sum = 0; for (int i = 0; i < blackBoard.LookOn_ModePercent.Length; i++) { sum += blackBoard.LookOn_ModePercent[i]; } int randomV = Mogo.Util.RandomHelper.GetRandomInt(sum); sum = 0; for (int i = 0; i < blackBoard.LookOn_ModePercent.Length; i++) { sum += blackBoard.LookOn_ModePercent[i]; if (randomV <= sum) { blackBoard.LookOn_Mode = i; break; } } //Debug.Log("blackBoard.LookOn_Mode:" + blackBoard.LookOn_Mode); float tmpLookOn_ActTime = 0.0f; if (blackBoard.LookOn_Mode == 0 || blackBoard.LookOn_Mode == 1) {//接近,远离 tmpLookOn_ActTime = MoveStraight(); tmpLookOn_ActTime = blackBoard.LookOn_ModeInterval[blackBoard.LookOn_Mode]; } else if (blackBoard.LookOn_Mode == 2 || blackBoard.LookOn_Mode == 3) {//左右绕圈 //Debug.LogError("blackBoard.LookOn_ModeInterval[blackBoard.LookOn_Mode]" + blackBoard.LookOn_ModeInterval[blackBoard.LookOn_Mode]); tmpLookOn_ActTime = MoveAround(); tmpLookOn_ActTime = blackBoard.LookOn_ModeInterval[blackBoard.LookOn_Mode]; } else if (blackBoard.LookOn_Mode == 4) {//休息 float timeStanderd = blackBoard.LookOn_ModeInterval[blackBoard.LookOn_Mode]; float time = Mogo.Util.RandomHelper.GetRandomFloat(timeStanderd * 0.8f, timeStanderd * 1.2f); ProcEnterRest((uint)(time * 1000.0f)); tmpLookOn_ActTime = time * 1000.0f; } else if (blackBoard.LookOn_Mode == 5) {//冲锋 tmpLookOn_ActTime = MoveAssault(); } if (tmpLookOn_ActTime >= 0.0f) { blackBoard.LookOn_ActTime = (uint)(tmpLookOn_ActTime * 1000); blackBoard.LookOn_Tick = GetTickCount(); } }