Exemplo n.º 1
0
    public void ChangeStars()
    {
        //Get the amount of stars of the current level and display them
        starsToDisplay = currentLevel.currentStars;

        switch (starsToDisplay)
        {
        case 0:
            Star0.SetActive(true);
            break;

        case 1:
            Star0.SetActive(false);
            Star1.SetActive(true);
            break;

        case 2:
            Star1.SetActive(false);
            Star2.SetActive(true);
            break;

        case 3:
            Star2.SetActive(false);
            Star3.SetActive(true);
            break;
        }
    }
 public void ChangeProgress(float NewProgress)
 {
     //Setting the stars active based on the amount of progress.
     transform.localScale = new Vector2(NewProgress, transform.localScale.y);
     progress             = NewProgress;
     if (progress > (1f / 3f))
     {
         Star1.SetActive(true);
     }
     else
     {
         Star1.SetActive(false);
     }
     if (progress > (2f / 3f))
     {
         Star2.SetActive(true);
     }
     else
     {
         Star2.SetActive(false);
     }
     if (progress == 1f)
     {
         Star3.SetActive(true);
     }
     else
     {
         Star3.SetActive(false);
     }
 }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()         //Mise en Place de la Scene.
    {
        End   = GameObject.Find("End");
        Star1 = GameObject.Find("1 Star");
        Star2 = GameObject.Find("2 Star");
        Star3 = GameObject.Find("3 Star");
        Star1.SetActive(false);
        Star2.SetActive(false);
        Star3.SetActive(false);
        Fermeture = GameObject.Find("Fermeture");
        Bienjoue  = GameObject.Find("BienJoué");
        genial    = GameObject.Find("Génial");
        excellent = GameObject.Find("Excellent");
        score     = GameObject.Find("Score");
        Fermeture.SetActive(false);
        Bienjoue.SetActive(false);
        genial.SetActive(false);
        excellent.SetActive(false);
        next = GameObject.Find("Next Level").GetComponent <Button>();

        score.GetComponent <Text>().text = "Score: " + GameManager.Score.ToString();

        switch (GameManager.Stars)
        {
        case 0:
            GameObject.Find("Main Camera").GetComponent <AudioSource>().clip = bad;
            GameObject.Find("Main Camera").GetComponent <AudioSource>().Play();
            Fermeture.SetActive(true);
            next.interactable = false;
            break;

        case 1:
            GameObject.Find("Main Camera").GetComponent <AudioSource>().clip = applause;
            GameObject.Find("Main Camera").GetComponent <AudioSource>().Play();
            Bienjoue.SetActive(true);
            Star1.SetActive(true);
            break;

        case 2:
            GameObject.Find("Main Camera").GetComponent <AudioSource>().clip = applause;
            GameObject.Find("Main Camera").GetComponent <AudioSource>().Play();
            genial.SetActive(true);
            Star1.SetActive(true);
            Star2.SetActive(true);
            break;

        case 3:
            GameObject.Find("Main Camera").GetComponent <AudioSource>().clip = applause;
            GameObject.Find("Main Camera").GetComponent <AudioSource>().Play();
            excellent.SetActive(true);
            Star1.SetActive(true);
            GameObject.Find("Canvas").GetComponent <AudioSource>().PlayOneShot(good);
            Star2.SetActive(true);
            Star3.SetActive(true);
            break;
        }
    }
 void Start()
 {
     transform = GetComponent <RectTransform> ();
     width     = transform.rect.width;
     frame     = GameObject.Find("Frame").GetComponent <RectTransform> ();
     Star1     = GameObject.Find("Star1");
     Star1.SetActive(false);
     Star2 = GameObject.Find("Star2");
     Star2.SetActive(false);
     Star3 = GameObject.Find("Star3");
     Star3.SetActive(false);
 }
Exemplo n.º 5
0
    public void OnContinueClicked()
    {
        HidePopup();
        StartCoroutine(DeActivate(1f, () => { if (ContinueClicked != null)
                                              {
                                                  ContinueClicked();
                                              }
                                  }));
        AudioManager.Instance.PlaySound(AudioManager.SFX.CLICK);

        StarsPanel.SetActive(false);
        Star1.SetActive(false);
        Star2.SetActive(false);
        Star3.SetActive(false);
    }
Exemplo n.º 6
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);

            AlignText(WinningText, Alignment.Center, 25);
            AlignText(ScoreText, Alignment.Center, 175);

            ScoreText.Text = DisplayedScore.ToString("N0");

            WinningText.Draw(spriteBatch);
            ScoreText.Draw(spriteBatch);

            RestartButton.Draw(spriteBatch);
            NextButton.Draw(spriteBatch);

            Star1.Draw(spriteBatch);
            Star2.Draw(spriteBatch);
            Star3.Draw(spriteBatch);
        }
