Ejemplo n.º 1
0
    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;
    }
Ejemplo n.º 2
0
 public void QueueText(string text)
 {
     if (SpeechBubble == null)
     {
         SpeechBubble = SpeechBubblePool.Instance.GetObjectFromPool();
     }
     SpeechBubble.QueueText(text);
 }
Ejemplo n.º 3
0
 public void Reset()
 {
     if (SpeechBubble != null)
     {
         SpeechBubble.OnFinishedPlaying -= PlayingAction;
         SpeechBubble.OnFinishedTalking -= TalkingAction;
     }
     SpeechBubble = null;
 }
Ejemplo n.º 4
0
 private void PlayingAction()
 {
     SpeechBubble.OnFinishedPlaying -= PlayingAction;
     SpeechBubble.OnFinishedTalking -= TalkingAction;
     if (OnFinishedPlaying != null)
     {
         OnFinishedPlaying();
     }
     SpeechBubble = null;
 }