Ejemplo n.º 1
0
    protected override void Start()
    {
        base.Start();

        answerSlots    = new Text[4];
        answerBlocks   = new AnswerBlock[4];
        fakeAnswers    = new HashSet <int> ();
        correctPlayers = new HashSet <int> ();
        gameMgr        = GameObject.Find("GameManager").GetComponent <GameManager> ();
        Transform canvas = GameObject.Find("HPBars").transform.Find("SphinxCanvas");

        panel            = canvas.Find("Panel").GetComponent <Image> ();
        question         = panel.GetComponentInChildren <Text> ();
        countdown        = canvas.Find("Countdown").GetComponent <Text> ();
        answer1          = canvas.Find("Answer1").GetComponent <Text> ();
        answer2          = canvas.Find("Answer2").GetComponent <Text> ();
        answer3          = canvas.Find("Answer3").GetComponent <Text> ();
        answer4          = canvas.Find("Answer4").GetComponent <Text> ();
        answerBlock1     = transform.FindChild("answerBlock1").GetComponent <AnswerBlock> ();
        answerBlock2     = transform.FindChild("answerBlock2").GetComponent <AnswerBlock> ();
        answerBlock3     = transform.FindChild("answerBlock3").GetComponent <AnswerBlock> ();
        answerBlock4     = transform.FindChild("answerBlock4").GetComponent <AnswerBlock> ();
        answerSlots [0]  = answer1;
        answerSlots [1]  = answer2;
        answerSlots [2]  = answer3;
        answerSlots [3]  = answer4;
        answerBlocks [0] = answerBlock1;
        answerBlocks [1] = answerBlock2;
        answerBlocks [2] = answerBlock3;
        answerBlocks [3] = answerBlock4;

        AskQuestion();
    }
Ejemplo n.º 2
0
 public BlockMatcher(GameObject equationBlock, GameObject answerBlock)
 {
     equationBlockScript = equationBlock.GetComponent <EquationBlock>();
     answerBlockScript   = answerBlock.GetComponent <AnswerBlock>();
     this.answerBlock    = answerBlock;
     this.equationBlock  = equationBlock;
     CheckMatch();
 }
Ejemplo n.º 3
0
        public SpeedState()
        {
            water   = new FancyWater(WaterLine, waterHeight, waterPoints, waterColor);
            results = new SpeedResultsState();

            scoreLabel = new TextLabel()
            {
                Font     = new Font("Arial", 30, FontStyle.Bold),
                DrawMode = UI.DrawMode.Centered,
                Location = new Point(Program.Width - 120, 60),
                Text     = "0"
            };

            scoreAddLabel = new FadeLabel()
            {
                Font       = new Font("Arial", 20, FontStyle.Bold),
                DrawMode   = UI.DrawMode.Centered,
                Location   = new Point(Program.Width - 120, 60),
                Text       = "0",
                FadeTime   = .8f,
                FadeDeltaY = -60
            };

            timeLabel = new TextLabel()
            {
                Font     = new Font("Arial", 30, FontStyle.Bold),
                DrawMode = UI.DrawMode.Centered,
                Location = new Point(Program.Width / 2, 60)
            };

            SetTimeLabel();

            Size blockSize = new Size(Program.Width / 3 + 1, Program.Height - (WaterLine + waterHeight));

            blocks    = new AnswerBlock[3];
            blocks[0] = new AnswerBlock(new Point(0, WaterLine + waterHeight), Color.Red, blockSize, "A", 0, this);
            blocks[1] = new AnswerBlock(new Point(blockSize.Width, WaterLine + waterHeight), Color.Green, blockSize, "B", 1, this);
            blocks[2] = new AnswerBlock(new Point(blockSize.Width * 2, WaterLine + waterHeight), Color.Blue, blockSize, "C", 2, this);

            ParseBoatData();

            AddBoat();
        }
Ejemplo n.º 4
0
        protected override void KeyPressed(KeyEventArgs e, bool repeating)
        {
            if (e.KeyCode == Keys.Escape)
            {
                Program.SetCurrentState(new TransitionState(this, Program.MainMenu, .4f, .1f, .4f));
            }

            if (repeating || !buttonKeys.Contains(e.KeyCode))
            {
                return;
            }

            int         buttonsPerBlock = blocks[0].Buttons.Length;
            int         index           = buttonKeys.IndexOf(e.KeyCode) % (blocks.Length * buttonsPerBlock);
            AnswerBlock block           = blocks[index / blocks.Length];


            if (block.Enabled)
            {
                block.Buttons[index % buttonsPerBlock].Select();
            }
        }
