Пример #1
0
    private void OnHotspotClicked(
        HotspotWidget hotspotWidget,
        WidgetEvent widgetEvent)
    {
        if (m_currentNavRef.IsValid)
        {
            WidgetEvent.MouseClickEventParameters eventParameters =
                widgetEvent.EventParameters as WidgetEvent.MouseClickEventParameters;
            Point2d     clickPoint  = new Point2d(eventParameters.worldX, eventParameters.worldY);
            HotspotInfo hotspotInfo = hotspotWidget.Userdata as HotspotInfo;

            switch (hotspotInfo.hotspotType)
            {
            case eHotspotType.energy_tank:
            {
                EnergyTankData energyTankData = hotspotInfo.hotspotEntity as EnergyTankData;

                m_contextOverlayController.OnEnergyTankClicked(clickPoint, energyTankData);
            }
            break;

            case eHotspotType.portal:
            {
                RoomPortal portal = hotspotInfo.hotspotEntity as RoomPortal;

                m_contextOverlayController.OnPortalClicked(clickPoint, portal);
            }
            break;
            }
        }
    }
Пример #2
0
    // Parsing
    public static RoomData FromObject(JsonData jsonData)
    {
        RoomData roomData = new RoomData();

        int gameID = SessionData.GetInstance().GameID;
        int room_x = (int)jsonData["room_x"];
        int room_y = (int)jsonData["room_y"];
        int room_z = (int)jsonData["room_z"];

        float world_x = jsonData["world_x"].IsInt ? (float)((int)jsonData["world_x"]) : (float)((double)jsonData["world_x"]);
        float world_y = jsonData["world_y"].IsInt ? (float)((int)jsonData["world_y"]) : (float)((double)jsonData["world_y"]);
        float world_z = jsonData["world_z"].IsInt ? (float)((int)jsonData["world_z"]) : (float)((double)jsonData["world_z"]);

        roomData.RoomKey.Set(gameID, room_x, room_y, room_z);
        roomData.WorldPosition.Set(world_x, world_y, world_z);
        roomData.StaticRoomData = StaticRoomData.FromObject(roomData.RoomKey, jsonData["data"]);

        {
            JsonData portalList = jsonData["portals"];

            for (int portalIndex = 0; portalIndex < portalList.Count; portalIndex++)
            {
                JsonData   portalObject = portalList[portalIndex];
                RoomPortal portal       = RoomPortal.FromObject(portalObject);

                roomData.RoomPortals.Add(portal);
            }
        }

        {
            JsonData mobObjects = jsonData["mobs"];

            roomData.m_mobs = new Dictionary <int, MobData>();

            for (int mobIndex = 0; mobIndex < mobObjects.Count; mobIndex++)
            {
                JsonData mobObject = mobObjects[mobIndex];
                MobData  mobData   = MobData.FromObject(mobObject);

                roomData.SetMobById(mobData.mob_id, mobData);
            }
        }

        {
            JsonData energyTankObjects = jsonData["energyTanks"];

            roomData.m_energyTanks = new Dictionary <int, EnergyTankData>();

            for (int energyTankIndex = 0; energyTankIndex < energyTankObjects.Count; energyTankIndex++)
            {
                JsonData       energyTankObject = energyTankObjects[energyTankIndex];
                EnergyTankData energyTankData   = EnergyTankData.FromObject(energyTankObject);

                roomData.SetEnergyTankById(energyTankData.energy_tank_id, energyTankData);
            }
        }

        return(roomData);
    }
 // Context Overlay Events
 public void OnPortalClicked(Point3d entryPoint, RoomPortal portal)
 {
     if (!m_gameWorldModel.IsAsyncRequestPending &&
         m_gameWorldModel.IsEventCursorAtLastEvent &&
         !m_gameWorldModel.IsEventPlaybackActive &&
         m_gameWorldModel.IsWorldPointOnNavMesh(entryPoint))
     {
         m_gameWorldModel.RequestCharacterPortal(entryPoint, portal);
     }
 }
