get() публичный статический Метод

public static get ( ) : MemoryManager,
Результат MemoryManager,
Пример #1
0
    private void prepareGameLevelIfNecessary()
    {
        if (!_isGameLevelPrepared)
        {
            //TODO put this code into a separate implementation of a "Level" interface
            //with methods such as "OnStartState", "OnGameState(bool isPause)" and so on
            //so that those modals don't appear on every level
            //Also: put specific interface elements into level scene and then move them to interface hierarchy

            mainMenu.setResume();

            //TODO remove this temporary hack
            switch (MemoryManager.get().configuration.getMode())
            {
            case GameConfiguration.GameMode.ADVENTURE:
                fadeSprite.gameObject.SetActive(true);
                ModalManager.setModal(intro, true, introContinueButton.gameObject, introContinueButton.GetType().Name);
                changeState(GameState.Pause);
                break;

            case GameConfiguration.GameMode.SANDBOX:
                break;

            default:
                Logger.Log("GameStateController::Update unknown game mode=" + MemoryManager.get().configuration.getMode(), Logger.Level.WARN);
                break;
            }
            _isGameLevelPrepared = true;
        }
    }
Пример #2
0
    private void loadAvailableBioBricks()
    {
        Logger.Log("AvailableBioBricksManager::loadAvailableBioBricks", Logger.Level.INFO);
        LevelInfo levelInfo = null;

        MemoryManager.get().tryGetCurrentLevelInfo(out levelInfo);
        if (null != levelInfo && levelInfo.areAllBioBricksAvailable)
        {
            //load all biobricks
            //loadBioBricks(_allBioBrickFiles, _availableBioBricks);
            //or just copy them
            foreach (BioBrick bb in getAllBioBricks())
            {
                _availableBioBricks.AddLast(bb);
            }
        }
        else
        {
            //default behavior
            List <string> filesToLoad = new List <string>(_availableBioBrickFiles);
            filesToLoad.Add(MemoryManager.get().configuration.getGameMapName());
            loadBioBricks(filesToLoad.ToArray(), _availableBioBricks);
        }
        Logger.Log("AvailableBioBricksManager::loadAvailableBioBricks _availableBioBricks=" + _availableBioBricks.Count, Logger.Level.DEBUG);
    }
Пример #3
0
    public void setAndSaveLevelName(GameConfiguration.GameMap newMap, string cause = null)
    {
        if (!string.IsNullOrEmpty(cause))
        {
            Logger.Log("GameStateController::setAndSaveLevelName by " + cause, Logger.Level.DEBUG);
        }
        else
        {
            Logger.Log("GameStateController::setAndSaveLevelName", Logger.Level.DEBUG);
        }

        switch (newMap)
        {
        case GameConfiguration.GameMap.ADVENTURE1:
        case GameConfiguration.GameMap.SANDBOX1:
        case GameConfiguration.GameMap.SANDBOX2:
            //saving level name into MemoryManager
            //because GameStateController current instance will be destroyed during restart
            //whereas MemoryManager won't
            MemoryManager.get().configuration.gameMap = newMap;
            break;

        default:
            Logger.Log("GameStateController::setAndSaveLevelName unmanaged level=" + newMap, Logger.Level.WARN);
            break;
        }
    }
Пример #4
0
    // Warning: loads from inputFiles is an array of names of files inside 'biobrickFilesPathPrefix'
    void loadDevices()
    {
        LinkedList <BioBrick> availableBioBricks = AvailableBioBricksManager.get().getAvailableBioBricks();
        LinkedList <BioBrick> allBioBricks       = AvailableBioBricksManager.get().getAllBioBricks();

        LevelInfo levelInfo = null;

        MemoryManager.get().tryGetCurrentLevelInfo(out levelInfo);

        List <Device> devices = new List <Device>();

        DeviceLoader dLoader = new DeviceLoader(availableBioBricks, allBioBricks);

        string[] filesToLoad;
        string   currentMapDevicesFilePath = MemoryManager.get().configuration.getGameMapName();

        if (null == levelInfo || !levelInfo.areAllDevicesAvailable)
        {
            filesToLoad = new string[] { currentMapDevicesFilePath };
        }
        else
        {
            List <string> fileList = new List <string>(deviceFiles);
            fileList.Add(currentMapDevicesFilePath);
            filesToLoad = fileList.ToArray();
        }
        foreach (string file in filesToLoad)
        {
            string fullPathFile = deviceFilesPathPrefix + file;
            Logger.Log("Inventory::loadDevices loads device file " + fullPathFile, Logger.Level.TRACE);
            devices.AddRange(dLoader.loadDevicesFromFile(fullPathFile));
        }
        UpdateData(devices, new List <Device>(), new List <Device>());
    }
