Ejemplo n.º 1
0
    void Start()
    {
        simplifiedPos = new Vector2Int((int)transform.position.x, (int)transform.position.y);
        GameObject roomControllerObject = GameObject.FindGameObjectWithTag("Rooms");

        rController             = roomControllerObject.GetComponent <roomController>();
        transformRoomController = roomControllerObject.GetComponent <Transform>();
        Invoke("spawnRooms", 0.5f);
    }
Ejemplo n.º 2
0
    private void Start()
    {
        BGM = BGMGO.GetComponent <AudioSource>();
        cameraController = cameraControllerGO.GetComponent <cameraController>();
        player           = playerGO.GetComponent <playerCharacter>();
        roomGO           = Instantiate(roomGO);
        room             = roomGO.GetComponent <roomController>();
        BGM.Play();
        alive = true;

        playerGO.transform.localPosition = new Vector3(room.initialPositionX, room.initialPositionY, playerGO.transform.localPosition.z);
        getNotifiables();
        OrderNotifiables();
    }
Ejemplo n.º 3
0
 public void Action(GameObject clickedObject)
 {
     if (build)
     {
         gridCell       gridCell       = clickedObject.GetComponent <gridCell>();
         roomController roomController = clickedObject.GetComponent <roomController>();
         if (gridCell != null)
         {
             if (thingToBuild != null)
             {
                 gridCell.buildGameObject(thingToBuild);
             }
         }
         else if (roomController != null)
         {
             roomController.buildRoom(roomToBuild.prefab);
         }
     }
     else
     {
         Destroy(clickedObject.gameObject);
     }
 }
Ejemplo n.º 4
0
    void Start()
    {
        usableHeight = topLeft.y - bottomRight.y + 1;
        usableWidth  = bottomRight.x - topLeft.x + 1;

        rController = GameObject.FindGameObjectWithTag("Rooms").GetComponent <roomController>();

        if (!isStartingRoom)
        {
            topLeft.x     += (int)transform.position.x; //se ajusta a la x de la room adecuada
            topLeft.y     += (int)transform.position.y; //se ajusta a la y de la room adecuada
            bottomRight.x += (int)transform.position.x; //se ajusta a la x de la room adecuada
            bottomRight.y += (int)transform.position.y; //se ajusta a la y de la room adecuada

            //se añaden posiciones inutilizables
            //rController.usedCells.Add(new Vector2Int((int)transform.position.x, (int)transform.position.y));

            rController.usedCells.Add(new Vector2Int((int)transform.position.x + 10, (int)transform.position.y - 2));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x + 10, (int)transform.position.y - 1));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x + 10, (int)transform.position.y));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x + 10, (int)transform.position.y + 1));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x + 9, (int)transform.position.y - 2));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x + 9, (int)transform.position.y - 1));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x + 9, (int)transform.position.y));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x + 9, (int)transform.position.y + 1));

            rController.usedCells.Add(new Vector2Int((int)transform.position.x - 10, (int)transform.position.y - 2));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x - 10, (int)transform.position.y - 1));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x - 10, (int)transform.position.y));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x - 10, (int)transform.position.y + 1));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x - 9, (int)transform.position.y - 2));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x - 9, (int)transform.position.y - 1));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x - 9, (int)transform.position.y));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x - 9, (int)transform.position.y + 1));

            rController.usedCells.Add(new Vector2Int((int)transform.position.x - 1, (int)transform.position.y - 6));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x, (int)transform.position.y - 6));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x + 1, (int)transform.position.y - 6));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x - 1, (int)transform.position.y - 5));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x, (int)transform.position.y - 5));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x + 1, (int)transform.position.y - 5));

            rController.usedCells.Add(new Vector2Int((int)transform.position.x - 1, (int)transform.position.y + 2));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x, (int)transform.position.y + 2));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x + 1, (int)transform.position.y + 2));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x - 1, (int)transform.position.y + 3));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x, (int)transform.position.y + 3));
            rController.usedCells.Add(new Vector2Int((int)transform.position.x + 1, (int)transform.position.y + 3));

            if (rController.currentRooms >= rController.maxRooms)
            {
                rController.usedCells.Add(new Vector2Int((int)transform.position.x, (int)transform.position.y));
                rController.usedCells.Add(new Vector2Int((int)transform.position.x + 1, (int)transform.position.y));
                rController.usedCells.Add(new Vector2Int((int)transform.position.x - 1, (int)transform.position.y));
                rController.usedCells.Add(new Vector2Int((int)transform.position.x, (int)transform.position.y + 1));
                rController.usedCells.Add(new Vector2Int((int)transform.position.x + 1, (int)transform.position.y + 1));
                rController.usedCells.Add(new Vector2Int((int)transform.position.x - 1, (int)transform.position.y + 1));
                rController.usedCells.Add(new Vector2Int((int)transform.position.x, (int)transform.position.y - 1));
                rController.usedCells.Add(new Vector2Int((int)transform.position.x + 1, (int)transform.position.y - 1));
                rController.usedCells.Add(new Vector2Int((int)transform.position.x - 1, (int)transform.position.y - 1));
            }

            if (Random.Range(0.0f, 1.0f) < rController.centralChance)
            {
                initializeCentralElement(rController.centralElemList[Random.Range(0, rController.centralElemList.Count)]);
            }

            for (int i = 0; i < rController.elementList.Count; i++)
            {
                int amount = Random.Range(rController.elementNumberMean[i] - rController.elementNumberVariance[i], rController.elementNumberMean[i] + rController.elementNumberVariance[i]);
                initializeElement(rController.elementList[i], amount);
            }
        }
    }
