예제 #1
0
        public MMORoomSettings GetRoomSettings(string name)
        {
            MMORoomSettings settings = new MMORoomSettings(name);

            settings.IsGame   = false;
            settings.MaxUsers = 8;
            settings.Name     = name;
            settings.AllowOwnerOnlyInvitation = true;
            settings.DefaultAOI = new Vec3D((int)800, (int)600, 0);
            settings.GroupId    = "default";
            settings.MapLimits  = new MapLimits(new Vec3D((int)0, (int)0, (int)0), new Vec3D((int)1008, (int)1008, (int)0));
            settings.ProximityListUpdateMillis = 33;

            RoomPermissions permissions = new RoomPermissions();

            permissions.AllowNameChange     = true;
            permissions.AllowPublicMessages = true;
            settings.Permissions            = permissions;

            RoomEvents events = new RoomEvents();

            events.AllowUserExit            = true;
            events.AllowUserEnter           = true;
            events.AllowUserCountChange     = true;
            events.AllowUserVariablesUpdate = true;

            settings.Events    = events;
            settings.Extension = new RoomExtension("Java", "gameloop.RoomExtension");

            return(settings);
        }
예제 #2
0
 public void CreateRoom(MMORoomSettings settings)
 {
     if (settings != null && _sfs != null)
     {
         _sfs.Send(new CreateRoomRequest(settings, true));
     }
 }
    public static void SendCreateRoomRequest(this SmartFox smartfox, string roomName, bool autojoin = true, Room roomToLeave = null)
    {
        MMORoomSettings settings = new MMORoomSettings(roomName);

        settings.DefaultAOI = new Vec3D(25f, 1f, 25f);
        settings.MapLimits  = new MapLimits(new Vec3D(-100f, 1f, -100f), new Vec3D(100f, 1f, 100f));
        settings.MaxUsers   = 100;
        settings.Extension  = new RoomExtension("pyTest", "MMORoomDemo.py");

        smartfox.SendCreateRoomRequest(settings, autojoin, roomToLeave);
    }
예제 #4
0
    private void OnLogin(BaseEvent evt)
    {
        string roomName = "UnityMMODemo";

        // We either create the Game Room or join it if it exists already
        if (sfs.RoomManager.ContainsRoom(roomName))
        {
            sfs.Send(new JoinRoomRequest(roomName));
        }
        else
        {
            MMORoomSettings settings = new MMORoomSettings(roomName);
            settings.DefaultAOI = new Vec3D(25f, 1f, 25f);
            settings.MapLimits  = new MapLimits(new Vec3D(-100f, 1f, -100f), new Vec3D(100f, 1f, 100f));
            settings.MaxUsers   = 100;
            settings.Extension  = new RoomExtension("MMORoomDemo", "sfs2x.extension.mmo.MMORoomDemoExtension");
            sfs.Send(new CreateRoomRequest(settings, true));
        }
    }
예제 #5
0
        public override void Validate(SmartFox sfs)
        {
            List <string> list = new List <string>();

            if (settings.Name == null || settings.Name.Length == 0)
            {
                list.Add("Missing room name");
            }
            if (settings.MaxUsers <= 0)
            {
                list.Add("maxUsers must be > 0");
            }
            if (settings.Extension != null)
            {
                if (settings.Extension.ClassName == null || settings.Extension.ClassName.Length == 0)
                {
                    list.Add("Missing Extension class name");
                }
                if (settings.Extension.Id == null || settings.Extension.Id.Length == 0)
                {
                    list.Add("Missing Extension id");
                }
            }
            if (settings is MMORoomSettings)
            {
                MMORoomSettings mMORoomSettings = settings as MMORoomSettings;
                if (mMORoomSettings.DefaultAOI == null)
                {
                    list.Add("Missing default AOI (area of interest)");
                }
                if (mMORoomSettings.MapLimits != null && (mMORoomSettings.MapLimits.LowerLimit == null || mMORoomSettings.MapLimits.HigherLimit == null))
                {
                    list.Add("Map limits must be both defined");
                }
            }
            if (list.Count > 0)
            {
                throw new SFSValidationError("CreateRoom request error", list);
            }
        }
예제 #6
0
    // Login Handlers
    void loginHandler(BaseEvent e)
    {
        trace("user[" + e.Params["user"] + "] Successfully logged into zone!");

        // We either create the Game Room or join it if it exists already
        if (sfs.RoomManager.ContainsRoom(roomName))
        {
            trace("GameRoom already exists! Joining the room");
            sfs.Send(new JoinRoomRequest(roomName));
        }
        else
        {
            trace("GameRoom does not exists! creating the room... Joining the room...");
            MMORoomSettings settings = new MMORoomSettings(roomName);
            settings.DefaultAOI = new Vec3D(300f, 180f, 0f);
            settings.MapLimits  = new MapLimits(new Vec3D(-500f, -220f, 0f), new Vec3D(500f, 220f, 0f));
            settings.MaxUsers   = 10;
            settings.Extension  = new RoomExtension("Brawl", "com.xplosion.BrawlExtension");
            sfs.Send(new CreateRoomRequest(settings, true));
        }

        localUser = sfs.UserManager.GetUserByName(UserName);
    }
