Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        ProgramMode   = Program_Mode.START_SCREEN;
        DoorState     = DOOR_STATE.DOOR_CLOSED;
        GamePlayState = GAMEPLAY_STATE.INIT;
        ReadingState  = READING_STATE.NONE;

        DoorAudioSource = MiddleDoor.GetComponent <AudioSource>();

        Lever.transform.parent.gameObject.SetActive(false);
        GM_AudioSource = GetComponent <AudioSource>();

        OtherNotesProgressHash = 0;
        GameCompleteHash       = (1 << (i32)Letter.Tag.OTHER_1) | (1 << (i32)Letter.Tag.OTHER_2) | (1 << (i32)Letter.Tag.OTHER_3) | (1 << (i32)Letter.Tag.OTHER_4);

        Human.SetActive(false);

        BlackScreen.SetActive(false);
        Credits.SetActive(false);

        GameMixer.GetFloat("GM_Volume", out VCR_Current_Volume);
        VCR_Target_Volume = VCR_Current_Volume;
        T = 0.0f;

        FirstCoffinActivated  = false;
        SecondCoffinActivated = false;
        ThirdCoffinActivated  = false;

        FirstCoffinLight.SetActive(false);
        SecondCoffinLight.SetActive(false);
        ThirdCoffinLight.SetActive(false);

        CoffinMinDistance = 14.0f;

        StartedAlready = false;

#if IGNORED
        GameMixer.GetFloat("GM_Volume", out OriginalTrainVolume);
        GameMixer.SetFloat("GM_Volume", OriginalTorchSound);
#endif
    }
