示例#1
0
        private void Init(object mapData)
        {
            datamanager = DataManager.GetInstance();
            battleType  = datamanager.GetBattleType();
            selfMark    = datamanager.GetForceMark();

            miniMapBg = transform.Find("Mask/Bg").GetComponent <Image>();
            point     = transform.Find("Mask/Bg/Point").gameObject;

            if (battleType == BattleType.BattleP2vsP2)
            {
                GameResourceLoadManager.GetInstance().LoadAtlasSprite(GameConstants.MINIMAP_2V2ID, delegate(string name, AtlasSprite atlasSprite, System.Object param)
                {
                    miniMapBg.SetSprite(atlasSprite);
                }, true);

                MapData2V2 map2v2 = ( MapData2V2 )mapData;
                mapSize = map2v2.mapSize;

                miniMapWidthLimit  = map2v2.GetCameraWidthRange();
                miniMapHeightLimit = map2v2.GetCameraHeightRange();
            }
            else if (battleType == BattleType.BattleP1vsP1 || battleType == BattleType.Tutorial)
            {
                GameResourceLoadManager.GetInstance().LoadAtlasSprite(GameConstants.MINIMAP_1V1ID, delegate(string name, AtlasSprite atlasSprite, System.Object param)
                {
                    miniMapBg.SetSprite(atlasSprite);
                }, true);

                MapData1V1 map1v1 = ( MapData1V1 )mapData;
                mapSize = map1v1.mapSize;

                miniMapWidthLimit  = map1v1.GetCameraWidthRange();
                miniMapHeightLimit = map1v1.GetCameraHeightRange();
            }
            else
            {
                GameResourceLoadManager.GetInstance().LoadAtlasSprite("MapPVE", delegate(string name, AtlasSprite atlasSprite, System.Object param)
                {
                    miniMapBg.SetSprite(atlasSprite);
                }, true);

                //When we have more map need change.
                MapDataPVE mapPvE = ( MapDataPVE )mapData;
                mapSize = mapPvE.mapSize;

                miniMapWidthLimit  = mapPvE.GetCameraWidthRange();
                miniMapHeightLimit = mapPvE.GetCameraHeightRange();
            }

            miniMapRect = miniMapBg.GetComponent <RectTransform>();

            miniMapSize  = miniMapRect.sizeDelta;
            minimapRatio = miniMapSize.x / miniMapSize.y;
            realMapRatio = mapSize.x / mapSize.z;

            if (realMapRatio > minimapRatio)
            {
                isNeedFit = true;
                mapProportionalDifference = realMapRatio - minimapRatio;
            }

            miniMapWidthRatio  = (miniMapSize.x / mapSize.x);
            miniMapHeightRatio = (miniMapSize.y / mapSize.z);

            elementIconDic    = new Dictionary <long, Transform>();
            elementIconParent = transform.Find("Mask/ElementParent").transform;

            cameraOffset = Camera.main.transform.position;

            InitMiniMapElement(battleType);

            controller = new MiniMapController(this);

            DebugUtils.Log(DebugUtils.Type.MiniMap, "The MiniMapView initialization Complete.");
        }
示例#2
0
 public void SetMapData(MapData1V1 mapData)
 {
     this.mapData = mapData;
 }
示例#3
0
    public void ApplyBattleMode(GameObject battleMap)
    {
        DataManager clientData = DataManager.GetInstance();
        BattleType  type       = clientData.GetBattleType();

        mainCamera = Camera.main.GetComponent <NavigateCamera>();

        if (clientData.GetBattleSimluateState())
        {
            SimulateBattleMessageManager simBattleManager = this.gameObject.AddComponent <SimulateBattleMessageManager>();
            simBattleManager.Initialize();
            mainCamera.SetCameraControlType(CameraControlType.Observer);
        }
        else
        {
            mainCamera.SetCameraControlType(CameraControlType.Player);
        }

        if (BattleType == BattleType.BattleP2vsP2)
        {
            mapData2V2 = battleMap.AddComponent <MapData2V2>();
            mapData2V2.InitializeMapData2v2();
            mainCamera.SetCameraOriginalPosition(mapData2V2.GetCameraOriginalPosition(mark));
            mainCamera.SetCameraInvertMode(mapData2V2.GetCameraInvertType(mark));    // TODO: In PVE may need some special setting
            mainCamera.SetCameraAngle(mapData2V2.GetCameraOriginalAngle(mark));
            mainCamera.SetCameraFieldOfViewValue(mapData2V2.GetViewField(clientData.camareViewChoose));
            mainCamera.SetCameraRange(mapData2V2.GetCameraHeightRange(mark), mapData2V2.GetCameraWidthRange(mark));

            MessageDispatcher.PostMessage(MessageType.InitMiniMap, mapData2V2);

            renderWorld.RenderStart(mapData2V2);
        }
        else if (battleType == BattleType.BattleP1vsP1 || battleType == BattleType.Tutorial)
        {
            mapData1V1 = battleMap.AddComponent <MapData1V1>();
            mapData1V1.InitializeMapData1v1();
            mainCamera.SetCameraOriginalPosition(mapData1V1.GetCameraOriginalPosition(mark));
            mainCamera.SetCameraInvertMode(mapData1V1.GetCameraInvertType(mark));    // TODO: In PVE may need some special setting
            mainCamera.SetCameraAngle(mapData1V1.GetCameraOriginalAngle(mark));
            mainCamera.SetCameraFieldOfViewValue(mapData1V1.GetViewField(clientData.camareViewChoose));
            mainCamera.SetCameraRange(mapData1V1.GetCameraHeightRange(mark), mapData1V1.GetCameraWidthRange(mark));

            MessageDispatcher.PostMessage(MessageType.InitMiniMap, mapData1V1);

            renderWorld.RenderStart(mapData1V1);

            if (battleType == BattleType.Tutorial)
            {
                InitPVEMode(battleType);
            }
        }
        else
        {
            mapDataPVE = battleMap.GetComponent <MapDataPVE>();
            mapDataPVE.InitializeMapDataPvE();
            mainCamera.SetCameraOriginalPosition(mapDataPVE.GetCameraOriginalPosition(mark));
            mainCamera.SetCameraFieldOfViewValue(mapDataPVE.GetViewField(clientData.camareViewChoose));
            mainCamera.SetCameraRange(mapDataPVE.GetCameraHeightRange(), mapDataPVE.GetCameraWidthRange());

            mainCamera.SetCameraInvertMode();
            MessageDispatcher.PostMessage(MessageType.InitMiniMap, mapDataPVE);

            renderWorld.RenderStart(mapDataPVE);
            InitPVEMode(battleType);
        }


        DebugUtils.Log(DebugUtils.Type.Battle, "Battle type = " + type.ToString());
    }