Пример #5
0
    public string getLastCheckpointName()
    {
        string levelName          = MemoryManager.get().configuration.getGameMapName();
        string lastCheckpointName = null == _lastCheckpoint?"":_lastCheckpoint.name;
        string result             = string.IsNullOrEmpty(lastCheckpointName)?lastCheckpointName:levelName + checkpointSeparator + lastCheckpointName;

        return(result);
    }
Пример #6
0
 private void loadLevels()
 {
     Logger.Log("GameStateController::loadLevels", Logger.Level.INFO);
     //take into account order of loading to know which LinkManager shall ask which one
     Application.LoadLevelAdditive(_interfaceScene);
     Application.LoadLevelAdditive(_bacteriumScene);
     Application.LoadLevelAdditive(MemoryManager.get().configuration.getSceneName());
 }
    public override void click()
    {
        Logger.Log("the game will " + itemName + "...");

        CustomDataValue modeValue = GameConfiguration.GameMode.ADVENTURE == MemoryManager.get().configuration.getMode() ? CustomDataValue.SANDBOX : CustomDataValue.ADVENTURE;

        RedMetricsManager.get().sendEvent(TrackingEvent.SELECTMENU, new CustomData(CustomDataTag.OPTION, modeValue.ToString()));

        GameStateController.get().goToOtherGameMode();
    }
Пример #8
0
 void antiDuplicateInitialization()
 {
     MemoryManager.get();
     Logger.Log("MemoryManager::antiDuplicateInitialization with hashcode=" + this.GetHashCode() + " and _instance.hashcode=" + _instance.GetHashCode(), Logger.Level.INFO);
     if (this != _instance)
     {
         Logger.Log("MemoryManager::antiDuplicateInitialization self-destruction", Logger.Level.INFO);
         Destroy(this.gameObject);
     }
 }
Пример #9
0
    public void goToOtherGameMode()
    {
        Logger.Log("GameStateController::goToOtherGameMode", Logger.Level.INFO);
        GameConfiguration.GameMap destination =
            (MemoryManager.get().configuration.gameMap == GameConfiguration.GameMap.ADVENTURE1) ?
            GameConfiguration.GameMap.SANDBOX2 :
            GameConfiguration.GameMap.ADVENTURE1;

        setAndSaveLevelName(destination, "goToOtherGameMode");
        RedMetricsManager.get().sendEvent(TrackingEvent.SWITCH, new CustomData(CustomDataTag.GAMELEVEL, destination.ToString()));
        internalRestart();
    }
Пример #10
0
    public void triggerEnd(EndGameCollider egc)
    {
        MemoryManager.get().sendCompletionEvent();

        gUITransitioner.TerminateGraphs();

        //TODO merge fadeSprite with Modal background
        fadeSprite.gameObject.SetActive(true);
        fadeSprite.FadeIn();

        StartCoroutine(waitFade(2f, egc));
    }
Пример #11
0
    public static void changeLanguageTo(Language lang)
    {
        RedMetricsManager.get().sendEvent(TrackingEvent.CONFIGURE, new CustomData(CustomDataTag.LANGUAGE, lang.ToString()));

        Localization.instance.currentLanguage = lang.ToString();

        MemoryManager.get().configuration.language = lang;

        foreach (UILocalize localize in GameObject.FindObjectsOfType <UILocalize>())
        {
            localize.Localize();
        }
    }
Пример #12
0
    private static void internalRestart()
    {
        Logger.Log("GameStateController::restart", Logger.Level.INFO);
        //TODO reload scene but reset all of its components without using MemoryManager
        //note: ways to transfer data from one scene to another
        //get data from previous instance
        //other solution: make all fields static
        //other solution: fix initialization through LinkManagers
        //that automatically take new GameStateController object
        //and leave old GameStateController object with old dead links to destroyed objects

        MemoryManager.get().configuration.restartBehavior = GameConfiguration.RestartBehavior.GAME;
        Application.LoadLevel(_masterScene);
    }
