예제 #1
0
        private void Test()
        {
            Game g = new Game();
            PropertyBag p = new PropertyBag();
            g.Properties = p;
            g.Owner = -1;

            TurnedGameServerGame tg = new TurnedGameServerGame(g);
            string msg ="";
            CharacterInfo ci1 = new CharacterInfo();
            ci1.ID = 1;
            ci1.CharacterName = "Alpha";
            ServerCharacterInfo t1 = new ServerCharacterInfo(ci1);
            tg.AddPlayer(t1, ref msg);

            CharacterInfo ci2 = new CharacterInfo();
            ci2.ID = 2;
            ci2.CharacterName = "Bravo";
            ServerCharacterInfo t2 = new ServerCharacterInfo(ci2);
            tg.AddPlayer(t2, ref msg);

            CharacterInfo ci3 = new CharacterInfo();
            ci3.ID = 3;
            ci3.CharacterName = "Charly";
            ServerCharacterInfo t3 = new ServerCharacterInfo(ci3);
            tg.AddPlayer(t3, ref msg);

            string msg2 ="";
            tg.StartGame(ref msg2, true);
        }
예제 #2
0
 public PacketRelay()
 {
     OriginServer = "";
     TargetServer = "";
     From = new CharacterInfo(-1);
     To = Guid.Empty;
     Message = new byte[0];
 }
 private void FirePlayerRemoved(string msg, ClientServerOutboundConnection con, CharacterInfo player, Game g, PropertyBag parms)
 {
     if (PlayerRemovedInvoker != null)
     {
         PlayerRemovedInvoker(msg, con, player, g, parms);
     }
 }
 private void FirePlayerJoined(bool isFromCentralServer, bool isFromContentServer, bool result, string msg, ClientServerOutboundConnection con, CharacterInfo player, Game g, PropertyBag parms)
 {
     if (PlayerJoinedInvoker != null)
     {
         PlayerJoinedInvoker(isFromCentralServer, isFromContentServer, result, msg, con, player, g, parms);
     }
 }
예제 #5
0
파일: Game.cs 프로젝트: kamilion/WISP
        public override void Deserialize(byte[] data, Pointer p, bool includeSubComponents)
        {
            // General match info
            Owner = BitPacker.GetInt(data, p);
            GameID = new Guid(BitPacker.GetString(data, p));

            // Options
            Properties = BitPacker.GetPropertyBag(data, p);

            // Players
            int numPlayers = BitPacker.GetInt(data, p);
            for (int i = 0; i < numPlayers; i++)
            {
                CharacterInfo ci = new CharacterInfo();
                ci.Properties = BitPacker.GetPropertyBag(data, p);
                ci.Stats = BitPacker.GetStatBag(data, p);
                ci.ID = BitPacker.GetInt(data, p);
                Players.Add(ci.ID, ci);
            }

            base.Deserialize(data, p, includeSubComponents);
        }
 private void OnCharacterActivated(INetworkConnection con, Packet gmsg)
 {
     PacketGenericMessage msg = gmsg as PacketGenericMessage;
     CharacterInfo ci = msg.Parms.GetComponentProperty((int)PropertyID.CharacterInfo) as CharacterInfo;
     CurrentCharacter = ci;
     FireCharacterActivated(this, EventArgs.Empty);
 }
 protected virtual void OnRequestSelectCharacterReply(INetworkConnection con, Packet reply)
 {
     PacketReply p = reply as PacketReply;
     if (p.ReplyCode != ReplyType.OK)
     {
         FireSelectCharacterFailed(p.ReplyMessage);
     }
     else if (p.ReplyCode == ReplyType.OK)
     {
         CurrentCharacter = p.Parms.GetComponentProperty((int)PropertyID.CharacterInfo) as CharacterInfo;
         FireCharacterActivated(this, EventArgs.Empty);
     }
 }
예제 #8
0
 public ServerCharacterInfo(CharacterInfo characterInfo, Guid ownerId)
     : this(characterInfo, null)
 {
     m_Owner = ownerId;
 }
예제 #9
0
 public ServerCharacterInfo(CharacterInfo characterInfo, ServerUser owner)
 {
     OwningAccount = owner;
     m_CharacterInfo = characterInfo;
     OnInitialize();
 }
예제 #10
0
 public ServerCharacterInfo(CharacterInfo characterInfo)
     : this(characterInfo, null)
 {
 }
예제 #11
0
        public override void Deserialize(byte[] data, Pointer p, bool includeComponents)
        {
            m_CharacterInfo = new Shared.CharacterInfo();
            m_CharacterInfo.Deserialize(data, p, includeComponents);

            ServerUser su = new ServerUser();
            su.AuthTicket = Guid.Empty;

            su.OwningServer = BitPacker.GetString(data, p);
            su.ID = new Guid(BitPacker.GetString(data, p));
            su.AccountName = BitPacker.GetString(data, p);

            su.Profile = (AccountProfile)BitPacker.GetSerializableWispObject(data, p);

            su.CurrentCharacter = this;
            this.TargetResource = new Guid(BitPacker.GetString(data, p));

            OwningAccount = su;

            base.Deserialize(data, p, includeComponents);
        }
예제 #12
0
 protected ServerCharacterInfo OnCharacterObjectCreate(CharacterInfo ci, ServerUser owner)
 {
     if (CharacterObjectCreate != null)
     {
         return CharacterObjectCreate(ci, owner);
     }
     return new ServerCharacterInfo(CreateNewCharacterShell(), owner);
 }
예제 #13
0
 /// <summary>
 /// Creates a default character object with stats and properties based on the XML character template file values.
 /// </summary>
 /// <returns></returns>
 public CharacterInfo CreateNewCharacterShell()
 {
     CharacterInfo toon = new CharacterInfo();
     toon.Stats.UpdateWithValues(m_CharacterTemplateStats);
     toon.Properties.UpdateWithValues(m_CharacterTemplateProperties);
     return toon;
 }
예제 #14
0
 private void OnGameServer_PlayerRemoved(string msg, ClientServerOutboundConnection sender, CharacterInfo player, Game theGame, PropertyBag parms)
 {
     FirePlayerRemovedFromGame(msg, sender, player, theGame, parms);
 }
예제 #15
0
 private void OnGameServer_PlayerJoined(bool isFromCentralServer, bool isFromContentServer, bool success, string msg, ClientServerOutboundConnection sender, CharacterInfo player, Game theGame, PropertyBag parms)
 {
     FirePlayerJoinedGame(false, true, success, msg, sender, player, theGame, parms);
 }
예제 #16
0
        private void OnCentralServer_PlayerJoined(bool isFromCentralServer, bool isFromContentServer, bool success, string msg, ClientServerOutboundConnection sender, CharacterInfo player, Game theGame, PropertyBag parms)
        {
            if (theGame == null)
            {
                msg += "Unknow game: null";
                success = false;
            }

            if (success)
            {
                m_PendingGameToJoin = theGame;
            }

            FirePlayerJoinedGame(true, false, success, msg, sender, player, theGame, parms);

            // let's disconnect from central and join the GS, if Central says it's okay.
            if (success)
            {
                Log.LogMsg("Successfully joined a game. Waiting for transfer confirmation. ");
            }
            else
            {
                Log.LogMsg("Failed to join content instance. " + msg);
            }
        }