Exemplo n.º 7
0
 void OutputStar()
 {
     if (PlayerPrefs.GetInt("Score") < 6)
     {
     }
     if (PlayerPrefs.GetInt("Score") > 6 && PlayerPrefs.GetInt("Score") < 12)
     {
         Star1.SetActive(true);
     }
     if (PlayerPrefs.GetInt("Score") > 12 && PlayerPrefs.GetInt("Score") < 20)
     {
         Star1.SetActive(true);
         Star2.SetActive(true);
     }
     if (PlayerPrefs.GetInt("Score") > 20)
     {
         Star1.SetActive(true);
         Star2.SetActive(true);
         Star3.SetActive(true);
     }
 }
Exemplo n.º 8
0
    IEnumerator ShowStars(int starsCount)
    {
        yield return(new WaitForSeconds(1f));

        if (starsCount >= 1)
        {
            Star1.SetActive(true);
            AudioManager.Instance.PlaySound(AudioManager.SFX.STAR);
            yield return(new WaitForSeconds(0.5f));
        }

        if (starsCount >= 2)
        {
            Star2.SetActive(true);
            AudioManager.Instance.PlaySound(AudioManager.SFX.STAR);
            yield return(new WaitForSeconds(0.5f));
        }

        if (starsCount >= 3)
        {
            Star3.SetActive(true);
            AudioManager.Instance.PlaySound(AudioManager.SFX.STAR);
        }
    }
Exemplo n.º 9
0
 public void Configure(int StarAchieved)
 {
     Star1.SetActive(StarAchieved >= 1);
     Star2.SetActive(StarAchieved >= 2);
     Star3.SetActive(StarAchieved >= 3);
 }
