コード例 #1
0
    // Model Event Handlers
    public void OnGameLoaded()
    {
        GameData      currentGame      = m_gameWorldModel.CurrentGame;
        CharacterData currentCharacter = currentGame.GetCharacterById(m_gameWorldModel.CurrentCharacterID);
        RoomKey       currentRoomKey   = currentCharacter.CurrentRoomKey;

        // Rebuild all the entities that are part of this room
        OnRoomLoaded(currentRoomKey);

        // Roll back the recent events so that the player can see them played back
        while (m_gameWorldModel.ReverseCurrentEvent(this))
        {
        }

        m_gameWorldModel.EventPlaybackMode = GameWorldModel.eGameEventMode.playing;
        gameWorldView.RefreshEventControls(m_gameWorldModel);

        // Re-Connect to the IRC back-end
        {
            if (m_chatWindowController != null)
            {
                m_chatWindowController.OnDestroy();
                m_chatWindowController = null;
            }

            m_chatWindowController = new ChatWindowController(this);
            m_chatWindowController.Start(gameWorldView.RootWidgetGroup);
        }
    }
コード例 #2
0
        public bool MovePlayer(
            RoomKey fromRoomKey,
            RoomKey toRoomKey,
            Point3d toRoomPosition,
            float toRoomAngle,
            int playerID)
        {
            bool             success  = false;
            RequestRoomCache fromRoom = GetRequestRoomCache(fromRoomKey);
            Player           player   = fromRoom.GetPlayer(m_dbContext, playerID);

            if (player != null)
            {
                if (fromRoomKey != toRoomKey)
                {
                    fromRoom.RemovePlayer(playerID);
                    GetRequestRoomCache(toRoomKey).AddPlayer(player);

                    player.RoomKey.Set(toRoomKey);
                }

                player.Position.Set(toRoomPosition);
                player.Angle = toRoomAngle;

                success = true;
            }

            return(success);
        }
コード例 #3
0
 private void Remove(int x, int y, Room rm)
 {
     var key = new RoomKey(x, y);
     HashSet<Room> roomList;
     if (rooms.TryGetValue(key, out roomList))
         roomList.Remove(rm);
 }
コード例 #4
0
        public PortalRequestProcessor(
            int character_id,
            Point3d portal_position,
            float portal_angle,
            int portal_id)
        {
            m_character_id = character_id;
            m_portal_position = new Point3d(portal_position);
            m_portal_angle = portal_angle;
            m_portal_id = portal_id;

            m_world = null;
            m_room = null;
            m_opposing_room = null;
            m_portal = null;
            m_opposing_portal = null;
            m_opposing_portal_position = new Point3d();
            m_current_room_key = null;
            m_opposing_room_key = null;
            m_current_character_position = new Point3d();
            m_current_character_angle = 0.0f;
            m_game_id = -1;
            m_move_to_target = false;

            m_result_event_list = null;
        }
コード例 #5
0
        public void Part1(long cardkey, long doorkey, long expected)
        {
            var sut    = new RoomKey();
            var actual = sut.EncryptionKey(cardkey, doorkey);

            Assert.Equal(expected, actual);
        }
コード例 #6
0
        public static void InsertMobs(
            AsyncRPGDataContext db_context,
            RoomKey roomKey,
            List <Mob> mobs)
        {
            foreach (Mob mob in mobs)
            {
                Mobs dbMob = new Mobs
                {
                    MobTypeID = mob.MobType.ID,
                    GameID    = mob.RoomKey.game_id,
                    RoomX     = mob.RoomKey.x,
                    RoomY     = mob.RoomKey.y,
                    RoomZ     = mob.RoomKey.z,
                    X         = mob.Position.x,
                    Y         = mob.Position.y,
                    Z         = mob.Position.z,
                    Angle     = mob.Angle,
                    Health    = mob.Health,
                    Energy    = mob.Energy,
                    AiData    = Mob.SerializeAIData(mob.AIState)
                };

                db_context.Mobs.InsertOnSubmit(dbMob);
                db_context.SubmitChanges();

                mob.ID = dbMob.MobID;
            }
        }
コード例 #7
0
        private bool HitTest(int x, int y, Rect bounds)
        {
            var key      = new RoomKey(x, y);
            var roomList = rooms.GetValueOrDefault(key, (HashSet <Room>)null);

            return(roomList != null && roomList.Any(room => !room.Bounds.Intersection(bounds).IsEmpty));
        }
