Beispiel #1
0
 void Dispose()
 {
     arena   = null;
     fighter = null;
     socket  = null;
     client  = null;
     buffer  = null;
     reader  = null;
 }
Beispiel #2
0
        internal static FantasyArena CreateArena(string name)
        {
            FantasyArena arena = GetArena(name);

            if (arena == null)
            {
                arena = new FantasyArena(name);
                arenas.Add(arena);
            }
            return(arena);
        }
Beispiel #3
0
        public static FantasyArena JoinArena(FantasyFighterPlayer fighter, string name)
        {
            FantasyArena arena = GetArena(name);

            if (arena != null)
            {
                arena.Add(fighter);
                FantasyServer.lobby_fighters.Remove(fighter);
            }
            return(arena);
        }
Beispiel #4
0
        void HandleMessage(MessageCommon msg)
        {
            switch (msg.message_type)
            {
            case MessageCommon.FantasyFighterMessage.Login:
                fighter.name = (msg as FantasyLoginMessage).username;
                events(fighter.name + " connected");
                //MessageBox.Show( (msg as FantasyLoginMessage).username + " connected" );
                break;

            case MessageCommon.FantasyFighterMessage.ChangeWeapon:
                fighter.weapon = (msg as FantasyFighterWeapon).weapon;
                arena.NotifyPeers(this);
                events(fighter.name + " new weapon " + fighter.weapon);
                break;

            case MessageCommon.FantasyFighterMessage.ChangeStance:
                fighter.stance = (msg as FantasyFighterStance).stance;
                arena.NotifyPeers(this);
                events(fighter.name + " new stance " + fighter.weapon);
                break;

            case MessageCommon.FantasyFighterMessage.CreateArena:
                FantasyArena      created = FantasyArenaList.CreateArena((msg as FantasyArenaCreate).arena_name);
                FantasyArenaAdded added   = new FantasyArenaAdded(created.name);
                Byte[]            output  = added.Serialize();
                foreach (FantasyFighterPlayer player in FantasyServer.lobby_fighters)
                {
                    player.Send(output);
                }
                break;

            case MessageCommon.FantasyFighterMessage.JoinArena:
                arena = FantasyArenaList.JoinArena(this, (msg as FantasyArenaJoin).arena_name);

                {
                    FantasyFighterProtocol.FantasyArenaJoined send = new FantasyFighterProtocol.FantasyArenaJoined(arena.name);
                    Send(send.Serialize());
                }
                break;

            case MessageCommon.FantasyFighterMessage.ListArenas:
            {
                FantasyFighterProtocol.FantasyArenaList send = new FantasyFighterProtocol.FantasyArenaList(FantasyArenaList.GetNames());
                Send(send.Serialize());
            }
            break;
            }
        }