예제 #1
0
 public void GetMoney(Unit deadUnit)
 {
     Debug.Log("Oh! I've received " + deadUnit.rewardCoins + " coins! :D yay");
     AddCoins(deadUnit.rewardCoins);
     score.Add(deadUnit.rewardCoins);
     MoneyTextManager.Instance.CreateText(GameObject.Find("Grid+Camera").transform.FindChild("Grid").transform.position, deadUnit.rewardCoins.ToString(), true);
 }
예제 #2
0
        public void UpdateHighscoresTest()
        {
            ScoreManager scoreManager = new ScoreManager();
            Score        s            = new Score()
            {
                PlayerName = "NONAME",
                Value      = "0025",
            };

            scoreManager.Add(s);

            Score currentHighscore = scoreManager.Highscores[0];

            s = new Score()
            {
                PlayerName = "NONAME",
                Value      = "0014",
            };
            scoreManager.Add(s);

            Score newHighscore = scoreManager.Highscores[0];

            //The UpdateHighscores method is called when adding a new score, so no need to call it again

            Assert.AreNotEqual(currentHighscore.Value, newHighscore.Value);
        }
예제 #3
0
        public void PurgeTest()
        {
            ScoreManager <string> sm = new ScoreManager <string>();

            sm.Threshold = 0.99;
            bool added = sm.Add("zero", 0);

            added = sm.Add("one-half", 0.5);
            added = sm.Add("one", 1);
            Assert.AreEqual(sm.Count, 3);
            sm.Purge();
            Assert.AreEqual(sm.Count, 2);
        }
예제 #4
0
 void EndJump()
 {
     timer = 0;
     nJumps++;
     ScoreManager.Add(1);
     ResetPosition();
 }
예제 #5
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            _timer -= (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (_timer <= 0)
            {
                SetButtonPosition(_button);

                _scoreManager.Add(new Models.Score()
                {
                    PlayerName = "Bob",
                    Value      = _score
                });

                ScoreManager.Save(_scoreManager);
                _timer = 5;
                _score = 0;
            }

            _button.Update(gameTime);

            // TODO: Add your update logic here

            base.Update(gameTime);
        }
예제 #6
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            _timer -= (float)gameTime.ElapsedGameTime.TotalSeconds;

            // If the round is over
            if (_timer <= 0)
            {
                SetButtonPosition(_button);

                _scoreManager.Add(new Models.Score()
                {
                    PlayerName = "Bob",
                    Value      = _score,
                }
                                  );

                ScoreManager.Save(_scoreManager);

                _timer = 5;
                _score = 0;
            }

            _button.Update(gameTime);

            base.Update(gameTime);
        }
예제 #7
0
        public override void Update(GameTime gameTime)
        {
            foreach (var sprite in _sprites)
            {
                sprite.Update(gameTime, _sprites);
            }



            if (_score.Score1 > 11 || _score.Score2 > 11)
            {
                _scoreManager.Add(new GameScores()
                {
                    PlayerName = ($"Game{GameNum}"),
                    GameScore  = ($"Player 1 : {_score.Score1}  Player 2: {_score.Score2}"),
                    Games      = GameNum
                }
                                  );
                ScoreManager.Save(_scoreManager);



                GameNum = GameNum + 1;

                _game.ChangeState(new EndGameState(_game, _graphicsDevice, _content));
            }

            //base.Update(gameTime);
        }
 void Equal10()
 {
     textCalc.SetActive(false);
     textEqual10.SetActive();
     score.Add(10);
     invaders.DestroyList();
 }