Ejemplo n.º 5
0
        public static int RateScores(this AnswerBlock ansBlock, List <PatternAnswerSheet> partialSheet, bool[,] givenAnswers, bool multipleAnswers)
        {
            int scores = 0;

            var answerArray = ProcessSheetAnswers(partialSheet);

            for (int i = 0; i < partialSheet.Count; i++)
            {
                if (multipleAnswers)
                {
                    bool allRight  = true;
                    bool hasMarked = false;
                    for (int j = 0; j < partialSheet[i].Answer.Length; j++)
                    {
                        if (givenAnswers[i, j] != answerArray[i][j])
                        {
                            allRight = false;
                        }
                        if (givenAnswers[i, j])
                        {
                            hasMarked = true;
                        }
                    }
                    if (!hasMarked)
                    {
                        scores += 0;
                    }
                    else if (allRight)
                    {
                        scores += 1;
                    }
                    else
                    {
                        scores += -1;
                    }
                }
                else
                {
                    double match = 0;
                    var    CorrectAnswersNumber = 0;

                    for (int j = 0; j < answerArray[i].Count; j++)
                    {
                        if (givenAnswers[i, j] == answerArray[i][j])
                        {
                            if (answerArray[i].Where(x => x == true).Count() > 1)
                            {
                                match += 1;
                                CorrectAnswersNumber++;
                            }
                            if (match == answerArray[i].Where(x => x == true).Count())
                            {
                                match = 1;
                            }
                            else if (match < answerArray[i].Where(x => x == true).Count() && CorrectAnswersNumber == answerArray[i].Where(x => x == true).Count())
                            {
                                match = 0.5;
                            }

                            else
                            {
                                match = 1;
                            }
                        }
                        else
                        {
                            match = 0;
                        }
                    }

                    if (match > 0)
                    {
                        scores += (int)match;
                    }
                    else
                    {
                        scores += 0;
                    }
                }
            }

            return(scores);
        }
Ejemplo n.º 6
0
        public IHttpActionResult AddAnswerSheet([FromBody] List <PatternAnswerSheet> sheets)
        {
            var patternId = sheets[0].PatternId;
            var pattern   = db.Patterns.Include("AnswerBlocks").FirstOrDefault(x => x.Id == patternId);

            var answerBlock = new AnswerBlock()
            {
                PatternId           = patternId,
                AnswerOptionsNumber = 4
            };

            if (pattern != null)
            {
                var i = 1;
                if (pattern.AnswerBlocks.Count() != 0)
                {
                    i = pattern.AnswerBlocks.Last().FirstQuestionIndex + pattern.AnswerBlocks.Last().Rows;

                    answerBlock.FirstQuestionIndex = i;
                    answerBlock.Rows        = sheets.Count();
                    answerBlock.CoordinateX = pattern.AnswerBlocks.Last().CoordinateX + 1000;
                    answerBlock.CoordinateY = 500;

                    var tempPattern = new Pattern {
                        Image        = pattern.Image,
                        AnswerBlocks = new List <AnswerBlock>()
                    };

                    tempPattern.AnswerBlocks.Add(answerBlock);

                    var result = PatternGeneratorHelper.AddAnswerBlock(tempPattern);

                    pattern.Image = result.Image;
                    pattern.AnswerBlocks.Add(result.AnswerBlocks.First());

                    foreach (var sheet in sheets)
                    {
                        sheet.QuestionNumber = i;
                        i++;
                    }
                }
                else
                {
                    answerBlock.FirstQuestionIndex = i;
                    answerBlock.Rows        = sheets.Count();
                    answerBlock.CoordinateX = 500;
                    answerBlock.CoordinateY = 500;

                    var tempPattern = new Pattern
                    {
                        Image        = pattern.Image,
                        AnswerBlocks = new List <AnswerBlock>()
                    };

                    tempPattern.AnswerBlocks.Add(answerBlock);

                    var result = PatternGeneratorHelper.AddAnswerBlock(tempPattern);

                    pattern.Image = result.Image;
                    pattern.AnswerBlocks.Add(result.AnswerBlocks.First());

                    foreach (var sheet in sheets)
                    {
                        sheet.QuestionNumber = i;
                        i++;
                    }
                }

                db.AnswerBlocks.Add(answerBlock);
                db.AnswerSheets.AddRange(sheets);
                db.SaveChanges();
                return(Ok());
            }
            return(BadRequest());
        }