コード例 #8
0
    public static StaticRoomData FromObject(RoomKey roomKey, JsonData jsonData)
    {
        StaticRoomData staticRoomData = new StaticRoomData();

        // Fill in the room objects
        JsonData roomObjectArray = jsonData["objects"];

        if (roomObjectArray != null)
        {
            for (int roomObjectIndex = 0; roomObjectIndex < roomObjectArray.Count; roomObjectIndex++)
            {
                JsonData   roomObject = roomObjectArray[roomObjectIndex];
                RoomObject room       = RoomObject.FromObject(roomObject);

                staticRoomData.RoomObjects.Add(room);
            }
        }

        // Retrieve the room template by name
        string templateName = (string)jsonData["room_template_name"];

        staticRoomData.RoomTemplate = RoomTemplateManager.GetRoomTemplate(templateName);

        // Copy the nav mesh from the template
        staticRoomData.NavMesh =
            new AsyncRPGSharedLib.Navigation.NavMesh(
                roomKey,
                staticRoomData.RoomTemplate.NavMeshTemplate);

        return(staticRoomData);
    }
コード例 #9
0
        /// <summary>
        /// Registers the given room as a possibility if it isn't already registered.
        /// </summary>
        /// <param name="transform"></param>
        /// <param name="part"></param>
        private RoomMeta RegisterKey(MatrixI transform, PartFromPrefab part)
        {
            var      key = new RoomKey(transform, part);
            RoomMeta room;

            if (!m_openRooms.TryGetValue(key, out room))
            {
                var ent = new ProceduralRoom();
                ent.Init(transform, part);
                m_openRooms[key] = room = new RoomMeta(ent);
            }
            else if (room.Nonce == m_nonce)
            {
                return(room);
            }
            room.Nonce    = m_nonce;
            room.InFactor = 0;
            foreach (var mount in room.Room.MountPoints)
            {
                var other = mount.AttachedToIn(m_construction);
                if (other == null)
                {
                    continue;
                }
                room.InFactor++;
                m_possibleRooms.Add(other, room);
            }
            return(room);
        }
コード例 #10
0
    public static StaticRoomData FromObject(RoomKey roomKey, JsonData jsonData)
    {
        StaticRoomData staticRoomData = new StaticRoomData();

        // Fill in the room objects
        JsonData roomObjectArray = jsonData["objects"];
        if (roomObjectArray != null)
        {
            for (int roomObjectIndex = 0; roomObjectIndex < roomObjectArray.Count; roomObjectIndex++)
            {
                JsonData roomObject = roomObjectArray[roomObjectIndex];
                RoomObject room = RoomObject.FromObject(roomObject);

                staticRoomData.RoomObjects.Add(room);
            }
        }

        // Retrieve the room template by name
        string templateName = (string)jsonData["room_template_name"];
        staticRoomData.RoomTemplate = RoomTemplateManager.GetRoomTemplate(templateName);

        // Copy the nav mesh from the template
        staticRoomData.NavMesh =
            new AsyncRPGSharedLib.Navigation.NavMesh(
                roomKey,
                staticRoomData.RoomTemplate.NavMeshTemplate);

        return staticRoomData;
    }
コード例 #11
0
        public PortalRequestProcessor(
            int character_id,
            Point3d portal_position,
            float portal_angle,
            int portal_id)
        {
            m_character_id    = character_id;
            m_portal_position = new Point3d(portal_position);
            m_portal_angle    = portal_angle;
            m_portal_id       = portal_id;

            m_world                      = null;
            m_room                       = null;
            m_opposing_room              = null;
            m_portal                     = null;
            m_opposing_portal            = null;
            m_opposing_portal_position   = new Point3d();
            m_current_room_key           = null;
            m_opposing_room_key          = null;
            m_current_character_position = new Point3d();
            m_current_character_angle    = 0.0f;
            m_game_id                    = -1;
            m_move_to_target             = false;

            m_result_event_list = null;
        }
コード例 #12
0
        public async Task UpdateAsync(RoomKey roomKey, Room room)
        {
            var tagsDt = new DataTable();

            tagsDt.Columns.Add("Tag", typeof(string));
            foreach (string tag in room.Tags)
            {
                tagsDt.Rows.Add(tag);
            }

            using SqlConnection connection = new SqlConnection(_connectionString);
            await connection.OpenAsync();

            await connection.ExecuteAsync(
                "Room_Modify_tr",
                new
            {
                roomKey.HotelChain,
                roomKey.CountryCode,
                roomKey.Town,
                roomKey.Suburb,
                roomKey.RoomType,
                Room          = roomKey.Name,
                NewRoomType   = room.RoomType,
                NewRoom       = room.Name,
                NewRoomTagTVP = tagsDt.AsTableValuedParameter("TagTableType")
            },
                commandType : CommandType.StoredProcedure);
        }
コード例 #13
0
ファイル: RoomCollision.cs プロジェクト: Bog624s/Rotux
        void Add(int x, int y, Room rm)
        {
            var key      = new RoomKey(x, y);
            var roomList = rooms.GetValueOrCreate(key, k => new HashSet <Room>());

            roomList.Add(rm);
        }