예제 #9
0
        public void LoadUserInterface()
        {
            Score score = new Score();

            score.font     = Content.Load <SpriteFont>("ScoreFont");
            score.text     = "Core Charge : ";
            score.value    = 100;
            score.position = new Vector2(GraphicsDevice.Viewport.Width - 400, 50);
            score.color    = Color.White;
            score.type     = "SunHealth";
            score.scale    = new Vector2(1.0f, 1.0f);
            scoreManager.Add(score);

            Score mainScore = new Score();

            mainScore.font     = Content.Load <SpriteFont>("ScoreFont");
            mainScore.text     = "Score : ";
            mainScore.value    = 0;
            mainScore.position = new Vector2(50, 50);
            mainScore.color    = Color.White;
            mainScore.type     = "MainScore";
            mainScore.scale    = new Vector2(1.0f, 1.0f);
            scoreManager.Add(mainScore);

            Score gameOver = new Score();

            gameOver.texture  = Content.Load <Texture2D>("GameOver");
            gameOver.position = new Vector2(GraphicsDevice.Viewport.Width / 2 - 10, GraphicsDevice.Viewport.Height / 2 - 100);
            gameOver.scale    = new Vector2(0f, 0f);
            gameOver.color    = Color.White;
            gameOver.type     = "GameOver";
            scoreManager.Add(gameOver);

            Score playAgain = new Score();

            playAgain.defaultTexture = Content.Load <Texture2D>("PlayAgain");
            playAgain.hoverTexture   = Content.Load <Texture2D>("PlayAgain_Glow");
            playAgain.texture        = playAgain.defaultTexture;
            playAgain.position       = new Vector2(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2 + 50);
            playAgain.color          = Color.White;
            playAgain.type           = "PlayAgain";
            playAgain.scale          = new Vector2(0f, 0f);
            // playAgain.origin = new Vector2(playAgain.texture.Width / 2, playAgain.texture.Height / 2);
            scoreManager.Add(playAgain);
        }
예제 #10
0
        private void Exit_Click(object sender, System.EventArgs e)
        {
            var score = new Score();

            score.PlayerName = playerName;
            score.Value      = SpriteManager.Instance.Player.Score;
            scoreManager.Add(score);

            ScoreManager.Save(scoreManager);

            _game.Exit();
        }
예제 #11
0
파일: FizzBuzz.cs 프로젝트: chrmi/R12
 public void Check(int points)
 {
     if (points % 3 == 0 && points % 5 == 0)
     {
         GameObject prefab = Instantiate(Resources.Load("FizzBuzz")) as GameObject;
         Destroy(prefab, 3);
         scoreManager.Add(3);
     }
     else if (points % 3 == 0)
     {
         GameObject prefab = Instantiate(Resources.Load("Fizz")) as GameObject;
         Destroy(prefab, 3);
         scoreManager.Add(1);
     }
     else if (points % 5 == 0)
     {
         GameObject prefab = Instantiate(Resources.Load("Buzz")) as GameObject;
         Destroy(prefab, 3);
         scoreManager.Add(2);
     }
 }
예제 #12
0
        public override void PostUpdate(GameTime gameTime)
        {
            foreach (var leftSprite in _sprites.Where(c => c is ICollidable))
            {
                foreach (var rightSprite in _sprites.Where(c => c is ICollidable))
                {
                    // Don't do anything if they're the same sprite!
                    if (leftSprite == rightSprite)
                    {
                        continue;
                    }

                    // Don't do anything if they're not colliding
                    if (!leftSprite.Hitbox.Intersects(rightSprite.Hitbox))
                    {
                        continue;
                    }

                    ((ICollidable)leftSprite).OnCollide(rightSprite);
                }
            }

            for (int i = 0; i < _sprites.Count; i++)
            {
                if (_sprites[i].IsRemoved)
                {
                    _sprites.RemoveAt(i);
                    i--;
                }
            }

            // Add the children sprites to the list of sprites (ie bullets)
            int spriteCount = _sprites.Count;

            for (int i = 0; i < spriteCount; i++)
            {
                var sprite = _sprites[i];
                foreach (var child in sprite.Children)
                {
                    _sprites.Add(child);
                }
                sprite.Children = new List <Sprite>();
            }

            // If the player is dead,save the scores, and return to the highscore state
            if (_player.IsDead)
            {
                _scoreManager.Add(_player.Score);
                ScoreManager.Save(_scoreManager);
                _game.ChangeState(new HighscoresState(_game, _content));
            }
        }
예제 #13
0
        public void AddTest1()
        {
            ScoreManager <string> sm = new ScoreManager <string>();

            sm.Threshold = 1;
            bool added = sm.Add(new ScoredObject <string>()
            {
                Item = "one", Score = 1
            });

            Assert.IsTrue(added);
            Assert.AreEqual(sm.Count, 1);
            Assert.AreEqual(sm.TopScore, 1);
            added = sm.Add(new ScoredObject <string>()
            {
                Item = "one-half", Score = 0.5
            });
            Assert.IsTrue(added);
            Assert.AreEqual(sm.Count, 2);
            added = sm.Add(new ScoredObject <string>()
            {
                Item = "minus-one", Score = -1
            });
            Assert.IsFalse(added);
            Assert.AreEqual(sm.Count, 2);
            added = sm.Add(new ScoredObject <string>()
            {
                Item = "two", Score = 2
            });
            Assert.IsTrue(added);
            Assert.AreEqual(sm.Count, 3);
            Assert.AreEqual(sm.TopScore, 2);
            Assert.AreEqual(sm.TopItem, "two");
            added = sm.Add(new ScoredObject <string>()
            {
                Item = "one", Score = 3
            });
            Assert.IsFalse(added);
        }
