public RectTransform GetItem(int index, RectTransform recyclableItem) { if (null == recyclableItem) { // 初回ロード時はinstantateItemCountで指定した回数分だけitemがnullで来るので、ここで生成してあげる // 以降はitemが再利用されるため、Reflesh()しない限りnullは来ない recyclableItem = Instantiate(itemPrefab).GetComponent <RectTransform>(); ScoreRewardContext item = new ScoreRewardContext(); item.DidSelectItem = OnSelectGetItem; recyclableItem.gameObject.GetComponent <M4uContextRoot>().Context = item; viewItems.Add(item); //位置調整 RectTransform offset = recyclableItem.gameObject.GetComponent <ScoreRewardListItem>().Offset.GetComponent <RectTransform>(); float posX = recyclableItem.sizeDelta.x * -1.0f; offset.anchoredPosition = new Vector2(posX, offset.anchoredPosition.y); } { if (RewardList.Count > index) { ScoreRewardContext item = recyclableItem.gameObject.GetComponent <ScoreRewardListItem>().Context; item.setup(RewardList[index].Reward, RewardList[index].RewardType); //Debug.LogWarning("ScoreReward index=" + index); } } return(recyclableItem); }
public void OnSelectGetItem(ScoreRewardContext item) { if (m_Ready == false || ServerApi.IsExists) { return; } SoundUtil.PlaySE(SEID.SE_MENU_OK); int[] reward_ids = new int[1]; reward_ids[0] = item.Reward.fix_id; SendGetScoreReward(reward_ids); }
private void updateRewardList() { if (scoreInfo == null) { return; } RewardList.Clear(); achieveList.Clear(); List <PacketStructUserScoreReward> viewList = new List <PacketStructUserScoreReward>(); List <PacketStructUserScoreReward> getList = new List <PacketStructUserScoreReward>(); if (scoreInfo.reward_list != null) { for (int i = 0; i < scoreInfo.reward_list.Length; i++) { if (scoreInfo.reward_list[i] == null) { continue; } if (scoreInfo.reward_list[i].type - 1 != TabIndex) { continue; } bool bAchieve = false; switch (scoreInfo.reward_list[i].type) { case 1: { if (scoreInfo.hi_score >= scoreInfo.reward_list[i].score) { bAchieve = true; } } break; case 2: { if (scoreInfo.total_score >= scoreInfo.reward_list[i].score) { bAchieve = true; } } break; } if (bAchieve) { achieveList.Add(scoreInfo.reward_list[i]); } else { viewList.Add(scoreInfo.reward_list[i]); } } } if (scoreInfo.get_list != null) { for (int i = 0; i < scoreInfo.get_list.Length; i++) { if (scoreInfo.get_list[i] == null) { continue; } if (scoreInfo.get_list[i].type - 1 != TabIndex) { continue; } getList.Add(scoreInfo.get_list[i]); } } IsActiveGetAll = false; if (achieveList.Count != 0) { achieveList.Sort((a, b) => a.score - b.score); for (int i = 0; i < achieveList.Count; i++) { ScoreRewardContext scoreReward = new ScoreRewardContext(); scoreReward.setData(achieveList[i], ScoreRewardContext.REWARD_ACHIIEVE); RewardList.Add(scoreReward); } IsActiveGetAll = true; } if (viewList.Count != 0) { viewList.Sort((a, b) => a.score - b.score); for (int i = 0; i < viewList.Count; i++) { ScoreRewardContext scoreReward = new ScoreRewardContext(); scoreReward.setData(viewList[i], ScoreRewardContext.REWARD_SHOW); RewardList.Add(scoreReward); } } if (getList.Count != 0) { getList.Sort((a, b) => a.score - b.score); for (int i = 0; i < getList.Count; i++) { ScoreRewardContext scoreReward = new ScoreRewardContext(); scoreReward.setData(getList[i], ScoreRewardContext.REWARD_GET); RewardList.Add(scoreReward); } } scrollContent.Initialize(this); }