Ejemplo n.º 1
0
    void OnTriggerEnter(Collider col)
    {
        // Make sure it was actually the bottom player that collided
        if (col.gameObject != BotPlayer.S.gameObject) return;

        // Get useful player references
        botPlayer = BotPlayer.S.gameObject;
        botPlayerRigidBody = botPlayer.GetComponent<Rigidbody>();
        botPlayerScript = botPlayer.GetComponent<BotPlayer>();
        topPlayer = TopPlayer.S.gameObject;
        topPlayerRigidBody = topPlayer.GetComponent<Rigidbody>();
        topPlayerScript = topPlayer.GetComponent<TopPlayer>();

        // Disable BotPlayer
        botPlayerRigidBody.velocity = Vector3.zero;
        botPlayer.transform.rotation = Quaternion.LookRotation(botPlayer.transform.position) * Quaternion.Euler(0, 90, 0);
        botPlayerScript.anim.SetBool("Move", false);
        botPlayerScript.enabled = false;

        // Disable TopPlayer
        topPlayerRigidBody.velocity = Vector3.zero;
        topPlayer.transform.rotation = Quaternion.LookRotation(topPlayer.transform.position) * Quaternion.Euler(0, 90, 0);
        topPlayerScript.anim.SetBool("Move", false);
        topPlayerScript.enabled = false;

        // Begin moving to Cannon
        botPlayerScript.anim.SetBool("Move", true);
        botPlayerRigidBody.velocity = -(botPlayer.transform.position.normalized) * botPlayerScript.speed;
        movingToCannon = true;
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Processes the Game win event
    /// Writes an appropriate message on the User interface and updates the HighScore
    /// </summary>
    private void ProcessWin()
    {
        this.USER_INTERFACE.WriteSingleOutputLine("The secret word is " + this.currentWord.GetHiddenWord);
        this.USER_INTERFACE.WriteSingleOutputLine("\nYou won with " + this.currentMistakesCount + " mistakes");

        bool betterThanLast = this.highScoreBoard.IsResultHighScore(this.currentMistakesCount);

        if (!this.usedHelp && betterThanLast)
        {
            this.USER_INTERFACE.WriteSingleOutputLine("\nPlease enter your name for the top scoreboard: ");

            string    playerName   = this.USER_INTERFACE.ReadSingleInputLine();
            int       playerScore  = this.currentMistakesCount;
            TopPlayer newTopPlayer = new TopPlayer(playerName, playerScore);

            this.highScoreBoard.AddPlayer(newTopPlayer);

            this.ProcessHighscoreRequest();
        }
        else if (!betterThanLast)
        {
            this.USER_INTERFACE.WriteSingleOutputLine(" but your result is lower than top scores\n");
        }
        else
        {
            this.USER_INTERFACE.WriteSingleOutputLine(" but you have cheated. \nYou are not allowed to enter into the scoreboard.\n");
        }
    }
Ejemplo n.º 3
0
    public void LoadTopPlayerList()
    {
        TopList.Clear();
        Linq.CommandText = "SELECT PlayerName, zombie, zombie_mutant, zombie_strong, PlayerScores FROM charecter ORDER BY PlayerScores DESC";
        MySqlDataReader reader = Linq.ExecuteReader();
        int             r      = 0;

        while (reader.Read() && r < 10)
        {
            int       i = 0;
            TopPlayer t = new TopPlayer();
            t.nick             = reader.GetString(i++);
            t.zombieKill       = int.Parse(reader.GetString(i++));
            t.zombieMutantKill = int.Parse(reader.GetString(i++));
            t.zombieStrongKill = int.Parse(reader.GetString(i++));
            t.Score            = int.Parse(reader.GetString(i++));
            TopList.Add(t);
            r++;
        }
        reader.Close();
        top = new NetworkWriter();
        top.StartMessage(Networking_msgType_Sr.TopList);
        top.Write(TopList.Count);
        foreach (TopPlayer pl in TopList)
        {
            top.Write(pl.nick);
            top.Write(pl.zombieKill);
            top.Write(pl.zombieMutantKill);
            top.Write(pl.zombieStrongKill);
            top.Write(pl.Score);
        }
        top.FinishMessage();

        Invoke("LoadTopPlayerList", 30f);
    }
Ejemplo n.º 4
0
        public void AddPlayerTest7Players()
        {
            TopPlayer      player1        = new TopPlayer("Vasil", 5);
            TopPlayer      player2        = new TopPlayer("Pesho", 1);
            TopPlayer      player3        = new TopPlayer("Vesko", 4);
            TopPlayer      player4        = new TopPlayer("Nasko", 2);
            TopPlayer      player5        = new TopPlayer("Nasko", 8);
            TopPlayer      player6        = new TopPlayer("Nasko", 7);
            TopPlayer      player7        = new TopPlayer("Nasko", 0);
            HighScoreBoard highScoreBoard = new HighScoreBoard();

            highScoreBoard.AddPlayer(player1);
            highScoreBoard.AddPlayer(player2);
            highScoreBoard.AddPlayer(player3);
            highScoreBoard.AddPlayer(player4);
            highScoreBoard.AddPlayer(player5);
            highScoreBoard.AddPlayer(player6);
            highScoreBoard.AddPlayer(player7);

            Assert.AreEqual(player7, highScoreBoard.HighScores[0]);
            Assert.AreEqual(player2, highScoreBoard.HighScores[1]);
            Assert.AreEqual(player4, highScoreBoard.HighScores[2]);
            Assert.AreEqual(player3, highScoreBoard.HighScores[3]);
            Assert.AreEqual(player1, highScoreBoard.HighScores[4]);
        }
Ejemplo n.º 5
0
        public void AddPlayerTest1Players()
        {
            TopPlayer player1 = new TopPlayer("Vasil", 5);

            HighScoreBoard highScoreBoard = new HighScoreBoard();
            highScoreBoard.AddPlayer(player1);
            Assert.AreEqual(player1, highScoreBoard.HighScores[0]);
        }
Ejemplo n.º 6
0
 private void btnPlay_Click(object sender, RoutedEventArgs e)
 {
     if (TopPlayer.IsLoaded)
     {
         TopPlayer.Play();
         timerVideoTime.Start();
     }
 }
Ejemplo n.º 7
0
        public void AddPlayerTest1Players()
        {
            TopPlayer player1 = new TopPlayer("Vasil", 5);

            HighScoreBoard highScoreBoard = new HighScoreBoard();

            highScoreBoard.AddPlayer(player1);
            Assert.AreEqual(player1, highScoreBoard.HighScores[0]);
        }
        public void ItHasAllOfTheData()
        {
            TopPlayer firstResult = _topPlayersResult[0];

            Assert.Greater(firstResult.TotalNumberOfGamesPlayed, 0);
            Assert.Greater(firstResult.NemePointsSummary.TotalPoints, 0);
            Assert.True(!string.IsNullOrWhiteSpace(firstResult.PlayerName));
            Assert.Greater(firstResult.PlayerId, 0);
        }
Ejemplo n.º 9
0
        public void TestTopPlayerCreation()
        {
            TopPlayer topPlayer = new TopPlayer("Player1", 10);

            string playerName = topPlayer.PlayerName;
            Assert.AreEqual(playerName, "Player1");

            int playerScore = topPlayer.PlayerScore;
            Assert.AreEqual(playerScore, 10);
        }
Ejemplo n.º 10
0
 public TopPlayerViewModel Build(TopPlayer topPlayer)
 {
     return(new TopPlayerViewModel()
     {
         PlayerId = topPlayer.PlayerId,
         PlayerName = topPlayer.PlayerName,
         TotalNumberOfGamesPlayed = topPlayer.TotalNumberOfGamesPlayed,
         NemePointsSummary = new NemePointsSummaryViewModel(topPlayer.NemePointsSummary),
         WinPercentage = topPlayer.WinPercentage
     });
 }
Ejemplo n.º 11
0
 public TopPlayerViewModel Build(TopPlayer topPlayer)
 {
     return(new TopPlayerViewModel()
     {
         PlayerId = topPlayer.PlayerId,
         PlayerName = topPlayer.PlayerName,
         TotalNumberOfGamesPlayed = topPlayer.TotalNumberOfGamesPlayed,
         TotalPoints = topPlayer.TotalPoints,
         WinPercentage = topPlayer.WinPercentage
     });
 }
Ejemplo n.º 12
0
        public void TestTopPlayerCreation()
        {
            TopPlayer topPlayer = new TopPlayer("Player1", 10);

            string playerName = topPlayer.PlayerName;

            Assert.AreEqual(playerName, "Player1");

            int playerScore = topPlayer.PlayerScore;

            Assert.AreEqual(playerScore, 10);
        }
Ejemplo n.º 13
0
 public void AddPlayerTest3Players()
 {
     TopPlayer player1 = new TopPlayer("Vasil", 5);
     TopPlayer player2 = new TopPlayer("Pesho", 1);
     TopPlayer player3 = new TopPlayer("Vesko", 4);
     HighScoreBoard highScoreBoard = new HighScoreBoard();
     highScoreBoard.AddPlayer(player1);
     highScoreBoard.AddPlayer(player2);
     highScoreBoard.AddPlayer(player3);
     Assert.AreEqual(player2, highScoreBoard.HighScores[0]);
     Assert.AreEqual(player3, highScoreBoard.HighScores[1]);
     Assert.AreEqual(player1, highScoreBoard.HighScores[2]);
 }
Ejemplo n.º 14
0
        public void SetUp()
        {
            builder   = new TopPlayerViewModelBuilder();
            topPlayer = new TopPlayer()
            {
                PlayerId   = 1,
                PlayerName = "player name",
                TotalNumberOfGamesPlayed = 100,
                NemePointsSummary        = new NemePointsSummary(1, 5, 8),
                WinPercentage            = 75
            };

            topPlayerViewModel = builder.Build(topPlayer);
        }
Ejemplo n.º 15
0
        public void AddPlayerTest3Players()
        {
            TopPlayer      player1        = new TopPlayer("Vasil", 5);
            TopPlayer      player2        = new TopPlayer("Pesho", 1);
            TopPlayer      player3        = new TopPlayer("Vesko", 4);
            HighScoreBoard highScoreBoard = new HighScoreBoard();

            highScoreBoard.AddPlayer(player1);
            highScoreBoard.AddPlayer(player2);
            highScoreBoard.AddPlayer(player3);
            Assert.AreEqual(player2, highScoreBoard.HighScores[0]);
            Assert.AreEqual(player3, highScoreBoard.HighScores[1]);
            Assert.AreEqual(player1, highScoreBoard.HighScores[2]);
        }
Ejemplo n.º 16
0
        public void SetUp()
        {
            builder   = new TopPlayerViewModelBuilder();
            topPlayer = new TopPlayer()
            {
                PlayerId   = 1,
                PlayerName = "player name",
                TotalNumberOfGamesPlayed = 100,
                TotalPoints   = 1234,
                WinPercentage = 75
            };

            topPlayerViewModel = builder.Build(topPlayer);
        }
Ejemplo n.º 17
0
    // Use this for initialization
    protected override void Start()
    {
        base.Start();

        Seagull_gui.S.GetComponent<GUIText>().text = "x " + ammo.ToString() ;

        S = this;
        upKey = KeyCode.UpArrow;
        downKey = KeyCode.DownArrow;
        leftKey = KeyCode.LeftArrow;
        rightKey = KeyCode.RightArrow;

        sight = Instantiate (targeting_sight) as GameObject;
        //targeting_sight =  Instantiate (targeting_sight) as GameObject;
    }
Ejemplo n.º 18
0
    /// <summary>
    /// Adds a player to the HighScore board
    /// </summary>
    /// <param name="newPlayer">The player to be added to the HighScore board</param>
    public void AddPlayer(TopPlayer newPlayer)
    {
        if (this.IsResultHighScore(newPlayer.PlayerScore))
        {
            int newHighScoreIndex = this.HighScoreCount;
            if (this.HighScoreCount == HIGHSCORE_NUMBER_OF_RESULTS)
            {
                newHighScoreIndex = this.HighScoreCount - 1;
                this.HighScores[newHighScoreIndex] = newPlayer;
            }
            else
            {
                this.HighScores.Add(newPlayer);
            }

            if (this.HighScoreCount > 1)
            {
                this.HighScores = this.HighScores.OrderBy(x => x.PlayerScore).ToList();
            }
        }
    }
Ejemplo n.º 19
0
    /// <summary>
    /// Adds a player to the HighScore board
    /// </summary>
    /// <param name="newPlayer">The player to be added to the HighScore board</param>
    public void AddPlayer(TopPlayer newPlayer)
    {
        if (this.IsResultHighScore(newPlayer.PlayerScore))
        {
            int newHighScoreIndex = this.HighScoreCount;
            if (this.HighScoreCount == HIGHSCORE_NUMBER_OF_RESULTS)
            {
                newHighScoreIndex = this.HighScoreCount - 1;
                this.HighScores[newHighScoreIndex] = newPlayer;
            }
            else
            {
                this.HighScores.Add(newPlayer);
            }

            if (this.HighScoreCount > 1)
            {
                this.HighScores = this.HighScores.OrderBy(x => x.PlayerScore).ToList();
            }
        }
    }
Ejemplo n.º 20
0
        public static void AddToTop(TopPlayer topPlayer)
        {
            var currentTop = ReadTop();

            currentTop.Add(topPlayer);

            currentTop.OrderBy(t => t.Points);

            while (currentTop.Count > 10)
            {
                currentTop.RemoveAt(currentTop.Count - 1);
            }

            string json = string.Empty;

            try
            {
                json = JsonConvert.SerializeObject(currentTop, Formatting.Indented);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Unable serialize top10 entities: {ex.Message}.");
                return;
            }

            try
            {
                using (var sw = new StreamWriter("Data/Data/top.dat"))
                {
                    sw.Write(json);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Unable save top entities to file Data/Data/top.dat: {ex.Message}.");
            }
        }
Ejemplo n.º 21
0
        public void AddPlayerTest7Players()
        {
            TopPlayer player1 = new TopPlayer("Vasil", 5);
            TopPlayer player2 = new TopPlayer("Pesho", 1);
            TopPlayer player3 = new TopPlayer("Vesko", 4);
            TopPlayer player4 = new TopPlayer("Nasko", 2);
            TopPlayer player5 = new TopPlayer("Nasko", 8);
            TopPlayer player6 = new TopPlayer("Nasko", 7);
            TopPlayer player7 = new TopPlayer("Nasko", 0);
            HighScoreBoard highScoreBoard = new HighScoreBoard();
            highScoreBoard.AddPlayer(player1);
            highScoreBoard.AddPlayer(player2);
            highScoreBoard.AddPlayer(player3);
            highScoreBoard.AddPlayer(player4);
            highScoreBoard.AddPlayer(player5);
            highScoreBoard.AddPlayer(player6);
            highScoreBoard.AddPlayer(player7);

            Assert.AreEqual(player7, highScoreBoard.HighScores[0]);
            Assert.AreEqual(player2, highScoreBoard.HighScores[1]);
            Assert.AreEqual(player4, highScoreBoard.HighScores[2]);
            Assert.AreEqual(player3, highScoreBoard.HighScores[3]);
            Assert.AreEqual(player1, highScoreBoard.HighScores[4]);
        }
Ejemplo n.º 22
0
 public void Awake()
 {
     S = this;
     time = Time.time;
 }
Ejemplo n.º 23
0
    /// <summary>
    /// Processes the Game win event
    /// Writes an appropriate message on the User interface and updates the HighScore
    /// </summary>
    private void ProcessWin()
    {
        this.USER_INTERFACE.WriteSingleOutputLine("The secret word is " + this.currentWord.GetHiddenWord);
        this.USER_INTERFACE.WriteSingleOutputLine("\nYou won with " + this.currentMistakesCount + " mistakes");

        bool betterThanLast = this.highScoreBoard.IsResultHighScore(this.currentMistakesCount);

        if (!this.usedHelp && betterThanLast)
        {
            this.USER_INTERFACE.WriteSingleOutputLine("\nPlease enter your name for the top scoreboard: ");

            string playerName = this.USER_INTERFACE.ReadSingleInputLine();
            int playerScore = this.currentMistakesCount;
            TopPlayer newTopPlayer = new TopPlayer(playerName, playerScore);

            this.highScoreBoard.AddPlayer(newTopPlayer);

            this.ProcessHighscoreRequest();
        }
        else if (!betterThanLast)
        {
            this.USER_INTERFACE.WriteSingleOutputLine(" but your result is lower than top scores\n");
        }
        else
        {
            this.USER_INTERFACE.WriteSingleOutputLine(" but you have cheated. \nYou are not allowed to enter into the scoreboard.\n");
        }
    }
Ejemplo n.º 24
0
 private void RepeatButton_Click_1(object sender, RoutedEventArgs e)
 {
     TopPlayer.Pause();
     TopPlayer.Position = TopPlayer.Position + TimeSpan.FromSeconds(1);
     TopPlayer.Play();
 }
Ejemplo n.º 25
0
 private void TopPlayer_MediaOpened(object sender, RoutedEventArgs e)
 {
     timelineSlider.Maximum = TopPlayer.NaturalDuration.TimeSpan.TotalSeconds;
     timelineSlider.Value   = 0;
     TopPlayer.Play();
 }
Ejemplo n.º 26
0
 private void btnPause_Click(object sender, RoutedEventArgs e)
 {
     TopPlayer.Pause();
     timerVideoTime.Stop();
 }