Exemplo n.º 1
0
    void Start()
    {
        weaponHotbar = gameObject.GetComponent <WeaponHotbar>();

        foreach (var g in WeaponsToPickUp)
        {
            Pick(g);
        }

        weaponHotbar.HoldWeapon(0);
    }
Exemplo n.º 2
0
        public static void GetPlayerWeaponHotbar(Session MySession)
        {
            var connectionString = ConfigurationManager.ConnectionStrings["DevLocal"].ConnectionString;

            //Set connection property from connection string and open connection
            using MySqlConnection con = new MySqlConnection(connectionString);
            con.Open();

            //Queries DB for all characters and their necessary attributes  to generate character select
            //Later should convert to a SQL stored procedure if possible.
            //Currently pulls ALL charcters, will pull characters based on accountID.
            using var cmd   = new MySqlCommand("GetCharWeaponHotbar", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("charID", MySession.MyCharacter.ServerID);
            using MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                //Instantiate new character object, not to be confused with a newly created character
                WeaponHotbar thisHotbar = new WeaponHotbar
                                          (
                    //Hotbar name
                    rdr.GetString(0),
                    //primaryID
                    rdr.GetInt32(1),
                    //secondaryID
                    rdr.GetInt32(2)
                                          );

                //Add these weapon hotbars
                MySession.MyCharacter.WeaponHotbars.Add(thisHotbar);
            }
            rdr.Close();

            //If less then 4 weapon hotbars, need constructor dummies untill 4 total
            for (int i = MySession.MyCharacter.WeaponHotbars.Count(); i < 4; i++)
            {
                MySession.MyCharacter.WeaponHotbars.Add(new WeaponHotbar());
            }
        }