예제 #1
0
    void Update()
    {
        // Debug.Log(controller.collisions.below);

        if (bubbleCount >= bubbleRndEmit)
        {
            be.Emit(Random.Range(1, 2), 40f, Vector2.up);
            SetupNextBubbleEmit();
        }
        else
        {
            bubbleCount += Time.deltaTime;
        }

        st = new status().Init();

        // if(Input.GetKeyDown(KeyCode.Q)) hc.Kill();
        // gameObject.GetComponent<BubbleEmitter>().Emit(10, 50f, new Vector2(0.5f, 0.5f));

        if (hc.isDead)
        {
            st.Dead();
            an.Play("player_death");
            SFXHelper.PlayEffect(SFXs.Death);
            if (coroutine == null)
            {
                coroutine = StartCoroutine(ResetPlayerAfterSeconds(secondsToRespawn));
            }
        }

        //Movement
        var dir = HandleInput();

        HandleMovement();
        OrganizeInventory();

        //Animation
        if (!hc.isDead)
        {
            Animate();
        }

        //Loop
        currentOxygen -= Time.deltaTime;

        if (currentOxygen <= lastBreath)
        {
            //TODO: implement vision loss

            if (currentOxygen <= 0)
            {
                hc.Kill();
            }
        }

        //Open Inventory
        if (Input.GetKeyDown(KeyCode.E))
        {
            openInventory = !openInventory;
            if (Time.timeScale == 1.0f)
            {
                Time.timeScale = 0;
                inventoryManager.SetAvailableItems(GameObject.Find("ProximityRadius").GetComponent <ProximityFinder>().nearPickables);
                inventoryManager.inventoryPanel.gameObject.SetActive(openInventory);
            }
            else
            {
                Time.timeScale = 1.0F;
                inventoryManager.inventoryPanel.gameObject.SetActive(openInventory);
            }
        }

        //update oxygen panel
        oxyPanel.UpdateOxygenBar(currentOxygen / maxOxygen);
    }