コード例 #14
0
        public bool MoveMob(
            Point3d targetPosition)
        {
            bool success = false;

            if (path == null)
            {
                PathComputer pathComputer = new PathComputer();

                success =
                    pathComputer.BlockingPathRequest(
                        moveRequest.Room.runtime_nav_mesh,
                        moveRequest.Room.room_key,
                        new Point3d(mob.Position),
                        new Point3d(targetPosition));

                if (success)
                {
                    RoomKey  roomKey            = moveRequest.Room.room_key;
                    PathStep lastPathStep       = pathComputer.FinalPath[pathComputer.FinalPath.Count - 1];
                    PathStep secondLastPathStep = pathComputer.FinalPath[pathComputer.FinalPath.Count - 2];
                    Vector3d lastPathHeading    = lastPathStep.StepPoint - secondLastPathStep.StepPoint;
                    float    targetAngle        = MathConstants.GetAngleForVector(lastPathHeading);

                    path =
                        new EntityPath()
                    {
                        entity_id = mob.ID,
                        path      = pathComputer.FinalPath
                    };

                    // Post an event that we moved
                    output_game_events.Add(
                        new GameEvent_MobMoved()
                    {
                        mob_id     = mob.ID,
                        room_x     = roomKey.x,
                        room_y     = roomKey.y,
                        room_z     = roomKey.z,
                        from_x     = mob.Position.x,
                        from_y     = mob.Position.y,
                        from_z     = mob.Position.z,
                        from_angle = mob.Angle,
                        to_x       = targetPosition.x,
                        to_y       = targetPosition.y,
                        to_z       = targetPosition.z,
                        to_angle   = targetAngle
                    });

                    // Update the mob position and facing
                    mob.Position = targetPosition;
                    mob.Angle    = targetAngle;

                    // TODO: Update the mob energy based on the distance traveled
                }
            }

            return(success);
        }
コード例 #15
0
 public EnergyTank()
 {
     m_room_key       = new RoomKey();
     m_energy_tank_id = -1;
     m_position       = new Point3d();
     m_energy         = 0;
     m_faction        = GameConstants.eFaction.neutral;
 }
コード例 #16
0
    public static AsyncRPGSharedLib.Navigation.NavMesh GetNavMesh(RoomKey roomKey)
    {
        SessionData sessionData = SessionData.GetInstance();
        GameData gameData = sessionData.CurrentGameData;
        RoomData roomData = gameData.GetCachedRoomData(roomKey);

        return roomData.StaticRoomData.NavMesh;
    }
コード例 #17
0
ファイル: EnergyTank.cs プロジェクト: ltloibrights/AsyncRPG
 public EnergyTank()
 {
     m_room_key = new RoomKey();
     m_energy_tank_id = -1;
     m_position = new Point3d();
     m_energy = 0;
     m_faction = GameConstants.eFaction.neutral;
 }
コード例 #18
0
    public static AsyncRPGSharedLib.Navigation.NavMesh GetNavMesh(RoomKey roomKey)
    {
        SessionData sessionData = SessionData.GetInstance();
        GameData    gameData    = sessionData.CurrentGameData;
        RoomData    roomData    = gameData.GetCachedRoomData(roomKey);

        return(roomData.StaticRoomData.NavMesh);
    }
コード例 #19
0
 public EnergyTankData()
 {
     energy_tank_id = -1;
     energy = 0;
     ownership = GameConstants.eFaction.neutral;
     position = new Point3d();
     boundingBox = new AABB3d();
     room_key = new RoomKey();
 }
コード例 #20
0
 public static int GetRoomRandomSeed(
     AsyncRPGDataContext context,
     RoomKey roomKey)
 {
     return
         ((from r in context.Rooms
           where r.GameID == roomKey.game_id && r.X == roomKey.x && r.Y == roomKey.y && r.Z == roomKey.z
           select r.RandomSeed).Single());
 }
コード例 #21
0
        void Remove(int x, int y, Room rm)
        {
            var key = new RoomKey(x, y);

            if (rooms.TryGetValue(key, out HashSet <Room> roomList))
            {
                roomList.Remove(rm);
            }
        }
コード例 #22
0
ファイル: WorldQueries.cs プロジェクト: ltloibrights/AsyncRPG
 public static int GetRoomRandomSeed(
     AsyncRPGDataContext context,
     RoomKey roomKey)
 {
     return
         (from r in context.Rooms
          where r.GameID == roomKey.game_id && r.X == roomKey.x && r.Y == roomKey.y && r.Z == roomKey.z
          select r.RandomSeed).Single();
 }
