店舗開放処理追加 WorldMap.cs
This commit is contained in:
parent
46be4da4c7
commit
28f9fc3961
|
|
@ -856,11 +856,13 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 4e4f24e6699341769dc47066fac7fa38, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
titleText: {fileID: 0}
|
||||
levelText: {fileID: 0}
|
||||
iconTarget: {fileID: 0}
|
||||
progressSlider: {fileID: 0}
|
||||
button: {fileID: 0}
|
||||
titleText: {fileID: 6623300116970052218}
|
||||
levelText: {fileID: 6623300116824560410}
|
||||
iconTarget: {fileID: 6623300117055383976}
|
||||
progressSlider: {fileID: 6623300116374396847}
|
||||
button: {fileID: 6623300115501561980}
|
||||
brotherPanel: {fileID: 6960725688910489147}
|
||||
partTimerPanel: {fileID: 8891951417021859415}
|
||||
--- !u!1 &6623300116695627431
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -1203,7 +1205,7 @@ GameObject:
|
|||
- component: {fileID: 6623300117055383982}
|
||||
- component: {fileID: 6623300117055383983}
|
||||
m_Layer: 5
|
||||
m_Name: icon
|
||||
m_Name: iconTarget
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
|
|
@ -1220,7 +1222,8 @@ RectTransform:
|
|||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Children:
|
||||
- {fileID: 1202312085019358080}
|
||||
m_Father: {fileID: 6623300116529072775}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
|
@ -1576,3 +1579,79 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &9157707049469892783
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1202312085019358080}
|
||||
- component: {fileID: 7696835910450672046}
|
||||
- component: {fileID: 5469095571207879549}
|
||||
m_Layer: 5
|
||||
m_Name: icon
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1202312085019358080
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9157707049469892783}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 6623300117055383976}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: -0}
|
||||
m_SizeDelta: {x: 118, y: 118}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &7696835910450672046
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9157707049469892783}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &5469095571207879549
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9157707049469892783}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: 34b365f4d93bfac4fb472f0a176ec998, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
|
@ -8,23 +9,25 @@ namespace MyGame.Scenes.WorldMap.Scripts
|
|||
public class EarningView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Text titleText;
|
||||
[SerializeField] private Text levelText;
|
||||
[SerializeField] private TextMeshProUGUI levelText;
|
||||
[SerializeField] private Transform iconTarget;
|
||||
[SerializeField] private Slider progressSlider;
|
||||
[SerializeField] private Button button;
|
||||
private readonly CompositeDisposable compositeDisposable = new();
|
||||
|
||||
private void Start()
|
||||
[SerializeField] private GameObject brotherPanel;
|
||||
[SerializeField] private GameObject partTimerPanel;
|
||||
public IObservable<Unit> OnClick => button.OnClickAsObservable().TakeUntilDestroy(this);
|
||||
|
||||
public void SetLatestCity(bool active)
|
||||
{
|
||||
compositeDisposable.AddTo(this);
|
||||
brotherPanel.SetActive(active);
|
||||
partTimerPanel.SetActive(!active);
|
||||
}
|
||||
|
||||
public void SetData(PartTimerData partTimerData, float progressValue, Action onClick = null)
|
||||
public void SetData(CityData cityData, PartTimerData partTimerData, float progressValue)
|
||||
{
|
||||
titleText.text = cityData.Name;
|
||||
levelText.text = $"Lv.{partTimerData.level}";
|
||||
progressSlider.value = progressValue;
|
||||
compositeDisposable.Clear();
|
||||
button.OnClickAsObservable().Take(1).Subscribe(_ => onClick?.Invoke()).AddTo(compositeDisposable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,12 +15,7 @@ namespace MyGame.Scenes.WorldMap.Scripts
|
|||
[SerializeField] private GameObject fundButtonOff;
|
||||
[SerializeField] private GameObject detailObject;
|
||||
[SerializeField] private GameObject hideObject;
|
||||
private readonly CompositeDisposable compositeDisposable = new();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
compositeDisposable.AddTo(this);
|
||||
}
|
||||
public IObservable<Unit> OnFund => fundButton.OnClickAsObservable().TakeUntilDestroy(this);
|
||||
|
||||
public void SetActive(bool active)
|
||||
{
|
||||
|
|
@ -30,15 +25,15 @@ namespace MyGame.Scenes.WorldMap.Scripts
|
|||
|
||||
public void SetData(FundingData fundingData, int funded, Action<int> onComplete = null)
|
||||
{
|
||||
fundButtonOff.SetActive(funded / fundingData.needAmount != 1);
|
||||
fundButtonOff.SetActive(funded / fundingData.needAmount >= 1);
|
||||
fundButton.gameObject.SetActive(!fundButtonOff.activeSelf);
|
||||
progressSlider.value = (float)funded / fundingData.needAmount;
|
||||
progressText.text = $"{funded}/{fundingData.needAmount}";
|
||||
compositeDisposable.Clear();
|
||||
fundButton.OnClickAsObservable().ThrottleFirst(TimeSpan.FromSeconds(1f)).Subscribe(_ =>
|
||||
{
|
||||
FundingDialog.ShowDialog(fundingData, onComplete);
|
||||
}).AddTo(compositeDisposable);
|
||||
SetSlider(funded, fundingData.needAmount);
|
||||
}
|
||||
|
||||
private void SetSlider(float value, float max)
|
||||
{
|
||||
progressSlider.value = value / max;
|
||||
progressText.text = $"{value}/{max}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using MyGame.Scripts;
|
||||
using UniRx;
|
||||
using UniRx.Triggers;
|
||||
using UnityEngine;
|
||||
|
|
@ -17,9 +18,11 @@ namespace MyGame.Scenes.WorldMap.Scripts
|
|||
[SerializeField] private EarningView earningView;
|
||||
[SerializeField] private float selectDuration = 1f;
|
||||
[SerializeField] private float zoomScale = 1f;
|
||||
private readonly CompositeDisposable citySelectDisposable = new();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
citySelectDisposable.AddTo(this);
|
||||
#if UNITY_EDITOR
|
||||
this.UpdateAsObservable()
|
||||
.Where(_ => Input.GetKeyDown(KeyCode.R))
|
||||
|
|
@ -51,7 +54,7 @@ namespace MyGame.Scenes.WorldMap.Scripts
|
|||
fundingView.gameObject.SetActive(false);
|
||||
earningView.gameObject.SetActive(false);
|
||||
var beginPos = content.localPosition;
|
||||
var endPos = new Vector3(contentOffset.y, contentOffset.x + (beginPos - contentOffset).x / zoomScale);
|
||||
var endPos = new Vector3(contentOffset.x + (beginPos - contentOffset).x / zoomScale, contentOffset.y);
|
||||
this.CallLerp(selectDuration, f =>
|
||||
{
|
||||
var scale = Mathf.Lerp(zoomScale, 1f, f);
|
||||
|
|
@ -64,37 +67,50 @@ namespace MyGame.Scenes.WorldMap.Scripts
|
|||
shareGate = true;
|
||||
});
|
||||
}).AddTo(this);
|
||||
|
||||
/*
|
||||
* 初期実装都市のデータ設定
|
||||
*/
|
||||
gameData.IsFundingCompleted = true;
|
||||
GameDataUtils.CreateCityData(2);
|
||||
|
||||
foreach (var cityIcon in cityIcons)
|
||||
{
|
||||
/*
|
||||
* CityIconからCityIdを取得
|
||||
* 資金データを取得
|
||||
* 資金調達達成orバイト進捗50%以上であればNotifyアイコンフラグ
|
||||
*/
|
||||
cityIcon.SetNotify(false);
|
||||
var cityData = cityDataList.FirstOrDefault(data => data.id == cityIcon.CityId);
|
||||
var cityGameData = GameDataManager.GetCityGameData(cityIcon.CityId);
|
||||
if (cityGameData is null)
|
||||
{
|
||||
cityIcon.SetState(CityState.UnRelease);
|
||||
continue;
|
||||
}
|
||||
|
||||
// バイト収益
|
||||
var partTimerLevel = cityGameData.PartTimerLevel;
|
||||
var cityPartTimerDataList = partTimerDataList.Where(x => x.cityId == cityIcon.CityId).ToList();
|
||||
var partTimerData = cityPartTimerDataList.FirstOrDefault(data => data.level == partTimerLevel);
|
||||
cityIcon.SetState(cityGameData.IsFundingCompleted ? CityState.Release : CityState.Lock);
|
||||
|
||||
// 資金調達達成に関わらずバイト情報取得
|
||||
var partTimerData = partTimerDataList.FirstOrDefault(data => data.level == cityGameData.PartTimerLevel);
|
||||
if (partTimerData != null)
|
||||
{
|
||||
var heartProgress = partTimerData.heart / 10 * cityGameData.PartTimerElapsed / partTimerData.maxHeart;
|
||||
var coinProgress = partTimerData.sales / 10 * cityGameData.PartTimerElapsed / partTimerData.maxSales;
|
||||
// progress >= 50% で通知アイコン
|
||||
// リアルタイムでバッジ表示も可能
|
||||
// progress >= 50% で通知
|
||||
var (heartProgress, coinProgress) = CalcPartTimerProgress(partTimerData, cityGameData.PartTimerElapsed);
|
||||
if (Mathf.Max(heartProgress, coinProgress) >= .5f)
|
||||
{
|
||||
cityIcon.SetNotify(true);
|
||||
}
|
||||
}
|
||||
|
||||
// バイト強化可能か判定
|
||||
var nextLevelData = cityPartTimerDataList.FirstOrDefault(data => data.level == partTimerLevel + 1);
|
||||
var nextLevelData = partTimerDataList.FirstOrDefault(data => data.level == cityGameData.PartTimerLevel + 1);
|
||||
if (nextLevelData != null)
|
||||
{
|
||||
// 都市が開放されてから兄弟が働いて獲得したハートの合計
|
||||
if (nextLevelData.needHeart <= GameDataManager.GetCityGameData(nextLevelData.needHeartCityId).Heart)
|
||||
if (nextLevelData.needHeart <= GameDataUtils.GetPartTimerHeart(nextLevelData.cityId))
|
||||
{
|
||||
if (nextLevelData.needAmount <= cityGameData.Coin)
|
||||
{
|
||||
// 強化可能
|
||||
cityIcon.SetNotify(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -103,58 +119,96 @@ namespace MyGame.Scenes.WorldMap.Scripts
|
|||
.Where(_ => shareGate)
|
||||
.ThrottleFirst(TimeSpan.FromSeconds(1f))
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
shareGate = false;
|
||||
citySelectDisposable.Clear();
|
||||
|
||||
// 都市が最新店舗かどうか判定
|
||||
earningView.SetLatestCity(GameDataUtils.CheckLatestCity(cityIcon.CityId));
|
||||
|
||||
// バイト進捗
|
||||
if (partTimerData != null)
|
||||
{
|
||||
shareGate = false;
|
||||
|
||||
var isFunded = true;
|
||||
fundingView.ResetView();
|
||||
var index = 0;
|
||||
// 資金調達進捗
|
||||
foreach (var fundingData in fundingDataList.Where(x => x.cityId == cityIcon.CityId))
|
||||
var (heartProgress, coinProgress) = CalcPartTimerProgress(partTimerData, cityGameData.PartTimerElapsed);
|
||||
earningView.SetData(cityData, partTimerData, Mathf.Max(heartProgress, coinProgress));
|
||||
earningView.OnClick.Subscribe(_ =>
|
||||
{
|
||||
var now = cityGameData.FundingDict[fundingData.fundingCityId];
|
||||
isFunded &= now >= fundingData.needAmount;
|
||||
fundingView.SelectViews[index].SetActive(true);
|
||||
fundingView.SelectViews[index].SetData(fundingData, now, amount =>
|
||||
gameData.CurrentCityId = cityIcon.CityId;
|
||||
TransitionManager.Instance.LoadScene(GameScenes.Main);
|
||||
}).AddTo(citySelectDisposable);
|
||||
}
|
||||
fundingView.ResetView();
|
||||
fundingView.SetData(cityData);
|
||||
var index = 0;
|
||||
// 資金調達進捗
|
||||
var filteredFundingList = fundingDataList.Where(data => data.cityId == cityIcon.CityId).ToList();
|
||||
foreach (var fundingData in filteredFundingList)
|
||||
{
|
||||
cityGameData.FundingDict.TryAdd(fundingData.fundingCityId, 0);
|
||||
var view = fundingView.SelectViews[index];
|
||||
view.SetActive(true);
|
||||
view.SetData(fundingData, cityGameData.FundingDict[fundingData.fundingCityId]);
|
||||
view.OnFund.ThrottleFirst(TimeSpan.FromSeconds(1f)).Subscribe(_ =>
|
||||
{
|
||||
FundingDialog.ShowDialog(fundingData, amount =>
|
||||
{
|
||||
// 資金投入
|
||||
cityGameData.FundingDict[fundingData.fundingCityId] += amount;
|
||||
GameDataManager.GetCityGameData(fundingData.fundingCityId).Coin -= amount;
|
||||
cityGameData.IsFundingCompleted = filteredFundingList.All(data => cityGameData.FundingDict[data.fundingCityId] >= data.needAmount);
|
||||
GameDataManager.SaveGameData();
|
||||
|
||||
// 調達完了でPopup
|
||||
// view更新
|
||||
view.SetData(fundingData, cityGameData.FundingDict[fundingData.fundingCityId]);
|
||||
if (!cityGameData.IsFundingCompleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// 都市開放演出
|
||||
shareGate = false;
|
||||
earningView.gameObject.SetActive(false);
|
||||
fundingView.gameObject.SetActive(false);
|
||||
cityIcon.PlayAnimation(() =>
|
||||
{
|
||||
cityIcon.SetState(CityState.Release);
|
||||
FoodStandDialog.ShowDialog(cityData, () =>
|
||||
{
|
||||
earningView.SetLatestCity(true);
|
||||
// popup表示
|
||||
earningView.gameObject.SetActive(true);
|
||||
fundingView.gameObject.SetActive(false);
|
||||
shareGate = true;
|
||||
});
|
||||
});
|
||||
});
|
||||
index++;
|
||||
}
|
||||
}).AddTo(citySelectDisposable);
|
||||
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 endPos = contentOffset + (selectedPos - cityIcon.transform.localPosition) * zoomScale;
|
||||
this.CallLerp(selectDuration, f =>
|
||||
{
|
||||
var scale = Mathf.Lerp(1f, zoomScale, f);
|
||||
content.localPosition = Vector3.Lerp(beginPos, endPos, f);
|
||||
content.SetLocalScale(scale);
|
||||
}, () =>
|
||||
{
|
||||
// popup表示
|
||||
fundingView.gameObject.SetActive(!isFunded);
|
||||
earningView.gameObject.SetActive(isFunded);
|
||||
cancelWall.SetActive(true);
|
||||
shareGate = true;
|
||||
});
|
||||
}).AddTo(cityIcon);
|
||||
// 地図操作
|
||||
var beginPos = content.localPosition;
|
||||
var endPos = contentOffset + (selectedPos - cityIcon.transform.localPosition) * zoomScale;
|
||||
this.CallLerp(selectDuration, f =>
|
||||
{
|
||||
var scale = Mathf.Lerp(1f, zoomScale, f);
|
||||
content.localPosition = Vector3.Lerp(beginPos, endPos, f);
|
||||
content.SetLocalScale(scale);
|
||||
}, () =>
|
||||
{
|
||||
// popup表示
|
||||
earningView.gameObject.SetActive(cityGameData.IsFundingCompleted);
|
||||
fundingView.gameObject.SetActive(!earningView.isActiveAndEnabled);
|
||||
cancelWall.SetActive(true);
|
||||
shareGate = true;
|
||||
});
|
||||
}).AddTo(cityIcon);
|
||||
}
|
||||
}
|
||||
|
||||
private static (float heartProgress, float coinProgress) CalcPartTimerProgress(PartTimerData partTimerData, int elapsed)
|
||||
{
|
||||
var heartProgress = partTimerData.heart / 10 * elapsed / partTimerData.maxHeart;
|
||||
var coinProgress = partTimerData.sales / 10 * elapsed / partTimerData.maxSales;
|
||||
return (heartProgress, coinProgress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2001,6 +2001,7 @@ MonoBehaviour:
|
|||
selectedCityTarget: {fileID: 793599774}
|
||||
cityIcons:
|
||||
- {fileID: 1393332535}
|
||||
- {fileID: 1933194629}
|
||||
scrollRect: {fileID: 1967067868}
|
||||
cancelWall: {fileID: 1834691514}
|
||||
fundingView: {fileID: 1232183326}
|
||||
|
|
@ -2644,6 +2645,18 @@ CanvasRenderer:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1892482190}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &1933194629 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 2440113195234058918, guid: 3fd9701b4f03eb043814a62cebedf574,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 697966914}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 94d22fb4b30547a7a7d613555c1fd8da, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1956300630
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
Loading…
Reference in New Issue