Example #1
0
 public TutorialGUI(PlayerCounter playerCounter, bool isEnabled)
 {
     viroidTipGui = new SimpleTextGUI ("Stop red viroids from spreading!");
     this.isEnabled = isEnabled;
     tutorialPhase = TutorialPhases.wasd;
     this.playerCounter = playerCounter;
     setTutorialGraphics ();
 }
 void Awake()
 {
     tutInstructions = GameObject.Find("scoring");
     player = GameObject.FindGameObjectWithTag("Player");
     currentPhase = TutorialPhases.preparePhase;
     tutorialDialogue.SetActive(true);
     enemyTimer = 1.0f;
     player.GetComponent<PlayerController>().tutorialCheck = true;
 }
Example #3
0
    public void activate()
    {
        if (!isEnabled)
            return;

        bool swapIcon = false;
        if (Time.timeSinceLevelLoad - tutorialLastSwapTime > 1) {
            tutorialLastSwapTime = Time.timeSinceLevelLoad;
            swapIcon = true;
        }
        foreach (TutorialGraphic tg in tutorialGraphics) {
            if (tg == null)
                continue;

            if (swapIcon)
                tg.isUp = !tg.isUp;

            tg.activate ();
        }

        if (tutorialPhase == TutorialPhases.wasd) {
            for (int i=0; i<4; i++) {
                if (tutorialGraphics [i].enabled)
                    break;
                if (i == 3) {
                    tutorialPhase = TutorialPhases.jump;
                    tutorialGraphics [4].enabled = true;
                }
            }
        }

        if (tutorialPhase == TutorialPhases.jump && !tutorialGraphics [4].enabled) {
            tutorialPhase = TutorialPhases.leftclick;
            tutorialGraphics [5].enabled = true;
        }

        if (tutorialPhase == TutorialPhases.leftclick) {
            if (playerCounter.breakCount > 0) {
                tutorialPhase = TutorialPhases.rightclick;
                tutorialGraphics [5].enabled = false;
                tutorialGraphics [6].enabled = true;
            }
        }

        if (tutorialPhase == TutorialPhases.rightclick) {
            if (playerCounter.laserBreakCount > 0) {
                tutorialPhase = TutorialPhases.grav;
                tutorialGraphics [6].enabled = false;
                tutorialGraphics [7].enabled = true;
            }
        }

        if (tutorialPhase == TutorialPhases.grav) {
            if (playerCounter.usedFly) {
                tutorialPhase = TutorialPhases.viroidtip;
                viroidTipStart = Time.timeSinceLevelLoad;
                tutorialGraphics [7].enabled = false;
            }
        }

        if (tutorialPhase == TutorialPhases.viroidtip) {
            viroidTipGui.draw ();

            if (Time.timeSinceLevelLoad - viroidTipStart > 10)
                tutorialPhase = TutorialPhases.done;
        }
    }
    // Update is called once per frame
    void Update()
    {
        switch (currentPhase)
        {
            case TutorialPhases.preparePhase:
            if(tutorialDialogue.transform.FindChild("DialogueSystem").GetComponent<DialogueSystemScript>().firstStop == true)
            {
                currentPhase = TutorialPhases.shootPhase;
            }
            break;

            case TutorialPhases.shootPhase:

            tutInstructions.GetComponent<Text>().text = "Drag anywhere the Screen to Move Around";
            #if UNITY_EDITOR
            if (Input.GetMouseButton(0))
            {
                actionsDone += Time.deltaTime;
            }
            #endif

            #if UNITY_ANDROID
            int numberOfTouches = Input.touchCount;
            //move the player based on the deltaPosition of the Touch
            for (int i = 0; i < numberOfTouches; ++i)
            {
                Touch touch = Input.GetTouch(i);

                if(touch.phase == TouchPhase.Began)
                {
                    actionsDone += Time.deltaTime;
                }
                else if(touch.phase == TouchPhase.Moved)
                {
                    actionsDone += Time.deltaTime;
                }
            }
            #endif

            //check how much actionsDone have done
            if (actionsDone > 1.0f)
            {
        //              currentPhase = TutorialPhases.enemyPhase;
                if(diaActivated == false){
                    tutorialDialogue.transform.FindChild("DialogueSystem").GetComponent<DialogueSystemScript>().ActivateDialogue(true);
                    diaActivated = true;
                }
                if(diaActivated == true && tutorialDialogue.transform.FindChild("DialogueSystem").GetComponent<DialogueSystemScript>().dialogueActive == false)
                {
                    currentPhase = TutorialPhases.enemyPhase;
                    diaActivated = false;
                }
            }
            break;

            case TutorialPhases.enemyPhase:
            tutInstructions.GetComponent<Text>().text = "Kill enemies to Reach 20 Combo";

            enemyTimer -= Time.deltaTime;
            if (enemyTimer <= 0.0f && diaActivated == false)
            {
                GameObject go = Instantiate(tutorialEnemyWave[Random.Range(0, 3)]) as GameObject;
                go.SetActive(true);
                enemyTimer = 1.0f;
            }
            if (player.GetComponent<PlayerController>().comboCount >= 20)
            {
        //				currentPhase = TutorialPhases.getHitPhase;
        //				tutorialDialogue.transform.FindChild("DialogueSystem").GetComponent<DialogueSystemScript>().ActivateDialogue(true);

                if(diaActivated == false){
                    tutorialDialogue.transform.FindChild("DialogueSystem").GetComponent<DialogueSystemScript>().ActivateDialogue(true);
                    diaActivated = true;
                }
                if(diaActivated == true && tutorialDialogue.transform.FindChild("DialogueSystem").GetComponent<DialogueSystemScript>().dialogueActive == false)
                {
                    currentPhase = TutorialPhases.getHitPhase;
                    diaActivated = false;
                }
            }
            break;

            case TutorialPhases.getHitPhase:
            tutInstructions.GetComponent<Text>().text = "See what happens when you get hit";
            if(diaActivated == false)
            {
                player.GetComponent<PlayerController>().controllable = false;
                if(spawnShootEnemy == false)
                {
                    GameObject go = Instantiate(tutorialEnemyWave[4]) as GameObject;
                    go.SetActive(true);
                    spawnShootEnemy = true;
                }
            }
            if (player.GetComponent<PlayerController>().emotionPoint <= 1)
            {
                actionsDone += Time.deltaTime;
                if(actionsDone > 5.0f)
                {

        //					currentPhase = TutorialPhases.practicePhase;
        //					tutorialDialogue.transform.FindChild("DialogueSystem").GetComponent<DialogueSystemScript>().ActivateDialogue(true);

                    if(diaActivated == false){
                        tutorialDialogue.transform.FindChild("DialogueSystem").GetComponent<DialogueSystemScript>().ActivateDialogue(true);
                        diaActivated = true;
                    }
                    if(diaActivated == true && tutorialDialogue.transform.FindChild("DialogueSystem").GetComponent<DialogueSystemScript>().dialogueActive == false)
                    {
                        //player.GetComponent<PlayerController>().firstShield.GetComponent<SpriteRenderer>().enabled = true;
                        currentPhase = TutorialPhases.practicePhase;
                        diaActivated = false;
                    }
                }
            }
            break;

            case TutorialPhases.practicePhase:
            tutInstructions.GetComponent<Text>().text = "Get 40 Combo";
            if(diaActivated == false){
                player.GetComponent<PlayerController>().controllable = true;
                enemyTimer -= Time.deltaTime;
                if (enemyTimer <= 0.0f)
                {
                    GameObject go = Instantiate(tutorialEnemyWave[Random.Range(0, 4)]) as GameObject;
                    go.SetActive(true);
                    enemyTimer = Random.Range(0.5f, 1.0f);
                }
            }
            if (player.GetComponent<PlayerController>().comboCount >= 40)
            {
        //				tutorialDialogue.transform.FindChild("DialogueSystem").GetComponent<DialogueSystemScript>().ActivateDialogue(true);
        //				currentPhase = TutorialPhases.endPhase;

                if(diaActivated == false){
                    tutorialDialogue.transform.FindChild("DialogueSystem").GetComponent<DialogueSystemScript>().ActivateDialogue(true);
                    diaActivated = true;
                }
                if(diaActivated == true && tutorialDialogue.transform.FindChild("DialogueSystem").GetComponent<DialogueSystemScript>().dialogueActive == false)
                {
                    currentPhase = TutorialPhases.endPhase;
                    diaActivated = false;
                }
            }
            break;

            case TutorialPhases.endPhase:
            tutInstructions.GetComponent<Text>().text = "End of Tutorial";

            //set tutorial complete flag
            PlayerPrefs.SetInt("ppFirstPlay", 1);
            Social.ReportProgress("CgkI__bt5ooSEAIQAQ", 100.0f, (bool success) =>{

            });
            if(PlayerPrefs.GetInt("ppFirstPlay") > 0)
            {
                currentPhase = TutorialPhases.backPhase;
            }
            break;

            case TutorialPhases.backPhase:
            actionsDone += Time.deltaTime;
            if(actionsDone > 4.0f)
            {
                Application.LoadLevel("worldSelect");
            }
            break;
        }
    }
 IEnumerator ChangeStateDelay(TutorialPhases state, float time)
 {
     yield return new WaitForSeconds(time);
     currentPhase = state;
     StopCoroutine("ChangeAIStateDelay");
 }