Esempio n. 1
0
	void OnEntranceTriggered (RoomEntranceTrigger trigger) {
		Debug.LogError ("PLAYER HIT");
		//load next room
		// LoadNextRoom ();
		//if not gallery or beach, trigger room activation
		//if indoors, unlock previous room

	}
Esempio n. 2
0
 void OnEntranceTriggered(RoomEntranceTrigger trigger)
 {
     Debug.LogError ("PLAYER HIT");
     //load next room
     // LoadNextRoom ();
     //if not gallery or beach, trigger room activation
     //if indoors, unlock previous room
 }
Esempio n. 3
0
    public void Initialize(MyGameManager _game, MyGameRoom _prevRoom = null, bool _finalRoom = false)
    {
        gameManager = _game;
        prevRoom    = _prevRoom;
        roomPos     = transform.position;
        baseRoom    = transform;
        trigger     = baseRoom.gameObject.AddComponent <RoomEntranceTrigger> ();
        //previous room cleanup
        roomInitialized = false;

        // Texture tex = gameManager.floorTexs[UnityEngine.Random.Range (0, gameManager.floorTexs.Length)];
        for (int i = 0; i < groundRenderers.Length; i++)
        {
            groundRenderers[i].material.SetTexture("_MainTex", MyGameManager.state.wallTex);
        }

        bool roofless = (MyGameManager.state.roomTypeData.ceilingType == RoomCeilingType.None || MyGameManager.state.roomTypeData.ceilingType == RoomCeilingType.Open);

        //generate floor
        if (MyGameManager.state.roomTypeData.floorType == RoomFloorType.Dome)
        {
            AttachObject(gameManager.floorDomePool.SpawnFromPool());
        }
        else if (MyGameManager.state.roomTypeData.floorType == RoomFloorType.Spike)
        {
            AttachObject(gameManager.floorSpikePool.SpawnFromPool());
        }

        //calculate doors - generate walkway and attached game rooms for each door
        int doorCountAdj = (prevRoom != null) ? 1 : 0;
        int doorCount    = (_finalRoom) ?  doorCountAdj : 1 + doorCountAdj;

        if (!roofless)
        {
            if (MyGameManager.state.roomTypeData.ceilingType == RoomCeilingType.Spike)
            {
                AttachObject(gameManager.ceilingSpikePool.SpawnFromPool(), true);
            }
            else if (MyGameManager.state.roomTypeData.ceilingType == RoomCeilingType.Dome)
            {
                AttachObject(gameManager.ceilingDomePool.SpawnFromPool(), true);
            }
            else
            {
                AttachObject(gameManager.ceilingClosedPool.SpawnFromPool(), true);
            }

            for (int i = 0; i < doorCount; i++)
            {
                doors.Add(_game.doorPool.SpawnFromPool(roomPos));
            }

            //generate walls
            int wallCount = 5 - doorCount;
            for (int i = 0; i < wallCount; i++)
            {
                walls.Add(_game.wallPool.SpawnFromPool(roomPos));
            }
        }
        //set wall and door orientations
        int wallIndex = 0;
        int doorIndex = 0;
        int rotation  = 0;
        int targ      = UnityEngine.Random.Range(2, 4);

        for (int i = 0; i < 5; i++)
        {
            if (doorIndex < doorCount && (i == 0 || i == targ))                         //theres a door available and its an appropriate slot
            {
                if (!_finalRoom && (i != 0 || prevRoom == null))
                {
                    nextRoomIndex.Add(i);
                }
                if (!roofless)
                {
                    doors[doorIndex].parent      = attachmentAnchor;
                    doors[doorIndex].eulerAngles = new Vector3(0, doors[doorIndex].parent.eulerAngles.y + rotation, 0);
                    Renderer[] rend = doors[doorIndex].GetComponentsInChildren <Renderer> ();
                    // if (rend != null) {
                    for (int j = 0; j < rend.Length; j++)
                    {
                        rend[j].material.SetTexture("_MainTex", MyGameManager.state.wallTex);
                    }
                }
                doorIndex++;
            }
            else
            {
                if (!roofless)
                {
                    walls[wallIndex].parent      = attachmentAnchor;
                    walls[wallIndex].eulerAngles = new Vector3(0, walls[wallIndex].parent.eulerAngles.y + rotation, 0);
                    Renderer[] rend = walls[wallIndex].GetComponentsInChildren <Renderer> ();
                    // if (rend != null) {
                    for (int j = 0; j < rend.Length; j++)
                    {
                        rend[j].material.SetTexture("_MainTex", MyGameManager.state.wallTex);
                    }
                }
                wallIndex++;
            }
            rotation += wallAngle;
        }
        if (prevRoom == null)
        {
            // Transform decal = gameManager.decalPool[UnityEngine.Random.Range (0, gameManager.decalPool.Count)].SpawnFromPool();
            // decal.parent = attachmentAnchor;
            // decal.localPosition = new Vector3 (0, 2, 0);
            // AttachObject (gameManager.lightPool.SpawnFromPool());
            AttachObject(gameManager.narrativePool.SpawnFromPool());
        }
        else if (_finalRoom)
        {
            // Transform decal = gameManager.decalPool[UnityEngine.Random.Range (0, gameManager.decalPool.Count)].SpawnFromPool();
            AttachObject(gameManager.portalPool.SpawnFromPool());
            // decal.parent = attachmentAnchor;
            // decal.localPosition = new Vector3 (0, 2, 0);
        }
        else
        {
            if (roofless)
            {
                AttachObject(gameManager.torchPool.SpawnFromPool());
                // Transform decal = gameManager.decalPool[UnityEngine.Random.Range (0, gameManager.decalPool.Count)].SpawnFromPool();
                // decal.parent = attachmentAnchor;
                // decal.localPosition = new Vector3 (0, 2, 0);
            }
            else
            {
                AttachObject(gameManager.lightPool.SpawnFromPool());
            }


            int roomType = UnityEngine.Random.Range(0, 5);
            if (roomType >= 4)
            {
            }
            else if (roomType >= 3)
            {
            }
        }
        if (roofless)
        {
            for (int j = 0; j < columnRenderers.Length; j++)
            {
                columnRenderers[j].gameObject.SetActive(false);
            }
        }
        else
        {
            //Column Customization
            for (int j = 0; j < columnRenderers.Length; j++)
            {
                columnRenderers[j].gameObject.SetActive(true);
                columnRenderers[j].material = MyGameManager.state.columnMat;
            }
        }


        // transform.name += gameManager.rooms.Count;

        if (prevRoom != null)
        {
            transform.transform.LookAt(prevRoom.transform, Vector3.up);

            Vector3 offset = new Vector3(0, -18, 0);
            transform.eulerAngles = transform.transform.eulerAngles + offset;
        }
        InitializeConnections();
    }
