Пример #1
0
    /*Get all the enabled colliders in the current room, add them to a list for later use and disable them.*/
    public void turnOffColliders()
    {
        //only initialize if the mainCameraScript is not initialized before. save extra calls to GetComponent.
        if (sceneManager == null)
        {
            sceneManager = ChapterSceneManager.instance;
        }

        //toBeToggled should be set each time this method is called, to ensure that we are indeed enabling all colliders
        //in the current room on MainCamera
        toBeToggled = sceneManager.currentRoom.gameObject;
        Debug.Log("Turning off colliders in " + toBeToggled.name);
        Collider2D[] colliders = toBeToggled.GetComponentsInChildren <Collider2D> ();
        foreach (Collider2D colliderInScene in colliders)
        {
            if (colliderInScene.enabled)
            {
                colliderInScene.enabled = false;
                collidersToToggle.Add(colliderInScene);
            }
        }
        PlayMakerFSM[] fsms = this.GetComponents <PlayMakerFSM>();
        foreach (PlayMakerFSM fsm in fsms)
        {
            fsm.SendEvent("collidersOff");
        }
    }
Пример #2
0
    // "OLD COMMENT": When turning on colliders with nested calls tot his, we get undefined since the second time you turn off the colliders
    // you no longer have a reference to the original tag.

    /*New Description of this method: "This methods turns on all the colliders in a room, the conditions for turning them on are:
     *      1)they should be in the toBeToggled list, this ensures that they were actually enabled before they were disabled
     *      2)they exist in the current room of Main Camera Script."
     */
    public void turnOnColliders()
    {
        //only initialize if the mainCameraScript is not initialized before. save extra calls to GetComponent.
        if (sceneManager == null)
        {
            sceneManager = ChapterSceneManager.instance;
        }

        //toBeToggled should be set each time this method is called, to ensure that we are indeed enabling all colliders
        //in the current room on MainCamera
        GameObject roomGameObject = sceneManager.currentRoom.gameObject;

        if (toBeToggled == null)
        {
            turnOnColliders(roomGameObject);
        }
        else
        {
            if (toBeToggled.Equals(roomGameObject))
            {
                turnOnColliders(roomGameObject);
            }
            else
            {
                turnOnColliders(toBeToggled);                 // You have to turn on the previous room that you have turned off colliders or else we will leave it permanently off
                turnOnColliders(roomGameObject);
            }
        }
        CollidersOff();
    }
Пример #3
0
        private void TurnOnColliders()
        {
            ChapterSceneManager sceneManager = ChapterSceneManager.instance;
            //toBeToggled should be set each time this method is called, to ensure that we are indeed enabling all colliders
            //in the current room on MainCamera
            GameObject roomGameObject = sceneManager.currentRoom.gameObject;

            if (toBeToggled == null)
            {
                turnOnColliders(roomGameObject);
            }
            else
            {
                if (toBeToggled.Equals(roomGameObject))
                {
                    turnOnColliders(roomGameObject);
                }
                else
                {
                    turnOnColliders(toBeToggled);                     // You have to turn on the previous room that you have turned off colliders or else we will leave it permanently off
                    turnOnColliders(roomGameObject);
                }
            }
            CollidersOff();
        }
Пример #4
0
        public override void OnEnter()
        {
            _sceneManager = ChapterSceneManager.instance;

            if (_sceneManager.currentRoomId == roomId.Value)
            {
                Fsm.Event(isFocused);
                Finish();
            }
        }
Пример #5
0
    void Awake()
    {
        //save out position so that positioning doesn't get messed up by HaikuSaveableObjects on rooms
        _outPosition = transform.position;
        string firstTwoChars = name.Substring(0, 2);

        int roomId;

        if (!int.TryParse(firstTwoChars, out roomId))
        {
            // Set RoomID to a two digit number.
            // If it isn't two digits, just grab the first number.
            roomId = int.Parse(name[0].ToString());
        }

        ChapterSceneManager sceneManager = ChapterSceneManager.instance;

        sceneManager.RegisterRoom(roomId, this);
    }
Пример #6
0
 void OnDestroy()
 {
     s_instance = null;
 }
Пример #7
0
 void Awake()
 {
     s_instance = this;
 }
Пример #8
0
    // Update is called once per frame
    void Update()
    {
        if (_sceneManager == null)
        {
            _sceneManager = ChapterSceneManager.instance;
            return;
        }

        if (Input.GetKeyDown(KeyCode.F1))
        {
            _sceneManager.FocusRoom(1);
        }
        else if (Input.GetKeyDown(KeyCode.F2))
        {
            _sceneManager.FocusRoom(2);
        }
        else if (Input.GetKeyDown(KeyCode.F3))
        {
            _sceneManager.FocusRoom(3);
        }
        else if (Input.GetKeyDown(KeyCode.F4))
        {
            _sceneManager.FocusRoom(4);
        }
        else if (Input.GetKeyDown(KeyCode.F5))
        {
            _sceneManager.FocusRoom(5);
        }
        else if (Input.GetKeyDown(KeyCode.F6))
        {
            _sceneManager.FocusRoom(6);
        }
        else if (Input.GetKeyDown(KeyCode.F7))
        {
            _sceneManager.FocusRoom(7);
        }
        else if (Input.GetKeyDown(KeyCode.F8))
        {
            _sceneManager.FocusRoom(8);
        }
        else if (Input.GetKeyDown(KeyCode.F9))
        {
            _sceneManager.FocusRoom(9);
        }
        else if (Input.GetKeyDown(KeyCode.F10))
        {
            _sceneManager.FocusRoom(10);
        }
        else if (Input.GetKeyDown(KeyCode.F11))
        {
            _sceneManager.FocusRoom(11);
        }
        else if (Input.GetKeyDown(KeyCode.F12))
        {
            _sceneManager.FocusRoom(12);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            ChapterUIManager.instance.ForceSelectItemId(1);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            ChapterUIManager.instance.ForceSelectItemId(2);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            ChapterUIManager.instance.ForceSelectItemId(3);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            ChapterUIManager.instance.ForceSelectItemId(4);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            ChapterUIManager.instance.ForceSelectItemId(5);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha6))
        {
            ChapterUIManager.instance.ForceSelectItemId(6);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha7))
        {
            ChapterUIManager.instance.ForceSelectItemId(7);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha8))
        {
            ChapterUIManager.instance.ForceSelectItemId(8);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha9))
        {
            ChapterUIManager.instance.ForceSelectItemId(9);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha0))
        {
            ChapterUIManager.instance.ForceSelectItemId(10);
        }
        else if (Input.GetKeyDown(KeyCode.Minus))
        {
            ChapterUIManager.instance.ForceSelectItemId(11);
        }
        else if (Input.GetKeyDown(KeyCode.Equals))
        {
            ChapterUIManager.instance.ForceSelectItemId(12);
        }
        else if (Input.GetKeyDown(KeyCode.Space))
        {
            GameObject.Find("ConversationCanvas").GetComponent <PlayMakerFSM>().SendEvent("deactivate");
        }
        else if (Input.GetKeyDown(KeyCode.L))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }
        else if (Input.GetKeyDown(KeyCode.K))
        {
        }
        else if (Input.GetKeyDown(KeyCode.S))
        {
        }
    }
Пример #9
0
 void Start()
 {
     _sceneManager = ChapterSceneManager.instance;
 }