public void SetEntity(Entity entity) { LookType = LookType.none; EventManager.Instance.AddListener(this); Entity = entity; AnimationManager = GetComponent <LoadedEntityAnimationManager>(); transform.position = new Vector3(entity.Position.x, transform.position.y, entity.Position.z); RigidBody = GetComponent <Rigidbody>(); Collider = GetComponent <CapsuleCollider>(); //Initiate the health bar for this entity GameObject entityhealthBar = Instantiate(ResourceManager.GetEntityGameObject("healthbar")); entityhealthBar.transform.parent = transform; entityhealthBar.transform.localPosition = new Vector3(0, 2, 0); EntityHealthBar = entityhealthBar.GetComponentInChildren <EntityHealthBar>(); DETAILS = (entity is NPC) ? (entity as NPC).EntityRelationshipManager.Personality.ToString() : ""; GROUND_LAYER_MASK = LayerMask.GetMask("Ground"); if (!(entity is Player)) { IsPlayer = false; LEPathFinder = gameObject.AddComponent <LEPathFinder>(); // Destroy(gameObject.GetComponent<Rigidbody>()); GameObject speechBubble = Instantiate(ResourceManager.GetEntityGameObject("speechbubble")); speechBubble.transform.SetParent(transform); speechBubble.transform.localPosition = Vector3.zero; SpeechBubble = speechBubble.GetComponent <EntitySpeechBubble>(); //SpeechBubble.SetText("this is a test", 5); } else { IsPlayer = true; } float speed = IsRunning ? Entity.MovementData.RunSpeed : Entity.MovementData.WalkSpeed; LEPathFinder?.SetSpeed(speed); LastTickPosition = entity.Position; }
/// <summary> /// Sets if the entity should currently be running or not /// </summary> /// <param name="running"></param> public void SetRunning(bool running) { IsIdle = false; if (IsPlayer) { } else { float speed = running ? Entity.MovementData.RunSpeed : Entity.MovementData.WalkSpeed; LEPathFinder?.SetSpeed(speed); AnimationManager.SetSpeedPercentage(1); } IsRunning = running; }