feature_tasting_animation を develop にマージしました。

This commit is contained in:
shogo kimura 2021-12-14 15:30:37 +09:00
commit 2b21800ef7
13 changed files with 414 additions and 94 deletions

View File

@ -91,6 +91,8 @@ AnimatorStateMachine:
- {fileID: 51081042415013300} - {fileID: 51081042415013300}
- {fileID: 4394378192515912696} - {fileID: 4394378192515912696}
- {fileID: -4201787685094799525} - {fileID: -4201787685094799525}
- {fileID: 1938256483501769669}
- {fileID: 265964369079198928}
m_EntryTransitions: [] m_EntryTransitions: []
m_StateMachineTransitions: {} m_StateMachineTransitions: {}
m_StateMachineBehaviours: [] m_StateMachineBehaviours: []
@ -242,25 +244,37 @@ AnimatorController:
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 9100000} m_Controller: {fileID: 0}
- m_Name: Promotion - m_Name: Promotion
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 9100000} m_Controller: {fileID: 0}
- m_Name: Sleepy - m_Name: Sleepy
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 9100000} m_Controller: {fileID: 0}
- m_Name: Walk - m_Name: Walk
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 9100000} m_Controller: {fileID: 0}
- m_Name: Tasting
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
- m_Name: TastingWalk
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers: m_AnimatorLayers:
- serializedVersion: 5 - serializedVersion: 5
m_Name: Base Layer m_Name: Base Layer
@ -299,6 +313,56 @@ AnimatorStateTransition:
m_InterruptionSource: 0 m_InterruptionSource: 0
m_OrderedInterruption: 1 m_OrderedInterruption: 1
m_CanTransitionToSelf: 0 m_CanTransitionToSelf: 0
--- !u!1101 &265964369079198928
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: TastingWalk
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -7730918100354297461}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &1938256483501769669
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Tasting
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -6388531656861423336}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &4390197982913342166 --- !u!1102 &4390197982913342166
AnimatorState: AnimatorState:
serializedVersion: 5 serializedVersion: 5

View File

@ -76,6 +76,8 @@ public class BulkOrder : MonoBehaviour
// カウントリセット // カウントリセット
gameData.OrderConditionCount = 0; gameData.OrderConditionCount = 0;
GameDataManager.SaveGameData(); GameDataManager.SaveGameData();
// 試食スタート
BrotherPinkView.Instance.StartTasting();
LocalCacheManager.Load<Action>(CancelCallbackTag, null)?.Invoke(); LocalCacheManager.Load<Action>(CancelCallbackTag, null)?.Invoke();
LocalCacheManager.Remove(CancelCallbackTag); LocalCacheManager.Remove(CancelCallbackTag);
// キャンセルと同時に閉じる // キャンセルと同時に閉じる

View File