예제 #14
0
        public void AddTest()
        {
            ScoreManager scoreManager = new ScoreManager();
            Score        s            = new Score()
            {
                PlayerName = "NONAME",
                Value      = "0025",
            };

            scoreManager.Add(s);

            CollectionAssert.Contains(scoreManager.Scores, s);
        }
예제 #15
0
        public void ForEachTest()
        {
            ScoreManager <string> sm = new ScoreManager <string>();

            sm.Threshold = 1.1;
            sm.Add("zero", 0);
            sm.Add("1", 1);
            sm.Add("2", 2);

            List <string> expecteditems = new List <string>()
            {
                "zero", "1", "2"
            };
            List <string> items = new List <string>();

            foreach (string item in sm)
            {
                items.Add(item);
            }

            for (int i = 0; i < 3; i++)
            {
                Assert.AreEqual(items[i], expecteditems[i]);
            }

            sm.Revalidate();
            items.Clear();
            foreach (string item in sm)
            {
                items.Add(item);
            }

            expecteditems.Remove("zero");
            for (int i = 0; i < 2; i++)
            {
                Assert.AreEqual(items[i], expecteditems[i]);
            }
        }
예제 #16
0
        public void Update(int inScore)
        {
            _score = inScore;
            if (inScore != _lastScore)
            {
                _scoreManager.Add(new Score {
                    Value = inScore
                });

                ScoreManager.Save(_scoreManager);
            }

            _lastScore = inScore;
        }
예제 #17
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     //Debug.Log("collision enter");
     if (collision.gameObject.tag == "Bullet")
     {
         //Debug.Log("Destroy");
         Explosion();
         var parent = transform.parent.gameObject;
         Debug.Log(parent);
         score.Add(value);
         parent.GetComponent <InvadersManager>().AddDestroyList(gameObject);
         calc.AddNum(value);
     }
 }
예제 #18
0
    public void Add(Mino mino)
    {
        foreach (Vector2Int m in mino.AllPositions)
        {
            fieldMinoSprites[m.x, m.y].sprite = MinoManager.Sprites[(int)mino.Type];
            minoExists[m.x, m.y] = true;
        }

        int deleteLines = 0;

        for (int i = 0; i < HEIGHT; ++i)
        {
            bool lineDelete = true;
            for (int j = 0; j < WIDTH; ++j)
            {
                if (minoExists[j, i] == false)
                {
                    lineDelete = false;
                }
            }
            if (lineDelete)
            {
                for (int ii = i; ii < HEIGHT - 1; ++ii)
                {
                    for (int j = 0; j < WIDTH; ++j)
                    {
                        fieldMinoSprites[j, ii].sprite = fieldMinoSprites[j, ii + 1].sprite;
                        minoExists[j, ii] = minoExists[j, ii + 1];
                    }
                }
                --i;
                ++deleteLines;
            }
        }
        LineManager.Add(deleteLines);
        ScoreManager.Add(SCORE_NORMAL[deleteLines] * LevelManager.Get());
    }
예제 #19
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     //Debug.Log("collision enter");
     if (collision.gameObject.tag == "Bullet")
     {
         score.Add(20);
         calc.AddNum(0);
         //Debug.Log("Destroy");
         Destroy(this.gameObject);
     }
     else if (collision.gameObject.tag == "Trap")
     {
         Destroy(this.gameObject);
     }
 }
예제 #20
0
        public void AddTest()
        {
            ScoreManager <string> sm = new ScoreManager <string>();

            sm.Threshold = 1;
            bool added = sm.Add("one", 1);

            Assert.IsTrue(added);
            Assert.AreEqual(sm.Count, 1);
            Assert.AreEqual(sm.TopScore, 1);
            added = sm.Add("one-half", 0.5);
            Assert.IsTrue(added);
            Assert.AreEqual(sm.Count, 2);
            added = sm.Add("minus one", -1);
            Assert.IsFalse(added);
            Assert.AreEqual(sm.Count, 2);
            added = sm.Add("two", 2);
            Assert.IsTrue(added);
            Assert.AreEqual(sm.Count, 3);
            Assert.AreEqual(sm.TopScore, 2);
            Assert.AreEqual(sm.TopItem, "two");
            added = sm.Add("one", 3);
            Assert.IsFalse(added);
        }
