예제 #1
0
        // Called directly by GetCharacterList() webservice
        public static bool GetAccountCharacterList(
            string connection_string,
            int account_id,
            out CharacterState[] character_list,
            out string result)
        {
            bool success = true;

            character_list = null;
            result = SuccessMessages.GENERAL_SUCCESS;

            using (AsyncRPGDataContext context = new AsyncRPGDataContext(connection_string))
            {
                try
                {
                    CharacterQueries.GetAccountCharacterList(context, account_id, out character_list);
                }
                catch (System.Exception)
                {
                    success = false;
                    result = ErrorMessages.DB_ERROR + "(Failed to get account character list state)";
                }
            }

            return success;
        }
        // Result Data
        public BindCharacterToGameRequestProcessor(
            int character_id,
            int game_id)
        {
            m_character_id = character_id;
            m_game_id = game_id;

            m_character_state = null;
            m_previous_game_id = -1;
        }
        public CharacterDeleteRequestProcessor(
            int account_id,
            int character_id)
        {
            m_account_id = account_id;
            m_character_id = character_id;

            m_character_state= null;
            m_remaining_character_ids = null;
        }
        private bool LookupGameCharacterData(
            RequestCache requestCache,
            out string result_code)
        {
            bool success;

            CharacterQueries.GetGameCharacterList(
                requestCache.DatabaseContext,
                m_game_id,
                out m_characters);

            m_my_character = Array.Find(m_characters, c => c.character_id == m_character_id);

            success= (m_my_character != null);
            result_code = success ? SuccessMessages.GENERAL_SUCCESS : ErrorMessages.DB_ERROR + "(My character not associated with game)";

            return success;
        }
        private TypedFlags<eBindGameAction> LookupCharacterData(
            RequestCache requestCache)
        {
            TypedFlags<eBindGameAction> actionFlags = new TypedFlags<eBindGameAction>();

            actionFlags.Clear();

            // Get the current state of the character before moving them to another game
            m_character_state = CharacterQueries.GetFullCharacterState(requestCache.DatabaseContext, m_character_id);

            // Get the previous game this character was a part of, if any
            m_previous_game_id = m_character_state.game_id;

            // Only bother doing anything if the character isn't already bound to this game
            if (m_previous_game_id != m_game_id)
            {
                if (m_previous_game_id != -1)
                {
                    actionFlags.Set(eBindGameAction.leaveGame, true);
                }

                actionFlags.Set(eBindGameAction.joinGame, true);
            }

            return actionFlags;
        }
예제 #6
0
        public static void GetGameCharacterList(
            AsyncRPGDataContext context,
            int game_id,
            out CharacterState[] character_list)
        {
            List<CharacterState> temp_character_list = new List<CharacterState>();

            var query =
                from c in context.Characters
                join g in context.Games on c.GameID equals g.GameID
                where c.GameID == game_id
                select new
                {
                    c.CharacterID,
                    c.Name,
                    c.Archetype,
                    c.Gender,
                    c.PictureID,
                    c.PowerLevel,
                    c.RoomX, c.RoomY, c.RoomZ,
                    c.X, c.Y, c.Z, c.Angle,
                    c.GameID,
                    GameName = g.Name
                };

            foreach (var dbCharacter in query)
            {
                CharacterState entry = new CharacterState();

                entry.character_id = dbCharacter.CharacterID;
                entry.character_name = dbCharacter.Name;
                entry.archetype = dbCharacter.Archetype;
                entry.gender = dbCharacter.Gender ? 1 : 0;
                entry.picture_id = dbCharacter.PictureID;
                entry.power_level = dbCharacter.PowerLevel;
                entry.room_x = dbCharacter.RoomX;
                entry.room_y = dbCharacter.RoomY;
                entry.room_z = dbCharacter.RoomZ;
                entry.x = (float)dbCharacter.X;
                entry.y = (float)dbCharacter.Y;
                entry.z = (float)dbCharacter.Z;
                entry.angle = (float)dbCharacter.Angle;
                entry.game_id = dbCharacter.GameID;
                entry.game_name = dbCharacter.GameName;

                temp_character_list.Add(entry);
            }

            character_list = temp_character_list.ToArray();
        }
