コード例 #1
0
 void Awake()
 {
     if (singleton != null)
     {
         Debug.Log("WorldCanvasManager singleton already defined");
     }
     singleton = this;
 }
コード例 #2
0
 public void Initialize()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Debug.LogWarning("Instance exists");
     }
 }
コード例 #3
0
 void Awake()
 {
     if (worldCanvasManager == null)          //like a singleton
     {
         worldCanvasManager = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
コード例 #4
0
ファイル: GameManager.cs プロジェクト: Staszk/Diced_Pumpkins
    private void Awake()
    {
        _eventSystem = new EventSystem();
        _eventSystem.Initialize();

        _inputSystem = new InputSystem();

        _inputTranslator = new InputTranslator();

        _audioManager = new AudioManager();
        _audioManager.Initialize();

        _bookManager = new BookManager(bookObject, bookCanvas);

        _worldCanvasManager = new WorldCanvasManager(worldCanvas, textField, scoreImage, sprites);
        _worldCanvasManager.Initialize();

        _inventoryManager = new InventoryManager();
        _inventoryManager.Initialize();

        _inventoryUIManager = new InventoryUIManager(inventoryCanvas);

        _sceneMenuUIManager = new SceneMenuUIManager(menuPanel, icon);

        _jsonManager = new JSONReadManager();
        _jsonManager.Initialize();
        _jsonManager.LoadFile("FoodObjectFile");
        _jsonManager.LoadFile("SceneObjectFile");

        _sceneManager = new SceneManager(mainCamera);
        _sceneManager.Initialize();

        // Assign EventTypes to EventListeners
        // and Add them to the EventSystem's list
        _eventSystem.addListener(EventType.KEY_PRESSED, _inputTranslator);

        _eventSystem.addListener(EventType.BOOK_INTERACT, _bookManager);
        _eventSystem.addListener(EventType.NUM_EVENT_TYPES, _bookManager);

        _eventSystem.addListener(EventType.BOOK_INTERACT, _audioManager);
        _eventSystem.addListener(EventType.PAGE_FLIPPED, _audioManager);
        _eventSystem.addListener(EventType.KNIFE_CUT, _audioManager);

        _eventSystem.addListener(EventType.POINTS_SCORED, _worldCanvasManager);

        _eventSystem.addListener(EventType.FOOD_INVENTORY, _inventoryUIManager);
        _eventSystem.addListener(EventType.SCREEN_PRESSED, _inventoryUIManager);

        _eventSystem.addListener(EventType.SCENE_MENU, _sceneMenuUIManager);
        _eventSystem.addListener(EventType.SCREEN_PRESSED, _sceneMenuUIManager);
    }