Beispiel #1
0
 public void SetCab(PlayableGame cabinet)
 {
     myCab = cabinet;
 }
 void Start()
 {
     pgScript = gameObject.GetComponent<PlayableGame>();
 }
Beispiel #3
0
 void TakePositionFor(PlayableGame whichGame)
 {
     Vector3 sameHeightFix = whichGame.standHere.position;
     sameHeightFix.y = transform.position.y;
     transform.position = Vector3.Slerp(transform.position,
                                        sameHeightFix,
                                        Time.deltaTime);
 }
Beispiel #4
0
    // Update is called once per frame
    void Update()
    {
        if(Input.GetKey( KeyCode.Escape )) {
            showMouse();
            Application.Quit();
        }

        if((gameOverMessage && gameOverMessage.activeSelf) ||
            (winMessage && winMessage.activeSelf)) {
            if(Input.GetKeyDown(KeyCode.Space)) {
                Application.LoadLevel(Application.loadedLevel);
            }
            return; // game frozen, player lost
        }

        if(playingNow != null) {
            LookToward(playingNow.transform);
            TakePositionFor(playingNow);

            if(Input.GetKeyDown(KeyCode.Backspace) || playingNow.gameScreen.isPlaying == false) {
                // playingNow.gameScreen.isPlaying = false; // nah, leave it running but cease input!

                PlayerDistrib.instance.Shuffle(); // BEFORE releasing player assignment, or it may appear here
                playingNow.playerHere = null; // freeing up player assignment AFTER the shuffle

                playingNow = null;
                tokenBillsChange(0,0);

                if(ticketNum == allGameCount && MenuManager.tournyMode==false) {
                    if(winMessage) {
                        winMessage.SetActive(true);
                    }
                }
            }
            return;
        }

        if(parentDialog && parentDialog.activeSelf) {
            LookToward(dialogLookFocus.transform);
            return; // freeze while in dialog
        }

        if(Input.GetKeyDown(KeyCode.Space)) {
            RaycastHit rhInfo;
            if( Physics.Raycast(transform.position, transform.forward, out rhInfo, 3.0f)) {
                AdultText atScript = rhInfo.collider.GetComponent<AdultText>();
                if(atScript) {
                    // talk to ticket guy to quit out of high scores round
                    if(atScript.questionList.Length == 1 && MenuManager.tournyMode) {
                        if(gameOverMessage) {
                            gameOverMessage.SetActive(true);
                        }
                        // Application.LoadLevel( Application.loadedLevel );
                        SoundCenter.instance.PlayClipOn( SoundCenter.instance.adultTalk,
                            transform.position, 1.0f);
                        return;
                    }

                    parentDialog.SetActive(true);
                    showMouse();
                    lastAdultSpokenTo = rhInfo.collider.GetComponent<TokenInteraction>();
                    dialogLookFocus = rhInfo.collider.transform;

                    if(atScript) {

                        QuestionOption grabQues = atScript.GetNextQues();
                        int randNots = Random.Range(0,5);
                        expectingResponse =
                            (randNots % 2 ==1 ? grabQues.yesIsRight == false :
                             					grabQues.yesIsRight);

                        string notReplace = "";
                        for(int i=0;i<randNots;i++) {
                            notReplace += " not";
                        }

                        adultSays.text = grabQues.theyAsk.Replace(" %NOTS%",notReplace)/* +
                            "\n(Expecting: " + (expectingResponse ? "Yes" : "No")+")"*/;
                    } else {
                        adultSays.text = "(Needs dialog data!)";
                    }
                    SoundCenter.instance.PlayClipOn( SoundCenter.instance.adultTalk,
                                                    transform.position, 1.0f);
                } else {
                    int hadTokens = tokens;

                    PlayableGame playScript = rhInfo.collider.GetComponent<PlayableGame>();

                    TokenInteraction tiScript = rhInfo.collider.GetComponent<TokenInteraction>();
                    if(tiScript == null) {
                        return;
                    }
                    float distFromFront;

                    if(playScript) {
                        if(playScript.playerHere != null) {
                            distFromFront = 500.0f;
                        } else {
                            distFromFront = Vector3.Distance(transform.position,
                                playScript.gameScreen.myCab.standHere.position);
                        }
                    } else {
                        distFromFront = 0.0f;
                    }

                    if(distFromFront < 1.5f) {
                        bool hadTheMoney = false;
                        if(playScript && playScript.gameScreen.isPlaying) {
                            hadTheMoney = true;
                            Debug.Log("no tokens needed, already in play");
                        } else if(tiScript) {
                            hadTheMoney = tiScript.tokenExchange(this);
                        } else {
                            Debug.Log("Touched: " + rhInfo.collider.name);
                        }

                        if(playScript && hadTheMoney) {
                            StartCoroutine(StartGameInAMoment(playScript));
                        }
                    }
                }
            } else {
                Debug.Log ("Not close enough");
            }
        }

        float mouseOrHorizKeys =
            Input.GetAxis("Horizontal") + Input.GetAxis("Mouse X");
        mouseOrHorizKeys = Mathf.Clamp(mouseOrHorizKeys, -1.0f, 1.0f);

        transform.Rotate(Vector3.up, mouseOrHorizKeys * Time.deltaTime * 85.0f);
    }
Beispiel #5
0
 IEnumerator StartGameInAMoment(PlayableGame playScript)
 {
     yield return new WaitForSeconds(0.05f); // keeps spacebar from counting as input on this game
     playScript.playerHere = gameObject;
     if(prevMsgReset != null) {
         StopCoroutine(prevMsgReset);
     }
     playingNow = playScript;
     playingNow.gameScreen.GameStart();
     tokenBillText.text = "" + playingNow.gameName.Replace("\\n", "\n") + "\nBACKSPACE: QUIT\n" +
         playingNow.gameInstructions.Replace("\\n", "\n");
 }