Пример #13
0
    // Use this for initialization
    void Awake()
    {
        GameObject       perso           = GameObject.Find(persoGameObjectName);
        Hero             hero            = perso.GetComponent <Hero>();
        PhenoFickContact pheno           = perso.GetComponent <PhenoFickContact>();
        GUITransitioner  guiTransitioner = GUITransitioner.get();
        CellControl      cellControl     = perso.GetComponent <CellControl>();

        //Cellcontrol connection
        guiTransitioner.control = cellControl;

        InterfaceLinkManager interfaceLinkManager = GameObject.Find(InterfaceLinkManager.interfaceLinkManagerGameObjectName).GetComponent <InterfaceLinkManager>();

        cellControl.absoluteWASDButton     = interfaceLinkManager.absoluteWASDButton;
        cellControl.leftClickToMoveButton  = interfaceLinkManager.leftClickToMoveButton;
        cellControl.relativeWASDButton     = interfaceLinkManager.relativeWASDButton;
        cellControl.rightClickToMoveButton = interfaceLinkManager.rightClickToMoveButton;

        cellControl.selectedKeyboardControlTypeSprite = interfaceLinkManager.selectedKeyboardControlTypeSprite;
        cellControl.selectedMouseControlTypeSprite    = interfaceLinkManager.selectedMouseControlTypeSprite;

        interfaceLinkManager.controlsArray.cellControl = cellControl;


        //Hero connections
        hero.lifeAnimation   = GameObject.Find("LifeLogo").GetComponent <LifeLogoAnimation>();
        hero.energyAnimation = GameObject.Find("EnergyLogo").GetComponent <EnergyLogoAnimation>();

        GameObject.Find("LifeIndicator").GetComponent <LifeIndicator>().hero     = hero;
        GameObject.Find("EnergyIndicator").GetComponent <EnergyIndicator>().hero = hero;
        guiTransitioner.hero = hero;


        //PhenoFickcontact connections
        //TODO use InterfaceLinkManager
        pheno.vectroPanel       = GameObject.Find("RoomMediumInfoBackgroundSprite").GetComponent <VectrosityPanel>();
        pheno.graphMoleculeList = GameObject.Find("MediumInfoPanelRoom").GetComponent <GraphMoleculeList>();


        //Main Camera
        guiTransitioner.mainBoundCamera = GameObject.Find("Main Camera").GetComponent <BoundCamera>();

        //MemoryManager reporting
        MemoryManager.get().hero = hero;
    }
Пример #14
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.RightControl))
        {
            MemoryManager.get().configuration.switchMetricsGameVersion();
            isTestGUID = MemoryManager.get().configuration.isTestGUID();

            //display feedback for logging mode
            GameObject go      = new GameObject();
            GUIText    guiText = go.AddComponent <GUIText>();
            go.transform.position = new Vector3(0.5f, 0.5f, 0.0f);
            if (isTestGUID)
            {
                guiText.text = "REDMETRICS TEST MODE";
            }
            else
            {
                guiText.text = "REDMETRICS DEFAULT MODE";
            }

            StartCoroutine(waitAndDestroy(go));
        }
    }
Пример #15
0
 public bool tryGetCurrentLevelInfo(out LevelInfo levelInfo)
 {
     Logger.Log("MemoryManager::tryGetCurrentLevelInfo", Logger.Level.DEBUG);
     levelInfo = null;
     return(_loadedLevelInfo.TryGetValue(MemoryManager.get().configuration.getSceneName(), out levelInfo));
 }
 public override void initialize()
 {
     itemName = GameConfiguration.GameMode.ADVENTURE == MemoryManager.get().configuration.getMode() ? sandbox : adventure;
 }
Пример #17
0
 public static void updateAdminStatus()
 {
     _isAdminMode = Application.isEditor || MemoryManager.get().configuration.isTestGUID();
 }