Пример #4
0
    public static RoomPortal FromObject(JsonData jsonData)
    {
        RoomPortal portal = new RoomPortal();

        portal.portal_id = (int)jsonData["id"];
        portal.target_portal_id = (int)jsonData["target_portal_id"];

        float x0 = jsonData["x0"].IsInt ? (float)((int)jsonData["x0"]) : (float)((double)jsonData["x0"]);
        float y0 = jsonData["y0"].IsInt ? (float)((int)jsonData["y0"]) : (float)((double)jsonData["y0"]);
        float x1 = jsonData["x1"].IsInt ? (float)((int)jsonData["x1"]) : (float)((double)jsonData["x1"]);
        float y1 = jsonData["y1"].IsInt ? (float)((int)jsonData["y1"]) : (float)((double)jsonData["y1"]);

        portal.boundingBox.SetBounds2d(x0, y0, x1, y1);

        return portal;
    }
Пример #5
0
    public static RoomPortal FromObject(JsonData jsonData)
    {
        RoomPortal portal = new RoomPortal();

        portal.portal_id        = (int)jsonData["id"];
        portal.target_portal_id = (int)jsonData["target_portal_id"];

        float x0 = jsonData["x0"].IsInt ? (float)((int)jsonData["x0"]) : (float)((double)jsonData["x0"]);
        float y0 = jsonData["y0"].IsInt ? (float)((int)jsonData["y0"]) : (float)((double)jsonData["y0"]);
        float x1 = jsonData["x1"].IsInt ? (float)((int)jsonData["x1"]) : (float)((double)jsonData["x1"]);
        float y1 = jsonData["y1"].IsInt ? (float)((int)jsonData["y1"]) : (float)((double)jsonData["y1"]);

        portal.boundingBox.SetBounds2d(x0, y0, x1, y1);

        return(portal);
    }
Пример #6
0
 void setTreasureRoomWithPortals(string previous, string current)
 {
     previousRoom_entrance         = bossPreRoom.transform.Find(previous + "Entrance").gameObject;
     previousRoom_exit             = bossPreRoom.transform.Find(previous + "Door").gameObject;
     previousRoom_portal           = previousRoom_exit.GetComponent <RoomPortal>();
     previousRoom_exit.tag         = "ExitDoor";
     currentRoom_entrance          = bossRoom.transform.Find(current + "Entrance").gameObject;
     currentRoom_exit              = bossRoom.transform.Find(current + "Door").gameObject;
     currentRoom_portal            = currentRoom_exit.GetComponent <RoomPortal>();
     currentRoom_exit.tag          = "EnterDoor";
     currentRoom_portal.exitPoint  = previousRoom_entrance;
     previousRoom_portal.exitPoint = currentRoom_entrance;
     currentRoom_exit.SetActive(true);
     currentRoom_entrance.SetActive(true);
     previousRoom_exit.SetActive(true);
     previousRoom_entrance.SetActive(true);
     currentRoom_portal.getProperPosition();
     previousRoom_portal.getProperPosition();
 }
