Beispiel #1
0
 public void VieHahmo(Playerstats player)
 {
     using (connection)
     {
         yhdista();
         string     command    = "INSERT INTO characters(Name, lifeleech, manaleech, defence, dmg, speed, hp, accuracy, level, incdmg, critchance, critdmg, locationX, locationY, towerlvl, hpregen ,inchp, exp, exptonextlvl) VALUES(@name, @lifeleech, @manaleech, @def, @dmg, @speed, @hp, @accuracy, @lvl, @incDMG, @critchance, @critdmg, @locationX, @locationY, @towerlvl, @hpregen, @inchp, @exp, @expToNext)";
         SqlCommand sqlCommand = new SqlCommand(command, connection);
         sqlCommand.Parameters.AddWithValue("@name", player.Name);
         sqlCommand.Parameters.AddWithValue("@lifeleech", player.Lifeleech);
         sqlCommand.Parameters.AddWithValue("@manaleech", player.Manaleech);
         sqlCommand.Parameters.AddWithValue("@def", player.Def);
         sqlCommand.Parameters.AddWithValue("@dmg", player.Dmg);
         sqlCommand.Parameters.AddWithValue("@speed", player.Speed);
         sqlCommand.Parameters.AddWithValue("@hp", player.Hp);
         sqlCommand.Parameters.AddWithValue("@accuracy", player.Accuracy);
         sqlCommand.Parameters.AddWithValue("@lvl", player.Lvl);
         sqlCommand.Parameters.AddWithValue("@critchance", player.Critchance);
         sqlCommand.Parameters.AddWithValue("@critdmg", player.Critdmg);
         sqlCommand.Parameters.AddWithValue("@locationX", player.LocationX);
         sqlCommand.Parameters.AddWithValue("@locationY", player.LocationY);
         sqlCommand.Parameters.AddWithValue("@towerlvl", player.Towerlvl);
         sqlCommand.Parameters.AddWithValue("@hpregen", player.Hpregen);
         sqlCommand.Parameters.AddWithValue("@inchp", player.Inchp);
         sqlCommand.Parameters.AddWithValue("@incDMG", player.Increaseddmg);
         sqlCommand.Parameters.AddWithValue("@exp", player.Exp);
         sqlCommand.Parameters.AddWithValue("@expToNext", player.Exptonext);
         sqlCommand.ExecuteNonQuery();
         ViePassivetree(player);
     }
 }
Beispiel #2
0
        public Playerstats Haeskilltree(Playerstats player)
        {
            string command = "Select * From skillpoints WHERE characterid = @id";

            using (SqlCommand sqlCommand = new SqlCommand(command, connection))
            {
                yhdista();
                sqlCommand.Parameters.AddWithValue("@id", player.Id);
                using (SqlDataReader reader = sqlCommand.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        player.Def1        = reader.GetInt32(4);
                        player.Def2        = reader.GetInt32(5);
                        player.Dmg1        = reader.GetInt32(2);
                        player.Dmg2        = reader.GetInt32(3);
                        player.Dmglesslife = reader.GetInt32(7);
                        player.Doublearmor = reader.GetBoolean(15);
                        player.Dualstrike  = reader.GetBoolean(8);
                        player.Life1       = reader.GetInt32(11);
                        player.Life2       = reader.GetInt32(12);
                        player.Lifereg1    = reader.GetInt32(13);
                        player.Lifereg2    = reader.GetInt32(14);
                        player.Lifesteal1  = reader.GetInt32(9);
                        player.Lifesteal2  = reader.GetInt32(10);
                        player.Bigdef      = reader.GetInt32(6);
                    }
                }
            }
            return(player);
        }
