// on the load of the win screen add 1 point to the current streak counter
    private void Awake()
    {
        AudioHelper.PlayClip2D(winSound, .1f);

        tracker = FindObjectOfType <StreakTracker>();
        tracker._currentStreak += 1;

        tracker.SaveStreak();
    }
    public static void SaveTracker(StreakTracker tracker)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/tracker.game";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        StreakData data = new StreakData(tracker);

        formatter.Serialize(stream, data);
        stream.Close();
    }
示例#3
0
文件: QuizState.cs 项目: Etny/Flagr
        public QuizState(int QuestionCount) : base()
        {
            this.QuestionCount = QuestionCount;

            //Set UI elements
            flags   = new FlagContainer[queueSize];
            buttons = new QuizButton[4];

            //Set question counter
            QuestionCounter = new TextLabel()
            {
                Font     = new Font("Arial", 30, FontStyle.Bold),
                DrawMode = UI.DrawMode.Centered,
                Location = new Point(currentFlagX, 40)
            };

            //Set scoring
            results = new ResultsState()
            {
                Questions      = QuestionCount,
                ScorePerAnswer = scorePerFlag
            };
            tracker = new StreakTracker()
            {
                Location = new Point(150, buttonTop + buttonHeight + (buttonSpacing / 2))
            };
            scoreLabel = new TextLabel()
            {
                Font     = new Font("Arial", 30, FontStyle.Bold),
                DrawMode = UI.DrawMode.Centered,
                Location = new Point(Program.Width - 200, buttonTop + buttonHeight + (buttonSpacing / 2)),
                Text     = "0"
            };
            scoreAddLabel = new FadeLabel()
            {
                Font       = new Font("Arial", 20, FontStyle.Bold),
                DrawMode   = UI.DrawMode.Centered,
                Location   = new Point(Program.Width - 200, buttonTop + buttonHeight + (buttonSpacing / 2)),
                Text       = "0",
                Color      = Color.Green,
                FadeTime   = .8f,
                FadeDeltaY = -100
            };

            currentFlagY = QuestionCounter.Location.Y + ((buttonTop - QuestionCounter.Location.Y) / 2);

            //Set curve for flag movement
            bezier = new BezierCurve(new PointF[] { new PointF(1, -.4f), new PointF(0.8f, 1) }, maxFreezeTime);

            //Set answer selection
            rng = new Random();

            //Add and correctly position buttons
            int[] buttonX = { Program.Width / 2 - (buttonWidth + buttonSpacing / 2), Program.Width / 2 + buttonSpacing / 2 };
            int[] buttonY = { buttonTop, buttonTop + buttonHeight + buttonSpacing };

            for (int i = 0; i < 4; i++)
            {
                buttons[i]           = new QuizButton(buttonX[i % 2], buttonY[i / 2], buttonWidth, buttonHeight, i + 1);
                buttons[i].OnSelect += ButtonPressed;
            }

            //Fill the flag queue
            for (int i = 0; i < 5; i++)
            {
                AddRandomFlag();
            }

            //Select random answers
            NextFlag();

            //Remove the flag at end of queue
            flags[queueSize - 1] = null;

            timer = new Stopwatch();
            timer.Start();
        }
示例#4
0
 private void Awake()
 {
     tracker = FindObjectOfType <StreakTracker>();
 }
 public StreakData(StreakTracker streak)
 {
     currentStreak = streak._currentStreak;
     bestStreak    = streak._bestStreak;
 }