Exemplo n.º 10
0
    void Update()
    {
        if (showScoreCircles && CameraManager.cameraAdjusted)
        {
            if (ang < maxAng)
            {
                ang += Time.deltaTime * 300;
            }
            else
            {
                ang = maxAng;
            }
            levelSquare.transform.localRotation = Quaternion.AngleAxis(ang, Vector3.back);

            UpdatePlatformObjectProperties(currentScoreCircle, currentScoreCirclePos, 1f, true, true);
            UpdatePlatformObjectProperties(prevScoreCircleFar, prevScoreCircleFarPos, circleAlphaFar, true, true);
            UpdatePlatformObjectProperties(prevScoreCircleNear, prevScoreCircleNearPos, circleAlphaNear, true, true);
            UpdatePlatformObjectProperties(nextScoreCircleNear, nextScoreCircleNearPos, circleAlphaNear, true, true);
            UpdatePlatformObjectProperties(nextScoreCircleFar, nextScoreCircleFarPos, circleAlphaFar, true, true);

            UpdatePlatformObjectProperties(hintButton, hintButtonPos, 1f, true, false);

            UpdatePlatformObjectProperties(timerCircle3Star, timerCircle3Pos, 1f, false, false);
            UpdatePlatformObjectProperties(timerCircle2Star, timerCircle2Pos, 1f, false, false);
            UpdatePlatformObjectProperties(timerCircle1Star, timerCircle1Pos, 1f, false, false);

            if (prevScoreCircleFar.transform.localPosition == prevScoreCircleFarPos)
            {
                showScoreCircles = false;
            }
        }

        if (WaitForHintFlag && !waitingFlag)
        {
            if (score == 0 || score == 1)
            {
                StartCoroutine(WaitForHint(2.0f));
            }
            else
            {
                StartCoroutine(WaitForHint(1.0f));
            }
        }

        if (ShowHintScreenFlag)
        {
            hintScreen.transform.localScale = Vector3.Lerp(hintScreen.transform.localScale, hintScreenSize, circleSpeed * Time.deltaTime);
        }

        if (HideHintScreenFlag)
        {
            hintScreen.transform.localScale = Vector3.Lerp(hintScreen.transform.localScale, hintScreenCollapseSize, circleSpeed * Time.deltaTime);
        }



        if (StartTimerFlag && !PauseTimerFlag)
        {
            if (!timerSlider.activeSelf)
            {
                timerSlider.SetActive(true);

                homeButton.SetActive(false);
                pauseButton.SetActive(true);
            }

            float currTime = TimeManager.GetCurrentTime() - pauseDuration;

            if (currTime < TimeManager.time3star)
            {
                timerStartCounter3 += Time.deltaTime / TimeManager.time3star;
                timerSlider.transform.localPosition = Vector3.Lerp(timerSliderInitPos, timerCircle3Star.transform.localPosition, timerStartCounter3);
                timerSlider.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColour3Star"];
            }
            else if (currTime < TimeManager.time2star)
            {
                timerStartCounter2 += Time.deltaTime / (TimeManager.time2star - TimeManager.time3star);
                timerSlider.transform.localPosition = Vector3.Lerp(timerCircle3Star.transform.localPosition, timerCircle2Star.transform.localPosition, timerStartCounter2);
                timerSlider.GetComponent <SpriteRenderer> ().color      = colourDict ["TimerColour2Star"];
                timerCircle3Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColourOff"];
                timerCircle3Star.GetComponentInChildren <Text> ().text  = "";
            }
            else if (currTime < TimeManager.time1star)
            {
                timerStartCounter1 += Time.deltaTime / (TimeManager.time1star - TimeManager.time2star);
                timerSlider.transform.localPosition = Vector3.Lerp(timerCircle2Star.transform.localPosition, timerCircle1Star.transform.localPosition, timerStartCounter1);
                timerSlider.GetComponent <SpriteRenderer> ().color      = colourDict ["TimerColour1Star"];
                timerCircle2Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColourOff"];
                timerCircle2Star.GetComponentInChildren <Text> ().text  = "";
                timerCircle3Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColourOff"];
                timerCircle3Star.GetComponentInChildren <Text> ().text  = "";
            }
            else
            {
                timerCircle2Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColourOff"];
                timerCircle2Star.GetComponentInChildren <Text> ().text  = "";
                timerCircle3Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColourOff"];
                timerCircle3Star.GetComponentInChildren <Text> ().text  = "";
            }
        }

        if (ScoreCompleteFlag)
        {
            UpdatePlatformObjectProperties(prevScoreCircleFar, currentScoreCirclePos, 0f, true, true);
            UpdatePlatformObjectProperties(prevScoreCircleNear, currentScoreCirclePos, 0f, true, true);
            UpdatePlatformObjectProperties(nextScoreCircleNear, currentScoreCirclePos, 0f, true, true);
            UpdatePlatformObjectProperties(nextScoreCircleFar, currentScoreCirclePos, 0f, true, true);

            Color newColor = Color.Lerp(currentScoreCircle.GetComponent <SpriteRenderer> ().color, LevelColour, alphaSpeed * Time.deltaTime);
            currentScoreCircle.GetComponent <SpriteRenderer> ().color = newColor;
            currentScoreCircle.GetComponentInChildren <Text> ().color = newColor;

            if (prevScoreCircleFar.transform.localPosition == currentScoreCircle.transform.localPosition)
            {
                print("SCORE COMPLETED.....");

                //Flip tiles to show menu items
                flipTilesFlag     = true;
                ScoreCompleteFlag = false;

                HintEnabled = false;

                CameraManager.ZoomInPlatform();

                homeButton.SetActive(true);
                pauseButton.SetActive(false);
            }
        }

        //Flip tiles to show Menu
        if (flipTilesFlag)
        {
            FlipTilesAndShowMenu();
        }

        //Show Menu Screen
        if (ShowStarsFlag)
        {
            if (!TimeTakenShown)
            {
                TimeTakenObj = Instantiate(TimeTakenText, transform);
                TimeTakenObj.transform.position = Star2.transform.position + new Vector3(0, 2, 0);
                TimeTakenObj.GetComponentInChildren <Text> ().text = "Completed in " + TimeManager.GetTimeTaken() + "s.";
                TimeTakenShown = true;
            }

            Quaternion _targetRotation = Quaternion.Euler(new Vector3(0, 0, 180));

            if (myStar >= 1 && !Star1RotCompleteFlag)
            {
                Star1.GetComponent <SpriteRenderer>().color = Color.Lerp(Star1.GetComponent <SpriteRenderer> ().color, colourDict ["StarColour"], alphaSpeed * Time.deltaTime);

                Star1.transform.localRotation = Quaternion.Lerp(Star1.transform.localRotation, _targetRotation, 10 * Time.deltaTime);
                Star1.transform.localScale    = Vector3.Lerp(Star1.transform.localScale, new Vector3(0.6f, 0.6f, 0.6f), 10 * Time.deltaTime);
                if (Star1.transform.localRotation == _targetRotation)
                {
                    Star1RotCompleteFlag = true;
                }
            }
            if (myStar >= 2 && !Star2RotCompleteFlag && Star1RotCompleteFlag)
            {
                Star2.GetComponent <SpriteRenderer>().color = Color.Lerp(Star2.GetComponent <SpriteRenderer> ().color, colourDict ["StarColour"], alphaSpeed * Time.deltaTime);

                Star2.transform.localRotation = Quaternion.Lerp(Star2.transform.localRotation, _targetRotation, 10 * Time.deltaTime);
                Star2.transform.localScale    = Vector3.Lerp(Star2.transform.localScale, new Vector3(0.6f, 0.6f, 0.6f), 10 * Time.deltaTime);
                if (Star2.transform.localRotation == _targetRotation)
                {
                    Star2RotCompleteFlag = true;
                }
            }
            if (myStar >= 3 && !Star3RotCompleteFlag && Star2RotCompleteFlag)
            {
                Star3.GetComponent <SpriteRenderer>().color = Color.Lerp(Star3.GetComponent <SpriteRenderer> ().color, colourDict ["StarColour"], alphaSpeed * Time.deltaTime);

                _targetRotation = Quaternion.Euler(new Vector3(0, 0, 180));
                Star3.transform.localRotation = Quaternion.Lerp(Star3.transform.localRotation, _targetRotation, 10 * Time.deltaTime);
                Star3.transform.localScale    = Vector3.Lerp(Star3.transform.localScale, new Vector3(0.6f, 0.6f, 0.6f), 10 * Time.deltaTime);
                if (Star3.transform.localRotation == _targetRotation)
                {
                    Star3RotCompleteFlag = true;
                }
            }

            if ((myStar == 1 && Star1RotCompleteFlag) || (myStar == 2 && Star2RotCompleteFlag) || (myStar == 3 && Star3RotCompleteFlag))
            {
                ShowStarsFlag = false;
            }
        }

        //Retry enabled
        if (RetryPlatformFlag)
        {
            UpdatePlatformObjectProperties(prevScoreCircleFar, prevScoreCircleFarPos, circleAlphaFar, true, true);
            UpdatePlatformObjectProperties(prevScoreCircleNear, prevScoreCircleNearPos, circleAlphaNear, true, true);
            UpdatePlatformObjectProperties(nextScoreCircleNear, nextScoreCircleNearPos, circleAlphaNear, true, true);
            UpdatePlatformObjectProperties(nextScoreCircleFar, nextScoreCircleFarPos, circleAlphaFar, true, true);

            timerCircle3Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColour3Star"];
            timerCircle2Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColour2Star"];
            timerCircle1Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColour1Star"];

            timerCircle3Star.GetComponentInChildren <Text> ().text = transform.GetComponent <TimeManager> ().time3star.ToString() + " s";
            timerCircle2Star.GetComponentInChildren <Text> ().text = transform.GetComponent <TimeManager> ().time2star.ToString() + " s";
            timerCircle1Star.GetComponentInChildren <Text> ().text = transform.GetComponent <TimeManager> ().time1star.ToString() + " s";

            if (prevScoreCircleFar.transform.localPosition == prevScoreCircleFarPos)
            {
                RetryPlatformFlag = false;
            }
        }
    }