Ejemplo n.º 5
0
    public void edgeReached(CustomEnums.directions direction)
    {
        GameObject nextRoom = room.getNextRoom(direction);

        if (nextRoom != null && !changingRoom)
        {
            //PREPARATION FOR THE ANIMATION
            float xOffset            = 0;
            float yOffset            = 0;
            float animationMovementX = 0;
            float animationMovementY = 0;
            if (direction == CustomEnums.directions.right)
            {
                xOffset            = 36.25f;
                animationMovementX = -player.transform.localPosition.x * 2 + 0.25f;
            }
            else if (direction == CustomEnums.directions.left)
            {
                xOffset            = -36.25f;
                animationMovementX = -player.transform.localPosition.x * 2 - 0.25f;
            }
            else if (direction == CustomEnums.directions.up)
            {
                yOffset            = 20.25f;
                animationMovementY = -player.transform.localPosition.y * 2 + 1f;
            }
            else
            {
                yOffset            = -20.25f;
                animationMovementY = -player.transform.localPosition.y * 2 - 2f;
            }


            //CREO HABITACION
            changingRoom = true;
            GameObject nextRoomInstance = Instantiate(nextRoom);
            nextRoomInstance.transform.position = new Vector3(transform.position.x + xOffset, transform.position.y + yOffset, transform.position.z);

            //ACTUALIZO LOS NOTIFIERS
            updateNotifiableState(false); //desactivo los notifiers antiguos
            getNotifiables();
            OrderNotifiables();
            initializeNotifiers(currentColor == SceneColor.red);

            //ANIMACION DEL JUGADOR
            player.modifyCollisions(false);
            moveSmoothly moveSmoothlyPlayer = player.GetComponent <moveSmoothly>();
            moveSmoothlyPlayer.moveObjectiveX   = animationMovementX;
            moveSmoothlyPlayer.moveObjectiveY   = animationMovementY;
            moveSmoothlyPlayer.animationSeconds = 1;
            moveSmoothlyPlayer.UpdatePath();
            moveSmoothlyPlayer.move();

            //ANIMACION CAMARA
            cameraController.move(xOffset, yOffset, 1);
            StartCoroutine(givePlayerControl(roomGO));

            roomGO = nextRoomInstance;
            room   = roomGO.GetComponent <roomController>();
        }
    }