예제 #21
0
        public void SaveAndLoadTest()
        {
            ScoreManager scoreManager = new ScoreManager();
            Score        s            = new Score()
            {
                PlayerName = "NONAME",
                Value      = "0014",
            };

            scoreManager.Add(s);

            ScoreManager.Save(scoreManager);
            scoreManager = ScoreManager.Load();

            Assert.AreEqual(s.Value, scoreManager.Scores[0].Value);
        }
예제 #22
0
        private void OnCollisionEnter(Collision Collision)
        {
            switch (Collision.transform.gameObject.tag)
            {
            case "Target":
                ParticleHitPrefab = Instantiate(ParticleHitPrefab, Collision.contacts[0].point, Quaternion.identity);
                ParticleHitPrefab.GetComponent <ParticleSystem>().Play();

                GameObject.Find("HitSoundSource").GetComponent <AudioSource>().Play();

                if (Timer.Finished)
                {
                    return;
                }

                // Sphere cast
                RaycastHit[] OutHit;
                OutHit = Physics.SphereCastAll(transform.position, DetectionRadius, transform.forward);

                // Spawn the score hit UI element (for feedback)
                int ScoreToAdd = Collision.gameObject.GetComponent <Target>().Tier2;
                ScoreManager.Add(ScoreToAdd);

                ScoreHitPrefab         = Instantiate(ScoreHitPrefab, Collision.contacts[0].point, Quaternion.identity);
                TextComponent          = ScoreHitPrefab.transform.GetChild(0).GetComponent <TextMeshProUGUI>();
                TextComponent.color    = Color.blue;
                TextComponent.fontSize = 38892.0f;
                TextComponent.text     = "+" + ScoreToAdd;
                ScoreHitPrefab.transform.LookAt(new Vector3(0.0f, 0.0f, 0.0f));
                ScoreHitPrefab.transform.rotation = Quaternion.LookRotation(Vector3.zero - ScoreHitPrefab.transform.position) * Quaternion.Inverse(new Quaternion(0.0f, 180.0f, 0.0f, 1.0f));

                // Destroy every target in the sphere's reach
                foreach (RaycastHit Hit in OutHit)
                {
                    if (Hit.transform.gameObject.tag == "Target")
                    {
                        Hit.transform.GetComponent <Target>().Hit = true;
                        Hit.transform.GetComponent <Target>().Hide();
                    }
                }
                break;

            case "Water":
                Destroy(gameObject);                         // Destroy duck
                break;
            }
        }
예제 #23
0
파일: Registers.cs 프로젝트: chrmi/R12
 public void Add(char tileValue)
 {
     if (registers[active].GetComponent <Register>().Add(tileValue))
     {
     }
     else
     {
         active++;
         if (active > registers.Length - 1)
         {
             SceneManager.LoadScene("Main");
         }
         else
         {
             registers[active].GetComponent <Register>().Add(tileValue);
         }
     }
     scoreManager.Add(hexValues[tileValue]);
 }
예제 #24
0
    public void CheckUserSelect(Melody user_selected)
    {
        Melody melody = melody_sheet[user_melody_index];

        if (melody.unique_name == user_selected.unique_name)
        {
            user_melody_index++;
            if (user_melody_index >= melody_sheet.Count)
            {
                user_melody_index = 0;
                score_manager.Add();
                b12.color = new Color(255, 255, 255, 1);
                StartCoroutine(AddAndPlay(2));
            }
        }
        else
        {
            GameOver();
        }
    }
예제 #25
0
    void Awake()
    {
        _score = Manager.Instance.Score;
        _name  = Manager.Instance.Name;

        _scoreManager = new ScoreManager();
        ScoreManager.Load();

        _scoreManager.Add(new Score
        {
            Value      = _score,
            PlayerName = _name
        });
        ScoreManager.Save(_scoreManager);

        SetPlayerPref.SaveAll();


        Debug.LogWarning("Finished !");
    }
