public override void OnTickIdle(ObjNPC npc, float delta) { if (!npc.CanMove()) { return; } if (npc.IsMoving()) { return; } if (mPtIdx < 0 || mPtIdx >= ListDestination.Count) { npc.Disapeare(); return; } if (mTime > DateTime.Now) { return; } if (MoveResult.AlreadyThere == npc.MoveTo(ListDestination[mPtIdx])) { mPtIdx++; mTime = DateTime.Now.AddSeconds(WaitTime); } }
public override void OnTickIdle(ObjNPC npc, float delta) { if (!npc.CanMove()) { return; } if (npc.IsMoving()) { return; } if (mStayTime > DateTime.Now) { return; } if (ListDestination.Count <= 0) { return; } if (MoveResult.AlreadyThere == npc.MoveTo(ListDestination[mPtIdx])) { if (mForward) { mPtIdx++; if (mPtIdx >= ListDestination.Count) { mForward = false; mPtIdx = ListDestination.Count - 2; } } else { mPtIdx--; if (mPtIdx < 0) { mForward = true; mPtIdx = 1; } } mStayTime = DateTime.Now.AddSeconds(WaitTime); } }
public override void OnTickIdle(ObjNPC npc, float delta) { if (npc.IsAggressive()) { if (npc.TableNpc.ViewDistance > 0) { var target = ScanEnemy(npc, (float)npc.TableNpc.ViewDistance); if (target != null) { npc.EnterState(BehaviorState.Combat); npc.PushHatre(target, 1); npc.AddEnemy(target.ObjId); target.AddEnemy(npc.ObjId); return; } } } if (!npc.CanMove()) { return; } if (npc.IsMoving()) { return; } if (mPtIdx < 0 || mPtIdx >= ListDestination.Count) { //npc.Disapeare(); return; } if (mTime > DateTime.Now) { return; } if (MoveResult.AlreadyThere == npc.MoveTo(ListDestination[mPtIdx])) { mPtIdx++; mTime = DateTime.Now.AddSeconds(WaitTime); } }
public override void OnTickCombat(ObjNPC npc, float delta) { var enemyTarget = GetEnemyCharacter(npc); if (enemyTarget == null) { npc.EnterState(BehaviorState.Idle); return; } if (!npc.CanMove()) { return; } NextSkill = FindFreeSkill(npc, enemyTarget); if (NextSkill == -1) { return; } var tbSkill = Table.GetSkill(NextSkill); if (tbSkill == null) { return; } if ((SkillTargetType)tbSkill.TargetType == SkillTargetType.SELF || (eCampType)tbSkill.CampType == eCampType.Team) { if (npc.IsMoving()) { npc.StopMove(); } if (npc.CanSkill()) { LastTargetId = enemyTarget.ObjId; SelectLastTarger = true; npc.TurnFaceTo(enemyTarget.GetPosition()); npc.UseSkill(ref NextSkill, npc); } return; } mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)tbSkill.TargetType, tbSkill.TargetParam); //跟着敌人打 if ((npc.GetPosition() - enemyTarget.GetPosition()).Length() > mSkillDistance) { npc.MoveTo(enemyTarget.GetPosition(), mSkillDistance - 0.1f); } else { if (npc.IsMoving()) { npc.StopMove(); } if (npc.CanSkill()) { LastTargetId = enemyTarget.ObjId; SelectLastTarger = true; npc.TurnFaceTo(enemyTarget.GetPosition()); npc.UseSkill(ref NextSkill, enemyTarget); } } }