コード例 #23
0
ファイル: WorldQueries.cs プロジェクト: ltloibrights/AsyncRPG
 public static string GetRoomStaticData(
     AsyncRPGDataContext context,
     RoomKey roomKey)
 {
     return
         (from r in context.Rooms
          where r.GameID == roomKey.game_id && r.X == roomKey.x && r.Y == roomKey.y && r.Z == roomKey.z
          select r.StaticData).Single();
 }
コード例 #24
0
ファイル: WorldQueries.cs プロジェクト: ltloibrights/AsyncRPG
 public static bool DoesRoomExist(
     AsyncRPGDataContext context,
     RoomKey roomKey)
 {
     return
         (from r in context.Rooms
          where r.GameID == roomKey.game_id && r.X == roomKey.x && r.Y == roomKey.y && r.Z == roomKey.z
          select r).Count() > 0;
 }
コード例 #25
0
 public EnergyTankData()
 {
     energy_tank_id = -1;
     energy         = 0;
     ownership      = GameConstants.eFaction.neutral;
     position       = new Point3d();
     boundingBox    = new AABB3d();
     room_key       = new RoomKey();
 }
コード例 #26
0
 public MobSpawner()
 {
     m_room_key              = new RoomKey();
     m_mob_spawner_id        = -1;
     m_position              = new Point3d();
     m_spawn_table           = null;
     m_remaining_spawn_count = 0;
     m_random_seed           = 0;
 }
コード例 #27
0
ファイル: MobSpawner.cs プロジェクト: ltloibrights/AsyncRPG
 public MobSpawner()
 {
     m_room_key = new RoomKey();
     m_mob_spawner_id = -1;
     m_position = new Point3d();
     m_spawn_table = null;
     m_remaining_spawn_count = 0;
     m_random_seed = 0;
 }
コード例 #28
0
 public static bool DoesRoomExist(
     AsyncRPGDataContext context,
     RoomKey roomKey)
 {
     return
         ((from r in context.Rooms
           where r.GameID == roomKey.game_id && r.X == roomKey.x && r.Y == roomKey.y && r.Z == roomKey.z
           select r).Count() > 0);
 }
コード例 #29
0
 public static string GetRoomStaticData(
     AsyncRPGDataContext context,
     RoomKey roomKey)
 {
     return
         ((from r in context.Rooms
           where r.GameID == roomKey.game_id && r.X == roomKey.x && r.Y == roomKey.y && r.Z == roomKey.z
           select r.StaticData).Single());
 }
コード例 #30
0
        /// <summary>
        /// Query returning employee who is in possession of specified key.
        /// </summary>
        /// <param name="key">Target RoomKey object.</param>
        /// <returns>An Employee type object. May return null reference in case none of the employees has the given key. </returns>
        public async Task <Employee> GetEmployeeByOwnedKeyAsync(RoomKey key)
        {
            IEnumerable <Employee> results;

            using (CompanyDbContext companyDb = new CompanyDbContext())
            {
                results = await companyDb.Employees.Where(e => e.RecievedRoomKeys.Select(k => k.RoomKey_Id).Contains(key.RoomKey_Id)).ToListAsync().ConfigureAwait(false);
            }
            return(results.FirstOrDefault());
        }
コード例 #31
0
        public async Task <ActionResult <Room> > GetRoomDetails([FromQuery] RoomKey roomKey)
        {
            Room result = await _roomStore.FindDetailsAsync(roomKey);

            if (result != null)
            {
                return(Ok(result));
            }
            return(NotFound());
        }
コード例 #32
0
        public async Task <IActionResult> DeleteRoom([FromQuery] RoomKey roomKey)
        {
            if (!await _roomStore.CheckExistanceAsync(roomKey))
            {
                return(NotFound());
            }
            await _roomStore.DeleteAsync(roomKey);

            return(NoContent());
        }
コード例 #33
0
    private Dictionary <int, EnergyTankData> m_energyTanks;    // energy_tank_id -> Energy Tank Data

    public RoomData()
    {
        RoomKey        = new RoomKey();
        WorldPosition  = new Point3d();
        RoomPortals    = new List <RoomPortal>();
        StaticRoomData = new StaticRoomData();

        m_mobs        = new Dictionary <int, MobData>();
        m_energyTanks = new Dictionary <int, EnergyTankData>();
    }
コード例 #34
0
 public AIMoveRequestProcessor(
     RoomKey roomKey)
 {
     m_roomKey            = new RoomKey(roomKey);
     m_world              = null;
     m_room               = null;
     m_mobContexts        = new List <MobUpdateContext>();
     m_relevantGameEvents = new List <GameEventParameters>();
     m_playerPaths        = new List <EntityPath>();
 }
コード例 #35
0
 public AIMoveRequestProcessor(
     RoomKey roomKey)
 {
     m_roomKey = new RoomKey(roomKey);
     m_world = null;
     m_room = null;
     m_mobContexts = new List<MobUpdateContext>();
     m_relevantGameEvents = new List<GameEventParameters>();
     m_playerPaths = new List<EntityPath>();
 }