Пример #7
0
    void setBossRoomWithPortals(string previous, string current)
    {
        bossRoom                      = Instantiate(Resources.Load(path + "Bossroom", typeof(GameObject)) as GameObject, new Vector3(bossPreRoomLocation.x * range, bossPreRoomLocation.y * range, 0), Quaternion.identity);
        bossRoom.name                 = "BossRoom";
        previousRoom_entrance         = bossPreRoom.transform.Find(previous + "Entrance").gameObject;
        previousRoom_exit             = bossPreRoom.transform.Find(previous + "Portal").gameObject;
        previousRoom_portal           = previousRoom_exit.GetComponent <RoomPortal>();
        previousRoom_exit.tag         = "ExitDoor";
        currentRoom_entrance          = bossRoom.transform.Find(current + "Entrance").gameObject;
        currentRoom_exit              = bossRoom.transform.Find(current + "Portal").gameObject;
        currentRoom_portal            = currentRoom_exit.GetComponent <RoomPortal>();
        currentRoom_exit.tag          = "EnterDoor";
        currentRoom_portal.exitPoint  = previousRoom_entrance;
        previousRoom_portal.exitPoint = currentRoom_entrance;

        currentRoom_exit.SetActive(true);
        currentRoom_entrance.SetActive(true);
        previousRoom_exit.SetActive(true);
        previousRoom_entrance.SetActive(true);
        currentRoom_portal.getProperPosition();
        previousRoom_portal.getProperPosition();
    }
    public AsyncCharacterPortalRequest(
        GameObject requestOwnerObject, 
        CharacterEntity entity,
        Point3d entryPoint, 
        RoomPortal portal)
    {
        // Remember where we came from in case the server rejects our predictive movement request
        CharacterData characterData = entity.MyCharacterData;

        OriginalPosition = new Point3d(characterData.x, characterData.y, characterData.z);
        OriginalFacingAngle = characterData.angle;
        OriginalRoomKey = characterData.CurrentRoomKey;
        OriginPortal = portal;
        OriginPortalEntryPoint = entryPoint;

        m_entity = entity;
        m_requestOwnerObject = requestOwnerObject;

        Status = eRequestStatus.preflight;
        ResultCode = eResult.none;
        ResultDetails = "";
        ServerResponse = null;
    }
    public AsyncCharacterPortalRequest(
        GameObject requestOwnerObject,
        CharacterEntity entity,
        Point3d entryPoint,
        RoomPortal portal)
    {
        // Remember where we came from in case the server rejects our predictive movement request
        CharacterData characterData = entity.MyCharacterData;

        OriginalPosition       = new Point3d(characterData.x, characterData.y, characterData.z);
        OriginalFacingAngle    = characterData.angle;
        OriginalRoomKey        = characterData.CurrentRoomKey;
        OriginPortal           = portal;
        OriginPortalEntryPoint = entryPoint;

        m_entity             = entity;
        m_requestOwnerObject = requestOwnerObject;

        Status         = eRequestStatus.preflight;
        ResultCode     = eResult.none;
        ResultDetails  = "";
        ServerResponse = null;
    }
Пример #10
0
    public void RequestCharacterPortal(Point3d entryPoint, RoomPortal portal)
    {
        Debug.Log("GameWorldModel:requestCharacterPortal - Entering portal_id="
            +portal.portal_id+" at position ("+ entryPoint.x + ", " + entryPoint.y + ")");

        if (!IsCharacterPortalRequestPending)
        {
            GameData gameData = SessionData.GetInstance().CurrentGameData;
            CharacterEntity entity = GetCharacterEntity(CurrentCharacterID);
            AsyncCharacterPortalRequest characterPortalRequest = null;

            IsCharacterPortalRequestPending = true;

            characterPortalRequest = new AsyncCharacterPortalRequest(m_gameWorldController.gameObject, entity, entryPoint, portal);
            characterPortalRequest.Execute(
                (AsyncCharacterPortalRequest asyncRequest) =>
            {
                IsCharacterPortalRequestPending = false;

                switch (asyncRequest.ResultCode)
                {
                case AsyncCharacterPortalRequest.eResult.success:
                    {
                        Debug.Log("GameWorldModel:requestCharacterPortal - Portal Succeeded!");

                        // Tell anyone listening on IRC that the game state changed
                        m_gameWorldController.SendCharacterUpdatedGameEvent();

                        // Parse any incoming game events
                        if (asyncRequest.ServerResponse != null)
                        {
                            gameData.ParseEventResponse(asyncRequest.ServerResponse);
                        }

                        // If there were new events, notify the controller so that
                        // it can start playing the events back
                        if (!gameData.IsEventCursorAtLastEvent)
                        {
                            m_gameWorldController.OnGameHasNewEvents();
                        }
                    }
                    break;
                case AsyncCharacterPortalRequest.eResult.failed_path:
                case AsyncCharacterPortalRequest.eResult.failed_server_denied:
                    {
                        Debug.LogError("GameWorldModel:requestCharacterPortal - " + asyncRequest.ResultDetails);

                        m_gameWorldController.OnCharacterActionDisallowed(asyncRequest);
                    }
                    break;
                case AsyncCharacterPortalRequest.eResult.failed_server_connection:
                    {
                        Debug.LogError("GameWorldModel:requestCharacterPortal - " + asyncRequest.ResultDetails);

                        m_gameWorldController.OnRequestFailed("Connection Failed!");
                    }
                    break;
                }
            });
        }
    }