Beispiel #3
0
 public void luohahmo(Playerstats player)
 {
     using (connection)
     {
         yhdista();
         string     command    = "INSERT INTO characters(Name, lifeleech, manaleech, defence, dmg, speed, hp, accuracy, level, incdmg, critchance, critdmg, locationX, locationY, towerlvl, hpregen ,inchp, exp, exptonextlvl) VALUES(@name, @lifeleech, @manaleech, @def, @dmg, @speed, @hp, @accuracy, @lvl, @incDMG, @critchance, @critdmg, @locationX, @locationY, @towerlvl, @hpregen, @inchp, @exp, @expToNext)";
         SqlCommand sqlCommand = new SqlCommand(command, connection);
         sqlCommand.Parameters.AddWithValue("@name", player.Name);
         sqlCommand.Parameters.AddWithValue("@lifeleech", player.Lifeleech);
         sqlCommand.Parameters.AddWithValue("@manaleech", player.Manaleech);
         sqlCommand.Parameters.AddWithValue("@def", player.Def);
         sqlCommand.Parameters.AddWithValue("@dmg", player.Dmg);
         sqlCommand.Parameters.AddWithValue("@speed", player.Speed);
         sqlCommand.Parameters.AddWithValue("@hp", player.Hp);
         sqlCommand.Parameters.AddWithValue("@accuracy", player.Accuracy);
         sqlCommand.Parameters.AddWithValue("@lvl", player.Lvl);
         sqlCommand.Parameters.AddWithValue("@critchance", player.Critchance);
         sqlCommand.Parameters.AddWithValue("@critdmg", player.Critdmg);
         sqlCommand.Parameters.AddWithValue("@locationX", player.LocationX);
         sqlCommand.Parameters.AddWithValue("@locationY", player.LocationY);
         sqlCommand.Parameters.AddWithValue("@towerlvl", player.Towerlvl);
         sqlCommand.Parameters.AddWithValue("@hpregen", player.Hpregen);
         sqlCommand.Parameters.AddWithValue("@inchp", player.Inchp);
         sqlCommand.Parameters.AddWithValue("@incDMG", player.Increaseddmg);
         sqlCommand.Parameters.AddWithValue("@exp", player.Exp);
         sqlCommand.Parameters.AddWithValue("@expToNext", player.Exptonext);
         sqlCommand.ExecuteNonQuery();
         // tässä välissä haetaan pelaajan id koska sitä tarvitaan
         command = "SELECT TOP 1 * FROM characters ORDER BY ID DESC";
         using (sqlCommand = new SqlCommand(command, connection))
         {
             using (SqlDataReader reader = sqlCommand.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     player.Id = reader.GetInt32(0);
                 }
             }
         }
         command    = "INSERT INTO skillpoints(characterid, dmg1, dmg2, def1, def2, bigdef, life1, life2, lifesteal1, lifesteal2, dmglesslife, dualstrike, lifereg1, lifereg2, doublearmor) Values(@characterid, @dmg1, @dmg2, @def1, @def2, @bigdef, @life1, @life2, @lifesteal1, @lifesteal2, @dmglesslife, @dualstrike, @lifereg1, @lifereg2, @doublearmor)";
         sqlCommand = new SqlCommand(command, connection);
         sqlCommand.Parameters.AddWithValue("@dmg1", player.Dmg1);
         sqlCommand.Parameters.AddWithValue("@dmg2", player.Dmg2);
         sqlCommand.Parameters.AddWithValue("@def1", player.Def1);
         sqlCommand.Parameters.AddWithValue("@def2", player.Def2);
         sqlCommand.Parameters.AddWithValue("@dmglesslife", player.Dmglesslife);
         sqlCommand.Parameters.AddWithValue("@doublearmor", player.Doublearmor);
         sqlCommand.Parameters.AddWithValue("@dualstrike", player.Dualstrike);
         sqlCommand.Parameters.AddWithValue("@life1", player.Life1);
         sqlCommand.Parameters.AddWithValue("@life2", player.Life2);
         sqlCommand.Parameters.AddWithValue("@lifereg1", player.Lifereg1);
         sqlCommand.Parameters.AddWithValue("@lifereg2", player.Lifereg2);
         sqlCommand.Parameters.AddWithValue("@lifesteal1", player.Lifesteal1);
         sqlCommand.Parameters.AddWithValue("@lifesteal2", player.Lifesteal2);
         sqlCommand.Parameters.AddWithValue("@bigdef", player.Bigdef);
         sqlCommand.Parameters.AddWithValue("@characterid", player.Id);
         sqlCommand.ExecuteNonQuery();
     }
 }
Beispiel #4
0
 public inventoryform(List <Esineet> inventory, Playerstats playerstats, TheGame theGame)
 {
     InitializeComponent();
     player       = playerstats;
     game         = theGame;
     newinventory = inventory;
     Itemsorting();
 }