コード例 #36
0
        /// <summary>
        /// Resets assigned employee of specified room key to null value.
        /// </summary>
        /// <param name="key">Target room key.</param>
        /// <returns></returns>
        public async Task TakeTheRoomKeyAsync(RoomKey key)
        {
            using (CompanyDbContext companyDb = new CompanyDbContext())
            {
                key.ChangeAssignedEmployee(null);
                companyDb.Entry(key).State = EntityState.Modified;

                await companyDb.SaveChangesAsync().ConfigureAwait(false);
            }
        }
コード例 #37
0
ファイル: RoomData.cs プロジェクト: ltloibrights/AsyncRPG
    private Dictionary<int, MobData> m_mobs; // mob_id -> Mob Data

    #endregion Fields

    #region Constructors

    public RoomData()
    {
        RoomKey = new RoomKey();
        WorldPosition = new Point3d();
        RoomPortals = new List<RoomPortal>();
        StaticRoomData = new StaticRoomData();

        m_mobs = new Dictionary<int, MobData>();
        m_energyTanks = new Dictionary<int, EnergyTankData>();
    }
コード例 #38
0
 public Mob()
 {
     m_room_key = new RoomKey();
     m_mob_id   = -1;
     m_position = new Point3d();
     m_angle    = 0f;
     m_mob_type = null;
     m_health   = 0;
     m_energy   = 0;
     m_ai_data  = null;
 }
コード例 #39
0
        public async Task <ActionResult <Room> > EditRoom([FromQuery] RoomKey roomKey, [FromBody] Room room)
        {
            room.SetHotelKey(roomKey);
            if (!await _roomStore.CheckExistanceAsync(roomKey))
            {
                return(NotFound());
            }
            await _roomStore.UpdateAsync(roomKey, room);

            return(Ok(room));
        }
コード例 #40
0
ファイル: Mob.cs プロジェクト: ltloibrights/AsyncRPG
 public Mob()
 {
     m_room_key = new RoomKey();
     m_mob_id= -1;
     m_position = new Point3d();
     m_angle = 0f;
     m_mob_type = null;
     m_health= 0;
     m_energy= 0;
     m_ai_data = null;
 }
コード例 #41
0
ファイル: EnergyTank.cs プロジェクト: ltloibrights/AsyncRPG
        public static EnergyTank CreateEnergyTank(RoomKey roomKey, EnergyTankTemplate template)
        {
            EnergyTank newEnergyTank = new EnergyTank();

            newEnergyTank.m_room_key = new RoomKey(roomKey);
            newEnergyTank.m_energy_tank_id = -1; // energy tank ID not set until this gets saved into the DB
            newEnergyTank.m_position = new Point3d(template.Position);
            newEnergyTank.m_energy = template.Energy;
            newEnergyTank.m_faction = GameConstants.eFaction.neutral;

            return newEnergyTank;
        }
コード例 #42
0
        public static EnergyTank CreateEnergyTank(RoomKey roomKey, EnergyTankTemplate template)
        {
            EnergyTank newEnergyTank = new EnergyTank();

            newEnergyTank.m_room_key       = new RoomKey(roomKey);
            newEnergyTank.m_energy_tank_id = -1; // energy tank ID not set until this gets saved into the DB
            newEnergyTank.m_position       = new Point3d(template.Position);
            newEnergyTank.m_energy         = template.Energy;
            newEnergyTank.m_faction        = GameConstants.eFaction.neutral;

            return(newEnergyTank);
        }
コード例 #43
0
ファイル: MobSpawner.cs プロジェクト: ltloibrights/AsyncRPG
        public static MobSpawner CreateMobSpawner(RoomKey roomKey, MobSpawnerTemplate template, MobSpawnTableSet spawnTableSet, Random rng)
        {
            MobSpawner newMobSpawner = new MobSpawner();

            newMobSpawner.m_room_key = new RoomKey(roomKey);
            newMobSpawner.m_mob_spawner_id = -1; // spawner ID not set until this gets saved into the DB
            newMobSpawner.m_position = new Point3d(template.Position);
            newMobSpawner.m_remaining_spawn_count = RNGUtilities.RandomInt(rng, 0, template.MaxSpawnCount);
            newMobSpawner.m_random_seed = rng.Next();
            newMobSpawner.m_spawn_table = spawnTableSet.GetMobSpawnTableByName(template.SpawnTableName);

            return newMobSpawner;
        }
コード例 #44
0
ファイル: NavRef.cs プロジェクト: ltloibrights/AsyncRPG
        public NavRef(int navCellIndex, RoomKey roomKey)
        {
            m_navCellIndex = navCellIndex;

            if (roomKey != null)
            {
                m_roomKey = new RoomKey(roomKey);
            }
            else
            {
                m_roomKey = new RoomKey();
            }
        }
コード例 #45
0
        public NavRef(int navCellIndex, RoomKey roomKey)
        {
            m_navCellIndex = navCellIndex;

            if (roomKey != null)
            {
                m_roomKey = new RoomKey(roomKey);
            }
            else
            {
                m_roomKey = new RoomKey();
            }
        }
コード例 #46
0
        public RequestRoomCache(RoomKey roomKey)
        {
            m_roomKey = new RoomKey(roomKey);

            m_allEnergyTanksCached = false;
            m_energyTanks          = new Dictionary <int, EnergyTank>();

            m_allMobsCached = false;
            m_mobs          = new Dictionary <int, Mob>();

            m_allPlayersCached = false;
            m_players          = new Dictionary <int, Player>();
        }
コード例 #47
0
    public GameEvent_MobMoved()
        : base()
    {
        EventType = GameEvent.eEventType.mob_moved;

        MobID = -1;
        CurrentRoomKey = new RoomKey();

        FromPosition = new Point3d();
        FromAngle = 0;

        ToPosition = new Point3d();
        ToAngle = 0;
    }
コード例 #48
0
    public GameEvent_CharacterMoved()
        : base()
    {
        EventType = GameEvent.eEventType.character_moved;

        CharacterID = -1;
        CurrentRoomKey = new RoomKey();

        FromPosition = new Point3d();
        FromAngle = 0;

        ToPosition = new Point3d();
        ToAngle = 0;
    }
コード例 #49
0
ファイル: Player.cs プロジェクト: ltloibrights/AsyncRPG
 public Player()
 {
     m_character_id = -1;
     m_character_name = "";
     m_archetype = GameConstants.eArchetype.warrior;
     m_gender = GameConstants.eGender.Female;
     m_picture_id = -1;
     m_power_level = 0;
     m_energy = 0;
     m_health = 0;
     m_room_key = new RoomKey();
     m_position = new Point3d();
     m_energy = 0;
 }
コード例 #50
0
    public GameEvent_CharacterPortaled()
        : base()
    {
        EventType = GameEvent.eEventType.character_portaled;

        CharacterID = -1;
        FromRoomKey = new RoomKey();
        ToRoomKey = new RoomKey();

        FromPosition = new Point3d();
        FromAngle = 0;

        ToPosition = new Point3d();
        ToAngle = 0;
    }
コード例 #51
0
ファイル: Room.cs プロジェクト: ltloibrights/AsyncRPG
        public Point3d world_position; // World space coordinates of the lower-left hand corner (min corner)

        #endregion Fields

        #region Constructors

        public Room(RoomKey rk)
        {
            room_key = rk;
            random_seed = rk.GetHashCode();
            world_position.Set(
                (float)room_key.x * WorldConstants.ROOM_X_SIZE,
                (float)room_key.y * WorldConstants.ROOM_Y_SIZE,
                (float)room_key.z * WorldConstants.ROOM_Z_SIZE);
            portalRoomSideBitmask = new TypedFlags<MathConstants.eSignedDirection>();
            connectivity_id= -1;

            portals = new List<Portal>();
            mobSpawners = new List<MobSpawner>();
            static_room_data = new StaticRoomData();
            static_room_data.room_template_name = "";
            static_room_data.objects = null;
            runtime_nav_mesh = new NavMesh();
        }
コード例 #52
0
        public MoveRequestProcessor(
            int character_id,
            Point3d target_position,
            float target_angle)
        {
            m_character_id = character_id;
            m_target_position = new Point3d(target_position);
            m_target_angle = target_angle;

            m_world = null;
            m_room = null;
            m_current_room_key = null;
            m_current_character_position = new Point3d();
            m_current_character_angle = 0.0f;
            m_game_id = -1;
            m_ai_relevant_events = new List<GameEventParameters>();

            m_result_event_list = null;
        }
コード例 #53
0
        public HackEnergyTankRequestProcessor(
            int character_id,
            int energy_tank_id)
        {
            m_character_id = character_id;
            m_energy_tank_id = energy_tank_id;

            m_world = null;
            m_room = null;
            m_energy_tank = null;
            m_current_room_key = null;
            m_current_character_position = new Point3d();
            m_current_character_angle = 0.0f;
            m_game_id = -1;
            m_move_to_target = false;
            m_ai_relevant_events = new List<GameEventParameters>();

            m_result_event_list = null;
        }
コード例 #54
0
ファイル: WorldQueries.cs プロジェクト: ltloibrights/AsyncRPG
        public static List<Portal> GetRoomPortals(
            AsyncRPGDataContext context,
            RoomKey roomKey)
        {
            List<Portal> portals = new List<Portal>();

            var query =
                from p in context.Portals
                where p.GameID == roomKey.game_id && p.RoomX == roomKey.x && p.RoomY == roomKey.y && p.RoomZ == roomKey.z
                select p;

            foreach (var dbPortal in query)
            {
                Portal portal = Portal.CreatePortal(dbPortal);

                portals.Add(portal);
            }

            return portals;
        }
コード例 #55
0
        public static List<EnergyTank> GetEnergyTanks(
            AsyncRPGDataContext db_context,
            RoomKey roomKey)
        {
            List<EnergyTank> energyTanks = new List<EnergyTank>();

            var roomEnergyTankQuery =
                from e in db_context.EnergyTanks
                where e.GameID == roomKey.game_id && e.RoomX == roomKey.x && e.RoomY == roomKey.y && e.RoomZ == roomKey.z
                select e;

            foreach (EnergyTanks dbEnergyTank in roomEnergyTankQuery)
            {
                EnergyTank energyTank = EnergyTank.CreateEnergyTank(dbEnergyTank);

                energyTanks.Add(energyTank);
            }

            return energyTanks;
        }
コード例 #56
0
    public static bool AddPathRequest(
        RoomKey roomKey, 
        Point3d startPoint, 
        Point3d endPoint, 
        PathComputer.OnPathComputerComplete onComplete)
    {
        bool success = false;

        if (m_instance != null)
        {
            PathComputer pathComputer = new PathComputer();
            AsyncRPGSharedLib.Navigation.NavMesh navMesh = GetNavMesh(roomKey);

            if (pathComputer.NonBlockingPathRequest(navMesh, roomKey, startPoint, endPoint, onComplete))
            {
                m_instance.m_requestQueue.Add(pathComputer);
                success = true;
            }
        }

        return success;
    }
コード例 #57
0
ファイル: Room.cs プロジェクト: ltloibrights/AsyncRPG
        //TODO: LoadRoom - Convert this over to a request processor
        public static bool LoadRoom(
            AsyncRPGDataContext context,
            World world,
            RoomKey room_key, 
            out Room room, 
            out string result)
        {
            bool success;
            string json_static_data = WorldQueries.GetRoomStaticData(context, room_key);

            room = null;
            success = false;

            // Load static room data for this room
            if (json_static_data.Length > 0)
            {
                StaticRoomData static_room_data = null;

                try
                {
                    if (json_static_data.Length == 0)
                    {
                        throw new ArgumentException();
                    }

                    static_room_data = JsonMapper.ToObject<StaticRoomData>(json_static_data);
                }
                catch (System.Exception)
                {
                    static_room_data = null;
                }

                if (static_room_data != null)
                {
                    room = new Room(room_key);
                    room.static_room_data = static_room_data;

                    success = true;
                    result = SuccessMessages.GENERAL_SUCCESS;
                }
                else
                {
                    result = ErrorMessages.DB_ERROR + "(Failed to parse room static data)";
                }
            }
            else
            {
                result = ErrorMessages.DB_ERROR + "(Failed to get room static data)";
            }

            // If the static room data parsed, load everything else
            if (success)
            {
                RoomTemplate roomTemplate = world.RoomTemplates.GetTemplateByName(room.static_room_data.room_template_name);

                // Load the random seed for the room
                room.random_seed = WorldQueries.GetRoomRandomSeed(context, room_key);

                // Setup the runtime nav mesh
                room.runtime_nav_mesh = new NavMesh(room.room_key, roomTemplate.NavMeshTemplate);

                // Load all of the portals for this room
                room.portals = WorldQueries.GetRoomPortals(context, room_key);

                // Flag all of the room sides that have portals
                foreach (Portal p in room.portals)
                {
                    room.portalRoomSideBitmask.Set(p.room_side, true);
                }

                // Load mob spawners for this room
                room.mobSpawners = MobQueries.GetMobSpawners(context, world.MobSpawnTables, room_key);
            }

            return success;
        }