Пример #18
0
    // Update is called once per frame
    void Update()
    {
        if (isShortcutKeyDown(KeyCode.X))
        {
            Logger.Log("pressed shortcut to teleport Cellia to the pursuit", Logger.Level.INFO);
            CellControl.get().teleport(new Vector3(500, 0, 637));
        }
        else if (isShortcutKeyDown(KeyCode.V))
        {
            Logger.Log("pressed shortcut to teleport Cellia to the GFP BioBrick", Logger.Level.INFO);
            CellControl.get().teleport(new Vector3(168, 0, 724));
        }
        else if (isShortcutKeyDown(KeyCode.W))
        {
            Logger.Log("pressed shortcut to teleport Cellia to the end of the game", Logger.Level.INFO);
            CellControl.get().teleport(new Vector3(-150, 0, 1110));
        }

        switch (_gameState)
        {
        case GameState.Start:

            endWindow.SetActive(false);
            mainMenu.setNewGame();
            if (GameConfiguration.RestartBehavior.GAME == MemoryManager.get().configuration.restartBehavior)
            {
                leaveMainMenu();
            }
            else
            {
                goToMainMenuFrom(GameState.Game);
            }
            break;

        case GameState.MainMenu:
            if (Input.GetKeyUp(KeyCode.UpArrow))
            {
                mainMenu.selectPrevious();
            }
            else if (Input.GetKeyUp(KeyCode.DownArrow))
            {
                mainMenu.selectNext();
            }
            else if (Input.GetKeyUp(KeyCode.Return) || Input.GetKeyUp(KeyCode.KeypadEnter))
            {
                mainMenu.getCurrentItem().click();
            }
            else if (Input.GetKeyDown(KeyCode.Escape))
            {
                mainMenu.escape();
            }
            break;

        case GameState.Game:

            prepareGameLevelIfNecessary();

            //pause
            if (isShortcutKeyDown(_pauseKey))
            {
                Logger.Log("GameStateController::Update - Escape/Pause key pressed", Logger.Level.DEBUG);
                ModalManager.setModal(pauseIndicator, false);
                changeState(GameState.Pause);
            }
            //main menu
            else if (Input.GetKeyDown(KeyCode.Escape))
            {
                goToMainMenuFrom(GameState.Game);
            }
            //inventory
            //TODO add DNA damage accumulation management when player equips/unequips too often
            else if (isShortcutKeyDown(_inventoryKey) && Inventory.isOpenable())
            {
                Logger.Log("GameStateController::Update inventory key pressed", Logger.Level.INFO);
                gUITransitioner.GoToScreen(GUITransitioner.GameScreen.screen2);
            }
            //crafting
            else if (isShortcutKeyDown(_craftingKey) && CraftZoneManager.isOpenable())
            {
                Logger.Log("GameStateController::Update craft key pressed", Logger.Level.INFO);
                gUITransitioner.GoToScreen(GUITransitioner.GameScreen.screen3);
            }

            /*
             * else if(isShortcutKeyDown(_sandboxKey))
             * {
             *  Logger.Log("GameStateController::Update sandbox key pressed from scene="+MemoryManager.get ().configuration.getSceneName(), Logger.Level.INFO);
             *  goToOtherGameMode();
             * }*/
            //TODO fix this feature

            /*
             * else if(isShortcutKeyDown(_forgetDevicesKey))
             * {
             *  Inventory.get ().switchDeviceKnowledge();
             * }*/
            break;

        case GameState.Pause:
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                goToMainMenuFrom(GameState.Pause);
            }
            else
            {
                GameStateTarget newState = ModalManager.manageKeyPresses();
                if (GameStateTarget.NoAction != newState)
                {
                    if (
                        GameStateTarget.NoTarget != newState &&
                        GameStateTarget.Pause != newState
                        )
                    {
                        changeState(getStateFromTarget(newState));
                    }
                }
                else
                {
                    switch (gUITransitioner._currentScreen)
                    {
                    case GUITransitioner.GameScreen.screen1:
                        break;

                    case GUITransitioner.GameScreen.screen2:
                        if (isShortcutKeyDown(_inventoryKey) || Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Return))
                        {
                            Logger.Log("GameStateController::Update out of inventory key pressed", Logger.Level.INFO);
                            gUITransitioner.GoToScreen(GUITransitioner.GameScreen.screen1);
                        }
                        else if (isShortcutKeyDown(_craftingKey) && CraftZoneManager.isOpenable())
                        {
                            Logger.Log("GameStateController::Update inventory to craft key pressed", Logger.Level.INFO);
                            gUITransitioner.GoToScreen(GUITransitioner.GameScreen.screen3);
                        }
                        break;

                    case GUITransitioner.GameScreen.screen3:
                        if (isShortcutKeyDown(_inventoryKey) && Inventory.isOpenable())
                        {
                            Logger.Log("GameStateController::Update craft to inventory key pressed", Logger.Level.INFO);
                            gUITransitioner.GoToScreen(GUITransitioner.GameScreen.screen2);
                        }
                        else if (isShortcutKeyDown(_craftingKey) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyUp(KeyCode.KeypadEnter))
                        {
                            Logger.Log("GameStateController::Update out of craft key pressed", Logger.Level.INFO);
                            gUITransitioner.GoToScreen(GUITransitioner.GameScreen.screen1);
                        }
                        break;

                    default:
                        Logger.Log("GameStateController::Update unknown screen " + gUITransitioner._currentScreen, Logger.Level.WARN);
                        break;
                    }
                }
            }
            break;

        case GameState.End:
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                goToMainMenuFrom(GameState.End);
            }
            break;

        default:
            break;
        }
    }
Пример #19
0
 private void initializeIfNecessary()
 {
     _isAbsoluteWASD    = MemoryManager.get().configuration.isAbsoluteWASD;
     _isLeftClickToMove = MemoryManager.get().configuration.isLeftClickToMove;
     reset();
 }