Esempio n. 4
0
    public void Initialize(MyGameManager _game, MyGameRoom _prevRoom = null, bool _finalRoom = false)
    {
        gameManager = _game;
            prevRoom = _prevRoom;
            roomPos = transform.position;
            baseRoom = transform;
            trigger = baseRoom.gameObject.AddComponent<RoomEntranceTrigger> ();
            //previous room cleanup
            roomInitialized = false;

            // Texture tex = gameManager.floorTexs[UnityEngine.Random.Range (0, gameManager.floorTexs.Length)];
            for (int i = 0; i < groundRenderers.Length; i++) {
                groundRenderers[i].material.SetTexture ("_MainTex", MyGameManager.state.wallTex);
            }

            bool roofless = (MyGameManager.state.roomTypeData.ceilingType == RoomCeilingType.None || MyGameManager.state.roomTypeData.ceilingType == RoomCeilingType.Open);
            //generate floor
            if (MyGameManager.state.roomTypeData.floorType == RoomFloorType.Dome) {
                AttachObject (gameManager.floorDomePool.SpawnFromPool ());
            } else if (MyGameManager.state.roomTypeData.floorType == RoomFloorType.Spike) {
                AttachObject (gameManager.floorSpikePool.SpawnFromPool ());
            }

            //calculate doors - generate walkway and attached game rooms for each door
            int doorCountAdj = (prevRoom != null) ? 1 : 0;
            int doorCount = (_finalRoom) ?  doorCountAdj : 1 + doorCountAdj;

            if (!roofless) {
                if (MyGameManager.state.roomTypeData.ceilingType == RoomCeilingType.Spike) {
                    AttachObject (gameManager.ceilingSpikePool.SpawnFromPool (), true);
                } else if (MyGameManager.state.roomTypeData.ceilingType == RoomCeilingType.Dome) {
                    AttachObject (gameManager.ceilingDomePool.SpawnFromPool (), true);
                } else {
                    AttachObject (gameManager.ceilingClosedPool.SpawnFromPool (), true);
                }

                for (int i = 0; i < doorCount; i++) {
                    doors.Add (_game.doorPool.SpawnFromPool (roomPos));
                }

                //generate walls
                int wallCount = 5 - doorCount;
                for (int i = 0; i < wallCount; i++) {
                    walls.Add (_game.wallPool.SpawnFromPool (roomPos));
                }
            }
            //set wall and door orientations
            int wallIndex = 0;
            int doorIndex = 0;
            int rotation = 0;
            int targ = UnityEngine.Random.Range (2,4);

            for (int i = 0; i < 5; i++) {
                if (doorIndex < doorCount && (i == 0 || i == targ)) {	//theres a door available and its an appropriate slot
                    if (!_finalRoom && (i != 0 || prevRoom == null)) {
                        nextRoomIndex.Add (i);
                    }
                    if (!roofless) {
                        doors[doorIndex].parent = attachmentAnchor;
                        doors[doorIndex].eulerAngles = new Vector3 (0, doors[doorIndex].parent.eulerAngles.y + rotation, 0);
                        Renderer[] rend = doors[doorIndex].GetComponentsInChildren<Renderer> ();
                        // if (rend != null) {
                        for (int j = 0; j < rend.Length; j++) {
                            rend[j].material.SetTexture ("_MainTex", MyGameManager.state.wallTex);
                        }
                    }
                    doorIndex++;
                } else {
                    if (!roofless) {
                        walls[wallIndex].parent = attachmentAnchor;
                        walls[wallIndex].eulerAngles = new Vector3 (0, walls[wallIndex].parent.eulerAngles.y + rotation, 0);
                        Renderer[] rend = walls[wallIndex].GetComponentsInChildren<Renderer> ();
                        // if (rend != null) {
                        for (int j = 0; j < rend.Length; j++) {
                            rend[j].material.SetTexture ("_MainTex", MyGameManager.state.wallTex);
                        }
                    }
                    wallIndex++;
                }
                rotation += wallAngle;
            }
            if (prevRoom == null) {
                // Transform decal = gameManager.decalPool[UnityEngine.Random.Range (0, gameManager.decalPool.Count)].SpawnFromPool();
                // decal.parent = attachmentAnchor;
                // decal.localPosition = new Vector3 (0, 2, 0);
                // AttachObject (gameManager.lightPool.SpawnFromPool());
                AttachObject (gameManager.narrativePool.SpawnFromPool());

            } else if (_finalRoom) {
                // Transform decal = gameManager.decalPool[UnityEngine.Random.Range (0, gameManager.decalPool.Count)].SpawnFromPool();
                AttachObject (gameManager.portalPool.SpawnFromPool());
                // decal.parent = attachmentAnchor;
                // decal.localPosition = new Vector3 (0, 2, 0);

            } else {
                if (roofless) {
                    AttachObject (gameManager.torchPool.SpawnFromPool());
                    // Transform decal = gameManager.decalPool[UnityEngine.Random.Range (0, gameManager.decalPool.Count)].SpawnFromPool();
                    // decal.parent = attachmentAnchor;
                    // decal.localPosition = new Vector3 (0, 2, 0);
                } else {
                    AttachObject (gameManager.lightPool.SpawnFromPool());
                }

                int roomType = UnityEngine.Random.Range (0, 5);
                if (roomType >= 4) {

                } else if (roomType >= 3) {

                }
            }
            if (roofless) {
                for (int j = 0; j < columnRenderers.Length; j++) {
                    columnRenderers[j].gameObject.SetActive (false);
                }
            } else {
            //Column Customization
                for (int j = 0; j < columnRenderers.Length; j++) {
                    columnRenderers[j].gameObject.SetActive (true);
                    columnRenderers[j].material = MyGameManager.state.columnMat;
                }
            }

            // transform.name += gameManager.rooms.Count;

            if (prevRoom != null) {
                transform.transform.LookAt (prevRoom.transform, Vector3.up);

                Vector3 offset = new Vector3 (0, -18, 0);
                transform.eulerAngles = transform.transform.eulerAngles + offset;
            }
            InitializeConnections ();
    }