Exemplo n.º 1
0
        public static void Initialize(GameClock gameClock)
        {
            gameClock.TickEvent += new GameClock.TickHandler(On_Tick);
            PlayerManager.gameClock = gameClock;

            Query query = new Query("select * from Player");

            foreach (DataRow player_row in query.result.Tables[0].Rows)
            {
                Players.Add(player_row["user_name"].ToString(), new Player(player_row["user_name"].ToString(), PlayerManager.gameClock));
            }

            MainForm.Log("PlayerManager Initialized");
        }
Exemplo n.º 2
0
        private void Load_Database_Values()
        {
            Query query = new Query("select * from Player where user_name=\'" + this.user_name + "\'");

            if (query.result.Tables[0].Rows.Count != 0)
            {
                this.ID = (int)query.result.Tables[0].Rows[0]["id"];
                this.strategy = (PLAYER_STRAT)(int)query.result.Tables[0].Rows[0]["strategy"];
                this.credits_current = (int)query.result.Tables[0].Rows[0]["credits_current"];
                this.Asteroids = Parse_Asteroids(query.result.Tables[0].Rows[0]["asteroids"].ToString());
                this.Structures = Parse_Structures(query.result.Tables[0].Rows[0]["structures"].ToString());
                this.Ships_Attacking = Parse_Ships(query.result.Tables[0].Rows[0]["ships_attacking"].ToString());
                this.Ships_Defending = Parse_Ships(query.result.Tables[0].Rows[0]["ships_defending"].ToString());

                this.action_attack = Parse_Action(query.result.Tables[0].Rows[0]["action_attack"].ToString());
                this.action_build_ship = Parse_Action(query.result.Tables[0].Rows[0]["action_build_ship"].ToString());
                this.action_build_struct = Parse_Action(query.result.Tables[0].Rows[0]["action_build_struct"].ToString());
                this.action_research = Parse_Action(query.result.Tables[0].Rows[0]["action_research"].ToString());
                this.action_diplomacy = Parse_Action(query.result.Tables[0].Rows[0]["action_diplomacy"].ToString());
                this.action_direct = Parse_Action(query.result.Tables[0].Rows[0]["action_direct"].ToString());

                this.tech_ship_weapons = (int)query.result.Tables[0].Rows[0]["tech_ship_weapons"];
                this.tech_ship_hp = (int)query.result.Tables[0].Rows[0]["tech_ship_hp"];
                this.tech_ship_engine = (int)query.result.Tables[0].Rows[0]["tech_ship_engine"];
                this.tech_ship_stealth = (int)query.result.Tables[0].Rows[0]["tech_ship_stealth"];
                this.tech_struct_weapons = (int)query.result.Tables[0].Rows[0]["tech_struct_weapons"];
                this.tech_struct_hp = (int)query.result.Tables[0].Rows[0]["tech_struct_hp"];
                this.tech_struct_econ = (int)query.result.Tables[0].Rows[0]["tech_struct_mining"];
                this.tech_struct_research = (int)query.result.Tables[0].Rows[0]["tech_struct_research"];
                this.tech_struct_diplomacy = (int)query.result.Tables[0].Rows[0]["tech_struct_diplomacy"];
                this.tech_construct_speed = (int)query.result.Tables[0].Rows[0]["tech_construct_speed"];
                this.tech_base_sensors = (int)query.result.Tables[0].Rows[0]["tech_base_sensors"];
                this.tech_base_fleet_cap = (int)query.result.Tables[0].Rows[0]["tech_base_fleet_cap"];
                this.tech_base_asteroid_cap = (int)query.result.Tables[0].Rows[0]["tech_base_asteroid_cap"];

                if (this.action_attack.Type == PLAYER_ACTION.ACTION_NO_ACTION)
                {
                    fleet_at_home = true;
                }
                else
                {
                    fleet_at_home = false;
                }
            }
            else
            {
                MainForm.Log("Error! A player got past authentication without existing! Username: " + this.user_name);
            }
        }
Exemplo n.º 3
0
        public void Save_Database_Values()
        {
            Query query = new Query("select * from Player where user_name=\'" + this.user_name + "\'");

            if (query.result.Tables[0].Rows.Count != 0)
            {
                query.result.Tables[0].Rows[0]["credits_current"] = this.credits_current;

                query.result.Tables[0].Rows[0]["asteroids"] = Serialize_Asteroids(this.Asteroids);

                query.result.Tables[0].Rows[0]["structures"] = Serialize_Structures(this.Structures);

                //Store Ships
                query.result.Tables[0].Rows[0]["ships_attacking"] = Serialize_Ships(this.Ships_Attacking);
                query.result.Tables[0].Rows[0]["ships_defending"] = Serialize_Ships(this.Ships_Defending);

                //Store Actions
                query.result.Tables[0].Rows[0]["action_attack"] = Serialize_Action(this.action_attack);
                query.result.Tables[0].Rows[0]["action_build_ship"] = Serialize_Action(this.action_build_ship);
                query.result.Tables[0].Rows[0]["action_build_struct"] = Serialize_Action(this.action_build_struct);
                query.result.Tables[0].Rows[0]["action_research"] = Serialize_Action(this.action_research);
                query.result.Tables[0].Rows[0]["action_diplomacy"] = Serialize_Action(this.action_diplomacy);
                query.result.Tables[0].Rows[0]["action_direct"] = Serialize_Action(this.action_direct);

                //Store Tech Levels
                query.result.Tables[0].Rows[0]["tech_ship_weapons"] = this.tech_ship_weapons;
                query.result.Tables[0].Rows[0]["tech_ship_hp"] = this.tech_ship_hp;
                query.result.Tables[0].Rows[0]["tech_ship_engine"] = this.tech_ship_engine;
                query.result.Tables[0].Rows[0]["tech_ship_stealth"] = this.tech_ship_stealth;
                query.result.Tables[0].Rows[0]["tech_struct_weapons"] = this.tech_struct_weapons;
                query.result.Tables[0].Rows[0]["tech_struct_hp"] = this.tech_struct_hp;
                query.result.Tables[0].Rows[0]["tech_struct_mining"] = this.tech_struct_econ;
                query.result.Tables[0].Rows[0]["tech_struct_research"] = this.tech_struct_research;
                query.result.Tables[0].Rows[0]["tech_struct_diplomacy"] = this.tech_struct_diplomacy;
                query.result.Tables[0].Rows[0]["tech_construct_speed"] = this.tech_construct_speed;
                query.result.Tables[0].Rows[0]["tech_base_sensors"] = this.tech_base_sensors;
                query.result.Tables[0].Rows[0]["tech_base_fleet_cap"] = this.tech_base_fleet_cap;
                query.result.Tables[0].Rows[0]["tech_base_asteroid_cap"] = this.tech_base_asteroid_cap;

                query.Update();
            }
        }