Exemple #1
0
    public void GetInput(string theInput)
    {
        Random randy = new Random();

        WriteLine("--" + theInput);
        updateTextPosition();
        theInput = theInput.ToLower();
        char[] myCharCollection = new char[theInput.Length];
        myCharCollection = theInput.ToCharArray();
        if (!theInput.Contains(','))
        {
            theInput = new string(myCharCollection.Where(c => !char.IsPunctuation(c)).ToArray());
        }
        switch (theInput)
        {
        //TESTMODE COMMANDS----------------------------------------------------------------------------------------
        case "testmode":
            WriteLine(">>>testMode starting...");
            testMode = true;
            break;

        case "testmodeoff":
            testMode = false;
            WriteLine(">>>testMode stopped...");
            break;

        //CONVERSATIONAL COMMANDS----------------------------------------------------------------------------------
        case "thecakeisalie":
            WriteLine(">>>Well, for my sister GLADoS that might be true, but I'll give you all the cake you want!");
            break;

        case "read a book":
            WriteLine(">>>I'm a computer, I can't read. You can check out the Digital Library though.");
            break;

        //INVENTORY DEBUG COMMANDS---------------------------------------------------------------------------------
        case "give player something":
            if (inventoryChanger.GivePlayer(InventoryManager.ERK_ITEM))
            {
                WriteLine(">>>Giving Player an ERK... [OK]");
            }
            else
            {
                WriteLine("Giving Player an ERK... [FAIL]");
            }
            break;

        //DOOR COMMANDS-------------------------------------------------------------------------------------------
        //UNLOCK DOORS
        case "opn7169":
            WriteLine("UNLOCKING DOORS...");
            if (gameManager.commandEntered)
            {
                Write(" [FAIL--ALREADY UNLOCKED]");
            }
            else
            {
                gameManager.commandEntered = true;
                Write(" [OK]");
            }
            break;

        //OPEN DOORS----------------------------------------
        case "open bathroom door":
            if (doorManager.Open(DoorManager.BATHROOM_DOOR))
            {
                Write(" [OK]");
            }
            else
            {
                Write(" [FAIL--DOOR ALREADY OPEN]");
            }
            break;

        case "open airlock door one":
            if (doorManager.Open(DoorManager.AIRLOCK_DOOR_ONE))
            {
                Write(" [OK]");
            }
            else
            {
                Write(" [FAIL--DOOR ALREADY OPEN]");
            }
            break;

        case "open airlock door two":
            if (doorManager.Open(DoorManager.AIRLOCK_DOOR_TWO))
            {
                Write(" [OK]");
            }
            else
            {
                Write(" [FAIL--DOOR ALREADY OPEN]");
            }
            break;

        case "open emergency airlock door one":
            if (doorManager.Open(DoorManager.EMERGENCY_AIRLOCK_DOOR_ONE))
            {
                Write(" [OK]");
            }
            else
            {
                Write(" [FAIL--DOOR ALREADY OPEN]");
            }
            break;

        case "open emergency airlock door two":
            if (doorManager.Open(DoorManager.EMERGENCY_AIRLOCK_DOOR_TWO))
            {
                Write(" [OK]");
            }
            else
            {
                Write(" [FAIL--DOOR ALREADY OPEN]");
            }
            break;

        //CLOSE DOORS----------------------------------------
        case "close bathroom door":
            if (doorManager.Close(DoorManager.BATHROOM_DOOR))
            {
                Write(" [OK]");
            }
            else
            {
                Write(" [FAIL--DOOR ALREADY CLOSED]");
            }
            break;

        case "close airlock door one":
            if (doorManager.Close(DoorManager.AIRLOCK_DOOR_ONE))
            {
                Write(" [OK]");
            }
            else
            {
                Write(" [FAIL--DOOR ALREADY CLOSED]");
            }
            break;

        case "close airlock door two":
            if (doorManager.Close(DoorManager.AIRLOCK_DOOR_TWO))
            {
                Write(" [OK]");
            }
            else
            {
                Write(" [FAIL--DOOR ALREADY CLOSED]");
            }
            break;

        case "close emergency airlock door one":
            if (doorManager.Close(DoorManager.EMERGENCY_AIRLOCK_DOOR_ONE))
            {
                Write(" [OK]");
            }
            else
            {
                Write(" [FAIL--DOOR ALREADY CLOSED]");
            }
            break;

        case "close emergency airlock door two":
            if (doorManager.Close(DoorManager.EMERGENCY_AIRLOCK_DOOR_TWO))
            {
                Write(" [OK]");
            }
            else
            {
                Write(" [FAIL--DOOR ALREADY CLOSED]");
            }
            break;

        //VARIABLE COMMANDS----------------------------------------------------------------------------------------------
        default:
            //TODO check unconstant stuff
            //TELEPORTATION--------------------------------------------------------------------------------------------------
            if (theInput.Contains("tp"))
            {
                //A really long line of code that does a lot of stuff.
                player.setPlayerPosition(Vector3String.StringToVector3(theInput.Split(' ')[1]));
                break;
            }
            //TIME
            if (theInput.Contains("timeset"))
            {
                int timeToSet;
                if (int.TryParse(theInput.Split(' ')[1], out timeToSet))
                {
                    timemanager.setTime(timeToSet);
                    WriteLine(" [OK]");
                }
                else
                {
                    WriteLine(" [Failed -- Not An Integer]");
                }
                break;
            }
            WriteLine(">>>ai.exe error. Unable to interpret [" + theInput + "]");
            break;
        }
        updateTextPosition();
    }
    // Update is called once per frame
    void Update()
    {
        cpuEnabled = cameraManager.valuesINeedSaved(); //Returns whether the cpu camera is active or not

        int timeThisFrame = timeManager.time;


        //-------------------------------------------------------------------------------------------------------------------------------------------------------------
        if (timeManager.timeUpdated)
        {
            if (timeThisFrame > 0 && !stationInitialized)
            {
                inventoryChanger.Give(InventoryChanger.BETASTORAGE_ONE_INVENTORY, InventoryManager.ERK_ITEM);
                inventoryChanger.Give(InventoryChanger.BETASTORAGE_ONE_INVENTORY, InventoryManager.ERK_ITEM);
                inventoryChanger.Give(InventoryChanger.BETASTORAGE_ONE_INVENTORY, InventoryManager.BATTERY_ITEM);
                inventoryChanger.Give(InventoryChanger.BETASTORAGE_ONE_INVENTORY, InventoryManager.BATTERY_ITEM);
                inventoryChanger.Give(InventoryChanger.BETASTORAGE_ONE_INVENTORY, InventoryManager.BATTERY_ITEM);
                inventoryChanger.Give(InventoryChanger.BETASTORAGE_TWO_INVENTORY, InventoryManager.ERK_ITEM);
                inventoryChanger.Give(InventoryChanger.BETASTORAGE_TWO_INVENTORY, InventoryManager.ERK_ITEM);
                inventoryChanger.Give(InventoryChanger.BETASTORAGE_TWO_INVENTORY, InventoryManager.BATTERY_ITEM);
                inventoryChanger.Give(InventoryChanger.BETASTORAGE_TWO_INVENTORY, InventoryManager.BATTERY_ITEM);
                inventoryChanger.Give(InventoryChanger.BETASTORAGE_TWO_INVENTORY, InventoryManager.BATTERY_ITEM);
                inventoryChanger.GivePlayer(InventoryManager.FOOD_ITEM);
                inventoryChanger.GivePlayer(InventoryManager.FOOD_ITEM);
                inventoryChanger.GivePlayer(InventoryManager.WATER_ITEM);
                stationInitialized = true;
            }
            if (timeThisFrame > 2 && firstDayNotShown) //DAY 1
            {
                firstDayNotShown = false;
                CrossFadeInAnnouncement("Day One");
            }
            if (timeThisFrame > 5 && !firstDayIndicatorHidden) //DAY 1 Hide
            {
                firstDayIndicatorHidden = true;
                CrossFadeOutAnnouncement("Day One");
            }
            if (playerIn(1) && !firstCheckpoint && !helpTextShown)
            {
                StartCoroutine(ShowHelpText());
            }
            if (timeThisFrame > 0 && cpuEnabled && !firstCheckpoint) //Begin Printing Initial Instructions!!!!
            {
                print("First Checkpoint Activated!");
                StartCoroutine(DayOneTextOne());
                firstCheckpoint = true;
                //TODO unlock doors
            }
            if (firstCheckpoint && playerIn(3) && cpuEnabled && !secondCheckpoint) //User is in the Beta Storage now, print second set of instructions.
            {
                print("Second Checkpoint Activiated!");
                StartCoroutine(DayOneTextTwo());
                secondCheckpoint = true;
            }
            if (secondCheckpoint && !thirdCheckpoint && cpuEnabled && inventoryManager.Player.ERKAmount > 0 && inventoryManager.Player.BatteriesAmount > 0) //User has grabbed a battery and ERK, commence more instructions.
            {
                print("Third Checkpoint Activated!");
                StartCoroutine(DayOneTextThree());
                thirdCheckpoint = true;
            }
            if (thirdCheckpoint && !fourthCheckpoint && playerIn(1) && cpuEnabled) //User in room one, just finished first mission.
            {
                print("Fourth Checkpoint Activated!");
                StartCoroutine(DayOneTextFour());
                fourthCheckpoint = true;
            }
            if (fourthCheckpoint && !commandEntered && !fifthCheckpoint)
            {
                //Don't do anything, just reserving a spot
            }
            if (fourthCheckpoint && commandEntered && !fifthCheckpoint && cpuEnabled)
            {
                print("Fifth Checkpoint Activated!");
                StartCoroutine(DayOneTextFive());
                fifthCheckpoint = true;
            }
            if (fifthCheckpoint && playerIn(7) && !sixthCheckpoint && cpuEnabled)
            {
                print("Sixth Checkpoint Activated!");
                StartCoroutine(DayOneTextSix());
                sixthCheckpoint = true;
            }
            if (sixthCheckpoint && pumpGameComplete && playerIn(7) && cpuEnabled && !seventhCheckpoint)
            {
                print("Seventh Checkpoint Activiated");
                StartCoroutine(DayOneTextSeven());
                seventhCheckpoint = true;
            }
            if (seventhCheckpoint && playerIn(1) && cpuEnabled && !eighthCheckpoint)
            {
                print("Eight Checkpoint Activiated");
                StartCoroutine(DayOneTextEight());
                eighthCheckpoint = true;
            }
            if (eighthCheckpoint && playerIn(1) && cpuEnabled && !ninthCheckpoint) //add other stuff here
            {
                print("Ninth Checkpoint Activated!");
                StartCoroutine(DayOneTextNine());
                ninthCheckpoint = true;
            }
            if (ninthCheckpoint && playerIn(1) && cpuEnabled && !tenthCheckpoint) //add other stuff here
            {
                print("Tenth Checkpoint Activated!");
                StartCoroutine(DayOneTextTen());
                tenthCheckpoint = true;
            }
            //LOSING SCRIPTS---------------------------------------------------------------------------
            if (timeThisFrame > 150 && !tenthCheckpoint && !emergencyMode) //First challenge
            {
                emergencyMode         = true;
                lightManager.redalert = true;
                musicController.stopSound(MusicController.MUSIC);
                musicController.startSound(MusicController.ALARM_SOUND);
            }
            if (emergencyMode && cpuEnabled && !emergencyMessageShown)
            {
                emergencyMessageShown = true;
                StartCoroutine(asteroidComing());
            }
            if (timeOfImpact < timeManager.time && !startedLosing)
            {
                startedLosing         = true;
                lightManager.redalert = false;
                lightManager.blackout = true;
                player.GetComponent <PlayerMove>().enabled = false;
                musicController.startSound(MusicController.CRASH_SOUND);
                StartCoroutine(cameraManager.AsteroidImpact());
            }
            //WINNING------------------------------------------------------------------------------------
            if (timeThisFrame > 150 && tenthCheckpoint)
            {
                lightManager.redalert   = false;
                lightManager.greenalert = true;
                StartCoroutine(WinRoutine());
            }
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Pause();
        }
    }