public override void OnEnter(object args = null) { Kid k = npc as Kid; k.PlayWalkAnimation(); if (args is Player player) { _followedPlayer = player; // First add the kid as a new follower. _followedPlayer.AddFollower(npc as Kid); // Promo guy count should not exceed the follower kid count. if (!_isPromoGuySpawnedForThisKid) { _isPromoGuySpawnedForThisKid = true; _promotionGuyManager.SpawnPromotionGuy(); } } else { _aiManager.ChangeState(npc, typeof(Kid_Idle)); } }
public override void OnEnter(object args = null) { npc.followerKid = args as Kid; _aiManager.ChangeState(npc.followerKid, typeof(Kid_FollowPromotionGuy), npc); CalculateFleePath(); }
public override void OnUpdate() { if (!_flyStarted) { _freezeTimer -= Time.deltaTime; if (_freezeTimer <= 0) { _flyStarted = true; flyDirection = (npc.transform.position - _entityManager.players[0].transform.position).normalized; flyNormalDirection = new Vector3(flyDirection.y, -flyDirection.x, 0); // normal vector of flying direction vector npc.rigidbody2D.AddForce(flyDirection * flyingSpeed + flyNormalDirection * flyHeight / 3, ForceMode2D.Impulse); // ServiceLocator.Current.Get<AudioManager>().PlayHitSFX(); } } if (_flyStarted) { _flyTimer -= Time.deltaTime; if (_flyTimer <= 0) { npc.rigidbody2D.velocity = Vector2.zero; npc.aiPath.rvoDensityBehavior.enabled = true; if (npc.stunned) { npc.ResetAnimatorTriggers(); npc.Animator.SetTrigger("Idle"); _aiManager.ChangeState(npc, typeof(MallWorker_Idle)); } } else { npc.rigidbody2D.AddForce(-flyNormalDirection * flyHeightCounter, ForceMode2D.Force); flyHeightCounter -= _timeMultiplier * Time.deltaTime; if (flyHeightCounter <= 0) { flyHeightCounter = 0; } npc.ResetAnimatorTriggers(); npc.stunned = true; // randomly choose to play flying animation flyingAnimationType = Random.Range(1, 100); if (flyingAnimationType % 2 == 0) { npc.Animator.SetTrigger("Fly1"); } else { npc.Animator.SetTrigger("Fly2"); } } } }
public override void OnUpdate() { if (npc.rigidbody2D.velocity.magnitude < stillSpeed) { npc.rigidbody2D.velocity = Vector2.zero; npc.aiPath.rvoDensityBehavior.enabled = true; _aiManager.ChangeState(npc, typeof(Consumer_MoveToTarget)); } }
public void SpawnPromotionGuy() { // Get random spawn point. Transform randomSpawn = teleportPoints[Random.Range(0, teleportPoints.Count)]; // Get promotion guy from prison. PromotionGuy promotionGuy = _promotionGuysInPrison[0]; _promotionGuysInPrison.Remove(promotionGuy); // Teleport promotion guy to wild! _promotionGuysInWild.Add(promotionGuy); // Teleport! promotionGuy.aiPath.Teleport(randomSpawn.transform.position); // Start chasing a kid! _aiManager.ChangeState(promotionGuy, typeof(PromotionGuy_ChaseKid)); }
public override void OnUpdate() { _standUpTimer -= Time.deltaTime; if (_standUpTimer <= 0) { npc.stunned = false; float dst = Vector2.Distance(npc.transform.position, npc.spawnPosition); if (dst > _walkBackToOriginalPositionDst) { _aiManager.ChangeState(npc, typeof(NormalCustomer_WalkToSpawnPosition)); } } }
public override void OnEnter(object args = null) { if (args is Player player) { _followedPlayer = player; npc.StartFollowing(_followedPlayer.transform); // First add the kid as a new follower. // _followedPlayer.AddFollower(npc); } else { _aiManager.ChangeState(npc, typeof(MallWorker_Idle)); } }
private void LookForPlayer() { int layerMask = 1 << LayerMask.NameToLayer("Player"); Vector2 mallWorkerPosition = npc.transform.position; int foundPlayerCount = Physics2D.OverlapBoxNonAlloc(mallWorkerPosition, Vector2.one * 16.0f, 0.0f, foundPlayer, layerMask); if (foundPlayerCount > 0) { for (int i = 0; i < foundPlayerCount; i++) { if (foundPlayer[i].TryGetComponent(out Player player)) { _aiManager.ChangeState(npc, typeof(MallWorker_FollowPlayer), player); } } } }
private void LookForKid() { int layerMask = 1 << LayerMask.NameToLayer("Kid"); Vector2 promotionGuyPosition = npc.transform.position; int foundKidCount = Physics2D.OverlapBoxNonAlloc(promotionGuyPosition, Vector2.one * 2.5f, 0.0f, foundKid, layerMask); if (foundKidCount > 0) { for (int i = 0; i < foundKidCount; i++) { if (foundKid[i].TryGetComponent(out Kid kid)) { // If we found the kid we're following! if (kid == _followedKid) { _followedPlayer.RemoveFollower(kid); npc.StopFollowing(); _aiManager.ChangeState(npc, typeof(PromotionGuy_RunAwayWithKid), kid); } } } } }
public override void OnUpdate() { _aiManager.ChangeState(npc, typeof(Consumer_MoveToTarget)); }