Exemple #2
0
        private void buttonLoadData_Click(object sender, EventArgs e)
        {
            if (openFileDialogRefract.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            try
            {
                string Content = "";
                using (System.IO.StreamReader S = new System.IO.FileInfo(openFileDialogRefract.FileName).OpenText())
                    Content = S.ReadToEnd();

                Content = Content.Replace("\r", "");
                string[] Lines = Content.Split('\n');

                List <PanelFresnelReflectance.RefractionData> Data = new List <PanelFresnelReflectance.RefractionData>();
                READING_STATE State          = READING_STATE.UNKNOWN;
                bool          InsertExisting = false;
                for (int LineIndex = 0; LineIndex < Lines.Length; LineIndex++)
                {
                    string   Line   = Lines[LineIndex];
                    string[] Values = Line.Split(' ', '\t');
                    if (Line == "" || Values.Length == 0)
                    {
                        continue;                               // Skip empty lines
                    }
                    if (Values.Length != 2)
                    {
                        throw new Exception("Unexpected line " + LineIndex + " does not contain exactly 2 values! (" + Line + ")");
                    }

                    if (Values[0].ToLower() == "wl")
                    {
                        if (Values[1].ToLower() == "n")
                        {
                            State = READING_STATE.N;
                        }
                        else if (Values[1].ToLower() == "k")
                        {
                            State = READING_STATE.K;
                        }
                        else
                        {
                            throw new Exception("Unexpected data type \"" + Values[1] + "\" at line " + LineIndex + ". Expecting either n or k.");
                        }
                        InsertExisting = Data.Count > 0;        // Populate list or insert in existing one?
                        continue;                               // Skip this descriptor line
                    }

                    float wl;
                    if (!float.TryParse(Values[0], out wl))
                    {
                        throw new Exception("Failed to parse wavelength at line " + LineIndex);
                    }
                    float v;
                    if (!float.TryParse(Values[1], out v))
                    {
                        throw new Exception("Failed to parse " + (State == READING_STATE.N ? "n" : "k") + " at line " + LineIndex);
                    }

                    PanelFresnelReflectance.RefractionData D = null;
                    if (InsertExisting)
                    {                           // Find existing slot in list
                        foreach (PanelFresnelReflectance.RefractionData ExistingD in Data)
                        {
                            if (Math.Abs(ExistingD.Wavelength - wl) < 1e-6f)
                            {                                   // Found it!
                                D = ExistingD;
                                break;
                            }
                        }
                        if (D == null)
                        {
                            throw new Exception("Failed to retrieve wavelength " + wl + " in existing array of values populated by " + (State == READING_STATE.N ? "k" : "n") + " values at line " + LineIndex);
                        }
                    }
                    else
                    {                           // Simply append
                        D = new PanelFresnelReflectance.RefractionData()
                        {
                            Wavelength = wl
                        };
                        Data.Add(D);
                    }

                    if (State == READING_STATE.N)
                    {
                        D.n = v;
                    }
                    else
                    {
                        D.k = v;
                    }
                }

                outputPanelFresnelGraph.Data = Data.ToArray();
                checkBoxData.Checked         = true;
            }
            catch (Exception _e)
            {
                MessageBox.Show(this, "Failed to load data file:" + _e.Message, "Argh!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        //print(GamePlayState);
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (ProgramMode == Program_Mode.MENU)
            {
                ProgramMode = Program_Mode.GAME;
            }
            else if (ProgramMode == Program_Mode.GAME)
            {
                ProgramMode = Program_Mode.MENU;
            }
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            if (ProgramMode == Program_Mode.START_SCREEN)
            {
                ProgramMode = Program_Mode.GAME;
                ELEKTRICITY.Play();
            }

            StartCoroutine(DoorOpenEffect());
        }


        if (Input.GetKeyDown(KeyCode.Escape) && ProgramMode == Program_Mode.START_SCREEN)
        {
            Application.Quit(0);
        }


        if (ProgramMode == Program_Mode.START_SCREEN)
        {
            for (u32 Index = 0;
                 Index < StartScreenItems.Length;
                 ++Index)
            {
                StartScreenItems[Index].SetActive(true);
            }
            ThePlayer.SetActive(false);
        }
        else
        {
            for (u32 Index = 0;
                 Index < StartScreenItems.Length;
                 ++Index)
            {
                StartScreenItems[Index].SetActive(false);
            }
            ThePlayer.SetActive(true);
        }

        v3 PlayerPosition = ThePlayer.transform.position; // TODO(@rudra): Every frame?

        if (Rectangle.IsInRectangle(CSG_Room1.GetRect(), PlayerPosition))
        {
            CurrentPlayerRoom = PLAYER_CURRENT_ROOM.ROOM_1;
        }

        if (Rectangle.IsInRectangle(CSG_Room2.GetRect(), PlayerPosition))
        {
            CurrentPlayerRoom = PLAYER_CURRENT_ROOM.ROOM_2;
        }

        if (Rectangle.IsInRectangle(CSG_Room3.GetRect(), PlayerPosition))
        {
            CurrentPlayerRoom = PLAYER_CURRENT_ROOM.ROOM_3;

            if (GamePlayState == GAMEPLAY_STATE.RIGHT_DOOR_OPENED)
            {
                GamePlayState            = GAMEPLAY_STATE.START_CRAZINESS;
                Human.transform.rotation = Quaternion.Euler(0.0f, 25.0f, 0.0f);
                Camera.IncreaseVHSVerticalOffset(0.04f);

                VCR_Target_Volume = 9.0f;
                T = 0.0f;
#if IGNORED
                f32 CurrentPlayTime = GM_AudioSource.time;

                GM_AudioSource.clip = VCR_Mid;
                GM_AudioSource.loop = true;
                GM_AudioSource.Play();
                GM_AudioSource.time = CurrentPlayTime;
#endif
            }
        }


        if (CurrentPlayerRoom == PLAYER_CURRENT_ROOM.ROOM_2 && DoorState == DOOR_STATE.DOOR_OPEN && GamePlayState == GAMEPLAY_STATE.INIT)
        {
            CloseDoor();

            StartCoroutine(ActivateCoffins());
            //StartCoroutine(OpenDoorWhenCollected());
        }


        if (CurrentPlayerRoom == PLAYER_CURRENT_ROOM.ROOM_2 && DoorState == DOOR_STATE.DOOR_OPEN && GamePlayState == GAMEPLAY_STATE.READ_FOURTH_NOTE)
        {
            CloseDoor();
            GamePlayState = GAMEPLAY_STATE.LEVER_SEQUENCE;
            StartCoroutine(WaitAndStartCoffinsAndInitLever());
        }

        if (CurrentPlayerRoom == PLAYER_CURRENT_ROOM.ROOM_1 && DoorState == DOOR_STATE.DOOR_OPEN && GamePlayState == GAMEPLAY_STATE.FIRST_COLLECTED)
        {
            CloseDoor();
            GamePlayState = GAMEPLAY_STATE.WAITING_FOR_NOTES;

            Letter_1.GetComponent <Animation>().Play("SendLetter");
            Human.SetActive(true);
        }

        if (Camera.HitWithRaycast(LetterLayer) && ThePlayer.GetComponent <Player>().CollidedWithLetter)
        {
            Animation LetterAnimation = Camera.LookingAt.transform.parent.gameObject.GetComponent <Animation>();
            if (LetterAnimation.isPlaying)
            {
            }
            else
            {
                if (ReadingState == READING_STATE.NONE)
                {
                    ReadingState = READING_STATE.CAN_READ;
                }
            }
        }
        else
        {
            ReadingState = READING_STATE.NONE;
        }

        EKeyProcessed = false;

        if (ReadingState == READING_STATE.READING && Input.GetKeyDown(KeyCode.E))
        {
            EKeyProcessed = true;
            ReadingState  = READING_STATE.CAN_READ;

            Letter _L = Camera.LookingAt.GetComponent <Letter>();
            if (_L.LetterTag == Letter.Tag.FIRST)
            {
                if (GamePlayState == GAMEPLAY_STATE.WAITING_FOR_NOTES)
                {
                    GamePlayState = GAMEPLAY_STATE.READ_FIRST_NOTE;
                    Letter_1.transform.position = Letter_1_Table_Position.position;

                    GamePlayState = GAMEPLAY_STATE.SECOND_NOTE_SENT;
                    Letter_2.GetComponent <Animation>().Play("SendLetter");
                }
            }
            else if (_L.LetterTag == Letter.Tag.SECOND)
            {
                if (GamePlayState == GAMEPLAY_STATE.SECOND_NOTE_SENT)
                {
                    GamePlayState = GAMEPLAY_STATE.READ_SECOND_NOTE;
                    Letter_2.transform.position = Letter_2_Table_Position.position;

                    GamePlayState = GAMEPLAY_STATE.THIRD_NOTE_SENT;
                    Letter_3.GetComponent <Animation>().Play("SendLetter");
                }
            }
            else if (_L.LetterTag == Letter.Tag.THIRD)
            {
                if (GamePlayState == GAMEPLAY_STATE.THIRD_NOTE_SENT)
                {
                    GamePlayState = GAMEPLAY_STATE.READ_THIRD_NOTE;
                    Letter_3.transform.position = Letter_3_Table_Position.position;

                    GamePlayState = GAMEPLAY_STATE.FOURTH_NOTE_SENT;
                    Letter_4.GetComponent <Animation>().Play("SendLetter");
                }
            }
            else if (_L.LetterTag == Letter.Tag.FOURTH)
            {
                if (GamePlayState == GAMEPLAY_STATE.FOURTH_NOTE_SENT)
                {
                    GamePlayState = GAMEPLAY_STATE.READ_FOURTH_NOTE;
                    Letter_4.transform.position = Letter_4_Table_Position.position;

                    StartCoroutine(OpenDoorAndEnableLever());
                }
            }
            else
            {
                // NOTE(@rudra): Case for notes on the other side
                OtherNotesProgressHash = OtherNotesProgressHash | 1 << (i32)_L.LetterTag;
                if (OtherNotesProgressHash == GameCompleteHash)
                {
                    StartCoroutine(FinishingSequence());
                }
            }
        }


        if (ReadingState == READING_STATE.CAN_READ && Input.GetKeyDown(KeyCode.E) && !EKeyProcessed)
        {
            EKeyProcessed = true;
            ReadingState  = READING_STATE.READING;
        }

        ReadingBackground.SetActive(ReadingState == READING_STATE.READING);


        // NOTE(@rudra): Lever
        if (Camera.HitWithRaycast(LeverLayer) && ThePlayer.GetComponent <Player>().CollidedWithLever)
        {
            if (LeverState != LEVER_STATE.LEVER_ON)
            {
                LeverState = LEVER_STATE.LEVER_CAN_ACCESS;
            }
        }
        else
        {
            if (LeverState != LEVER_STATE.LEVER_ON)
            {
                LeverState = LEVER_STATE.LEVER_CANNOT_ACCESS;
            }
        }


        // NOTE(@rudra): Interact text
        if (ReadingState == READING_STATE.CAN_READ || LeverState == LEVER_STATE.LEVER_CAN_ACCESS)
        {
            InteractText.text = "E";
        }
        else
        {
            InteractText.text = "";
        }

        LetterText.text = "";
        if (ReadingState == READING_STATE.READING)
        {
            Letter _L = Camera.LookingAt.GetComponent <Letter>();
            if (_L != null)
            {
                LetterText.text = _L.Contents;
            }
        }

        // NOTE(@rudra): Handle Lever
        if (LeverState == LEVER_STATE.LEVER_CAN_ACCESS && Input.GetKeyDown(KeyCode.E))
        {
            LeverState = LEVER_STATE.LEVER_ON;
            Lever.GetComponent <Animation>().Play("LeverOn");

            StartCoroutine(LightOffSequence());
        }

        // NOTE(@rudra): Right door opening sequence
        if (GamePlayState == GAMEPLAY_STATE.LEVER_ACTIVATED)
        {
            f32 SqDistanceFromPlayer = DistanceSq(RightDoor.transform.position, ThePlayer.transform.position);

            if (SqDistanceFromPlayer <= 30.0f)
            {
                GamePlayState = GAMEPLAY_STATE.RIGHT_DOOR_OPENED;
                RightDoorPivot.GetComponent <Animation>().Play("RightDoorOpen");

                AudioSource RightDoorAudio = RightDoor.GetComponent <AudioSource>();
                RightDoorAudio.clip = RightDoorOpen;
                RightDoorAudio.Play();
            }
        }

        // NOTE(@rudra): Ending sequence
        if (CurrentPlayerRoom == PLAYER_CURRENT_ROOM.ROOM_3)
        {
        }

        GameMixer.GetFloat("GM_Volume", out VCR_Current_Volume);
        VCR_Current_Volume = Mathf.Lerp(VCR_Current_Volume, VCR_Target_Volume, T);
        GameMixer.SetFloat("GM_Volume", VCR_Current_Volume);
        T += 1.0f * Time.deltaTime;

        // NOTE(@rudra): Coffin sequence
        if (FirstCoffinActivated)
        {
            f32 SqDistanceFromPlayer = DistanceSq(FirstCoffinLight.transform.position, ThePlayer.transform.position);
            if (SqDistanceFromPlayer <= CoffinMinDistance)
            {
                StartCoroutine(WaitAndActivateSecondCoffin());
            }
        }
        if (SecondCoffinActivated)
        {
            f32 SqDistanceFromPlayer = DistanceSq(SecondCoffinLight.transform.position, ThePlayer.transform.position);
            if (SqDistanceFromPlayer <= CoffinMinDistance)
            {
                StartCoroutine(WaitAndActivateThirdCoffin());
            }
        }
        if (ThirdCoffinActivated && !StartedAlready)
        {
            f32 SqDistanceFromPlayer = DistanceSq(ThirdCoffinLight.transform.position, ThePlayer.transform.position);
            if (SqDistanceFromPlayer <= CoffinMinDistance)
            {
                StartCoroutine(WaitAndActivateOpenDoor());
            }
        }
    }