@ -1012,7 +1012,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!4 &8458098820248002959 --- !u!4 &8458098820248002959
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1576,6 +1576,7 @@ GameObject:
- component: {fileID: 7854448232971748899} - component: {fileID: 7854448232971748899}
- component: {fileID: 7854448232971748898} - component: {fileID: 7854448232971748898}
- component: {fileID: 7854448232971748956} - component: {fileID: 7854448232971748956}
- component: {fileID: 3285748382438269010}
m_Layer: 0 m_Layer: 0
m_Name: Brother_pink m_Name: Brother_pink
m_TagString: Untagged m_TagString: Untagged
@ -1633,6 +1634,22 @@ SortingGroup:
m_SortingLayerID: 0 m_SortingLayerID: 0
m_SortingLayer: 0 m_SortingLayer: 0
m_SortingOrder: 23 m_SortingOrder: 23
--- !u!114 &3285748382438269010
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7854448232971748896}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: acf2a111dab748379c60a37b887bd20c, type: 3}
m_Name:
m_EditorClassIdentifier:
itemMany: {fileID: 7527088936072372818}
itemFew: {fileID: 3577262440827808746}
manyCount: 6
fewCount: 3
--- !u!1 &7854448233088646087 --- !u!1 &7854448233088646087
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -1,4 +1,5 @@
using System; using System;
using MyGame.Scenes.marketing.Scripts;
using UniRx; using UniRx;
using UniRx.Triggers; using UniRx.Triggers;
using UnityEngine; using UnityEngine;
@ -9,6 +10,8 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
private static readonly int Promotion = Animator.StringToHash("Promotion"); private static readonly int Promotion = Animator.StringToHash("Promotion");
private static readonly int Sleepy = Animator.StringToHash("Sleepy"); private static readonly int Sleepy = Animator.StringToHash("Sleepy");
private static readonly int Walk = Animator.StringToHash("Walk"); private static readonly int Walk = Animator.StringToHash("Walk");
private static readonly int Tasting = Animator.StringToHash("Tasting");
private static readonly int TastingWalk = Animator.StringToHash("TastingWalk");
private static readonly Vector2 RightPos = new Vector2(4.96f, -0.26f); private static readonly Vector2 RightPos = new Vector2(4.96f, -0.26f);
private static readonly Vector2 LeftPos = new Vector2(-4.96f, -0.26f); private static readonly Vector2 LeftPos = new Vector2(-4.96f, -0.26f);
@ -22,9 +25,12 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
public int FewerBorder => fewerBorder; public int FewerBorder => fewerBorder;
private Animator animator; private Animator animator;
private bool isManyCustomer; private TastingBasketView basketView;
private bool isLocked; private bool waitMove;
private bool isMoveLocked;
private bool isPromotion; private bool isPromotion;
private bool isEndingPromotion;
private bool isTasting;
private int nextId; private int nextId;
private readonly (int trigger, Vector2 wayPoint, float wait)[] pinkMoves = private readonly (int trigger, Vector2 wayPoint, float wait)[] pinkMoves =
{ {
@ -33,23 +39,48 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
(Walk, RightPos, 0f), (Walk, RightPos, 0f),
(Promotion, RightPos + Vector2.left * .03f, 5.35f), (Promotion, RightPos + Vector2.left * .03f, 5.35f),
}; };
private readonly (int trigger, Vector2 wayPoint, float wait)[] pinkTastingMoves =
{
(TastingWalk, LeftPos, 0f),
(Tasting, LeftPos + Vector2.right * .03f, 5.35f),
(TastingWalk, RightPos, 0f),
(Tasting, RightPos + Vector2.left * .03f, 5.35f),
};
private int moveIndex; private int moveIndex;
private Vector2 wayPoint; private Vector2 wayPoint;
private float durationDelta; private float durationDelta;
private float completedDuration; private float completedDuration;
private (int trigger, Vector2 wayPoint, float wait)[] selectedMoves;
private IDisposable moveLockDispose;
private Subject<int> setTrigger = new Subject<int>();
private void Awake() private void Awake()
{ {
setTrigger.AddTo(this);
nextId = Normal; nextId = Normal;
isManyCustomer = true; waitMove = true;
selectedMoves = pinkMoves;
} }
private void Start() private void Start()
{ {
pinkTransform.localPosition = RightPos; pinkTransform.localPosition = RightPos;
/*
* 1Setする
*
*/
setTrigger
.ThrottleFrame(1)
.Subscribe(x =>
{
if (animator != null)
{
animator.SetTrigger(x);
}
}).AddTo(this);
this.UpdateAsObservable().Subscribe(_ => this.UpdateAsObservable().Subscribe(_ =>
{ {
if (isManyCustomer || isLocked || isPromotion) if (waitMove || isMoveLocked || isPromotion)
{ {
return; return;
} }
@ -66,14 +97,16 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
} }
durationDelta = 0; durationDelta = 0;
moveIndex++; moveIndex++;
if (moveIndex == pinkMoves.Length) if (moveIndex == selectedMoves.Length)
{ {
ResetMove(); if (isTasting)
isLocked = true;
this.CallWaitForSeconds(coolTime, () =>
{ {
isLocked = false; moveIndex = 0;
}); SetPinkMove();
return;
}
ResetMove();
LockMove(coolTime);
return; return;
} }
SetPinkMove(); SetPinkMove();
@ -81,10 +114,21 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
}).AddTo(this); }).AddTo(this);
} }
private void LockMove(float time)
{
isMoveLocked = true;
moveLockDispose?.Dispose();
moveLockDispose = Observable.Timer(TimeSpan.FromSeconds(time))
.Subscribe(l => { }, () =>
{
isMoveLocked = false;
}).AddTo(this);
}
private void ResetMove() private void ResetMove()
{ {
waitMove = true;
moveIndex = 0; moveIndex = 0;
isManyCustomer = true;
if (animator != null) animator.SetTrigger(nextId); if (animator != null) animator.SetTrigger(nextId);
} }
@ -92,12 +136,13 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
{ {
target.DestroyAllChildrens(); target.DestroyAllChildrens();
animator = Instantiate(animatorPrefab, target); animator = Instantiate(animatorPrefab, target);
basketView = animator.GetComponent<TastingBasketView>();
this.UpdateAsObservable().Subscribe(_ => this.UpdateAsObservable().Subscribe(_ =>
{ {
target.localPosition = pinkTransform.localPosition; target.localPosition = pinkTransform.localPosition;
target.localRotation = pinkTransform.localRotation; target.localRotation = pinkTransform.localRotation;
}).AddTo(animator); }).AddTo(animator);
if (isManyCustomer || isPromotion) if (waitMove || isPromotion || isTasting)
{ {
return; return;
} }
@ -106,13 +151,14 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
private void SetPinkMove() private void SetPinkMove()
{ {
var move = pinkMoves[moveIndex]; var move = selectedMoves[moveIndex];
wayPoint = move.wayPoint; wayPoint = move.wayPoint;
completedDuration = move.wait; completedDuration = move.wait;
if (animator != null) if (animator != null)
{ {
animator.ResetTrigger(Normal); animator.ResetTrigger(Normal);
animator.SetTrigger(move.trigger); // animator.SetTrigger(move.trigger);
setTrigger.OnNext(move.trigger);
} }
if (Vector2.Distance(wayPoint, pinkTransform.localPosition.ToVector2()) < .01f) if (Vector2.Distance(wayPoint, pinkTransform.localPosition.ToVector2()) < .01f)
{ {
@ -127,10 +173,11 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
} }
} }
// お客さんが多い場合に使用するアニメーション切替え
private void SetTrigger(int id) private void SetTrigger(int id)
{ {
nextId = id; nextId = id;
if (isManyCustomer) if (waitMove)
{ {
animator.SetTrigger(id); animator.SetTrigger(id);
} }
@ -161,34 +208,50 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
{ {
if (animator != null) if (animator != null)
{ {
var stateInfo = animator.GetCurrentAnimatorStateInfo(0); animator.ResetTrigger(Promotion);
if (stateInfo.IsName("Brother_pink_promotion"))
{
var length = stateInfo.length;
var time = stateInfo.normalizedTime;
this.CallWaitForSeconds((1 - time % 1) * length - .3f, () =>
{
animator.ResetTrigger(Promotion);
ResetMove();
isPromotion = false;
});
return;
}
} }
ResetMove(); ResetMove();
isPromotion = false; isPromotion = false;
} }
public void SetWalk() public void StartTasting()
{ {
if (isLocked || isPromotion) // tasting発動
moveLockDispose?.Dispose();
isMoveLocked = false;
waitMove = false;
isTasting = true;
selectedMoves = pinkTastingMoves;
SetPinkMove();
}
public void StopTasting()
{
if (!isTasting)
{ {
return; return;
} }
if (isManyCustomer) isTasting = false;
selectedMoves = pinkMoves;
SetPinkMove();
}
public void SetTastingCount(int count)
{
if (basketView != null)
{ {
isManyCustomer = false; basketView.SetItem(count);
SetPinkMove();
} }
} }
public void SetWalk()
{
if (!waitMove || isMoveLocked || isPromotion || isTasting)
{
return;
}
waitMove = false;
SetPinkMove();
}
} }

View File

@ -23,6 +23,9 @@ public class CustomerFlow : MonoBehaviour
[Header("試食のお客さん出現間隔(秒)")] [Header("試食のお客さん出現間隔(秒)")]
[SerializeField] private float tastingCustomerInterval = 5f; [SerializeField] private float tastingCustomerInterval = 5f;
public float TastingCustomerInterval => tastingCustomerInterval;
private int adActiveCount = 0;
public IObservable<bool> Flow => walkerObservable.Merge(customerObservable, adWalkerObservable, tastingCustomerObservable); public IObservable<bool> Flow => walkerObservable.Merge(customerObservable, adWalkerObservable, tastingCustomerObservable);
private void Awake() private void Awake()
@ -66,8 +69,11 @@ public class CustomerFlow : MonoBehaviour
} }
#endif #endif
// 試食 // 試食
// tastingCustomerInterval毎にTastingCountを確認
var tastingTimer = Observable.Interval(TimeSpan.FromSeconds(tastingCustomerInterval)) var tastingTimer = Observable.Interval(TimeSpan.FromSeconds(tastingCustomerInterval))
.Where(_ => GameDataManager.GameData.TastingCount > 0) .Where(_ => adActiveCount <= 0) // 宣伝中判定
.Where(_ => GameDataManager.GameData.ShopStock.Count > 0) // 在庫ゼロ判定
.Where(_ => GameDataManager.GameData.TastingCount > 0) // 試食残り判定
.Publish() .Publish()
.RefCount(); .RefCount();
// 試食残りカウントを減らす // 試食残りカウントを減らす
@ -84,8 +90,10 @@ public class CustomerFlow : MonoBehaviour
{ {
var timerObservable = AdWalkerTimer().Publish().RefCount(); var timerObservable = AdWalkerTimer().Publish().RefCount();
adStartObservable.OnNext(timerObservable); adStartObservable.OnNext(timerObservable);
adActiveCount++;
timerObservable.Subscribe(_ => { }, () => timerObservable.Subscribe(_ => { }, () =>
{ {
adActiveCount--;
onComplete?.Invoke(); onComplete?.Invoke();
}).AddTo(this); }).AddTo(this);
} }

