販売シーン歩行者増加リワードの追加
This commit is contained in:
parent
83eb91027b
commit
0ff46301df
|
|
@ -1347,6 +1347,7 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8103176713869808018}
|
||||
- component: {fileID: 4251265789366133276}
|
||||
m_Layer: 5
|
||||
m_Name: Button_publicity
|
||||
m_TagString: Untagged
|
||||
|
|
@ -1375,6 +1376,21 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 43, y: 473}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &4251265789366133276
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2835369144934501534}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 58ef3d6173414297b79183d0e69563ae, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
rewardButton: {fileID: 8545829044125670743}
|
||||
DisableObject: {fileID: 8559323780514547720}
|
||||
remainTimeText: {fileID: 4542360576964296986}
|
||||
--- !u!1 &3213111080442531914
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -2466,7 +2482,6 @@ GameObject:
|
|||
- component: {fileID: 8136363072906095234}
|
||||
- component: {fileID: 8379488605594547508}
|
||||
- component: {fileID: 2771442342717633046}
|
||||
- component: {fileID: 4195116565246018284}
|
||||
m_Layer: 5
|
||||
m_Name: Button_publicity_off
|
||||
m_TagString: Untagged
|
||||
|
|
@ -2532,49 +2547,6 @@ MonoBehaviour:
|
|||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &4195116565246018284
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8559323780514547720}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 2771442342717633046}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!1001 &2246654624185019878
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
|||
private Animator animator;
|
||||
private bool isManyCustomer;
|
||||
private bool isLocked;
|
||||
private bool isPromotion;
|
||||
private int nextId;
|
||||
private readonly (int trigger, Vector2 wayPoint, float wait)[] pinkMoves =
|
||||
{
|
||||
|
|
@ -49,7 +50,7 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
|||
pinkTransform.localPosition = RightPos;
|
||||
this.UpdateAsObservable().Subscribe(_ =>
|
||||
{
|
||||
if (isManyCustomer || isLocked)
|
||||
if (isManyCustomer || isLocked || isPromotion)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -68,10 +69,8 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
|||
moveIndex++;
|
||||
if (moveIndex == pinkMoves.Length)
|
||||
{
|
||||
moveIndex = 0;
|
||||
ResetMove();
|
||||
isLocked = true;
|
||||
isManyCustomer = true;
|
||||
if (animator != null) animator.SetTrigger(nextId);
|
||||
this.CallWaitForSeconds(coolTime, () =>
|
||||
{
|
||||
isLocked = false;
|
||||
|
|
@ -83,6 +82,13 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
|||
}).AddTo(this);
|
||||
}
|
||||
|
||||
private void ResetMove()
|
||||
{
|
||||
moveIndex = 0;
|
||||
isManyCustomer = true;
|
||||
if (animator != null) animator.SetTrigger(nextId);
|
||||
}
|
||||
|
||||
public void SetBrotherView(Transform target)
|
||||
{
|
||||
target.DestroyAllChildrens();
|
||||
|
|
@ -140,11 +146,31 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
|||
SetTrigger(Sleepy);
|
||||
}
|
||||
|
||||
public void SetPromotion()
|
||||
public void StartPromotion()
|
||||
{
|
||||
isManyCustomer = true;
|
||||
pinkTransform.localPosition = LeftPos;
|
||||
isPromotion = true;
|
||||
animator.SetTrigger(Promotion);
|
||||
Vector3 localPosition = RightPos;
|
||||
localPosition += Vector3.forward * (localPosition.y + Mathf.Abs(walkSideBottomPos));
|
||||
pinkTransform.localPosition = localPosition;
|
||||
pinkTransform.localRotation = Quaternion.Euler(Vector3.zero);
|
||||
}
|
||||
|
||||
public void StopPromotion()
|
||||
{
|
||||
if (animator == null)
|
||||
{
|
||||
isPromotion = false;
|
||||
ResetMove();
|
||||
return;
|
||||
}
|
||||
var length = animator.GetCurrentAnimatorStateInfo(0).length;
|
||||
var time = animator.GetCurrentAnimatorStateInfo(0).normalizedTime;
|
||||
this.CallWaitForSeconds((1 - time % 1) * length - .3f, () =>
|
||||
{
|
||||
isPromotion = false;
|
||||
ResetMove();
|
||||
});
|
||||
}
|
||||
|
||||
public void SetWalk()
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ public class CustomerFlow : MonoBehaviour
|
|||
private IObservable<bool> customerObservable;
|
||||
private IObservable<bool> walkerObservable;
|
||||
private IObservable<bool> adWalkerObservable;
|
||||
private readonly Subject<Unit> adStartObservable = new Subject<Unit>();
|
||||
private readonly Subject<IObservable<Unit>> adStartObservable = new Subject<IObservable<Unit>>();
|
||||
private static readonly float checkHeartInterval = 1f;
|
||||
// 歩行者の出現間隔
|
||||
private static readonly float walkerInterval = 60f / 6;
|
||||
|
|
@ -45,22 +45,31 @@ public class CustomerFlow : MonoBehaviour
|
|||
|
||||
// 宣伝時、タップすると60秒だけ稼働するストリーム
|
||||
adWalkerObservable = adStartObservable
|
||||
.Delay(TimeSpan.FromSeconds(2f))
|
||||
.Select(x => Observable.Interval(TimeSpan.FromSeconds(3f))
|
||||
.Take(TimeSpan.FromSeconds(60f))
|
||||
.Do(_ => Debug.Log($"adWalker:{GetHashCode()}"))
|
||||
.Select(_ => false))
|
||||
.Switch();
|
||||
.Switch()
|
||||
// .Do(_ => Debug.Log($"adWalker:{GetHashCode()}"))
|
||||
.Select(_ => false);
|
||||
#if DEVELOPMENT_BUILD || UNITY_EDITOR
|
||||
if (UsayaStorageManager.LoadOrDefault(UsayaStorageFilename.Settings_Data, "DebugManyWalker", false))
|
||||
{
|
||||
Observable.Timer(TimeSpan.FromSeconds(1f), TimeSpan.FromSeconds(70f)).Subscribe(_ => { adStartObservable.OnNext(default); }).AddTo(this);
|
||||
// Observable.Timer(TimeSpan.FromSeconds(1f), TimeSpan.FromSeconds(70f)).Subscribe(_ => { adStartObservable.OnNext(default); }).AddTo(this);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void StartAdWalker()
|
||||
public void StartAdWalker(Action onComplete = null)
|
||||
{
|
||||
adStartObservable.OnNext(Unit.Default);
|
||||
var timerObservable = AdWalkerTimer().Publish().RefCount();
|
||||
adStartObservable.OnNext(timerObservable);
|
||||
timerObservable.Subscribe(_ => { }, () =>
|
||||
{
|
||||
onComplete?.Invoke();
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
private IObservable<Unit> AdWalkerTimer()
|
||||
{
|
||||
return Observable.Interval(TimeSpan.FromSeconds(3f))
|
||||
.Take(TimeSpan.FromSeconds(60f))
|
||||
.AsUnitObservable();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace MyGame.Scenes.marketing.Scripts
|
||||
{
|
||||
public class IncreaseCustomerButtonView : MonoBehaviour
|
||||
{
|
||||
private static readonly string remainTimeFormat = "{0:D2}:{1:D2}";
|
||||
[SerializeField] private Button rewardButton;
|
||||
[SerializeField] private GameObject DisableObject;
|
||||
[SerializeField] private Text remainTimeText;
|
||||
public IObservable<Unit> RewardButton => rewardButton.OnClickAsObservable().TakeUntilDestroy(this);
|
||||
|
||||
public void SetButtonActive(bool active)
|
||||
{
|
||||
rewardButton.gameObject.SetActive(active);
|
||||
DisableObject.SetActive(!active);
|
||||
}
|
||||
|
||||
public void SetTime(int seconds)
|
||||
{
|
||||
seconds = Mathf.Max(0, seconds);
|
||||
remainTimeText.text = string.Format(remainTimeFormat, seconds / 60, seconds % 60);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 58ef3d6173414297b79183d0e69563ae
|
||||
timeCreated: 1634792615
|
||||
|
|
@ -513,7 +513,8 @@ public class Market : SingletonMonoBehaviour<Market>
|
|||
|
||||
public void AdClickAction()
|
||||
{
|
||||
customerFlow.StartAdWalker();
|
||||
BrotherPinkView.Instance.StartPromotion();
|
||||
customerFlow.StartAdWalker(() => BrotherPinkView.Instance.StopPromotion());
|
||||
}
|
||||
|
||||
private void CheckAndFixStock()
|
||||
|
|
|
|||
|
|
@ -1,25 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MyGame.Scenes.marketing.Scripts;
|
||||
using MyGame.Scripts;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UniRx.Triggers;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MarketManager : MonoBehaviour
|
||||
{
|
||||
private static readonly double refreshWaitTime = 300;
|
||||
[SerializeField] private GameObject closeSign;
|
||||
[SerializeField] private ShopStockView stockView;
|
||||
[SerializeField] private MarketCartView cartView;
|
||||
[SerializeField] private BrotherBlueView blueView;
|
||||
[SerializeField] private IncreaseCustomerButtonView rewardButtonView;
|
||||
[SerializeField] private Transform pinkTarget;
|
||||
[SerializeField] private Transform coinPrefab;
|
||||
[SerializeField] private Transform rootTransform;
|
||||
private Market market;
|
||||
List<ProductData> productDataList;
|
||||
|
||||
private readonly Subject<int> resetRefreshTimer = new Subject<int>();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
resetRefreshTimer.AddTo(this);
|
||||
|
||||
SoundManager.Instance.PlayBGM("bgm_marketing");
|
||||
var gameData = GameDataManager.GameData;
|
||||
CoinManager.Instance.ChangeCoin(gameData.Coin);
|
||||
|
|
@ -40,6 +49,41 @@ public class MarketManager : MonoBehaviour
|
|||
cartView.SetStock(startStocks, false);
|
||||
BrotherPinkView.Instance.SetBrotherView(pinkTarget);
|
||||
|
||||
rewardButtonView.RewardButton.ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ =>
|
||||
{
|
||||
GetRewardDialog.ShowIncreaseCustomerDialog(() =>
|
||||
{
|
||||
market.AdClickAction();
|
||||
gameData.increaseCustomerTime = DateTime.UtcNow.AddSeconds(refreshWaitTime).ToBinary();
|
||||
#if UNITY_EDITOR
|
||||
gameData.increaseCustomerTime = DateTime.UtcNow.AddSeconds(10).ToBinary();
|
||||
#endif
|
||||
GameDataManager.SaveGameData();
|
||||
resetRefreshTimer.OnNext((int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds);
|
||||
});
|
||||
}).AddTo(this);
|
||||
|
||||
resetRefreshTimer
|
||||
.Subscribe(time =>
|
||||
{
|
||||
rewardButtonView.SetButtonActive(time <= 0);
|
||||
rewardButtonView.SetTime(time);
|
||||
Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1f))
|
||||
.Select(x => (int)(time - x))
|
||||
.TakeWhile(x => x > 0)
|
||||
.Subscribe(x =>
|
||||
{
|
||||
rewardButtonView.SetTime(x);
|
||||
}, () =>
|
||||
{
|
||||
rewardButtonView.SetButtonActive(true);
|
||||
}).AddTo(this);
|
||||
}).AddTo(this);
|
||||
|
||||
var remaining = (int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds;
|
||||
resetRefreshTimer.OnNext(remaining);
|
||||
|
||||
|
||||
// Customerの各アニメーション設定
|
||||
foreach (var controller in market.CustomerControllerList)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1982,7 +1982,8 @@ PrefabInstance:
|
|||
propertyPath: m_RootOrder
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedComponents:
|
||||
- {fileID: 4195116565246018284, guid: caaa748dbeed576499e8cae74d33f689, type: 3}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: caaa748dbeed576499e8cae74d33f689, type: 3}
|
||||
--- !u!224 &714437465 stripped
|
||||
RectTransform:
|
||||
|
|
@ -2105,6 +2106,18 @@ Transform:
|
|||
m_Father: {fileID: 2085962459}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &820175261 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 4251265789366133276, guid: caaa748dbeed576499e8cae74d33f689,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 714437464}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 58ef3d6173414297b79183d0e69563ae, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &865915984
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -2530,6 +2543,7 @@ MonoBehaviour:
|
|||
stockView: {fileID: 438315601}
|
||||
cartView: {fileID: 2048621276}
|
||||
blueView: {fileID: 1506158581}
|
||||
rewardButtonView: {fileID: 820175261}
|
||||
pinkTarget: {fileID: 1749782974}
|
||||
coinPrefab: {fileID: 8159396421809467538, guid: 9fc8076f17c26ff4d9be53b90a7dad4c,
|
||||
type: 3}
|
||||
|
|
|
|||
Loading…
Reference in New Issue