public virtual void loadDataMissions() { LogUtil.Log("Load Missions:"); int i = 0; //int totalPoints = 0; foreach (AppContentCollect mission in AppContentCollects.GetMissionsByWorld(GameWorlds.Current.code)) { GameObject item = NGUITools.AddChild(listGridRoot, listItemPrefab); item.name = "MissionItem" + i; UIUtil.UpdateLabelObject(item, "Container/Meta/LabelName", mission.display_name); UIUtil.UpdateLabelObject(item, "Container/Meta/LabelDescription", mission.description); // Update button action Transform buttonObject = item.transform.FindChild("Container/Button/ButtonAction"); if (buttonObject != null) { UIImageButton button = buttonObject.gameObject.GetComponent <UIImageButton>(); if (button != null) { string actionType = "mission"; string appContentState = AppContentStates.Current.code; string appState = AppStates.Current.code; string missionCode = mission.code; GameObjectData objData = button.gameObject.Get <GameObjectData>(); if (objData == null) { objData = button.gameObject.AddComponent <GameObjectData>(); } if (objData != null) { objData.Set(BaseDataObjectKeys.type, actionType); objData.Set(BaseDataObjectKeys.app_content_state, appContentState); objData.Set(BaseDataObjectKeys.app_state, appState); objData.Set(BaseDataObjectKeys.code, missionCode); } button.name = BaseUIButtonNames.buttonGamePlay + "$" + appContentState + "$" + missionCode; } } string currentType = "action"; foreach (GameObjectInactive obj in item.GetComponentsInChildren <GameObjectInactive>(true)) { if (obj.type == currentType) { obj.gameObject.Hide(); } } int j = 0; foreach (AppContentCollectItem action in mission.GetItemsData()) { foreach (GameObjectInactive obj in item.GetComponentsInChildren <GameObjectInactive>(true)) { if (obj.type == currentType) { string currentActionItem = currentType + "-" + (j + 1).ToString(); if (obj.code == currentActionItem) { Debug.Log("action.data.display_name:" + action.data.display_name); obj.gameObject.Show(); UIUtil.UpdateLabelObject( obj.gameObject, "LabelDescription", action.data.display_name); } } } j++; //GameObject iconObject = item.transform.FindChild("Container/Icon").gameObject; //UISprite iconSprite = iconObject.GetComponent<UISprite>(); //bool completed = false; //bool hasValue = GameProfileAchievements.Current.CheckIfAttributeExists(achievement.code); //if(hasValue) { //completed = GameProfileAchievements.Current.GetAchievementValue(achievement.code); //} //if(!hasValue) { //completed = GameProfileAchievements.Current.GetAchievementValue(achievement.code + "_" + achievement.pack_code); //} /* * string points = ""; * * if(completed) { * int currentPoints = achievement.points; * totalPoints += currentPoints; * * if(GameConfigs.useCoinRewardsForAchievements) { * currentPoints *= (int)GameConfigs.coinRewardAchievementPoint; * } * * points = "+" + currentPoints.ToString(); * * if(iconSprite != null) { * iconSprite.alpha = 1f; * } * //item.transform.FindChild("Container/ContainerComplete").gameObject.Show(); * } * else { * if(iconSprite != null) { * iconSprite.alpha = .33f; * } * //item.transform.FindChild("Container/ContainerComplete").gameObject.Hide(); * } */ //item.transform.FindChild("Container/LabelPoints").GetComponent<UILabel>().text = points; // Get trophy icon i++; } } //if(labelPoints != null) { // labelPoints.text = totalPoints.ToString("N0"); //} }
public virtual void loadDataMissions() { LogUtil.Log("Load Missions:"); int i = 0; double scoreTotal = 0; string worldCode = GameWorlds.Current.code; UpdateMetaLabels(); foreach (AppContentCollect mission in AppContentCollects.GetMissionsByWorld(worldCode)) { double scoreMission = 0; GameObject item = NGUITools.AddChild(listGridRoot, listItemPrefab); item.name = "MissionItem" + i; UIUtil.UpdateLabelObject(item, "Container/Meta/LabelName", mission.display_name); UIUtil.UpdateLabelObject(item, "Container/Meta/LabelDescription", mission.description); string actionType = BaseDataObjectKeys.mission; string appContentState = AppContentStates.Current.code; string appState = AppStates.Current.code; string missionCode = mission.code; // Update button action Transform buttonObject = item.transform.Find("Container/Button/ButtonAction"); if (buttonObject != null) { UIImageButton button = buttonObject.gameObject.GetComponent <UIImageButton>(); if (button != null) { GameObjectData objData = button.gameObject.Get <GameObjectData>(); if (objData == null) { objData = button.gameObject.AddComponent <GameObjectData>(); } if (objData != null) { objData.Set(BaseDataObjectKeys.type, actionType); objData.Set(BaseDataObjectKeys.app_content_state, appContentState); objData.Set(BaseDataObjectKeys.app_state, appState); objData.Set(BaseDataObjectKeys.code, missionCode); } button.name = BaseUIButtonNames.buttonGamePlay + "$" + appContentState + "$" + missionCode; } } // hide actions string currentType = BaseDataObjectKeys.action; foreach (GameObjectInactive obj in item.GetComponentsInChildren <GameObjectInactive>(true)) { if (obj.type == currentType) { obj.gameObject.Hide(); } } // fill in action content and stars int j = 0; foreach (AppContentCollectItem action in mission.GetItemsData()) { foreach (GameObjectInactive obj in item.GetComponentsInChildren <GameObjectInactive>(true)) { if (obj.type == currentType) { string index = (j + 1).ToString(); string currentActionItem = currentType + "-" + index; if (obj.code == currentActionItem) { //Debug.Log("action.data.display_name:" + action.data.display_name); obj.gameObject.Show(); UIUtil.UpdateLabelObject( obj.gameObject, "LabelDescription", action.data.display_name); // CHECK ACTION COMPLETE/SCORE STATE string collectType = BaseDataObjectKeys.mission; string collectKey = GameProfileModes.GetAppContentCollectItemKey( appState, appContentState, worldCode, BaseDataObjectKeys.all, mission.code, action.uid); bool complete = GameProfileModes.Current.GetContentCollectValue <bool>( collectType, collectKey, BaseDataObjectKeys.complete); double points = GameProfileModes.Current.GetContentCollectValue <double>( collectType, collectKey, BaseDataObjectKeys.points); if (points == 0) { points = GameProfileModes.Current.GetContentCollectValue <int>( collectType, collectKey, BaseDataObjectKeys.points); } if (complete) { // figure score scoreMission += points; } // STARS LIST SetStars(obj.gameObject, complete); // STARS STAR CONTAINER GameObject starObject = null; foreach (GameObjectInactive starItem in item.GetComponentsInChildren <GameObjectInactive>(true)) { if (starItem.code == "stars-star-" + index.ToString()) { starObject = starItem.gameObject; //Debug.Log("Worlds:loadDataMissions::StarObject Found"); } } SetStars(starObject, complete); } } } j++; } // fill score scoreTotal += scoreMission; Transform scoreObject = item.transform.Find("Container/Stars"); if (scoreObject != null) { UIUtil.UpdateLabelObject( scoreObject.gameObject, "LabelScore", scoreMission.ToString("N0")); } i++; } //Transform scoreTotalObject = item.transform.FindChild("Container/ScoreTotal"); //if(scoreObject != null) { // UIUtil.UpdateLabelObject( // scoreObject.gameObject, "LabelScoreTotal", scoreTotal.ToString("N0")); //} }