View File

@ -31,6 +31,9 @@ public class Market : SingletonMonoBehaviour<Market>
[SerializeField] private CustomerSetting customerSetting; [SerializeField] private CustomerSetting customerSetting;
[SerializeField] private CustomerController customerControllerPrefab; [SerializeField] private CustomerController customerControllerPrefab;
// 暫定
public float TastingCustomerInterval => customerFlow.TastingCustomerInterval;
public List<ProductStockData> DisplayFlavors => displayFlavors; public List<ProductStockData> DisplayFlavors => displayFlavors;
private List<ProductStockData> displayFlavors = new List<ProductStockData>(); private List<ProductStockData> displayFlavors = new List<ProductStockData>();
public List<int> ShuffledOrder => shuffledOrder; public List<int> ShuffledOrder => shuffledOrder;
@ -59,7 +62,7 @@ public class Market : SingletonMonoBehaviour<Market>
private int orderIndex; private int orderIndex;
private int oneByOneIndex = 0; private int oneByOneIndex = 0;
private GameData gameData; private GameData gameData;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
@ -333,6 +336,22 @@ public class Market : SingletonMonoBehaviour<Market>
BrotherPinkView.Instance.SetWalk(); BrotherPinkView.Instance.SetWalk();
} }
}).AddTo(this); }).AddTo(this);
isPromotion.Subscribe(x =>
{
if (x)
{
BrotherPinkView.Instance.StartPromotion();
}
else
{
BrotherPinkView.Instance.StopPromotion();
if (gameData.TastingCount > 0 && shopState.Value == ShopState.Open)
{
BrotherPinkView.Instance.StartTasting();
}
}
}).AddTo(this);
} }
@ -517,8 +536,7 @@ public class Market : SingletonMonoBehaviour<Market>
isPromotion.Value = true; isPromotion.Value = true;
customerFlow.StartAdWalker(() => customerFlow.StartAdWalker(() =>
{ {
isPromotion.Value = false; isPromotion.Value = false;
BrotherPinkView.Instance.StopPromotion();
}); });
} }

