ミッション追加
This commit is contained in:
parent
4c954f0dac
commit
a3c04c97d6
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a2309e5e619554230b1f6d3d9426ed51
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 66c0408cd45e7422cb6d59d2bdf4e998
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -391,6 +391,7 @@ GameObject:
|
||||||
- component: {fileID: 1628107519061200455}
|
- component: {fileID: 1628107519061200455}
|
||||||
- component: {fileID: 1628107519061200449}
|
- component: {fileID: 1628107519061200449}
|
||||||
- component: {fileID: 1628107519061200448}
|
- component: {fileID: 1628107519061200448}
|
||||||
|
- component: {fileID: 6952489502391719718}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: detail_Mission
|
m_Name: detail_Mission
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
|
@ -457,6 +458,25 @@ MonoBehaviour:
|
||||||
m_FillOrigin: 0
|
m_FillOrigin: 0
|
||||||
m_UseSpriteMesh: 0
|
m_UseSpriteMesh: 0
|
||||||
m_PixelsPerUnitMultiplier: 1
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!114 &6952489502391719718
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1628107519061200454}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 516f465654bf46d094f3493e145a183b, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
rewardButton: {fileID: 1628107518696448699}
|
||||||
|
disableObject: {fileID: 1628107520490624917}
|
||||||
|
rewardedObject: {fileID: 1628107518883220827}
|
||||||
|
coinText: {fileID: 1628107519630045354}
|
||||||
|
missionText: {fileID: 1628107520295442136}
|
||||||
|
progressText: {fileID: 1628107520281042222}
|
||||||
|
progressBar: {fileID: 1628107519738777243}
|
||||||
--- !u!1 &1628107519296330554
|
--- !u!1 &1628107519296330554
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -1177,7 +1197,7 @@ GameObject:
|
||||||
- component: {fileID: 1628107520295442137}
|
- component: {fileID: 1628107520295442137}
|
||||||
- component: {fileID: 1628107520295442136}
|
- component: {fileID: 1628107520295442136}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Text_detai
|
m_Name: Text_detail
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
using System;
|
||||||
|
using UniRx;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class MissionCompleteView : MonoBehaviour
|
||||||
|
{
|
||||||
|
private static readonly int OpenTrigger = Animator.StringToHash("OpenTrigger");
|
||||||
|
private static readonly int CloseTrigger = Animator.StringToHash("CloseTrigger");
|
||||||
|
|
||||||
|
[SerializeField] private Animator backgroundAnimator;
|
||||||
|
[SerializeField] private GameObject normalMissionObject;
|
||||||
|
[SerializeField] private GameObject dailyMissionObject;
|
||||||
|
[SerializeField] private Button closeButton;
|
||||||
|
[SerializeField] private Text coinText;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
var (missionData, callback) = LocalCacheManager.Load< (MissionData, Action)>(MissionManager.MissionDataTag);
|
||||||
|
closeButton.OnClickAsObservable().Subscribe(_ =>
|
||||||
|
{
|
||||||
|
callback?.Invoke();
|
||||||
|
transform.SetLocalScale(0);
|
||||||
|
backgroundAnimator.SetTrigger(CloseTrigger);
|
||||||
|
this.CallWaitForSeconds(.25f, () =>
|
||||||
|
{
|
||||||
|
TransitionManager.Instance.UnloadScene(GameScenes.MissionAchievement);
|
||||||
|
});
|
||||||
|
}).AddTo(this);
|
||||||
|
normalMissionObject.SetActive(missionData.Category == MissionCategory.Normal);
|
||||||
|
dailyMissionObject.SetActive(missionData.Category == MissionCategory.Daily);
|
||||||
|
coinText.text = missionData.reward.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5f2a9cddac65495987f3657236411f7a
|
||||||
|
timeCreated: 1632987547
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UniRx;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class MissionListView : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private MissionTabView normalTab;
|
||||||
|
[SerializeField] private MissionTabView dailyTab;
|
||||||
|
[SerializeField] private ScrollRect scrollRect;
|
||||||
|
[SerializeField] private MissionView itemViewPrefab;
|
||||||
|
|
||||||
|
private readonly ReactiveProperty<MissionCategory> selectedTab = new ReactiveProperty<MissionCategory>();
|
||||||
|
public IReadOnlyReactiveProperty<MissionCategory> SelectedTab => selectedTab;
|
||||||
|
private readonly List<(MissionCategory category, RectTransform content)> tabs = new List<(MissionCategory, RectTransform)>();
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
scrollRect.content.DestroyAllChildrens();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
selectedTab.AddTo(this);
|
||||||
|
selectedTab.Value = MissionCategory.Normal;
|
||||||
|
selectedTab.Subscribe(tabName =>
|
||||||
|
{
|
||||||
|
// タブ表示切り替え
|
||||||
|
normalTab.SetToggle(tabName == MissionCategory.Normal);
|
||||||
|
dailyTab.SetToggle(tabName == MissionCategory.Daily);
|
||||||
|
// コンテンツ切り替え
|
||||||
|
tabs.ForEach(x =>
|
||||||
|
{
|
||||||
|
x.content.gameObject.SetActive(x.category == tabName);
|
||||||
|
if (x.category == tabName)
|
||||||
|
{
|
||||||
|
scrollRect.content = x.content;
|
||||||
|
LayoutRebuilder.ForceRebuildLayoutImmediate(scrollRect.content);
|
||||||
|
scrollRect.verticalNormalizedPosition = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).AddTo(this);
|
||||||
|
normalTab.ClickObservable.Select(_ => MissionCategory.Normal)
|
||||||
|
.Merge(dailyTab.ClickObservable.Select(_ => MissionCategory.Daily))
|
||||||
|
.Subscribe(tabName =>
|
||||||
|
{
|
||||||
|
selectedTab.Value = tabName;
|
||||||
|
}).AddTo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MissionView AddItemView(MissionData missionData)
|
||||||
|
{
|
||||||
|
var index = tabs.FindIndex(x => x.category == missionData.Category);
|
||||||
|
if (index == -1)
|
||||||
|
{
|
||||||
|
index = tabs.Count;
|
||||||
|
var content = scrollRect.content;
|
||||||
|
tabs.Add((missionData.Category, Instantiate(content, content.parent)));
|
||||||
|
}
|
||||||
|
return Instantiate(itemViewPrefab, tabs[index].content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTab(MissionCategory category)
|
||||||
|
{
|
||||||
|
selectedTab.SetValueAndForceNotify(category);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bd3a66b31b924bb5858007ae9ebe1729
|
||||||
|
timeCreated: 1632980593
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
using System;
|
||||||
|
using UniRx;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class MissionManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static readonly string MissionDataTag = "MissionData";
|
||||||
|
private static readonly string TimeFormat = "更新まで:{0}時間{1}分{2}秒";
|
||||||
|
[SerializeField] private Button closeButton;
|
||||||
|
[SerializeField] private MissionListView listView;
|
||||||
|
[SerializeField] private Text timeLimitText;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
closeButton.OnClickAsObservable().Subscribe(_ =>
|
||||||
|
{
|
||||||
|
LocalCacheManager.Remove(MissionDataTag);
|
||||||
|
TransitionManager.Instance.UnloadScene(GameScenes.Mission);
|
||||||
|
}).AddTo(this);
|
||||||
|
|
||||||
|
listView.SelectedTab.Subscribe(category =>
|
||||||
|
{
|
||||||
|
timeLimitText.gameObject.SetActive(category == MissionCategory.Daily);
|
||||||
|
}).AddTo(this);
|
||||||
|
|
||||||
|
// ミッション読み込み
|
||||||
|
var missionList = SpreadsheetDataManager.Instance.GetBaseDataList<MissionData>(Const.MissionDataSheet);
|
||||||
|
|
||||||
|
// ミッション表示
|
||||||
|
foreach (var missionData in missionList)
|
||||||
|
{
|
||||||
|
var missionView = listView.AddItemView(missionData);
|
||||||
|
var progressValue = GetProgressValue(missionData);
|
||||||
|
missionView.SetData(missionData, progressValue);
|
||||||
|
missionView.SetButtonActive(missionData.count <= progressValue);
|
||||||
|
// if () // 達成済み
|
||||||
|
// {
|
||||||
|
// missionView.SetRewarded();
|
||||||
|
// }
|
||||||
|
// 達成処理
|
||||||
|
missionView.RewardButton.Take(1).Subscribe(_ =>
|
||||||
|
{
|
||||||
|
LocalCacheManager.Save(MissionDataTag, (missionData, new Action(() =>
|
||||||
|
{
|
||||||
|
GetReward(missionData);
|
||||||
|
missionView.SetRewarded();
|
||||||
|
// 達成ID保存
|
||||||
|
})));
|
||||||
|
TransitionManager.Instance.LoadSceneAdditive(GameScenes.MissionAchievement);
|
||||||
|
}).AddTo(missionView);
|
||||||
|
}
|
||||||
|
listView.SetTab(MissionCategory.Normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetProgressValue(MissionData missionData)
|
||||||
|
{
|
||||||
|
var gameData = GameDataManager.GameData;
|
||||||
|
switch (missionData.Condition)
|
||||||
|
{
|
||||||
|
case MissionCondition.CornCount:
|
||||||
|
return gameData.TotalAddCornSeed;
|
||||||
|
case MissionCondition.CustomerCount: // タップor来客した数
|
||||||
|
return gameData.TotalCustomerCount;
|
||||||
|
case MissionCondition.SalesCount: // 売った数
|
||||||
|
return gameData.TotalSales;
|
||||||
|
case MissionCondition.RareSalesCount: // レアを売った数
|
||||||
|
return gameData.RareTotalSales;
|
||||||
|
case MissionCondition.RecipeCount: // レシピの数
|
||||||
|
return gameData.MyRecipes.Length;
|
||||||
|
case MissionCondition.CoinConsumeCount: // コイン消費数
|
||||||
|
return gameData.TotalSubCoin;
|
||||||
|
case MissionCondition.SaltSalesCount:
|
||||||
|
return gameData.GetTotalSalesByFlavor(2);
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetReward(MissionData missionData)
|
||||||
|
{
|
||||||
|
if (missionData.RewardType == MissionRewardType.Coin)
|
||||||
|
{
|
||||||
|
CoinManager.Instance.AddCoinWithEffect(missionData.reward, () => {});
|
||||||
|
GameDataManager.GameData.Coin = CoinManager.Instance.OwnCoin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f36629f9262b466a9fab4c31cdf6f56c
|
||||||
|
timeCreated: 1632979804
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using UniRx;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class MissionTabView : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private Button button;
|
||||||
|
[SerializeField] private GameObject onObject;
|
||||||
|
[SerializeField] private GameObject offObject;
|
||||||
|
|
||||||
|
public IObservable<Unit> ClickObservable => button.OnClickAsObservable().TakeUntilDestroy(this);
|
||||||
|
public void SetToggle(bool active)
|
||||||
|
{
|
||||||
|
onObject.SetActive(active);
|
||||||
|
offObject.SetActive(!active);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 43c4132ef676491aa70fbf56f67e8436
|
||||||
|
timeCreated: 1632987044
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
using TMPro;
|
||||||
|
using UniRx;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class MissionView : MonoBehaviour
|
||||||
|
{
|
||||||
|
private static readonly string progressFormat = "{0} / {1}";
|
||||||
|
[SerializeField] private Button rewardButton;
|
||||||
|
[SerializeField] private GameObject disableObject;
|
||||||
|
[SerializeField] private GameObject rewardedObject;
|
||||||
|
[SerializeField] private Text coinText;
|
||||||
|
[SerializeField] private Text missionText;
|
||||||
|
[SerializeField] private TextMeshProUGUI progressText;
|
||||||
|
[SerializeField] private Slider progressBar;
|
||||||
|
public IObservable<Unit> RewardButton => rewardButton.OnClickAsObservable().TakeUntilDestroy(this);
|
||||||
|
|
||||||
|
public void SetData(MissionData missionData, int curentValue)
|
||||||
|
{
|
||||||
|
coinText.text = missionData.reward.ToString();
|
||||||
|
progressBar.value = Mathf.InverseLerp(0, missionData.count, curentValue);
|
||||||
|
progressText.text = string.Format(progressFormat, curentValue, missionData.count);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetButtonActive(bool active)
|
||||||
|
{
|
||||||
|
rewardButton.gameObject.SetActive(active);
|
||||||
|
disableObject.SetActive(!active);
|
||||||
|
rewardedObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetRewarded()
|
||||||
|
{
|
||||||
|
rewardButton.gameObject.SetActive(false);
|
||||||
|
disableObject.SetActive(false);
|
||||||
|
rewardedObject.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 516f465654bf46d094f3493e145a183b
|
||||||
|
timeCreated: 1632979820
|
||||||
Loading…
Reference in New Issue