예제 #26
0
        /// <summary>
        /// 就是新增
        /// </summary>
        /// <returns></returns>
        public ActionResult adds()
        {
            ScoreManager bll = new ScoreManager();
            score        se  = new score()
            {
                PointTime       = Convert.ToDateTime(Request.Form["PointTime"]),
                UserId          = Convert.ToInt32(Request.Form["UserId"]),
                systemId        = Convert.ToInt32(Request.Form["systemId"]),
                score_Condition = "可见"
            };
            var info = bll.Add(se);

            if (info)
            {
                return(Redirect("/LiuYi/Point/Index"));
            }
            else
            {
                return(Redirect("/LiuYi/Point/Index"));
            }
        }
예제 #27
0
 //Add the new highscore to the difficuly selected
 public void Add(int difficulty, int score)
 {
     insertManager.Add(difficulty, score);
 }
예제 #28
0
        public override void PostUpdate(GameTime gameTime)
        {
            var collidableSprites = _sprites.Where(c => c is ICollidable);

            foreach (var spriteA in collidableSprites)
            {
                foreach (var spriteB in collidableSprites)
                {
                    // Don't do anything if they're the same sprite!
                    if (spriteA == spriteB)
                    {
                        continue;
                    }

                    if (!spriteA.CollisionArea.Intersects(spriteB.CollisionArea))
                    {
                        continue;
                    }

                    if (spriteA.Intersects(spriteB))
                    {
                        ((ICollidable)spriteA).OnCollide(spriteB);
                    }
                }
            }

            // Add the children sprites to the list of sprites (ie bullets)
            int spriteCount = _sprites.Count;

            for (int i = 0; i < spriteCount; i++)
            {
                var sprite = _sprites[i];
                foreach (var child in sprite.Children)
                {
                    _sprites.Add(child);
                }

                sprite.Children = new List <Sprite>();
            }

            for (int i = 0; i < _sprites.Count; i++)
            {
                if (_sprites[i].IsRemoved)
                {
                    _sprites.RemoveAt(i);
                    i--;
                }
            }

            // If all the players are dead, we save the scores, and return to the highscore state
            if (_players.All(c => c.IsDead))
            {
                foreach (var player in _players)
                {
                    _scoreManager.Add(player.Score);
                }

                ScoreManager.Save(_scoreManager);

                _game.ChangeState(new HighscoresState(_game, _content));
            }
        }
예제 #29
0
 private void FlusiCollision(Collision2D collision)
 {
     Destroy(gameObject);
     ScoreManager.Add(10f);
 }
예제 #30
0
    // Update is called once per frame
    private void Update()
    {
        gameState = GetGameState();
        switch (gameState)
        {
        case (GameState.TileMoving):
            return;

        case GameState.HasEmptyTiles:
        {
            Collapse();
            FillField();
            break;
        }

        case GameState.TileSelected:
        {
            if (!Input.GetMouseButtonDown(0))
            {
                return;
            }
            var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
            if (hit.collider != null)
            {
                var position   = GetPoint(hit.collider.transform);
                var neighbours = GetNeighbours(selectedTile);
                if (neighbours.Any(pos => pos.X == position.X && pos.Y == position.Y))
                {
                    tiles[selectedTile].StopSpinning();
                    swappedTile = position;
                    SwapTiles(selectedTile, swappedTile);
                }
                else
                {
                    tiles[selectedTile].StopSpinning();
                    selectedTile = null;
                }
            }
            break;
        }

        case GameState.MovedTile:
        {
            var matches = tiles.FindMatches().ToList();
            if (matches.Any())
            {
                foreach (var tile in matches)
                {
                    tile.Remove();
                    ScoreManager.Add(1);
                }
            }
            else
            {
                SwapTiles(selectedTile, swappedTile);
            }
            selectedTile = null;
            swappedTile  = null;
            break;
        }

        case (GameState.None):
        {
            var matches = tiles.FindMatches().ToList();
            if (matches.Any())
            {
                foreach (var tile in matches)
                {
                    tile.Remove();
                    ScoreManager.Add(1);
                }
                break;
            }
            if (Input.GetMouseButtonDown(0))
            {
                var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
                if (hit.collider != null)
                {
                    var position = GetPoint(hit.collider.transform);
                    selectedTile = position;
                    tiles[selectedTile].StartSpinning();
                }
            }
            break;
        }
        }
    }