View File

@ -17,6 +17,7 @@ public class MarketManager : MonoBehaviour
[SerializeField] private MarketCartView cartView; [SerializeField] private MarketCartView cartView;
[SerializeField] private BrotherBlueView blueView; [SerializeField] private BrotherBlueView blueView;
[SerializeField] private IncreaseCustomerButtonView rewardButtonView; [SerializeField] private IncreaseCustomerButtonView rewardButtonView;
[SerializeField] private MarketSignBoardView signBoardView;
[SerializeField] private Transform pinkTarget; [SerializeField] private Transform pinkTarget;
[SerializeField] private Transform coinPrefab; [SerializeField] private Transform coinPrefab;
[SerializeField] private Transform rootTransform; [SerializeField] private Transform rootTransform;
@ -24,7 +25,7 @@ public class MarketManager : MonoBehaviour
private Market market; private Market market;
List<ProductData> productDataList; List<ProductData> productDataList;
private readonly Subject<int> resetRefreshTimer = new Subject<int>(); private readonly Subject<Unit> resetRefreshTimer = new Subject<Unit>();
private readonly CompositeDisposable ShopClosedCompositeDisposable = new CompositeDisposable(); private readonly CompositeDisposable ShopClosedCompositeDisposable = new CompositeDisposable();
private void Start() private void Start()
@ -67,7 +68,7 @@ public class MarketManager : MonoBehaviour
gameData.FinishTutorial(); gameData.FinishTutorial();
GameDataManager.SaveGameData(); GameDataManager.SaveGameData();
walkerMask.gameObject.SetActive(false); walkerMask.gameObject.SetActive(false);
resetRefreshTimer.OnNext((int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds); resetRefreshTimer.OnNext(Unit.Default);
SetShopView(market.CurrentShopState.Value); SetShopView(market.CurrentShopState.Value);
}).AddTo(controller).AddTo(this); }).AddTo(controller).AddTo(this);
}); });
@ -108,6 +109,7 @@ public class MarketManager : MonoBehaviour
cartView.SetStock(startStocks, false); cartView.SetStock(startStocks, false);
BrotherPinkView.Instance.SetBrotherView(pinkTarget); BrotherPinkView.Instance.SetBrotherView(pinkTarget);
// 宣伝ボタン
rewardButtonView.RewardButton.ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ => rewardButtonView.RewardButton.ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ =>
{ {
GetRewardDialog.ShowIncreaseCustomerDialog(() => GetRewardDialog.ShowIncreaseCustomerDialog(() =>
@ -118,14 +120,17 @@ public class MarketManager : MonoBehaviour
gameData.increaseCustomerTime = DateTime.UtcNow.AddSeconds(10).ToBinary(); gameData.increaseCustomerTime = DateTime.UtcNow.AddSeconds(10).ToBinary();
#endif #endif
GameDataManager.SaveGameData(); GameDataManager.SaveGameData();
resetRefreshTimer.OnNext((int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds); resetRefreshTimer.OnNext(Unit.Default);
}); });
}).AddTo(this); }).AddTo(this);
// onNextをトリガーに実行
IDisposable timerDisposable = null; IDisposable timerDisposable = null;
resetRefreshTimer resetRefreshTimer
.Select(_ => (int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds)
.Subscribe(time => .Subscribe(time =>
{ {
// タイマーの更新処理
timerDisposable?.Dispose(); timerDisposable?.Dispose();
rewardButtonView.SetButtonActive(time <= 0); rewardButtonView.SetButtonActive(time <= 0);
rewardButtonView.SetTime(time); rewardButtonView.SetTime(time);
@ -141,30 +146,21 @@ public class MarketManager : MonoBehaviour
}).AddTo(this); }).AddTo(this);
}).AddTo(this); }).AddTo(this);
var remaining = (int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds; resetRefreshTimer.OnNext(Unit.Default);
resetRefreshTimer.OnNext(remaining);
// アプリ復帰時に残り時間更新
Observable.EveryApplicationPause() Observable.EveryApplicationPause()
.Where(pause => !pause) .Where(pause => !pause)
.Subscribe(_ => .Subscribe(_ =>
{ {
resetRefreshTimer.OnNext((int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds); resetRefreshTimer.OnNext(Unit.Default);
}).AddTo(this); }).AddTo(this);
market.IsPromotion.Subscribe(active => market.IsPromotion.Subscribe(active =>
{ {
if (active) SoundManager.Instance.PlayBGM(active ? "bgm_publicity" : "bgm_marketing");
{
SoundManager.Instance.PlayBGM("bgm_publicity");
BrotherPinkView.Instance.StartPromotion();
}
else
{
SoundManager.Instance.PlayBGM("bgm_marketing");
}
}).AddTo(this); }).AddTo(this);
// Customerの各アニメーション設定 // Customerの各アニメーション設定
foreach (var controller in market.CustomerControllerList) foreach (var controller in market.CustomerControllerList)
{ {
@ -227,19 +223,70 @@ public class MarketManager : MonoBehaviour
.SkipWhile(_ => !gameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay)) .SkipWhile(_ => !gameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay))
.Subscribe(state => .Subscribe(state =>
{ {
Debug.Log($"SetShopView");
SetShopView(state); SetShopView(state);
}).AddTo(this); }).AddTo(this);
// 試食看板はStart時非表示
signBoardView.SetActiveTastingBoard(false);
// 宣伝ボタン/試食表示切替
var tastingComplete = new Subject<Unit>().AddTo(this);
market.CurrentShopState
.CombineLatest(market.IsPromotion, tastingComplete, (shopState, isPromotion, _) => (shopState == ShopState.Open, isPromotion))
.Subscribe(x =>
{
var (isOpen, isPromotion) = x;
if (isOpen)
{
if (isPromotion)
{
// 宣伝ボタン表示
rewardButtonView.gameObject.SetActive(true);
signBoardView.SetActiveTastingBoard(false);
}
else if (gameData.TastingCount > 0)
{
rewardButtonView.gameObject.SetActive(false);
// 試食表示
signBoardView.SetActiveTastingBoard(true);
BrotherPinkView.Instance.StartTasting();
BrotherPinkView.Instance.SetTastingCount(gameData.TastingCount);
signBoardView.SetTimer(gameData.TastingCount * (int)market.TastingCustomerInterval, () =>
{
BrotherPinkView.Instance.SetTastingCount(gameData.TastingCount);
}, () =>
{
// 試食タイマーが終わったら表示更新トリガー
tastingComplete.OnNext(Unit.Default);
BrotherPinkView.Instance.StopTasting();
});
}
else // 宣伝も試食も未発動
{
BrotherPinkView.Instance.StopTasting();
rewardButtonView.gameObject.SetActive(true);
}
}
else // 閉店
{
BrotherPinkView.Instance.StopTasting();
rewardButtonView.gameObject.SetActive(false);
signBoardView.CancelTasting();
}
}).AddTo(this);
// CombineLatest動かすのに必要
tastingComplete.OnNext(Unit.Default);
} }
private void SetShopView(ShopState state) private void SetShopView(ShopState state)
{ {
#if UNITY_EDITOR
Debug.Log($"SetShopView");
#endif
ShopClosedCompositeDisposable.Clear(); ShopClosedCompositeDisposable.Clear();
switch (state) switch (state)
{ {
case ShopState.Open: case ShopState.Open:
// 宣伝ボタン表示
rewardButtonView.gameObject.SetActive(true);
BrotherPinkView.Instance.SetNormal(); BrotherPinkView.Instance.SetNormal();
blueView.OpenAction(); blueView.OpenAction();
closeSign.SetActive(false); closeSign.SetActive(false);
@ -247,8 +294,6 @@ public class MarketManager : MonoBehaviour
case ShopState.Busy: case ShopState.Busy:
break; break;
case ShopState.Close: case ShopState.Close:
// 宣伝ボタン非表示
rewardButtonView.gameObject.SetActive(false);
if (market.CustomerList.Count(x => x.State.Value == CustomerState.Order) == 0) if (market.CustomerList.Count(x => x.State.Value == CustomerState.Order) == 0)
{ {
BrotherPinkView.Instance.SetSleepy(); BrotherPinkView.Instance.SetSleepy();

View File

@ -0,0 +1,53 @@
using System;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
namespace MyGame.Scenes.marketing.Scripts
{
public class MarketSignBoardView : MonoBehaviour
{
private static readonly string RemainTimeFormat = "残り{0:D2}{1:D2}";
private static readonly string TimeUpText = "終了";
[SerializeField] private Text remainTimeText;
[SerializeField] private GameObject normalBoardObject;
[SerializeField] private GameObject tastingBoardObject;
private IDisposable timerDispose;
// 宣伝中は宣伝優先で通常看板
public void SetActiveTastingBoard(bool active)
{
normalBoardObject.SetActive(!active);
tastingBoardObject.SetActive(active);
}
private void SetTime(int seconds)
{
seconds = Mathf.Max(0, seconds);
remainTimeText.text = string.Format(RemainTimeFormat, Mathf.Min(seconds / 60, 99), seconds % 60);
}
public void SetTimer(int remaining, Action onInterval = null, Action onComplete = null)
{
timerDispose?.Dispose();
var timer = Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1f))
.Select(x => (int)(remaining - x))
.TakeWhile(x => x >= 0);
timerDispose = timer.Subscribe(x =>
{
SetTime(x);
onInterval?.Invoke();
}, () =>
{
remainTimeText.text = TimeUpText;
onComplete?.Invoke();
}).AddTo(this);
}
public void CancelTasting()
{
timerDispose?.Dispose();
remainTimeText.text = TimeUpText;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7a19dcec25224a75a8f3635153cef5c9
timeCreated: 1639378152

View File

@ -303,6 +303,7 @@ public class ProductManagement : MonoBehaviour
GameDataManager.GameData.AddTastingCustomerCount(tank.Stock); GameDataManager.GameData.AddTastingCustomerCount(tank.Stock);
tank.ClearStock(); tank.ClearStock();
GameDataManager.SaveGameData(); GameDataManager.SaveGameData();
BrotherPinkView.Instance.StartTasting();
} }
private void OnDestroy() private void OnDestroy()

View File

@ -0,0 +1,31 @@
using UnityEngine;
namespace MyGame.Scenes.marketing.Scripts
{
public class TastingBasketView : MonoBehaviour
{
[SerializeField] private GameObject itemMany;
[SerializeField] private GameObject itemFew;
[SerializeField] private int manyCount;
[SerializeField] private int fewCount;
public void SetItem(int count)
{
if (count >= manyCount)
{
itemMany.SetActive(true);
itemFew.SetActive(false);
}
else if (count >= fewCount)
{
itemMany.SetActive(false);
itemFew.SetActive(true);
}
else
{
itemMany.SetActive(false);
itemFew.SetActive(false);
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: acf2a111dab748379c60a37b887bd20c
timeCreated: 1639454549

View File

@ -3622,7 +3622,7 @@ PrefabInstance:
- target: {fileID: 4293843007976718249, guid: 1c993e9707f1a4fada56020be27dde28, - target: {fileID: 4293843007976718249, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
value: 66.25009 value: 66.25
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1c993e9707f1a4fada56020be27dde28, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 1c993e9707f1a4fada56020be27dde28, type: 3}
@ -5582,6 +5582,7 @@ MonoBehaviour:
cartView: {fileID: 2048621276} cartView: {fileID: 2048621276}
blueView: {fileID: 1506158581} blueView: {fileID: 1506158581}
rewardButtonView: {fileID: 820175261} rewardButtonView: {fileID: 820175261}
signBoardView: {fileID: 1732899481}
pinkTarget: {fileID: 1749782974} pinkTarget: {fileID: 1749782974}
coinPrefab: {fileID: 8159396421809467538, guid: 9fc8076f17c26ff4d9be53b90a7dad4c, coinPrefab: {fileID: 8159396421809467538, guid: 9fc8076f17c26ff4d9be53b90a7dad4c,
type: 3} type: 3}
@ -6172,7 +6173,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!4 &1165998904 --- !u!4 &1165998904
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -6736,17 +6737,17 @@ RectTransform:
m_GameObject: {fileID: 1265140448} m_GameObject: {fileID: 1265140448}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0.005197392, y: 0.005197392, z: 0.005197392}
m_Children: m_Children:
- {fileID: 1629640653} - {fileID: 1629640653}
m_Father: {fileID: 1423968762} m_Father: {fileID: 1423968762}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0.001, y: -0.563}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 300, y: 300}
m_Pivot: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1265140450 --- !u!114 &1265140450
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -6754,16 +6755,11 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1265140448} m_GameObject: {fileID: 1265140448}
m_Enabled: 1 m_Enabled: 0
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} m_Script: {fileID: 11500000, guid: be39b2648c1548e2a2338ea75a51fcc6, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &1265140451 --- !u!114 &1265140451
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -6795,9 +6791,9 @@ Canvas:
m_GameObject: {fileID: 1265140448} m_GameObject: {fileID: 1265140448}
m_Enabled: 1 m_Enabled: 1
serializedVersion: 3 serializedVersion: 3
m_RenderMode: 1 m_RenderMode: 2
m_Camera: {fileID: 1277621136} m_Camera: {fileID: 658354829}
m_PlaneDistance: 0 m_PlaneDistance: 1
m_PixelPerfect: 0 m_PixelPerfect: 0
m_ReceivesEvents: 1 m_ReceivesEvents: 1
m_OverrideSorting: 0 m_OverrideSorting: 0
@ -7057,7 +7053,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!4 &1423968762 --- !u!4 &1423968762
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -7066,7 +7062,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1423968761} m_GameObject: {fileID: 1423968761}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.052, y: -0.277, z: 0} m_LocalPosition: {x: 0.31, y: 0.96, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 1265140449} - {fileID: 1265140449}
@ -13093,10 +13089,10 @@ RectTransform:
m_Father: {fileID: 1265140449} m_Father: {fileID: 1265140449}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 469.1, y: -28} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 170, y: 40} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1629640654 --- !u!114 &1629640654
MonoBehaviour: MonoBehaviour:
@ -13119,12 +13115,12 @@ MonoBehaviour:
m_Calls: [] m_Calls: []
m_FontData: m_FontData:
m_Font: {fileID: 12800000, guid: b5532e9ce15694f55a0893a76a98cd78, type: 3} m_Font: {fileID: 12800000, guid: b5532e9ce15694f55a0893a76a98cd78, type: 3}
m_FontSize: 28 m_FontSize: 52
m_FontStyle: 0 m_FontStyle: 1
m_BestFit: 0 m_BestFit: 0
m_MinSize: 2 m_MinSize: 0
m_MaxSize: 40 m_MaxSize: 300
m_Alignment: 3 m_Alignment: 4
m_AlignByGeometry: 0 m_AlignByGeometry: 0
m_RichText: 1 m_RichText: 1
m_HorizontalOverflow: 0 m_HorizontalOverflow: 0
@ -13418,6 +13414,7 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 1732899480} - component: {fileID: 1732899480}
- component: {fileID: 1732899481}
m_Layer: 0 m_Layer: 0
m_Name: Signboard m_Name: Signboard
m_TagString: Untagged m_TagString: Untagged
@ -13441,6 +13438,21 @@ Transform:
m_Father: {fileID: 1102296790} m_Father: {fileID: 1102296790}
m_RootOrder: 5 m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1732899481
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1732899479}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a19dcec25224a75a8f3635153cef5c9, type: 3}
m_Name:
m_EditorClassIdentifier:
remainTimeText: {fileID: 1629640654}
normalBoardObject: {fileID: 1165998903}
tastingBoardObject: {fileID: 1423968761}
--- !u!1 &1749782973 --- !u!1 &1749782973
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -13466,7 +13478,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1749782973} m_GameObject: {fileID: 1749782973}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 4.96, y: -0.26, z: 0} m_LocalPosition: {x: 3.46, y: -0.26, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 1189290113} - {fileID: 1189290113}