Exemplo n.º 11
0
    public void countPoints()
    {
        Time.timeScale = 0; //Pausa spelet och tiden
        int numSaved = 0;

        Points += timeFactor * countdownScript.getTimeLeft();
        victims = GameObject.FindGameObjectsWithTag("Victim");
        foreach (GameObject victim in victims)
        {
            victimParam = victim.GetComponent <Parameters>();
            Dictionary <string, object> ParamDic = victimParam.getParamHash();
            if ((string)ParamDic["SetPrio"] == "unset")
            {
                Points -= unSetTriagePenelty;
            }
            else if ((string)ParamDic["SetPrio"] == ParamDic["prio"].ToString().ToLower())
            {
                Debug.Log("Correct");
                numSaved += 1;
                Points   += correctTriagePoint;
            }
            else if ((string)ParamDic["SetPrio"] != ParamDic["prio"].ToString().ToLower())
            {
                Debug.Log("incorrect");
                Points -= incorrectTriagePenelty;
            }
            if ((bool)ParamDic["Bleeding"] == true)
            {
                Debug.Log("Bleeding");
                Points -= incorrectTriagePenelty;
            }
            //Debug.Log(ParamDic["prio"]+" : "+ParamDic["SetPrio"]);
        }
        foreach (GameObject item in GameOverList)
        {
            item.SetActive(true);
        }
        //Behöver göras dynamisk när vi har fler levels

        if (Points <= 0)
        {
            PointRatio = 0;
        }
        else
        {
            PointRatio = Points; //Kvot för nuv. poäng genom tot. möjliga poäng * 100
        }

        PointsTxt.text = PointRatio.ToString();
        LevelTxt.text  = "1";
        int starCapPoint = victims.Length * correctTriagePoint;

        Debug.Log(PointRatio + " : " + starCapPoint);
        if (PointRatio > starCapPoint * 0.25f)
        {
            Star1.SetActive(true);
        }

        if (PointRatio > starCapPoint * 0.5f)
        {
            Star2.SetActive(true);
        }

        if (PointRatio >= starCapPoint)
        {
            Star3.SetActive(true);
        }
    }