コード例 #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;
    }
コード例 #2
0
    public void SetEntity(Entity entity)
    {
        EventManager.Instance.AddListener(this);

        Entity           = entity;
        AnimationManager = GetComponent <LoadedEntityAnimationManager>();

        DistToGround       = 0;
        transform.position = new Vector3(entity.Position.x, transform.position.y, entity.Position.z);
        RigidBody          = GetComponent <Rigidbody>();
        Collider           = GetComponent <Collider>();


        GameObject entityhealthBar = Instantiate(ResourceManager.GetEntityGameObject("healthbar"));

        entityhealthBar.transform.parent        = transform;
        entityhealthBar.transform.localPosition = new Vector3(0, 2, 0);

        EntityHealthBar = entityhealthBar.GetComponentInChildren <EntityHealthBar>();

        // AnimControll = GetComponentInChildren<AnimatorController>();
    }