Ejemplo n.º 1
0
        public async Task <IActionResult> PutScoreClass([FromRoute] int id, [FromBody] ScoreClass scoreClass)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != scoreClass.ID)
            {
                return(BadRequest());
            }

            _context.Entry(scoreClass).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ScoreClassExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public static void Initialize(Context context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Scores.Any())
            {
                return;   // DB has been seeded
            }

            var scores = new ScoreClass[]
            {
                new ScoreClass {
                    Nickname = "Carson", Points = 3542, TypeOfScorer = "Human"
                },
                new ScoreClass {
                    Nickname = "Benson", Points = 1234, TypeOfScorer = "AI"
                },
                new ScoreClass {
                    Nickname = "Larson", Points = 4312, TypeOfScorer = "Human"
                },
            };

            foreach (ScoreClass s in scores)
            {
                context.Scores.Add(s);
            }
            context.SaveChanges();
        }
Ejemplo n.º 3
0
 public SingleplayerWindow()
 {
     InitializeComponent();
     backgroundMusic.Open(new Uri("sounds/gameMusic.mp3", UriKind.RelativeOrAbsolute));
     backgroundMusic.Play();
     Backgr.ImageSource = new BitmapImage(new Uri("images/backgame.png", UriKind.Relative));
     score            = 0;
     Width            = width + 100;
     foodCanvas.Width = canvas.Width = width;
     canvas.Height    = foodCanvas.Height = Height = height;
     myGrid.Height    = height;
     myGrid.Children.Add(new Rectangle
     {
         Height = height, Width = 100, StrokeDashCap = PenLineCap.Round,
         Stroke = Brushes.Gray
     });
     bestScore.Text   = ScoreClass.GetBestScore();
     time             = new DispatcherTimer();
     currentDurection = Directions.Stay;
     snakeBody        = new List <SnakeElement>();
     snakeBody.Add(new SnakeElement(new Point(moveSize, moveSize)));
     snakeBody[0].rectangle.Fill = SettingsClass.PlayerColor;
     time.Interval =
         new TimeSpan(0, 0, 0, 0, SettingsClass.Difficulty);
     time.Tick += time_Tick;
 }
Ejemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        timerObject = GameObject.Find("Timer");
        score       = GameObject.FindGameObjectWithTag("ScoreObject").GetComponent <ScoreClass>();
        turnTimer   = (int)waitTime;
        timerObject.GetComponent <TextMeshProUGUI>().text = turnTimer.ToString();

        sprites = new Dictionary <char, GameObject[]>();

        // Permet de reset le score à 0 dans le cas où le joueur rejoue
        resetScore();

        // Remplissage du tableau de sprites
        for (char c = 'A'; c <= 'Z'; c++)
        {
            sprites[c] = GameObject.FindGameObjectsWithTag("Letter_" + c);
        }

        letters = GameObject.FindGameObjectsWithTag("Letters");

        // Initialisation des valeurs par défaut
        if (nb_letters < 5)
        {
            nb_letters = 5;
        }
        if (max_turns == 0)
        {
            max_turns = 5;
        }
        gameAlive = true;

        // On lance la boucle via changeLetter, puis on lance un timer
        Invoke("changeLetters", 0.25f);
        InvokeRepeating("timerIncrement", 1.25f, 1f);
    }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        score         = GameObject.FindGameObjectWithTag("ScoreObject").GetComponent <ScoreClass>();
        gameGenerator = GameObject.FindGameObjectWithTag("GameGenerator").GetComponent <GameGenerator>();

        isWin = false;
    }
Ejemplo n.º 6
0
 // Lorsqu'on arrive dans la scène de fin, on récupère les différentes variables de score
 // On les affiche et on envoie le nombre de bonnes réponses
 void Start()
 {
     score           = GameObject.FindGameObjectWithTag("ScoreObject").GetComponent <ScoreClass>();
     goodAnswer.text = score.goodAnswer.ToString() + " / 20";
     badAnswer.text  = score.wrongAnswer.ToString() + " mauvaises réponses.";
     totalTime.text  = score.countSeconds.ToString() + " secondes au total.";
     timeOuts.text   = score.timeOut.ToString() + " timeouts.";
     SendScore(score.goodAnswer);
 }
