protected override void Configure() { // Inicio las variables para el seguimiento Vector3 diffPosition = Target.position - Me.position; float targetRadius = diffPosition.magnitude * 0.75f; float followOffset = diffPosition.y < 0 ? -diffPosition.y : diffPosition.y; // Inicio las variables para el look at float targetRotation = 5.0f; float slowRadius = 15.0f; Vector3 rotation = ExtraMath.DifferenceBetween( Quaternion.FromToRotation(Me.forward, Target.position - Me.position), Me.rotation ); float faceOffset = rotation.y < 0 ? -rotation.y : rotation.y; // Inicializo el estado FollowState followState = new FollowState(this); followState.InitializeFollow(Target, targetRadius, offsetY: followOffset); followState.InitializeFace(Target, targetRotation, slowRadius, offsetX: faceOffset); AddState(followState); }
public override void JustAppeared() { _followState = FollowState.None; if (!IsCombatMovementAllowed()) { SetCombatMovement(true); } if (me.GetFaction() != me.GetCreatureTemplate().Faction) { me.SetFaction(me.GetCreatureTemplate().Faction); } Reset(); }
new void Start() { base.Start(); RemainingFramesToChangeDirection = NFramesNeededToChangeDirection; RemainingFramesToReachEndpoint = NFramesNeededToChangeDirection; mcRef = GameObject.Find("MasterController").GetComponent <MasterControllerScript> (); cameraPivotY = GameObject.Find("CameraLerp").GetComponent <CameraManager> ().pivotY; spawnPosition = this.transform.position; // autopiloting in relative mode is // relative to spawnPosition, so keep it if (spriteHolder != null) { rendRef = spriteHolder.GetComponent <SpriteRenderer> (); matRef = spriteHolder.GetComponent <SpriteRenderer> ().material; } if (IdleAnimationSpeed > 0.0f) { animationDelay = 1.0f / IdleAnimationSpeed; } else { animationDelay = 0.0f; } showingFrame = 0; frameTime = 0.0f; followElapsedTime = 0.0f; followState = FollowState.noFollow; player = GameObject.Find("Player").GetComponent <PlayerScript> (); r = GetComponent <Rigidbody> (); if (markedAsStartFollowing) { startFollowingPlayer(); } }
private void Start() { followState = new FollowState(); patrolState = new PatrolState(); attackState = new AttackState(); animator = GetComponent <Animator>(); spriteRenderer = GetComponent <SpriteRenderer>(); stateMachine = new StateMachine <AI>(this); stateMachine.ChangeState(patrolState); enemyMask = LayerMask.GetMask(enemy); groundMask = LayerMask.GetMask(ground); currentHealth = maxHealth; healthBar.SetMaxHealth(maxHealth); }
void Start() { paths = new Queue(); nextPosition.z = -1; _transform = this.gameObject.transform; model.direction = this.currentDirection; state = FollowState.IDEL; attackRange = new ArrayList(); attackRange.Add(new Vector2()); attackRange.Add(new Vector2()); attackRange.Add(new Vector2()); this.normalAttackSkill = Config.GetInstance().GetSkillCOnfig(this.attribute.nskill); }
public void startFollowingPlayer() { autopilotAbsolute = true; followElapsedTime = 0.0f; followState = FollowState.follow; previousWalkSpeed = walkingSpeed; walkingSpeed = player.modulusSpeed; if (walkingSpeed == 0.0f) { walkingSpeed = player.speed; } if (mcRef == null) { mcRef = GameObject.Find("MasterController").GetComponent <MasterControllerScript> (); } mcRef.getStorage().storeStringValue("FollowingChar", this.name); mcRef.getStorage().storeFloatValue("FollowerRelativeCoordsX", 1.0f); mcRef.getStorage().storeFloatValue("FollowerRelativeCoordsY", 0.0f); mcRef.getStorage().storeFloatValue("FollowerRelativeCoordsZ", -1.0f); }
void Start() { fromAttr = GetComponent <BasicObjectAttr>(); FSMManager manager = GetComponent <FSMManager>(); RandomState search = new RandomState(); FollowState follow = new FollowState(); IdleState idle = new IdleState(); PatrolState patrol = new PatrolState(); InvestigateState investigateState = new InvestigateState(); patrol.patrolRoute = patrolRoute; patrol.setAgent(GetComponent <NavMeshAgent>()); manager.GetBasicState().configure("Player", (o) => { investigateState.setTargetPos(o.transform.position).SetDoWhenArrive(null); return(investigateState); }, (o) => { investigateState.setTargetPos(o.transform.position); investigateState.SetDoWhenArrive((s) => { Collider[] coll = Physics.OverlapSphere(gameObject.transform.position, fromAttr.dangerViewAreaRadius); foreach (Collider c in coll) { if (c.tag.Equals("Player")) { var go = Camera.main.GetComponent <GameOverCameraControl>(); go.showDeadEffect = true; return(null); } } return(patrol); }); return(investigateState); }); manager.setCurrentState(patrol); }
public override void Update() { if (controller.IsTrackerAppear) { FollowState followState = new FollowState(stateMgr, controller); stateMgr.SwitchTo(followState); } else { if (curStayTime <= 0) { curStayTime = Random.Range(STAY_TIME_MIN, STAY_TIME_MAX); curStatus = (curStatus + Random.Range(0, controller.IdlePivotList.Length)) % controller.IdlePivotList.Length; switch (curStatus) { case 0: controller.LeftEyeBehaviour.ResetPos(MOVE_TIME); controller.RightEyeBehaviour.ResetPos(MOVE_TIME); break; case 1: controller.LeftEyeBehaviour.Roll(MOVE_TIME); controller.RightEyeBehaviour.Roll(MOVE_TIME); break; default: controller.LeftEyeBehaviour.FollowTarget(controller.IdlePivotList[curStatus].transform.position, MOVE_TIME); controller.RightEyeBehaviour.FollowTarget(controller.IdlePivotList[curStatus].transform.position, MOVE_TIME); break; } } else { curStayTime -= Time.deltaTime; } } }
public override void ConfigFSM() { base.ConfigFSM(); states = new List <FSMState>(); //创建状态对象 //添加映射(AddMap)* //加入状态机 //-------------------- //随机移动 RandomMoveState randomMove = new RandomMoveState(); randomMove.AddMap(FSMTriggerID.ScoutedTargetIn, FSMStateID.Follow); randomMove.AddMap(FSMTriggerID.NoHealth, FSMStateID.Dead); states.Add(randomMove); //跟随 FollowState follow = new FollowState(); follow.AddMap(FSMTriggerID.ScoutedTargetOut, FSMStateID.RandomMove); follow.AddMap(FSMTriggerID.NoHealth, FSMStateID.Dead); follow.AddMap(FSMTriggerID.AttackTargetIn, FSMStateID.Attacking); states.Add(follow); //攻击 AttackingState attacking = new AttackingState(); attacking.AddMap(FSMTriggerID.AttackTargetOut, FSMStateID.Follow); attacking.AddMap(FSMTriggerID.NoHealth, FSMStateID.Dead); states.Add(attacking); //站立 IdleState idle = new IdleState(); //idle.AddMap(FSMTriggerID.) idle.AddMap(FSMTriggerID.NoHealth, FSMStateID.Dead); states.Add(idle); //死亡 DeadState dead = new DeadState(); states.Add(dead); }
// Start is called before the first frame update void Start()//pega varios componentes, randomiza velocidade do inimigos e das animações, define se o inimigo começa seguindo o jogador ou não { //attackCol = GameObject.FindGameObjectsWithTag("attackCol"); //handColEsq = GameObject.Find("HandColEsq"); //handColDir = GameObject.Find("HandColDir"); //armColEsq = GameObject.Find("ArmColEsq"); //armColDir = GameObject.Find("ArmColDir"); playerDetect = transform.GetChild(2).gameObject; agent = GetComponent <NavMeshAgent>(); anim = GetComponent <Animator>(); agent.speed = Random.Range(5, 20); anim.SetFloat("Velocity", agent.speed / 5); enMat = GetComponentInChildren <Renderer>().material; enColliders = GetComponents <Collider>(); rbEnemy = GetComponent <Rigidbody>(); if (agent.speed > 10) { //anim.SetInteger("SpeedVerifier", 2); currentFollow = FollowState.Run; } else { //anim.SetInteger("SpeedVerifier", 1); currentFollow = FollowState.Walk; } target = GameObject.FindGameObjectWithTag("Player"); if (startAsleep) { currentState = IaState.Asleep; InvokeRepeating("VerifyPlayerDistance", 0.1f, 1.5f); } else { currentState = IaState.Follow; } //print(anim.speed); }
public override IEnumerator startStateProcess() { int findTimes = Random.Range(FIND_TIMES_MIN, FIND_TIMES_MAX); for (int i = 0; i < findTimes; ++i) { controller.RightEyeBehaviour.FollowTarget(controller.RightPivot.transform.position, MOVE_TIME); controller.LeftEyeBehaviour.FollowTarget(controller.RightPivot.transform.position, MOVE_TIME); yield return(new WaitForSeconds(MOVE_TIME + Random.Range(STAY_TIME_MIN, STAY_TIME_MAX))); controller.RightEyeBehaviour.FollowTarget(controller.LeftPivot.transform.position, MOVE_TIME); controller.LeftEyeBehaviour.FollowTarget(controller.LeftPivot.transform.position, MOVE_TIME); yield return(new WaitForSeconds(MOVE_TIME + Random.Range(STAY_TIME_MIN, STAY_TIME_MAX))); } controller.RightEyeBehaviour.ResetPos(MOVE_TIME); controller.LeftEyeBehaviour.ResetPos(MOVE_TIME); yield return(new WaitForSeconds(MOVE_TIME + 0.5f)); controller.RightEyeBehaviour.Roll(ROLL_TIME); controller.LeftEyeBehaviour.Roll(ROLL_TIME); yield return(new WaitForSeconds(ROLL_TIME + STAY_TIME)); if (controller.IsTrackerAppear) { FollowState followState = new FollowState(stateMgr, controller); stateMgr.SwitchTo(followState); } else { IdleState idleState = new IdleState(stateMgr, controller); stateMgr.SwitchTo(idleState); } }
//State storage: follow state protected override void TickCore(Entity host, RealmTime time, ref object state) { FollowState s; if (state == null) { s = new FollowState(); } else { s = (FollowState)state; } var pet = host; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) { return; } Player player = host.playerOwner; //GetNearestEntity(acquireRange, null); switch (s.State) { case F.DontKnowWhere: if (s.RemainingTime > 0) { s.RemainingTime -= time.thisTickTimes; } else { s.State = F.Acquired; } break; case F.Acquired: if (player == null) { s.State = F.DontKnowWhere; s.RemainingTime = 0; break; } if (s.RemainingTime > 0) { s.RemainingTime -= time.thisTickTimes; } var vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length() > 20) { host.Move(player.X, player.Y); } else if (vect.Length() > 1) { var dist = host.GetSpeed(0.5f) * (time.thisTickTimes / 1000f); if (vect.Length() > 2) { dist = host.GetSpeed(0.5f + ((float)player.Stats[4] / 100)) * (time.thisTickTimes / 1000f); } else if (vect.Length() > 3.5) { dist = host.GetSpeed(0.5f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); } else if (vect.Length() > 5) { dist = host.GetSpeed(1.0f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); } else if (vect.Length() > 6) { dist = host.GetSpeed(1.35f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); } else if (vect.Length() > 7) { dist = host.GetSpeed(1.5f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); } else if (vect.Length() > 10) { dist = host.GetSpeed(2f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); } Status = CycleStatus.InProgress; vect.Normalize(); host.ValidateAndMove(host.X + vect.X * dist, host.Y + vect.Y * dist); } host.UpdateCount++; break; } state = s; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { FollowState s; if (state == null) { s = new FollowState(); } else { s = (FollowState)state; } Status = CycleStatus.NotStarted; Player player = host.GetPlayerOwner(); if (player.Owner == null) { host.Owner.LeaveWorld(host); return; } Vector2 vect; switch (s.State) { case F.DontKnowWhere: if (s.RemainingTime > 0) { s.RemainingTime -= time.ElapsedMsDelta; } else { s.State = F.Acquired; } break; case F.Acquired: if (player == null) { s.State = F.DontKnowWhere; s.RemainingTime = 0; break; } if (s.RemainingTime > 0) { s.RemainingTime -= time.ElapsedMsDelta; } vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length > 20) { host.Move(player.X, player.Y); host.UpdateCount++; } else if (vect.Length > 1) { float dist = host.EntitySpeed(player.Stats[4] / 10, time); if (vect.Length > 2 && vect.Length <= 3.5) { dist *= 1.75f; } else if (vect.Length > 3.5 && vect.Length <= 5) { dist *= 2f; } else if (vect.Length > 5 && vect.Length <= 6) { dist *= 2.25f; } else if (vect.Length > 6 && vect.Length <= 7) { dist *= 2.75f; } else if (vect.Length > 7 && vect.Length <= 10) { dist *= 3f; } else if (vect.Length > 10 && vect.Length <= 20) { dist *= 3.25f; } Status = CycleStatus.InProgress; vect.X -= Random.Next(-2, 2) / 2f; vect.Y -= Random.Next(-2, 2) / 2f; vect.Normalize(); host.ValidateAndMove(host.X + vect.X * dist, host.Y + vect.Y * dist); host.UpdateCount++; } break; } state = s; }
public void ChangeFollowState(FollowState newState) { FollowState = newState; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { FollowState s; if (state == null) { s = new FollowState(); } else { s = (FollowState)state; } Status = CycleStatus.NotStarted; Player player = host.GetPlayerOwner(); if (player.Owner == null) { host.Owner.LeaveWorld(host); return; } Vector2 vect; switch (s.State) { case F.DontKnowWhere: if (s.RemainingTime > 0) { s.RemainingTime -= time.thisTickTimes; } else { s.State = F.Acquired; } break; case F.Acquired: if (player == null) { s.State = F.DontKnowWhere; s.RemainingTime = 0; break; } if (s.RemainingTime > 0) { s.RemainingTime -= time.thisTickTimes; } vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length > 20) { host.Move(player.X, player.Y); host.UpdateCount++; } else if (vect.Length > 1) { float dist = host.GetSpeed(1.2f) * (time.thisTickTimes / 1000f); if (vect.Length > 2) { dist = host.GetSpeed(1.2f + ((float)player.Stats[4] / 100)) * (time.thisTickTimes / 1000f); } else if (vect.Length > 3.5) { dist = host.GetSpeed(1.2f + ((float)player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); } else if (vect.Length > 5) { dist = host.GetSpeed(1.3f + ((float)player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); } else if (vect.Length > 6) { dist = host.GetSpeed(1.4f + ((float)player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); } else if (vect.Length > 7) { dist = host.GetSpeed(1.5f + ((float)player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); } Status = CycleStatus.InProgress; vect.X -= Random.Next(-2, 2) / 2f; vect.Y -= Random.Next(-2, 2) / 2f; vect.Normalize(); host.ValidateAndMove(host.X + vect.X * dist, host.Y + vect.Y * dist); host.UpdateCount++; } break; } state = s; }
public FollowerAI(Creature creature) : base(creature) { _updateFollowTimer = 2500; _followState = FollowState.None; }
void AddFollowState(FollowState uiFollowState) { _followState |= uiFollowState; }
public Follow(FollowState followState, User user) { this.FollowState = followState; this.User = user; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { FollowState s; if (state == null) { s = new FollowState(); } else { s = (FollowState)state; } Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) { return; } var pet = host as Pet; if (pet != null) { host.AttackTarget = pet.PlayerOwner; } var player = host.AttackTarget ?? host.GetNearestEntity(acquireRange, null); Vector2 vect; switch (s.State) { case F.DontKnowWhere: if (player != null && s.RemainingTime <= 0) { s.State = F.Acquired; if (duration > 0) { s.RemainingTime = duration; } goto case F.Acquired; } else if (s.RemainingTime > 0) { s.RemainingTime -= time.ElaspedMsDelta; } break; case F.Acquired: if (player == null) { s.State = F.DontKnowWhere; s.RemainingTime = 0; break; } else if (s.RemainingTime <= 0 && duration > 0) { s.State = F.DontKnowWhere; s.RemainingTime = coolDown.Next(Random); Status = CycleStatus.Completed; break; } if (s.RemainingTime > 0) { s.RemainingTime -= time.ElaspedMsDelta; } vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length() > range) { Status = CycleStatus.InProgress; vect.X -= Random.Next(-2, 2) / 2f; vect.Y -= Random.Next(-2, 2) / 2f; vect.Normalize(); float dist = host.GetSpeed(speed) * (time.ElaspedMsDelta / 1000f); host.ValidateAndMove(host.X + vect.X * dist, host.Y + vect.Y * dist); } else { Status = CycleStatus.Completed; s.State = F.Resting; s.RemainingTime = 0; } break; case F.Resting: if (player == null) { s.State = F.DontKnowWhere; if (duration > 0) { s.RemainingTime = duration; } break; } Status = CycleStatus.Completed; vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length() > range + 1) { s.State = F.Acquired; s.RemainingTime = duration; goto case F.Acquired; } break; } state = s; }
public bool ValidateFollowState(FollowState followState, int releaseId, int userId) { FollowState actualFollowState = releaseRepository.GetFollowState(releaseId, userId); return(followState == actualFollowState); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if ((host as Pet)?.PlayerOwner == null) { return; } var pet = (Pet)host; FollowState s; if (state == null) { s = new FollowState(); s.State = F.DontKnowWhere; s.RemainingTime = 1000; } else { s = (FollowState)state; } Status = CycleStatus.NotStarted; var player = host.Owner.GetEntity(pet.PlayerOwner.Id) as Player; if (player == null) { var tile = host.Owner.Map[(int)host.X, (int)host.Y]; if (tile.Region != TileRegion.PetRegion) { if (!(host.Owner is PetYard)) { host.Owner.LeaveWorld(host); Status = CycleStatus.Completed; return; } if (tile.Region != TileRegion.Spawn) { host.Owner.LeaveWorld(host); Status = CycleStatus.Completed; return; } } } Status = CycleStatus.InProgress; switch (s.State) { case F.DontKnowWhere: if (s.RemainingTime > 0) { s.RemainingTime -= time.ElapsedMsDelta; } else { s.State = F.Acquired; } break; case F.Acquired: if (player == null) { s.State = F.DontKnowWhere; s.RemainingTime = 1000; break; } if (s.RemainingTime > 0) { s.RemainingTime -= time.ElapsedMsDelta; } var vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length() > 20) { host.Move(player.X, player.Y); } else if (vect.Length() > 1) { var dist = host.GetSpeed(0.5f) * (time.ElapsedMsDelta / 1000f); if (vect.Length() > 2) { dist = host.GetSpeed(0.7f + ((float)player.Stats[4] / 100)) * (time.ElapsedMsDelta / 1000f); } vect.Normalize(); host.ValidateAndMove(host.X + vect.X * dist, host.Y + vect.Y * dist); } break; } state = s; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { FollowState s; if (state == null) { s = new FollowState(); } else { s = (FollowState)state; } Status = CycleStatus.NotStarted; Player player = host.GetPlayerOwner(); Entity pet = player.Pet; bool hatchling = player.HatchlingPet; bool hatchlingNotification = player.HatchlingNotification; if (hatchling && !hatchlingNotification) { NOTIFICATION _notification = new NOTIFICATION { Color = new ARGB(0xFFFFFF), ObjectId = host.Id, Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"New Pet!\"}}" }; host.Owner.BroadcastMessage(_notification, null); player.HatchlingNotification = true; player.SendInfo("Please, leave vault to activate your pet (HP healing, MP healing, follow and shoot behaviors)."); return; } if (player.Owner == null || pet == null || host == null) { pet.Owner.LeaveWorld(host); return; } Vector2 vect = new Vector2(player.X - pet.X, player.Y - pet.Y); switch (s.State) { case F.DontKnowWhere: if (s.RemainingTime > 0) { s.RemainingTime -= time.ElapsedMsDelta; } else { s.State = F.Acquired; } break; case F.Acquired: if (player == null) { s.State = F.DontKnowWhere; s.RemainingTime = 0; break; } if (s.RemainingTime > 0) { s.RemainingTime -= time.ElapsedMsDelta; } vect = new Vector2(player.X - pet.X, player.Y - pet.Y); if (vect.Length > 1 && vect.Length <= 20) { float dist = host.EntitySpeed(player.Stats[4] / 10, time); if (vect.Length > 2 && vect.Length <= 3.5) { dist *= 1.75f; } else if (vect.Length > 3.5 && vect.Length <= 5) { dist *= 2f; } else if (vect.Length > 5 && vect.Length <= 6) { dist *= 2.25f; } else if (vect.Length > 6 && vect.Length <= 7) { dist *= 2.75f; } else if (vect.Length > 7 && vect.Length <= 10) { dist *= 3f; } else if (vect.Length > 10 && vect.Length <= 20) { dist *= 3.25f; } Status = CycleStatus.InProgress; vect.Normalize(); pet.ValidateAndMove(pet.X + vect.X * dist, pet.Y + vect.Y * dist); pet.UpdateCount++; } break; } state = s; }
void Awake() { followState = new FollowState(this); attackState = new AttackState(this); reviveState = new ReviveState(this); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { FollowState s; if (state == null) s = new FollowState(); else s = (FollowState)state; Status = CycleStatus.NotStarted; Player player = host.GetPlayerOwner(); if (player.Owner == null) { host.Owner.LeaveWorld(host); return; } Vector2 vect; switch (s.State) { case F.DontKnowWhere: if (s.RemainingTime > 0) s.RemainingTime -= time.thisTickTimes; else s.State = F.Acquired; break; case F.Acquired: if (player == null) { s.State = F.DontKnowWhere; s.RemainingTime = 0; break; } if (s.RemainingTime > 0) s.RemainingTime -= time.thisTickTimes; vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length > 20) { host.Move(player.X, player.Y); host.UpdateCount++; } else if (vect.Length > 1) { float dist = host.GetSpeed(1.2f) * (time.thisTickTimes / 1000f); if (vect.Length > 2) dist = host.GetSpeed(1.2f + ((float)player.Stats[4] / 100)) * (time.thisTickTimes / 1000f); else if (vect.Length > 3.5) dist = host.GetSpeed(1.2f + ((float)player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); else if (vect.Length > 5) dist = host.GetSpeed(1.3f + ((float)player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); else if (vect.Length > 6) dist = host.GetSpeed(1.4f + ((float)player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); else if (vect.Length > 7) dist = host.GetSpeed(1.5f + ((float)player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); Status = CycleStatus.InProgress; vect.X -= Random.Next(-2, 2) / 2f; vect.Y -= Random.Next(-2, 2) / 2f; vect.Normalize(); host.ValidateAndMove(host.X + vect.X * dist, host.Y + vect.Y * dist); host.UpdateCount++; } break; } state = s; }
bool HasFollowState(FollowState uiFollowState) { return((_followState & uiFollowState) != 0); }
private static void PrintFollowState(StringBuilder sb, string indention, FollowState followState) { sb.AppendLine(indention + "[FollowState]"); sb.AppendLine(indention + Indention + "[UnkFollowId: " + followState.UnkFollowId + "]"); sb.AppendLine(indention + Indention + "[UnkRange: " + followState.UnkRange + "]"); }
void RemoveFollowState(FollowState uiFollowState) { _followState &= ~uiFollowState; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if ((host as Pet)?.PlayerOwner == null) return; var pet = (Pet)host; FollowState s; if (state == null) s = new FollowState(); else s = (FollowState)state; Status = CycleStatus.NotStarted; var player = host.GetEntity(pet.PlayerOwner.Id) as Player; if (player == null) { var tile = host.Owner.Map[(int)host.X, (int)host.Y].Clone(); if (tile.Region != TileRegion.PetRegion) { if (!(host.Owner is PetYard)) { host.Owner.LeaveWorld(host); return; } if (tile.Region != TileRegion.Spawn) { host.Owner.LeaveWorld(host); return; } } } switch (s.State) { case F.DontKnowWhere: if (s.RemainingTime > 0) s.RemainingTime -= time.thisTickTimes; else s.State = F.Acquired; break; case F.Acquired: if (player == null) { s.State = F.DontKnowWhere; s.RemainingTime = 0; break; } if (s.RemainingTime > 0) s.RemainingTime -= time.thisTickTimes; var vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length > 20) { host.Move(player.X, player.Y); host.UpdateCount++; } else if (vect.Length > 1) { var dist = host.GetSpeed(0.5f) * (time.thisTickTimes / 1000f); if (vect.Length > 2) dist = host.GetSpeed(0.5f + ((float)player.Stats[4] / 100)) * (time.thisTickTimes / 1000f); else if (vect.Length > 3.5) dist = host.GetSpeed(0.5f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); else if (vect.Length > 5) dist = host.GetSpeed(1.0f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); else if (vect.Length > 6) dist = host.GetSpeed(1.35f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); else if (vect.Length > 7) dist = host.GetSpeed(1.5f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); else if (vect.Length > 10) dist = host.GetSpeed(2f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f); Status = CycleStatus.InProgress; vect.Normalize(); host.ValidateAndMove(host.X + vect.X * dist, host.Y + vect.Y * dist); host.UpdateCount++; } break; } state = s; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { FollowState s; if (state == null) s = new FollowState(); else s = (FollowState) state; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return; var player = host.GetNearestEntity(acquireRange, null); Vector2 vect; switch (s.State) { case F.DontKnowWhere: if (player != null && s.RemainingTime <= 0) { s.State = F.Acquired; if (duration > 0) s.RemainingTime = duration; goto case F.Acquired; } if (s.RemainingTime > 0) s.RemainingTime -= time.thisTickTimes; break; case F.Acquired: if (player == null) { s.State = F.DontKnowWhere; s.RemainingTime = 0; break; } if (s.RemainingTime <= 0 && duration > 0) { s.State = F.DontKnowWhere; s.RemainingTime = coolDown.Next(Random); Status = CycleStatus.Completed; break; } if (s.RemainingTime > 0) s.RemainingTime -= time.thisTickTimes; vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length() > range) { Status = CycleStatus.InProgress; vect.X -= Random.Next(-2, 2)/2f; vect.Y -= Random.Next(-2, 2)/2f; vect.Normalize(); float dist = host.GetSpeed(speed)*(time.thisTickTimes/1000f); host.ValidateAndMove(host.X + vect.X*dist, host.Y + vect.Y*dist); host.UpdateCount++; } else { Status = CycleStatus.Completed; s.State = F.Resting; s.RemainingTime = 0; } break; case F.Resting: if (player == null) { s.State = F.DontKnowWhere; if (duration > 0) s.RemainingTime = duration; break; } Status = CycleStatus.Completed; vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length() > range + 1) { s.State = F.Acquired; s.RemainingTime = duration; goto case F.Acquired; } break; } state = s; }
public void Move(float distance) { if (this.state == FollowState.DEAD) { return; } float d = GetTotalDistance(BattleControllor.hero.transform.localPosition, this.transform.localPosition); if (this.state == FollowState.WAIT_FOLLOW) { if (d < this.followIndex * Constance.GRID_GAP) { return; } this.running = true; this.PlayAnimation(); d = GetTotalDistance(BattleControllor.hero.transform.localPosition, this.transform.localPosition); this.state = FollowState.FOLLOW; this.running = true; this.PlayAnimation(); } if (d > this.followIndex * Constance.GRID_GAP + 0.02) { distance += 0.002f; } else if (d < this.followIndex * Constance.GRID_GAP) { distance -= 0.002f; } if (nextPosition.z == -1 && this.paths.Count > 0) { this.currentDirection = FindDirection(); this.model.direction = this.currentDirection; } if (nextPosition.z == -1) { _Move(distance); } else { float toNext = GetToNextPositionDistance(); while (distance > toNext) { _Move(toNext); distance -= toNext; if (this.paths.Count > 0) { this.currentDirection = FindDirection(); this.model.direction = this.currentDirection; } toNext = GetToNextPositionDistance(); if (toNext == 0) { this.nextPosition.z = -1; this.currentDirection = BattleControllor.hero.GetDirection(); this.model.direction = this.currentDirection; break; } } _Move(distance); } if (this.follower != null) { this.follower.Move(distance); } }
private void CmdUpdateState(FollowState state) { this.state = state; }
/// <summary> /// Will search for the rigidbody inside the spirit object /// </summary> private void Start() { this.rb = this.GetComponent <Rigidbody2D>(); this.state = FollowState.Staying; }
private bool IsFollowStateValid(FollowState followState, int id) { int?userId = HttpContext.Session.GetInt32(SessionHolder.SessionUserId); return(userId != null && releaseLogic.ValidateFollowState(followState, id, userId.GetValueOrDefault())); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { FollowState s; if (state == null) { s = new FollowState(); } else { s = (FollowState)state; } Status = CycleStatus.NotStarted; Player player = host.GetPlayerOwner(); if (player.Owner == null) { host.Owner.LeaveWorld(host); return; } switch (s.State) { case F.DontKnowWhere: if (s.RemainingTime > 0) { s.RemainingTime -= time.ElapsedMsDelta; } else { s.State = F.Acquired; } break; case F.Acquired: if (player == null) { s.State = F.DontKnowWhere; s.RemainingTime = 1000; break; } if (s.RemainingTime > 0) { s.RemainingTime -= time.ElapsedMsDelta; } var vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length() > 20) { host.Move(player.X, player.Y); } else if (vect.Length() > 1) { var dist = host.GetSpeed(0.5f) * (time.ElapsedMsDelta / 1000f); if (vect.Length() > 2) { dist = host.GetSpeed(0.7f + ((float)player.Stats[4] / 100)) * (time.ElapsedMsDelta / 1000f); } vect.Normalize(); host.ValidateAndMove(host.X + vect.X * dist, host.Y + vect.Y * dist); } break; } state = s; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { FollowState s; if (state == null) { s = new FollowState(); } else { s = (FollowState)state; } Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) { return; } Entity en = host.GetNearestEntity(acquireRange, null); if (!(en is Player)) { return; //It returned me a enemy, thats why we check for a player here } Player player = en as Player; Vector2 vect; switch (s.State) { case F.DontKnowWhere: if (player != null && s.RemainingTime <= 0) { s.State = F.Acquired; if (duration > 0) { s.RemainingTime = duration; } goto case F.Acquired; } if (s.RemainingTime > 0) { s.RemainingTime -= time.thisTickTimes; } break; case F.Acquired: if (player == null) { s.State = F.DontKnowWhere; s.RemainingTime = 0; break; } if (s.RemainingTime <= 0 && duration > 0) { s.State = F.DontKnowWhere; s.RemainingTime = coolDown.Next(Random); Status = CycleStatus.Completed; break; } if (s.RemainingTime > 0) { s.RemainingTime -= time.thisTickTimes; } vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length > range) { Status = CycleStatus.InProgress; vect.X -= Random.Next(-2, 2) / 2f; vect.Y -= Random.Next(-2, 2) / 2f; vect.Normalize(); float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f); host.ValidateAndMove(host.X + vect.X * dist, host.Y + vect.Y * dist); host.UpdateCount++; } else { Status = CycleStatus.Completed; s.State = F.Resting; s.RemainingTime = 0; } break; case F.Resting: if (player == null) { s.State = F.DontKnowWhere; if (duration > 0) { s.RemainingTime = duration; } break; } Status = CycleStatus.Completed; vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length > range + 1) { s.State = F.Acquired; s.RemainingTime = duration; goto case F.Acquired; } break; } state = s; }
void AddFollowState(FollowState uiFollowState) { m_uiFollowState |= uiFollowState; }