Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        // keeps track of time since last star for hint purposes
        timeSinceLastStar += 1 * Time.deltaTime;

        // turn on different hints depending on how long since last star
        if (Math.Ceiling(timeSinceLastStar) % 60 == 5 && !gameOver)
        {
            StartFirstHint();
        }
        else if (Math.Ceiling(timeSinceLastStar) % 60 == 10 && !gameOver)
        {
            StartSecondHint();
        }
        else if (Math.Ceiling(timeSinceLastStar) % 60 == 15 && !gameOver)
        {
            StartThirdHint();
        }

        // crosshair movement
        if (canMove)
        {
            if ((Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W)) && !crosshairUp)
            {
                this.transform.Translate(Vector2.up * movementOffset * Time.deltaTime);
            }
            if ((Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) && !crosshairDown)
            {
                this.transform.Translate(Vector2.down * movementOffset * Time.deltaTime);
            }
            if ((Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) && !crosshairLeft)
            {
                this.transform.Translate(Vector2.left * movementOffset * Time.deltaTime);
            }
            if ((Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) && !crosshairRight)
            {
                this.transform.Translate(Vector2.right * movementOffset * Time.deltaTime);
            }
        }

        // camera movement
        if (crosshairUp && !gameOver)
        {
            cameraMovementScript.moveUp();
        }
        if (crosshairDown && !gameOver)
        {
            cameraMovementScript.moveDown();
        }
        if (crosshairLeft && !gameOver)
        {
            cameraMovementScript.moveLeft();
        }
        if (crosshairRight && !gameOver)
        {
            cameraMovementScript.moveRight();
        }

        // logic for star being clicked
        if (Input.GetKeyUp(KeyCode.Return) && canClick && starText.text == targetScript.GetTarget() && !gameOver)
        {
            canClick = false;
            increaseScore(scoreIncrement);
            Invoke("CooledDown", coolDown);
            ResetHints();
            ChangeTargetStarColor();
            UpdateTargetStarDebug();
        }

        //logic for clicking a star that is not the target to play sound effect
        if (Input.GetKeyUp(KeyCode.Return) && canClick && starText.text != targetScript.GetTarget() &&
            starText.text != "" && !gameOver)
        {
            lastStar = GameObject.Find(starText.text);
            lastStar.transform.GetChild(1).GetComponent <SpriteRenderer>().enabled = true;
            Invoke("disableX", .6F);
            canClick = false;
            Invoke("CooledDown", coolDown);
            incorrectSound.Play();
        }

        // save score and load next screen when launch button pressed at end of game
        if (Input.GetKeyUp(KeyCode.Return) && launchButtonHovered)
        {
            lvlr.LoadNextLevelWithFinalInfo(currentScore, getStarsCollectedList(), timer.GetTimeLeft());
        }

        //testing increaseScore
        if (Input.GetKeyDown(KeyCode.Q) && !gameOver)
        {
            increaseScore(scoreIncrement);
        }

        // testing load with final score
        if (Input.GetKeyDown(KeyCode.E) && !gameOver)
        {
            lvlr.LoadNextLevelWithFinalInfo(currentScore, getStarsCollectedList(), GameObject.Find("Timer").GetComponent <TimerScript>().GetTimeLeft());
        }

        // cycle target star
        if (Input.GetKeyDown(KeyCode.T) || Input.GetKeyDown(KeyCode.N) && !gameOver)
        {
            UpdateTargetStarDebug();
        }

        // audio hint
        if (isAudioHint && !gameOver)
        {
            // gets distance from crosshair to target star
            double distanceToTarget = (Vector2.Distance(gameObject.transform.position, GameObject.Find(targetScript.GetTarget()).transform.position));
            // need to keep track to see if the sound actually changed so we can call Play on the Audio Source
            AudioClip prevSound = hintSound.clip;
            if (distanceToTarget > 15)
            {
                hintSound.clip = farSound;
            }
            else if (distanceToTarget > 7)
            {
                hintSound.clip = midSound;
            }
            else if (distanceToTarget > 1.5)
            {
                hintSound.clip = closeSound;
            }
            else
            {
                hintSound.clip = rapidSound;
            }
            if (prevSound != hintSound.clip)
            {
                hintSound.Play();
            }
        }

        // updates arrow hint while arrow hint is active
        if (isArrowHint && !gameOver)
        {
            UpdateArrows();
        }

        // first hint (star blinking)
        if (firstHintCalled && !gameOver)
        {
            blinkStar.transform.localScale += scaleChange;

            if (blinkStar.transform.localScale.x < 1.8f || blinkStar.transform.localScale.x > 2.4f)
            {
                scaleChange = -scaleChange;
            }
        }
    }
Esempio n. 2
0
    protected virtual void Update()
    {
        Conversation();

        if (Input.GetKeyDown(KeyCode.Alpha1) && isOption)
        {
            choice = 0;
            _timer.StopTimer();
            hasAnswer = true;
        }
        if (Input.GetKeyDown(KeyCode.Alpha2) && isOption)
        {
            choice = 1;
            _timer.StopTimer();
            hasAnswer = true;
        }
        if (Input.GetKeyDown(KeyCode.Alpha3) && isOption)
        {
            choice = 2;
            _timer.StopTimer();
            hasAnswer = true;
        }
        if (Input.GetKeyDown(KeyCode.Alpha4) && isOption)
        {
            choice = 3;
            _timer.StopTimer();
            hasAnswer = true;
        }

        if (_timer.GetTimeLeft() <= 0 && isOption)
        {
            choice = 3;
            _timer.StopTimer();
            hasAnswer = true;
        }

        if (choice != -1)
        {
            popup.gameObject.SetActive(false);
            finalScore += currNode.optionList[choice].score;

            if (currNode.optionList[choice].factionChurch < 0)
            {
                FactionManager.ClericBadValue += Mathf.Abs(currNode.optionList[choice].factionChurch);
            }
            FactionManager.ClericGoodValue += currNode.optionList[choice].factionChurch;

            if (currNode.optionList[choice].factionPolitics < 0)
            {
                FactionManager.PoliticBadValue += Mathf.Abs(currNode.optionList[choice].factionPolitics);
            }
            FactionManager.PoliticGoodValue += currNode.optionList[choice].factionPolitics;

            if (currNode.optionList[choice].factionArmy < 0)
            {
                FactionManager.ArmyBadValue += Mathf.Abs(currNode.optionList[choice].factionArmy);
            }
            FactionManager.ArmyGoodValue += currNode.optionList[choice].factionArmy;

            if (currNode.optionList[choice].factionCult < 0)
            {
                FactionManager.CultBadValue += Mathf.Abs(currNode.optionList[choice].factionCult);
            }
            FactionManager.CultGoodValue += currNode.optionList[choice].factionCult;

            PopupManager.CultGainedRep     += currNode.optionList[choice].factionCult;
            PopupManager.ArmyGainedRep     += currNode.optionList[choice].factionArmy;
            PopupManager.ChurchGainedRep   += currNode.optionList[choice].factionChurch;
            PopupManager.PoliticsGainedRep += currNode.optionList[choice].factionPolitics;
            PopupManager.GainedFollowers   += currNode.optionList[choice].score;
            ChangeNode();
        }

        if (Input.GetKeyDown(KeyCode.Space) && isPopup)
        {
            popup.gameObject.SetActive(false);
            isOption = true;
        }

        if (Input.GetKeyDown(KeyCode.Space) && !isTyping)
        {
            if (!isOption && !isPopup && NPC.GetComponent <CharClick>().IsOnDial())
            {
                index++;
                finishedTyping = false;
            }
        }
    }