Ejemplo n.º 7
0
 private void GameOver(string cause)
 {
     backgroundMusic.Stop();
     MessageBox.Show(cause);
     Close();
     time.Stop();
     this.Owner.Show();
     ScoreClass.AddScore(0); //нужно только для подсчета количества игр
     MainWindow.player.Play();
 }
Ejemplo n.º 8
0
 private void GameOver(string cause)
 {
     backgroundMusic.Stop();
     MessageBox.Show(cause);
     Close();
     time.Stop();
     this.Owner.Show();
     ScoreClass.AddScore(score);
     MainWindow.player.Play();
 }
Ejemplo n.º 9
0
        public async Task <ActionResult <ScoreClass> > PostScoreClass([FromBody] ScoreClass scoreClass)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Scores.Add(scoreClass);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetScoreClass", new { id = scoreClass.ID }, scoreClass));
        }
Ejemplo n.º 10
0
    public TeamID GetWinningTeam()
    {
        ScoreClass bestTeam = currentTeams[0];

        foreach (ScoreClass team in currentTeams)
        {
            if (team.score > bestTeam.score)
            {
                bestTeam = team;
            }
        }

        return(bestTeam.teamID);
    }
Ejemplo n.º 11
0
 public ScoreForm(MainForm mainForm, int score)
 {
     this.mainForms         = mainForm;
     this.mainForms.Enabled = false;
     Diem = score;
     InitializeComponent();
     string[] lines = File.ReadAllLines("Result.txt");
     foreach (var i in lines)
     {
         string[]   temp   = i.Split();
         ScoreClass newOne = new ScoreClass(temp[0].ToString(), Convert.ToInt32(temp[1]));
         listScore.Add(newOne);
     }
     for (int i = 0; i < listScore.Count; i++)
     {
         if (listScore[i].score <= score)
         {
             positions = i;
             break;
         }
     }
     if (positions != 0)
     {
         ScoreClass newone = new ScoreClass("You", score);
         listScore.Insert(positions, newone);
     }
     for (int i = 0; i < 10; i++)
     {
         this.dataGridView1.Rows.Add(i + 1, listScore[i].name, listScore[i].score);
     }
     label_score.Text = "Score: " + score;
     if (positions != 0)
     {
         label_score.Text         += "  Top: " + Convert.ToInt32(positions + 1).ToString();
         dataGridView1.CurrentCell = dataGridView1.Rows[positions].Cells[1];
     }
     else
     {
         label_score.Text += "  Top: UnRank";
         textBox_Name.Hide();
         label_name.Hide();
         dataGridView1.CurrentCell = null;
     }
     dataGridView1.ReadOnly = true;
 }
Ejemplo n.º 12
0
    public void Reset()
    {
        if (currentTeams != null)
        {
            currentTeams.Clear();
        }

        currentTeams = new List <ScoreClass>();

        foreach (TeamID teamID in gameManager.teamManager.currentTeams.Select(x => x.ID))
        {
            ScoreClass newTeam = new ScoreClass();
            newTeam.teamID = teamID;
            currentTeams.Add(newTeam);
        }

        currentTeams.Where(x => x.teamID == TeamID.NONE).First().numTiles = gameManager.GetComponent <MapManager>().tiles.Select(x => x.GetTeam()).Where(x => x == TeamID.NONE).Count();
    }
Ejemplo n.º 13
0
 private void AddToScoreBoard(ScoreClass newOne)
 {
     if (positions != 0)
     {
         string[] lines = File.ReadAllLines("Result.txt");
         using (StreamWriter writer = new StreamWriter("Result.txt"))
         {
             for (int i = 0; i < positions; i++)
             {
                 writer.WriteLine(lines[i]);
             }
             writer.WriteLine(newOne.name + " " + newOne.score);
             for (int i = positions; i < (lines.Length - 1); i++)
             {
                 writer.WriteLine(lines[i]);
             }
         }
     }
 }
Ejemplo n.º 14
0
 private void button_submit_Click(object sender, EventArgs e)
 {
     if (positions != 0)
     {
         ScoreClass newOne = new ScoreClass(dataGridView1.Rows[positions].Cells[1].Value.ToString(), Diem);
         string[]   lines  = File.ReadAllLines("Result.txt");
         using (StreamWriter writer = new StreamWriter("Result.txt"))
         {
             for (int i = 0; i < positions; i++)
             {
                 writer.WriteLine(lines[i]);
             }
             writer.WriteLine(newOne.name + " " + newOne.score);
             for (int i = positions; i < (lines.Length - 1); i++)
             {
                 writer.WriteLine(lines[i]);
             }
         }
     }
     Close();
 }
