Пример #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;
        }
    }
Пример #2
0
        public static void Main(string[] args)
        {
            int star1 = Star1.GetMultiplyExpensesEqualsTo2020();
            int star2 = Star2.GetMultiplyExpensesEqualsTo2020();

            Console.WriteLine($"Star 1: { star1 }");
            Console.WriteLine($"Star 2: { star2 }");
            Console.ReadKey();
        }
Пример #3
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);
        }
Пример #4
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;
            }
        }
    }
Пример #5
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);
        }
    }