Пример #11
0
    public void RequestCharacterPortal(Point3d entryPoint, RoomPortal portal)
    {
        Debug.Log("GameWorldModel:requestCharacterPortal - Entering portal_id="
                  + portal.portal_id + " at position (" + entryPoint.x + ", " + entryPoint.y + ")");

        if (!IsCharacterPortalRequestPending)
        {
            GameData                    gameData = SessionData.GetInstance().CurrentGameData;
            CharacterEntity             entity   = GetCharacterEntity(CurrentCharacterID);
            AsyncCharacterPortalRequest characterPortalRequest = null;

            IsCharacterPortalRequestPending = true;

            characterPortalRequest = new AsyncCharacterPortalRequest(m_gameWorldController.gameObject, entity, entryPoint, portal);
            characterPortalRequest.Execute(
                (AsyncCharacterPortalRequest asyncRequest) =>
            {
                IsCharacterPortalRequestPending = false;

                switch (asyncRequest.ResultCode)
                {
                case AsyncCharacterPortalRequest.eResult.success:
                    {
                        Debug.Log("GameWorldModel:requestCharacterPortal - Portal Succeeded!");

                        // Tell anyone listening on IRC that the game state changed
                        m_gameWorldController.SendCharacterUpdatedGameEvent();

                        // Parse any incoming game events
                        if (asyncRequest.ServerResponse != null)
                        {
                            gameData.ParseEventResponse(asyncRequest.ServerResponse);
                        }

                        // If there were new events, notify the controller so that
                        // it can start playing the events back
                        if (!gameData.IsEventCursorAtLastEvent)
                        {
                            m_gameWorldController.OnGameHasNewEvents();
                        }
                    }
                    break;

                case AsyncCharacterPortalRequest.eResult.failed_path:
                case AsyncCharacterPortalRequest.eResult.failed_server_denied:
                    {
                        Debug.LogError("GameWorldModel:requestCharacterPortal - " + asyncRequest.ResultDetails);

                        m_gameWorldController.OnCharacterActionDisallowed(asyncRequest);
                    }
                    break;

                case AsyncCharacterPortalRequest.eResult.failed_server_connection:
                    {
                        Debug.LogError("GameWorldModel:requestCharacterPortal - " + asyncRequest.ResultDetails);

                        m_gameWorldController.OnRequestFailed("Connection Failed!");
                    }
                    break;
                }
            });
        }
    }
Пример #12
0
 public void OnPortalTrigger(RoomPortal portal)
 {
     LastPortalId = portal.Id;
     StartCoroutine(RunSwitchRoomRoutine(portal.Scene));
 }
    // Model Events
    // View Events
    public void OnPortalClicked(Point2d entryPixelPoint, RoomPortal portal)
    {
        Point3d entryWorldPoint = GameConstants.ConvertPixelPositionToRoomPosition(entryPixelPoint);

        m_gameWorldController.OnPortalClicked(entryWorldPoint, portal);
    }
Пример #14
0
 // Context Overlay Events
 public void OnPortalClicked(Point3d entryPoint, RoomPortal portal)
 {
     if (!m_gameWorldModel.IsAsyncRequestPending &&
         m_gameWorldModel.IsEventCursorAtLastEvent &&
         !m_gameWorldModel.IsEventPlaybackActive &&
         m_gameWorldModel.IsWorldPointOnNavMesh(entryPoint))
     {
         m_gameWorldModel.RequestCharacterPortal(entryPoint, portal);
     }
 }
    // Model Events

    // View Events
    public void OnPortalClicked(Point2d entryPixelPoint, RoomPortal portal)
    {
        Point3d entryWorldPoint = GameConstants.ConvertPixelPositionToRoomPosition(entryPixelPoint);

        m_gameWorldController.OnPortalClicked(entryWorldPoint, portal);
    }