예제 #1
0
    // ---

    void Start()
    {
        rigidbody      = GetComponent <Rigidbody>();
        collider       = GetComponent <CapsuleCollider>();
        animator       = GetComponent <Animator>();
        liver          = GetComponent <Liver>();
        trigger        = GetComponentInChildren <Trigger>();
        trigger.OnStay = OnChildTriggerStay;
        camera         = Camera.main.transform;
        startGravity   = Gravity;

        liver.Health = Game.PlayerHealth ?? liver.Health;
        potionCount  = Game.PotionCount ?? potionCount;

        if (SceneManager.GetActiveScene().name != "OutsideCave")
        {
            var ui = Instantiate(Prefabs.Get("PlayerUi"), GameObject.FindGameObjectWithTag("Canvas").transform);

            liver.SetUi(GameObject.FindGameObjectWithTag("PlayerUiPanel").GetComponent <RectTransform>());
            potionCountUi = GameObject.FindGameObjectWithTag("PotionUiText").GetComponent <TextMeshProUGUI>();
        }

        start  = NormalStart;
        update = NormalUpdate;
        exit   = NormalExit;

        if (Game.spawnPosition != null)
        {
            transform.position = Game.spawnPosition.Value;
            Game.spawnPosition = null;
        }
    }
예제 #2
0
    void Start()
    {
        liver     = GetComponent <Liver>();
        rigidbody = GetComponent <Rigidbody>();
        animator  = GetComponentInChildren <Animator>();

        healthUi = Instantiate(Prefabs.Get("EnemyHP"), GameObject.FindGameObjectWithTag("Canvas").transform);
        healthUi.GetComponent <UiFollow>().target = hpTarget.transform;
        healthUi.SetActive(false);
        liver.SetUi(healthUi.GetComponentInChildren <HpBar>().GetComponent <RectTransform>());
    }