예제 #7
0
        public static CharacterState GetFullCharacterState(
            AsyncRPGDataContext context,
            int character_id)
        {
            CharacterState character_state = new CharacterState();

            var dbCharacter =
                (from c in context.Characters
                    join g in context.Games on c.GameID equals g.GameID into sr
                    from x in sr.DefaultIfEmpty()
                    where c.CharacterID == character_id
                    select new
                    {
                        c.Name,
                        c.Archetype,
                        c.Gender,
                        c.PictureID,
                        c.PowerLevel,
                        c.Energy,
                        c.RoomX,
                        c.RoomY,
                        c.RoomZ,
                        c.X,
                        c.Y,
                        c.Z,
                        c.Angle,
                        c.GameID,
                        GameName = x.Name ?? "" // Can be null if character isn't in a game
                    }).SingleOrDefault();

            character_state.character_id = character_id;
            character_state.character_name = dbCharacter.Name;
            character_state.archetype = dbCharacter.Archetype;
            character_state.gender = dbCharacter.Gender ? 1 : 0;
            character_state.picture_id = dbCharacter.PictureID;
            character_state.power_level = dbCharacter.PowerLevel;
            character_state.energy = dbCharacter.Energy;
            character_state.room_x = dbCharacter.RoomX;
            character_state.room_y = dbCharacter.RoomY;
            character_state.room_z = dbCharacter.RoomZ;
            character_state.x = (float)dbCharacter.X;
            character_state.y = (float)dbCharacter.Y;
            character_state.z = (float)dbCharacter.Z;
            character_state.angle = (float)dbCharacter.Angle;
            character_state.game_id = dbCharacter.GameID;
            character_state.game_name = dbCharacter.GameName;

            return character_state;
        }
예제 #8
0
        // Called directly by GetCharacterFullState() webservice
        public static bool GetFullCharacterState(
            string connection_string,
            int character_id,
            out CharacterState character_state,
            out string result)
        {
            bool success = true;

            result = SuccessMessages.GENERAL_SUCCESS;

            character_state = new CharacterState();

            using (AsyncRPGDataContext context = new AsyncRPGDataContext(connection_string))
            {
                try
                {
                    character_state = CharacterQueries.GetFullCharacterState(context, character_id);
                }
                catch (System.Exception)
                {
                    success = false;
                    result = ErrorMessages.DB_ERROR+"(Failed to get full character state)";
                }
            }

            return success;
        }
예제 #9
0
        public static void GetAccountCharacterList(
            AsyncRPGDataContext context,
            int account_id,
            out CharacterState[] character_list)
        {
            var query=
                from c in context.Characters
                join g in context.Games on c.GameID equals g.GameID into sr
                from x in sr.DefaultIfEmpty()
                where c.AccountID == account_id
                select new
                {
                    c.GameID,
                    GameName = x.Name ?? "", // Can be null if character isn't in a game
                    c.CharacterID,
                    c.Name,
                    c.Archetype,
                    c.Gender,
                    c.PictureID,
                    c.PowerLevel,
                    c.RoomX,
                    c.RoomY,
                    c.RoomZ,
                    c.X,
                    c.Y,
                    c.Z,
                    c.Angle
                };

            List<CharacterState> temp_character_list = new List<CharacterState>();

            foreach (var dbCharacter in query)
            {
                CharacterState entry = new CharacterState();

                entry.character_id = dbCharacter.CharacterID;
                entry.character_name = dbCharacter.Name;
                entry.archetype = dbCharacter.Archetype;
                entry.gender = dbCharacter.Gender ? 1 : 0;
                entry.picture_id = dbCharacter.PictureID;
                entry.power_level = dbCharacter.PowerLevel;
                entry.room_x = dbCharacter.RoomX;
                entry.room_y = dbCharacter.RoomY;
                entry.room_z = dbCharacter.RoomZ;
                entry.x = (double)dbCharacter.X;
                entry.y = (double)dbCharacter.Y;
                entry.z = (double)dbCharacter.Z;
                entry.angle = (double)dbCharacter.Angle;
                entry.game_id = dbCharacter.GameID;
                entry.game_name = dbCharacter.GameName;

                temp_character_list.Add(entry);
            }

            character_list = temp_character_list.ToArray();
        }
예제 #10
0
        public static Player CreatePlayer(CharacterState characterState)
        {
            Player player = new Player();

            player.m_character_id = characterState.character_id;
            player.m_character_name = characterState.character_name;
            player.m_archetype = (GameConstants.eArchetype)characterState.archetype;
            player.m_gender = (GameConstants.eGender)characterState.gender;
            player.m_picture_id = characterState.picture_id;
            player.m_power_level = characterState.power_level;
            player.m_energy = characterState.energy;
            player.m_health = 0; //TODO: characterState.health;
            player.m_room_key =
                new RoomKey(
                    characterState.game_id,
                    characterState.room_x,
                    characterState.room_y,
                    characterState.room_z);
            player.m_position = new Point3d((float)characterState.x, (float)characterState.y, (float)characterState.z);
            player.m_angle = (float)characterState.angle;

            return player;
        }