Ejemplo n.º 15
0
        public Scores()
        {
            InitializeComponent();
            Backgr.ImageSource = new BitmapImage(new Uri("images/main.jpg", UriKind.Relative));
            StackPanel stackPanel = new StackPanel();

            stackPanel.HorizontalAlignment = HorizontalAlignment.Left;
            stackPanel.Margin = new Thickness(10, 30, 0, 0);
            stackPanel.Height = Height - 100;
            var scores = ScoreClass.GetFirstScoresArray();

            for (int i = 0; i < scores.Length; i++)
            {
                var txtbl = new TextBlock();
                txtbl.FontSize = 24;
                txtbl.Text     = (i + 1).ToString() + ". " + scores[i];
                stackPanel.Children.Add(txtbl);
            }
            stackPanel.Children.Add(new TextBlock {
                Text = "Игр сыграно: " + ScoreClass.GetGamesCount(), FontSize = 26
            });
            myGrid.Children.Add(stackPanel);
        }
Ejemplo n.º 16
0
 public CreditCard(ScoreClass scoreClass)
 {
 }
Ejemplo n.º 17
0
    // Attach Event
    void OnTriggerEnter2D(Collider2D other)
    {
        if ((other.gameObject.layer == 8 || other.gameObject.layer == 9))
        {
            animator.SetBool("isJumping", false);
        }

        if (other.gameObject.layer == 9 && rigid.velocity.y < 0)
        {
            Block_obj_status block = other.gameObject.GetComponentInChildren <Block_obj_status>(true);
            Debug.Log(block.type);

            switch (block.type)
            {
            case "Up": {
                Vector2 upVelocity = new Vector2(0, block.value);
                rigid.AddForce(upVelocity, ForceMode2D.Impulse);
                break;
            }
            }
        }

        Debug.Log(other.gameObject.tag);
        Debug.Log("y - " + rigid.velocity.y);

        if (other.gameObject.tag == "mob" && !other.isTrigger && rigid.velocity.y < -5)
        {
            // bouncing
            Vector2 killVelocity = new Vector2(0, 10f);
            rigid.AddForce(killVelocity, ForceMode2D.Impulse);

            // kill monster
            MonsterMovement monster = other.gameObject.GetComponent <MonsterMovement>();
            monster.die();

            // get Score
            ScoreClass.setScore(monster.score);

            Debug.Log(monster.score);

            ScoreClass.addScore();
        }
        else if (other.gameObject.tag == "mob" && !other.isTrigger && !(rigid.velocity.y < -5))
        {
            Vector2 attackedVelocity = Vector2.zero;

            if (other.gameObject.transform.position.x > transform.position.x)
            {
                attackedVelocity = new Vector2(-2f, 3f);
            }
            else
            {
                attackedVelocity = new Vector2(2f, 3f);
            }

            rigid.AddForce(attackedVelocity, ForceMode2D.Impulse);

            hp--;
            Debug.Log(hp);
        }

        if (other.gameObject.tag == "gameover")
        {
            hp = 0;
        }

        if (other.gameObject.tag == "coin")
        {
            // get Score
            Block_obj_status coin = other.gameObject.GetComponent <Block_obj_status>();
            ScoreClass.setScore((int)coin.value);

            // Remove Coin
            Destroy(other.gameObject, 0f);

            ScoreClass.addScore();
        }

        if (other.gameObject.tag == "goal")
        {
            GameManager.EndGame();
        }
    }
Ejemplo n.º 18
0
    public void LoadHighScore()
    {
        string jsonData = File.ReadAllText(string.Concat(Application.persistentDataPath, "/Score.txt"));

        sc = JsonUtility.FromJson <ScoreClass>(jsonData);
    }
Ejemplo n.º 19
0
 // 初期化処理
 public ScoreList()
 {
     for(int i = 0; i < Val.Length; i++) {
         Val[i] = new ScoreClass();
     }
 }
Ejemplo n.º 20
0
 /// <summary>
 /// 後方シフト
 /// </summary>
 /// <param name="i">0を挿入するインデックス</param>
 private void BackShift(int i)
 {
     for(int n = Val.Length - 2; n >= i; n--) {
         Val[n + 1] = Val[n];
     }
     Val[i] = new ScoreClass();
 }