Beispiel #5
0
        public List <Playerstats> HaeHahmot()
        {
            List <Playerstats> players = new List <Playerstats>();

            using (connection)
            {
                yhdista();
                string command = "Select * From characters";
                using (SqlCommand sqlCommand = new SqlCommand(command, connection))
                {
                    using (SqlDataReader reader = sqlCommand.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Playerstats player = new Playerstats();
                            player.Id           = reader.GetInt32(0);
                            player.Name         = reader.GetString(1);
                            player.Increaseddmg = reader.GetDecimal(10);
                            player.Lifeleech    = reader.GetDecimal(2);
                            player.Manaleech    = reader.GetDecimal(3);
                            player.Def          = reader.GetDecimal(4);
                            player.Dmg          = reader.GetDecimal(5);
                            player.Speed        = reader.GetDecimal(6);
                            player.Hp           = reader.GetDecimal(7);
                            player.Accuracy     = reader.GetDecimal(8);
                            player.Lvl          = reader.GetInt32(9);
                            player.Critchance   = reader.GetDecimal(11);
                            player.Critdmg      = reader.GetDecimal(12);
                            player.LocationX    = reader.GetInt32(13);
                            player.LocationY    = reader.GetInt32(14);
                            player.Towerlvl     = reader.GetInt32(15);
                            player.Hpregen      = reader.GetDecimal(16);
                            player.Inchp        = reader.GetDecimal(17);
                            player.Exp          = reader.GetInt32(18);
                            player.Exptonext    = reader.GetInt32(19);
                            players.Add(player);
                        }
                    }
                }
            }
            List <Playerstats> allplayerstats = new List <Playerstats>();

            foreach (Playerstats player in players)
            {
                Haeskilltree(player);
                allplayerstats.Add(player);
            }
            return(allplayerstats);
        }
Beispiel #6
0
        public TheGame(Playerstats gotplayer)
        {
            InitializeComponent();

            this.DoubleBuffered = true;
            gc = new Gamecontroller(this);
            CreateWorld();
            gc.CalculatePlayerHp();
            gc.Player   = gotplayer;
            gc.Playerhp = gc.Player.Hp;
            gc.HaeInventory();
            UpdateStyles();
            UpdateUi();
            gc.PassiveTree1 = new PassiveTree(gc);
        }
Beispiel #7
0
 public void ViePassivetree(Playerstats player)
 {
     using (connection)
     {
         string     command    = "UPDATE skillpoints SET dmg1 = @dmg1, dmg2 = @dmg2, def1 = @def1, def2 = @def2, bigdef = @bigdef, life1 = @life1, life2 = @life2, lifesteal1 = @lifesteal1, lifesteal2 = @lifesteal2, dmglesslife = @dmglesslife, dualstrike = @dualstrike, lifereg1 = @lifereg1, lifereg2 = @lifereg2, doublearmor = @doublearmor WHERE characterid = @id";
         SqlCommand sqlCommand = new SqlCommand(command, connection);
         sqlCommand.Parameters.AddWithValue("@id", player.Id);
         sqlCommand.Parameters.AddWithValue("@dmg1", player.Dmg1);
         sqlCommand.Parameters.AddWithValue("@dmg2", player.Dmg2);
         sqlCommand.Parameters.AddWithValue("@def1", player.Def1);
         sqlCommand.Parameters.AddWithValue("@def2", player.Def2);
         sqlCommand.Parameters.AddWithValue("@dmglesslife", player.Dmglesslife);
         sqlCommand.Parameters.AddWithValue("@doublearmor", player.Doublearmor);
         sqlCommand.Parameters.AddWithValue("@dualstrike", player.Dualstrike);
         sqlCommand.Parameters.AddWithValue("@life1", player.Life1);
         sqlCommand.Parameters.AddWithValue("@life2", player.Life2);
         sqlCommand.Parameters.AddWithValue("@lifereg1", player.Lifereg1);
         sqlCommand.Parameters.AddWithValue("@lifereg2", player.Lifereg2);
         sqlCommand.Parameters.AddWithValue("@lifesteal1", player.Lifesteal1);
         sqlCommand.Parameters.AddWithValue("@lifesteal2", player.Lifesteal2);
         sqlCommand.Parameters.AddWithValue("@bigdef", player.Bigdef);
         sqlCommand.ExecuteNonQuery();
     }
 }
Beispiel #8
0
 public void Setplayer(Playerstats player)
 {
     this.player = player;
 }
Beispiel #9
0
 public void Setplayerinv(List <Esineet> lista, Playerstats gotplayer)
 {
     gc.Inventory = lista;
     gc.Player    = gotplayer;
 }