private void Awake()
 {
     stageViewPrefab    = LoadResourceController.GetCampaignStageView();
     playerCampaign     = DataPlayer.GetModule <PlayerCampaign>();
     campaignCollection = LoadResourceController.GetCampaignConfigCollection();
     mapConfig          = campaignCollection.GetMapCampaignConfigWithStageId(playerCampaign.GetLastStagePass());
 }
Beispiel #2
0
    public void SetupView(CampaignMapConfig map)
    {
        this.map = map;

        statusText.text = map.GetState().ToString();

        icon.sprite = LoadResourceController.GetCampaignMapIcon(map.mapId);

        mapIdText.text = "Map: " + map.mapId;
    }
    public CampaignMapConfig GetMapWithStageId(int stageId)
    {
        var mapId = CampaignMapConfig.GetMapId(stageId);

        for (int i = 0; i < mapList.Count; i++)
        {
            if (mapId == mapList[i].mapId)
            {
                return(mapList[i]);
            }
        }

        return(null);
    }
    public void Convert()
    {
        if (dataGroups.Length > 0)
        {
            var modeCount = CampaignModeConfig.GetModeId(dataGroups[dataGroups.Length - 1].stage);

            var modeConfigList = new CampaignWorldConfig();
            for (int i = 0; i < modeCount; i++)
            {
                var mode = new CampaignModeConfig();
                mode.modeId = i + 1;

                var mapElement = new CampaignMapConfig();
                mapElement.mapId = 1;
                mode.mapList.Add(mapElement);

                for (int j = 0; j < dataGroups.Length; j++)
                {
                    var data   = dataGroups[j];
                    var modeId = CampaignModeConfig.GetModeId(data.stage);

                    if (modeId == mode.modeId)
                    {
                        var mapId = CampaignMapConfig.GetMapId(data.stage);
                        if (mapId == mapElement.mapId)
                        {
                            mapElement.stageList.Add(data);
                        }
                        else
                        {
                            mapElement       = new CampaignMapConfig();
                            mapElement.mapId = mapId;
                            mapElement.stageList.Add(data);
                            mode.mapList.Add(mapElement);
                        }
                    }
                }

                modeConfigList.modeConfigList.Add(mode);
            }

            worldConfig = modeConfigList;
        }
    }
    public void UpdateView(CampaignMapConfig mapConfig)
    {
        this.mapConfig = mapConfig;

        LoadData();
    }
    public CampaignStageData GetNextStage(int lastStage)
    {
        var modeId = CampaignModeConfig.GetModeId(lastStage);

        // check mode with current stage
        var mode = GetModeCampaignWithId(modeId);

        if (mode == null)
        {
            return(null);
        }

        // check map with current stage
        var mapId = CampaignMapConfig.GetMapId(lastStage);

        var map = mode.GetMapWithId(mapId);

        if (map == null)
        {
            return(null);
        }

        var stage = map.GetNextStage(lastStage);

        if (stage != null)
        {
            return(stage);
        }

        // check stage in next map
        mapId += 1;
        map    = mode.GetMapWithId(mapId);
        if (map == null)
        {
            // if not exist next map, check stage in next mode
            modeId += 1;
            mode    = GetModeCampaignWithId(modeId);
            if (mode == null)
            {
                return(null);
            }

            map = mode.GetMapWithId(1);
            if (map == null)
            {
                return(null);
            }

            stage = map.GetNextStage(lastStage);
            if (stage != null)
            {
                return(stage);
            }
        }
        else
        {
            stage = map.GetNextStage(lastStage);
            if (stage != null)
            {
                return(stage);
            }
        }

        return(null);
    }