Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (bossUnit != null)
        {
            bossCanvas.GetComponentInChildren <Slider>().value = (bossUnit.currentHP / (float)bossUnit.maxHealth());
        }

        forceResetTimer -= Time.deltaTime;

        if (forceResetTimer <= 0f)
        {
            forceReset();
            forceResetTimer = 15f;
        }

        int roomX = (int)((p.transform.position.x + ROOM_OFFSET_X) / ROOM_SIZE_X);
        int roomY = (int)((p.transform.position.y + ROOM_OFFSET_Y) / ROOM_SIZE_Y);

        if (roomX != currRoomX || roomY != currRoomY)
        {
            forceResetTimer = 15f;
            FindObjectOfType <EnvSounds>().playRoomTransitionSound();
            FindObjectOfType <DungeonManager>().tryOpenBossDoor(roomX, roomY);



            resetTimer();
            Vector2 entry = new Vector2(roomX - currRoomX, roomY - currRoomY);

            if (roomY == 3)
            {
                startBossFight();
            }


            Camera.main.GetComponent <CameraFollow>().target = new Vector3((roomX * ROOM_SIZE_X), (roomY * ROOM_SIZE_Y), -8.5f);
            currRoomX = roomX;
            currRoomY = roomY;

            // player boost!
            FindObjectOfType <Player>().transform.position = FindObjectOfType <Player>().transform.position + 0.05f * (new Vector3(roomCenter().x, roomCenter().y, 0) - FindObjectOfType <Player>().transform.position);

            setDoor(entry);

            pm.Reset(p.flushMoves(), new Vector2(roomX * ROOM_SIZE_X, roomY * ROOM_SIZE_Y));

            playerRoomStartLoc = p.transform.position;
            // For the start loc, subtract a room size.
        }
    }