private void SubmitButton_OnClick(object sender, RoutedEventArgs e)
 {
     if (username.Text == "Admin" && battleID.Text == "12345")
     {
         loggedIn = true;
         admin    = true;
         MessageBox.Show("Successfully logged in as Admin!", "Login success", MessageBoxButton.OK);
     }
     else if (!string.IsNullOrEmpty(battleID.Text))
     {
         player_stats Player = player_statsDA.GetPlayerStats(int.Parse(battleID.Text));
         if (Player != null)
         {
             if (username.Text == Player.Name)
             {
                 loggedIn = true;
                 MessageBox.Show("Successfully logged in as " + username.Text + "!", "Login success", MessageBoxButton.OK);
                 LoginText.Text = "Welcome";
             }
             else
             {
                 MessageBox.Show("Invalid username", "Login error", MessageBoxButton.OK);
             }
         }
         else
         {
             MessageBox.Show("Battle ID not Found", "Login error", MessageBoxButton.OK);
         }
     }
     else
     {
         MessageBox.Show("Invalid username or battle ID!", "Login error", MessageBoxButton.OK);
     }
 }
        public static player_stats GetPlayerStats(int battleTag)
        {
            string query = "SELECT battle_tag, name, rank_points, num_of_kills, num_of_deaths, (num_of_kills/num_of_deaths) AS KD_ratio, CASE WHEN rank_points >= 800 THEN 'Radiant' WHEN rank_points >= 700 THEN 'Immortal' WHEN rank_points >= 600 THEN 'Diamond' WHEN rank_points >= 500 THEN 'Platinum' WHEN rank_points >= 400 THEN 'Gold' WHEN rank_points >= 300 THEN 'Silver' WHEN rank_points >= 200 THEN 'Bronze' WHEN rank_points >= 100 THEN 'Iron' ELSE 'Unranked' END AS rank_name FROM player_stats WHERE battle_tag = (@BattleTag) limit 1";

            cmd = DBHelper.GetPlayerQuery(query, battleTag);
            player_stats aUser = null;

            if (cmd != null)
            {
                dt  = new DataTable();
                sda = new MySqlDataAdapter(cmd);
                sda.Fill(dt);
                foreach (DataRow dr in dt.Rows)
                {
                    string uBattleTag = dr["battle_tag"].ToString();

                    string uName = dr["name"].ToString();

                    string uRankPoints = dr["rank_points"].ToString();

                    string uKillCount = dr["num_of_kills"].ToString();

                    string uDeathCount = dr["num_of_deaths"].ToString();

                    string uKDRatio = dr["KD_ratio"].ToString();

                    string uRank = dr["rank_name"].ToString();


                    aUser = new player_stats(uBattleTag, uName, uRankPoints, uKillCount, uDeathCount, uKDRatio, uRank);
                }
            }
            return(aUser);
        }
Esempio n. 3
0
    // Start is called before the first frame update
    void Start()
    {
        ps = GameObject.Find("Player").GetComponent <player_stats>();
        rb = gameObject.GetComponent <Rigidbody2D>();
        int direction = GameObject.Find("Final_boss").transform.localScale.x > 0 ? 1 : -1;

        rb.velocity = new Vector2(fireSpeed * direction, 0);
    }
Esempio n. 4
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.tag == "Player")
     {
         player_stats ps = GameObject.Find("Player").GetComponent <player_stats>();
         ps.pv -= damage;
         Destroy(gameObject);
     }
 }
Esempio n. 5
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.name == "Player")
     {
         player_stats ps = col.gameObject.GetComponent <player_stats>();
         ps.pv    -= damage;
         stats.pv -= 1;
     }
 }
        // GET: player_stats/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            player_stats player_stats = db.player_stats.Find(id);

            if (player_stats == null)
            {
                return(HttpNotFound());
            }
            return(View(player_stats));
        }