コード例 #58
0
        private bool VerifyRoomAccessibility(
            DungeonLayout layout,
            Dictionary<int, Portal> portalIdToPortalMap)
        {
            UnionFind<RoomKey> roomUnion = new UnionFind<RoomKey>();
            RoomKey targetRoomKey = new RoomKey();
            bool success = true;

            // Do a first pass over the rooms to fill out the union and the portal map
            for (DungeonLayout.RoomIndexIterator iterator = new DungeonLayout.RoomIndexIterator(layout.RoomGrid);
                iterator.Valid;
                iterator.Next())
            {
                DungeonLayout.RoomIndex roomIndex = iterator.Current;
                Room room = layout.GetRoomByIndex(roomIndex);

                // Add the room to the union set
                roomUnion.AddElement(room.room_key);
            }

            // Union together all of the rooms connected by portals
            for (DungeonLayout.RoomIndexIterator iterator = new DungeonLayout.RoomIndexIterator(layout.RoomGrid);
                iterator.Valid;
                iterator.Next())
            {
                DungeonLayout.RoomIndex roomIndex = iterator.Current;
                Room room = layout.GetRoomByIndex(roomIndex);

                foreach (Portal portal in room.portals)
                {
                    Portal targetPortal= portalIdToPortalMap[portal.target_portal_id];

                    targetRoomKey.game_id= layout.GameID;
                    targetRoomKey.x= targetPortal.room_x;
                    targetRoomKey.y= targetPortal.room_y;
                    targetRoomKey.z= targetPortal.room_z;

                    roomUnion.Union(room.room_key, targetRoomKey);
                }
            }

            // Verify that all rooms share the same connectivity id
            int sharedConnectivityId = -1;
            for (DungeonLayout.RoomIndexIterator iterator = new DungeonLayout.RoomIndexIterator(layout.RoomGrid);
                iterator.Valid;
                iterator.Next())
            {
                DungeonLayout.RoomIndex roomIndex = iterator.Current;
                Room room = layout.GetRoomByIndex(roomIndex);

                int roomConnectivityId= roomUnion.FindRootIndex(room.room_key);

                if (sharedConnectivityId != -1)
                {
                    if (sharedConnectivityId != roomConnectivityId)
                    {
                        _logger.WriteLine("DungeonValidator: FAILED: Found room not connected to other rooms in dungeon!");
                        _logger.WriteLine(string.Format("  game_id: {0}", layout.GameID));
                        _logger.WriteLine(string.Format("  room_key: {0},{1},{2}",
                            room.room_key.x, room.room_key.y, room.room_key.z));
                        success= false;
                        break;
                    }
                }
                else
                {
                    sharedConnectivityId= roomConnectivityId;
                }
            }

            return success;
        }
コード例 #59
0
    public void RequestRoomData(RoomKey roomKey, GameEvent.OnEventCompleteDelegate onComplete)
    {
        if (!IsRoomDataRequestPending)
        {
            // Cached room data is available
            if (SessionData.GetInstance().CurrentGameData.HasRoomData(roomKey))
            {
                // Update which room we're currently in
                SessionData.GetInstance().CurrentGameData.CurrentRoomKey = roomKey;

                // Notify the controller
                Debug.Log("Using cached room data");
                m_gameWorldController.OnRoomLoaded(roomKey);

                // Notify the caller
                if (onComplete != null)
                {
                    onComplete();
                }
            }
            // Have to request room data from the server
            else
            {
                AsyncJSONRequest roomDataRequest = AsyncJSONRequest.Create(m_gameWorldController.gameObject);
                Dictionary<string, object> request = new Dictionary<string, object>();

                request["game_id"] = SessionData.GetInstance().GameID;
                request["room_x"] = roomKey.x;
                request["room_y"] = roomKey.y;
                request["room_z"] = roomKey.z;

                IsRoomDataRequestPending = true;

                roomDataRequest.POST(
                    ServerConstants.roomDataRequestURL,
                    request,
                    (AsyncJSONRequest asyncRequest) =>
                {
                    if (asyncRequest.GetRequestState() == AsyncJSONRequest.eRequestState.succeded)
                    {
                        JsonData response = asyncRequest.GetResult();
                        string responseResult = (string)response["result"];

                        if (responseResult == "Success")
                        {
                            SessionData sessionData = SessionData.GetInstance();
                            GameData currentGame= sessionData.CurrentGameData;
                            RoomData roomData = RoomData.FromObject(response);

                            // Add the room data to the room cache
                            currentGame.SetCachedRoomData(roomData.RoomKey, roomData);

                            // Update which room we're currently in
                            currentGame.CurrentRoomKey = roomKey;

                            // Notify the controller
                            Debug.Log("Room Loaded");
                            m_gameWorldController.OnRoomLoaded(roomData.RoomKey);
                        }
                        else
                        {
                            Debug.Log("Room Data Request Failed: " + responseResult);
                            m_gameWorldController.OnRequestFailed(responseResult);
                        }
                    }
                    else
                    {
                        Debug.Log("Room Data Request Failed: " + asyncRequest.GetFailureReason());
                        m_gameWorldController.OnRequestFailed("Connection Failed!");
                    }

                    // Notify the caller
                    if (onComplete != null)
                    {
                        onComplete();
                    }

                    IsRoomDataRequestPending = false;
                });
            }
        }
    }
コード例 #60
0
 public RoomData GetRoomData(RoomKey roomKey)
 {
     return CurrentGame.GetCachedRoomData(roomKey);
 }