ビュー実装
This commit is contained in:
parent
198e7a855c
commit
6fe8aebed4
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using UniRx;
|
using UniRx;
|
||||||
using UniRx.Triggers;
|
using UniRx.Triggers;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
@ -12,8 +13,8 @@ namespace MyGame.Scenes.WorldMap.Scripts
|
||||||
[SerializeField] private CityIcon[] cityIcons;
|
[SerializeField] private CityIcon[] cityIcons;
|
||||||
[SerializeField] private ScrollRect scrollRect;
|
[SerializeField] private ScrollRect scrollRect;
|
||||||
[SerializeField] private GameObject cancelWall;
|
[SerializeField] private GameObject cancelWall;
|
||||||
[SerializeField] private GameObject investmentPopup;
|
[SerializeField] private FundingView fundingView;
|
||||||
[SerializeField] private GameObject earningPopup;
|
[SerializeField] private EarningView earningView;
|
||||||
[SerializeField] private float selectDuration = 1f;
|
[SerializeField] private float selectDuration = 1f;
|
||||||
[SerializeField] private float zoomScale = 1f;
|
[SerializeField] private float zoomScale = 1f;
|
||||||
|
|
||||||
|
|
@ -24,8 +25,21 @@ namespace MyGame.Scenes.WorldMap.Scripts
|
||||||
.Where(_ => Input.GetKeyDown(KeyCode.R))
|
.Where(_ => Input.GetKeyDown(KeyCode.R))
|
||||||
.Subscribe(_ => TransitionManager.Instance.LoadScene(GameScenes.WorldMap));
|
.Subscribe(_ => TransitionManager.Instance.LoadScene(GameScenes.WorldMap));
|
||||||
#endif
|
#endif
|
||||||
|
var gameData = GameDataManager.GameData;
|
||||||
|
var cityDataList = SpreadsheetDataManager.Instance.GetBaseDataList<CityData>(Const.CityDataSheet);
|
||||||
|
var fundingDataList = SpreadsheetDataManager.Instance.GetBaseDataList<FundingData>(Const.FundingDataSheet);
|
||||||
|
var partTimerDataList = SpreadsheetDataManager.Instance.GetBaseDataList<PartTimerData>(Const.PartTimerDataSheet);
|
||||||
|
|
||||||
|
fundingView.gameObject.SetActive(false);
|
||||||
|
earningView.gameObject.SetActive(false);
|
||||||
|
cancelWall.SetActive(false);
|
||||||
|
|
||||||
var content = scrollRect.content;
|
var content = scrollRect.content;
|
||||||
var contentOffset = content.localPosition;
|
var contentOffset = content.localPosition;
|
||||||
|
|
||||||
|
// 選択中の店舗を中央に持ってくる
|
||||||
|
content.localPosition = contentOffset.AddX(-cityIcons[0].transform.localPosition.x);
|
||||||
|
|
||||||
var selectedPos = selectedCityTarget.localPosition;
|
var selectedPos = selectedCityTarget.localPosition;
|
||||||
var shareGate = true;
|
var shareGate = true;
|
||||||
cancelWall.AddComponent<ObservableEventTrigger>().OnPointerClickAsObservable()
|
cancelWall.AddComponent<ObservableEventTrigger>().OnPointerClickAsObservable()
|
||||||
|
|
@ -34,7 +48,8 @@ namespace MyGame.Scenes.WorldMap.Scripts
|
||||||
.Subscribe(_ =>
|
.Subscribe(_ =>
|
||||||
{
|
{
|
||||||
shareGate = false;
|
shareGate = false;
|
||||||
investmentPopup.SetActive(false);
|
fundingView.gameObject.SetActive(false);
|
||||||
|
earningView.gameObject.SetActive(false);
|
||||||
var beginPos = content.localPosition;
|
var beginPos = content.localPosition;
|
||||||
var endPos = new Vector3(contentOffset.y, contentOffset.x + (beginPos - contentOffset).x / zoomScale);
|
var endPos = new Vector3(contentOffset.y, contentOffset.x + (beginPos - contentOffset).x / zoomScale);
|
||||||
this.CallLerp(selectDuration, f =>
|
this.CallLerp(selectDuration, f =>
|
||||||
|
|
@ -51,12 +66,78 @@ namespace MyGame.Scenes.WorldMap.Scripts
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
foreach (var cityIcon in cityIcons)
|
foreach (var cityIcon in cityIcons)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* CityIconからCityIdを取得
|
||||||
|
* 資金データを取得
|
||||||
|
* 資金調達達成orバイト進捗50%以上であればNotifyアイコンフラグ
|
||||||
|
*/
|
||||||
|
var cityGameData = GameDataManager.GetCityGameData(cityIcon.CityId);
|
||||||
|
|
||||||
|
// バイト収益
|
||||||
|
var partTimerLevel = cityGameData.PartTimerLevel;
|
||||||
|
var cityPartTimerDataList = partTimerDataList.Where(x => x.cityId == cityIcon.CityId).ToList();
|
||||||
|
var partTimerData = cityPartTimerDataList.FirstOrDefault(data => data.level == partTimerLevel);
|
||||||
|
|
||||||
|
if (partTimerData != null)
|
||||||
|
{
|
||||||
|
var heartProgress = partTimerData.heart / 10 * cityGameData.PartTimerElapsed / partTimerData.maxHeart;
|
||||||
|
var coinProgress = partTimerData.sales / 10 * cityGameData.PartTimerElapsed / partTimerData.maxSales;
|
||||||
|
// progress >= 50% で通知アイコン
|
||||||
|
}
|
||||||
|
|
||||||
|
// バイト強化可能か判定
|
||||||
|
var nextLevelData = cityPartTimerDataList.FirstOrDefault(data => data.level == partTimerLevel + 1);
|
||||||
|
if (nextLevelData != null)
|
||||||
|
{
|
||||||
|
// 都市が開放されてから兄弟が働いて獲得したハートの合計
|
||||||
|
if (nextLevelData.needHeart <= GameDataManager.GetCityGameData(nextLevelData.needHeartCityId).Heart)
|
||||||
|
{
|
||||||
|
if (nextLevelData.needAmount <= cityGameData.Coin)
|
||||||
|
{
|
||||||
|
// 強化可能
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cityIcon.OnClick
|
cityIcon.OnClick
|
||||||
.Where(_ => shareGate)
|
.Where(_ => shareGate)
|
||||||
.ThrottleFirst(TimeSpan.FromSeconds(1f))
|
.ThrottleFirst(TimeSpan.FromSeconds(1f))
|
||||||
.Subscribe(_ =>
|
.Subscribe(_ =>
|
||||||
{
|
{
|
||||||
shareGate = false;
|
shareGate = false;
|
||||||
|
|
||||||
|
var isFunded = true;
|
||||||
|
fundingView.ResetView();
|
||||||
|
var index = 0;
|
||||||
|
// 資金調達進捗
|
||||||
|
foreach (var fundingData in fundingDataList.Where(x => x.cityId == cityIcon.CityId))
|
||||||
|
{
|
||||||
|
var now = cityGameData.FundingDict[fundingData.fundingCityId];
|
||||||
|
isFunded &= now >= fundingData.needAmount;
|
||||||
|
fundingView.SelectViews[index].SetActive(true);
|
||||||
|
fundingView.SelectViews[index].SetData(fundingData, now, amount =>
|
||||||
|
{
|
||||||
|
// 資金投入
|
||||||
|
cityGameData.FundingDict[fundingData.fundingCityId] += amount;
|
||||||
|
GameDataManager.GetCityGameData(fundingData.fundingCityId).Coin -= amount;
|
||||||
|
GameDataManager.SaveGameData();
|
||||||
|
|
||||||
|
// 調達完了でPopup
|
||||||
|
});
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// バイト進捗&都市に行く
|
||||||
|
if (isFunded)
|
||||||
|
{
|
||||||
|
if (partTimerData != null)
|
||||||
|
{
|
||||||
|
var heartProgress = partTimerData.heart / 10 * cityGameData.PartTimerElapsed / partTimerData.maxHeart;
|
||||||
|
var coinProgress = partTimerData.sales / 10 * cityGameData.PartTimerElapsed / partTimerData.maxSales;
|
||||||
|
earningView.SetData(partTimerData, Mathf.Max(heartProgress, coinProgress));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var beginPos = content.localPosition;
|
var beginPos = content.localPosition;
|
||||||
var endPos = contentOffset + (selectedPos - cityIcon.transform.localPosition) * zoomScale;
|
var endPos = contentOffset + (selectedPos - cityIcon.transform.localPosition) * zoomScale;
|
||||||
this.CallLerp(selectDuration, f =>
|
this.CallLerp(selectDuration, f =>
|
||||||
|
|
@ -67,18 +148,13 @@ namespace MyGame.Scenes.WorldMap.Scripts
|
||||||
}, () =>
|
}, () =>
|
||||||
{
|
{
|
||||||
// popup表示
|
// popup表示
|
||||||
investmentPopup.SetActive(true);
|
fundingView.gameObject.SetActive(!isFunded);
|
||||||
|
earningView.gameObject.SetActive(isFunded);
|
||||||
cancelWall.SetActive(true);
|
cancelWall.SetActive(true);
|
||||||
shareGate = true;
|
shareGate = true;
|
||||||
});
|
});
|
||||||
}).AddTo(cityIcon);
|
}).AddTo(cityIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
investmentPopup.SetActive(false);
|
|
||||||
cancelWall.SetActive(false);
|
|
||||||
|
|
||||||
// 選択中の店舗を中央に持ってくる
|
|
||||||
content.localPosition = contentOffset.AddX(-cityIcons[0].transform.localPosition.x);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue