Ejemplo n.º 1
0
        /// <summary>
        /// Called when the character changes rooms.
        /// </summary>
        /// <param name="departingRoom">The departing room.</param>
        /// <param name="arrivalRoom">The arrival room.</param>
        protected virtual void OnRoomChanged(ITravelDirection direction, DefaultRoom departingRoom, DefaultRoom arrivalRoom)
        {
            EventHandler <OccupancyChangedEventArgs> handler = this.RoomChanged;

            if (handler == null)
            {
                return;
            }

            handler(this, new OccupancyChangedEventArgs(this, direction, departingRoom, arrivalRoom));
        }
Ejemplo n.º 2
0
    public void InitializeRoom(int defaultRoomIndex)
    {
        DefaultRoom roomSettings = defaultRooms[defaultRoomIndex];

        //load Scene
        PhotonNetwork.LoadLevel(roomSettings.sceneIndex);

        //create room
        RoomOptions roomOptions = new RoomOptions();

        roomOptions.MaxPlayers = (byte)roomSettings.maxPlayer;
        roomOptions.IsVisible  = true;
        roomOptions.IsOpen     = true;

        PhotonNetwork.JoinOrCreateRoom(roomSettings.Name, roomOptions, TypedLobby.Default);
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Moves this character to the given room going in the specified direction.
 /// </summary>
 /// <param name="directionEnteringFrom">The direction.</param>
 /// <param name="newRoom">The new room.</param>
 public void Move(ITravelDirection directionEnteringFrom, DefaultRoom newRoom)
 {
     this.CurrentRoom = newRoom;
     this.OnRoomChanged(directionEnteringFrom, this.CurrentRoom, newRoom);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructs the world.
        /// </summary>
        /// <param name="game">The game.</param>
        private async Task ConstructWorld(IGame game)
        {
            // Set up the Room
            var bedroom = new DefaultRoom {
                IsEnabled = true
            };
            var hallway = new DefaultRoom {
                IsEnabled = true
            };

            // Set up the Zone
            var weatherStates = new List <IWeatherState> {
                new ClearWeather(), new RainyWeather(), new ThunderstormWeather()
            };
            DefaultZone zone = new DefaultZone();

            zone.Name  = "Country Side";
            zone.Rooms = new List <DefaultRoom>()
            {
                bedroom
            };
            zone.WeatherStates          = weatherStates;
            zone.WeatherUpdateFrequency = 6;
            zone.WeatherChanged        += (sender, weatherArgs) => Console.WriteLine($"{zone.Name} zone weather has changed to {weatherArgs.CurrentState.Name}");
            DefaultZone zone2 = new DefaultZone();

            zone2.Name  = "Castle Rock";
            zone2.Rooms = new List <DefaultRoom> {
                hallway
            };
            zone2.WeatherStates          = weatherStates;
            zone2.WeatherUpdateFrequency = 2;
            zone2.WeatherChanged        += (sender, weatherArgs) => Console.WriteLine($"{zone2.Name} zone weather has changed to {weatherArgs.CurrentState.Name}");

            // Set up the World.
            IWorld world = new DefaultWorld();

            world.GameDayToRealHourRatio = 0.4;
            world.HoursPerDay            = 10;
            world.Name = "Sample World";
            world.SetNotificationManager(game.NotificationCenter);

            var morningState = new TimeOfDayState {
                Name = "Morning", StateStartTime = new TimeOfDay {
                    Hour = 2
                }
            };
            var afternoonState = new TimeOfDayState {
                Name = "Afternoon", StateStartTime = new TimeOfDay {
                    Hour = 5
                }
            };
            var nightState = new TimeOfDayState {
                Name = "Night", StateStartTime = new TimeOfDay {
                    Hour = 8
                }
            };

            world.AddTimeOfDayState(morningState);
            world.AddTimeOfDayState(afternoonState);
            world.AddTimeOfDayState(nightState);
            world.TimeOfDayChanged += World_TimeOfDayChanged;

            // Set up the Realm.
            DefaultRealm realm = new DefaultRealm(world, new TimeOfDay {
                Hour = 3, HoursPerDay = 10
            });

            realm.TimeZoneOffset = new TimeOfDay {
                Hour = 3, Minute = 10, HoursPerDay = world.HoursPerDay
            };
            realm.Name = "Realm 1";
            realm.SetNotificationManager(game.NotificationCenter);

            // Initialize the environment.
            Task task = world.Initialize();

            task.Wait();

            await world.AddRealmToWorld(realm);

            realm.AddZoneToRealm(zone);
            realm.AddZoneToRealm(zone2);
            await game.AddWorld(world);
        }