Esempio n. 7
0
        private void SubmitButton_OnClick(object sender, RoutedEventArgs e)
        {
            string playerID = UsernameText.Text;

            if (!string.IsNullOrEmpty(playerID))
            {
                int temp;
                if (int.TryParse(playerID, out temp))
                {
                    player_stats PStats = player_statsDA.GetPlayerStats(int.Parse(playerID));

                    if (PStats != null)
                    {
                        rp.Text = "Rank Points: ";
                        tk.Text = "Total Kills:";
                        td.Text = "Total Deaths: ";
                        kd.Text = "KD Ratio: ";

                        PlayerName.Text = PStats.Name;
                        PlayerTag.Text  = "#" + playerID;
                        RankPoints.Text = PStats.RankPoints;
                        Kills.Text      = PStats.KillCount;
                        Deaths.Text     = PStats.DeathCount;
                        kdratio.Text    = PStats.KDRatio;
                        Rank.Text       = PStats.RankName;

                        if (admin)
                        {
                            RankPoints_Updated.Visibility = Visibility.Visible;
                            Kills_Updated.Visibility      = Visibility.Visible;
                            Deaths_Updated.Visibility     = Visibility.Visible;
                            UpdateButton.Visibility       = Visibility.Visible;

                            RankPoints_Updated.Text = PStats.RankPoints;
                            Kills_Updated.Text      = PStats.KillCount;
                            Deaths_Updated.Text     = PStats.DeathCount;
                        }
                    }
                    else
                    {
                        MessageBox.Show($"Invalid Battle Tag! Try Again!");
                    }
                }
                else
                {
                    MessageBox.Show($"Invalid Battle Tag! Try Again!");
                }
            }
        }
    // Start is called before the first frame update
    void Start()
    {
        ps       = GameObject.Find("Player").GetComponent <player_stats>();
        hitbox   = GameObject.Find("hit_zone");
        rb       = gameObject.GetComponent <Rigidbody2D>();
        animator = gameObject.GetComponent <Animator>();

        slash = 0;
        slashDurationCounter = 0;

        dash         = 0;
        dashDuration = 0;

        direction = -1;

        firePoint = GameObject.Find("firePoint");
    }
Esempio n. 9
0
        private void SubmitButton_OnClick(object sender, RoutedEventArgs e)
        {
            player_stats Player = player_statsDA.GetPlayerStats(int.Parse(battleID.Text));

            if (Player != null)
            {
                RankPoints.Text           = Player.RankPoints.ToString();
                RankPoints.Visibility     = Visibility.Visible;
                RankPointsText.Visibility = Visibility.Visible;

                Kills.Text           = Player.KillCount.ToString();
                Kills.Visibility     = Visibility.Visible;
                KillsText.Visibility = Visibility.Visible;

                Deaths.Text          = Player.DeathCount.ToString();
                Deaths.Visibility    = Visibility.Visible;
                DeathText.Visibility = Visibility.Visible;
            }
        }
Esempio n. 10
0
        private void UpdateButton_OnClick(object sender, RoutedEventArgs e)
        {
            string playerID   = UsernameText.Text;
            string rankPoints = RankPoints_Updated.Text;
            string kills      = Kills_Updated.Text;
            string deaths     = Deaths_Updated.Text;

            if (admin)
            {
                if (!string.IsNullOrEmpty(playerID))
                {
                    int temp;
                    if (int.TryParse(playerID, out temp) && int.TryParse(rankPoints, out temp) && int.TryParse(kills, out temp) && int.TryParse(deaths, out temp))
                    {
                        player_statsDA.UpdatePlayerStats(int.Parse(playerID), int.Parse(rankPoints), int.Parse(kills), int.Parse(deaths));

                        player_stats PStats = player_statsDA.GetPlayerStats(int.Parse(playerID));

                        if (PStats != null)
                        {
                            MessageBox.Show("You updated " + PStats.Name, "Updated player", MessageBoxButton.OK);

                            RankPoints.Text = PStats.RankPoints.ToString();
                            Kills.Text      = PStats.KillCount;
                            Deaths.Text     = PStats.DeathCount;
                        }
                        else
                        {
                            MessageBox.Show($"Invalid Battle Tag! Try Again!");
                        }
                    }
                    else
                    {
                        MessageBox.Show($"Invalid Battle Tag! Try Again!");
                    }
                }
            }
            else
            {
                MessageBox.Show($"Access denied");
            }
        }
Esempio n. 11
0
    void OnTriggerEnter2D(Collider2D col)
    {
        rb.velocity = new Vector2(0, 0);
        Vector3 newScale = gameObject.transform.localScale;

        newScale.x = newScale.x * -1;
        gameObject.transform.localScale = newScale;
        ready = true;
        cd    = couldownAction;

        if (col.gameObject.tag == "Player")
        {
            player_stats ps = GameObject.Find("Player").GetComponent <player_stats>();

            if (!ps.noDamage)
            {
                ps.pv      -= damage;
                ps.noDamage = true;
                ps.damageCd = ps.noDamageTimer;
            }
        }
    }
Esempio n. 12
0
 // Start is called before the first frame update
 void Start()
 {
     ps = GameObject.Find("Player").GetComponent <player_stats>();
 }
Esempio n. 13
0
 // Start is called before the first frame update
 void Start()
 {
     rb        = gameObject.GetComponent <Rigidbody2D>();
     ps        = gameObject.GetComponent <player_stats>();
     animation = gameObject.GetComponent <Animator>();
 }