예제 #7
0
 public override void Execute(SmartFox sfs)
 {
     sfso.PutUtfString(KEY_NAME, settings.Name);
     sfso.PutUtfString(KEY_GROUP_ID, settings.GroupId);
     sfso.PutUtfString(KEY_PASSWORD, settings.Password);
     sfso.PutBool(KEY_ISGAME, settings.IsGame);
     sfso.PutShort(KEY_MAXUSERS, settings.MaxUsers);
     sfso.PutShort(KEY_MAXSPECTATORS, settings.MaxSpectators);
     sfso.PutShort(KEY_MAXVARS, settings.MaxVariables);
     sfso.PutBool(KEY_ALLOW_JOIN_INVITATION_BY_OWNER, settings.AllowOwnerOnlyInvitation);
     if (settings.Variables != null && settings.Variables.Count > 0)
     {
         ISFSArray iSFSArray = SFSArray.NewInstance();
         foreach (RoomVariable variable in settings.Variables)
         {
             if (variable is RoomVariable)
             {
                 RoomVariable roomVariable = variable as RoomVariable;
                 iSFSArray.AddSFSArray(roomVariable.ToSFSArray());
             }
         }
         sfso.PutSFSArray(KEY_ROOMVARS, iSFSArray);
     }
     if (settings.Permissions != null)
     {
         List <bool> list = new List <bool>();
         list.Add(settings.Permissions.AllowNameChange);
         list.Add(settings.Permissions.AllowPasswordStateChange);
         list.Add(settings.Permissions.AllowPublicMessages);
         list.Add(settings.Permissions.AllowResizing);
         sfso.PutBoolArray(KEY_PERMISSIONS, list.ToArray());
     }
     if (settings.Events != null)
     {
         List <bool> list2 = new List <bool>();
         list2.Add(settings.Events.AllowUserEnter);
         list2.Add(settings.Events.AllowUserExit);
         list2.Add(settings.Events.AllowUserCountChange);
         list2.Add(settings.Events.AllowUserVariablesUpdate);
         sfso.PutBoolArray(KEY_EVENTS, list2.ToArray());
     }
     if (settings.Extension != null)
     {
         sfso.PutUtfString(KEY_EXTID, settings.Extension.Id);
         sfso.PutUtfString(KEY_EXTCLASS, settings.Extension.ClassName);
         if (settings.Extension.PropertiesFile != null && settings.Extension.PropertiesFile.Length > 0)
         {
             sfso.PutUtfString(KEY_EXTPROP, settings.Extension.PropertiesFile);
         }
     }
     if (settings is MMORoomSettings)
     {
         MMORoomSettings mMORoomSettings = settings as MMORoomSettings;
         if (mMORoomSettings.DefaultAOI.IsFloat())
         {
             sfso.PutFloatArray(KEY_MMO_DEFAULT_AOI, mMORoomSettings.DefaultAOI.ToFloatArray());
             if (mMORoomSettings.MapLimits != null)
             {
                 sfso.PutFloatArray(KEY_MMO_MAP_LOW_LIMIT, mMORoomSettings.MapLimits.LowerLimit.ToFloatArray());
                 sfso.PutFloatArray(KEY_MMO_MAP_HIGH_LIMIT, mMORoomSettings.MapLimits.HigherLimit.ToFloatArray());
             }
         }
         else
         {
             sfso.PutIntArray(KEY_MMO_DEFAULT_AOI, mMORoomSettings.DefaultAOI.ToIntArray());
             if (mMORoomSettings.MapLimits != null)
             {
                 sfso.PutIntArray(KEY_MMO_MAP_LOW_LIMIT, mMORoomSettings.MapLimits.LowerLimit.ToIntArray());
                 sfso.PutIntArray(KEY_MMO_MAP_HIGH_LIMIT, mMORoomSettings.MapLimits.HigherLimit.ToIntArray());
             }
         }
         sfso.PutShort(KEY_MMO_USER_MAX_LIMBO_SECONDS, (short)mMORoomSettings.UserMaxLimboSeconds);
         sfso.PutShort(KEY_MMO_PROXIMITY_UPDATE_MILLIS, (short)mMORoomSettings.ProximityListUpdateMillis);
         sfso.PutBool(KEY_MMO_SEND_ENTRY_POINT, mMORoomSettings.SendAOIEntryPoint);
     }
     sfso.PutBool(KEY_AUTOJOIN, autoJoin);
     if (roomToLeave != null)
     {
         sfso.PutInt(KEY_ROOM_TO_LEAVE, roomToLeave.Id);
     }
 }
 public static void SendCreateRoomRequest(this SmartFox smartfox, MMORoomSettings settings, bool autojoin = true, Room roomToLeave = null)
 {
     smartfox.Send(new CreateRoomRequest(settings, autojoin, roomToLeave));
 }