タイトルシーン処理追加

This commit is contained in:
kimura 2021-11-05 14:12:11 +09:00
parent f0b5450fc5
commit b8824b3895
9 changed files with 359 additions and 15 deletions

View File

@ -0,0 +1,95 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1101 &-7668411738907292653
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 8164371926150459515}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 1
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1107 &-3734040722917284177
AnimatorStateMachine:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 8164371926150459515}
m_Position: {x: 290, y: 30, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 8164371926150459515}
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Brother_Blue_Title
serializedVersion: 5
m_AnimatorParameters: []
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: -3734040722917284177}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1102 &8164371926150459515
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Brother_blue_sell
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: -7668411738907292653}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 424afa0916a1b7846924a375903a59cd, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5b65ded1862f4476ca46768c377b6f65
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -10,7 +10,8 @@ AnimatorState:
m_Name: title_tapToStart_appear
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_Transitions:
- {fileID: -6763011001785118005}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
@ -26,6 +27,50 @@ AnimatorState:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &-7174306829838173463
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -2000307096932458094}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 1
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-6763011001785118005
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -2000307096932458094}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 1
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1107 &-2109975076305159465
AnimatorStateMachine:
serializedVersion: 5
@ -37,7 +82,7 @@ AnimatorStateMachine:
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: -2000307096932458094}
m_Position: {x: 200, y: 0, z: 0}
m_Position: {x: 220, y: -40, z: 0}
- serializedVersion: 1
m_State: {fileID: -7392227350473413052}
m_Position: {x: 240, y: 60, z: 0}
@ -50,7 +95,7 @@ AnimatorStateMachine:
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: -2000307096932458094}
m_DefaultState: {fileID: -7392227350473413052}
--- !u!1102 &-2000307096932458094
AnimatorState:
serializedVersion: 5
@ -61,7 +106,8 @@ AnimatorState:
m_Name: title_tapToStart
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_Transitions:
- {fileID: -7174306829838173463}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0

View File

@ -22,9 +22,7 @@ public class KitchenManager : MonoBehaviour
// Start is called before the first frame update
void Start()
{
// 実機でアプリ初回起動時にBGMならないの回避。1フレーム遅らせると鳴る
Observable.NextFrame().Subscribe(_ => SoundManager.Instance.PlayBGM("bgm_Main"));
SoundManager.Instance.PlayBGM("bgm_Main");
var gameData = GameDataManager.GameData;
// レシピの表示

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9ff4a0bab8caf4f8d8e35ca9e2a82694
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,93 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UniRx;
using UniRx.Triggers;
using UnityEngine;
public class Title : MonoBehaviour
{
[SerializeField] private FloatReactiveProperty customerInterval = new FloatReactiveProperty(1f);
[Space]
[SerializeField] private GameObject startObject;
[SerializeField] private CustomerData customerData;
[SerializeField] private CustomerController customerControllerPrefab;
// Start is called before the first frame update
void Start()
{
// 実機でアプリ初回起動時にBGMならないの回避。1フレーム遅らせると鳴る
Observable.NextFrame().Subscribe(_ => SoundManager.Instance.PlayBGM("bgm_Main"));
startObject.SetActive(false);
this.CallWaitForFrame(50, () =>
{
startObject.SetActive(true);
this.UpdateAsObservable()
.Select(_ => Input.GetMouseButton(0))
.DistinctUntilChanged()
.Skip(1)
.Take(1)
.Subscribe(_ =>
{
TransitionManager.Instance.LoadScene(GameScenes.Main);
}).AddTo(this);
});
// お客さん
customerInterval.Select(f =>
Observable.Interval(TimeSpan.FromSeconds(f)))
.Switch()
.Subscribe(t =>
{
// 一般客orセレブ
var (isSpecial, orderCount) = Market.GetCustomerData(false);
// 複数パターンある場合ChooseRandom
var prefab = isSpecial ? customerData.ChooseSpecialPrefab() : customerData.ChooseNormalPrefab();
var customerController = Instantiate(customerControllerPrefab, transform);
customerController.MoveEndObservable
.SkipLatestValueOnSubscribe()
.DistinctUntilChanged()
.Subscribe(prevMovingType =>
{
switch (prevMovingType)
{
case CustomerMovingType.WalkSide:
case CustomerMovingType.WalkSideEat:
Destroy(customerController.gameObject);
break;
default:
break;
}
}).AddTo(customerController);
customerController.Setup(new List<Transform>{transform});
customerController.OrderCount = orderCount;
customerController.CustomerPrefab = prefab;
customerController.ChangeCustomerState(CustomerState.Walk);
var customerObject = new GameObject();
customerObject.transform.parent = transform;
customerObject.transform.localPosition = customerController.transform.localPosition;
// controllerが破棄のタイミングでこちらも破棄
customerController.OnDestroyAsObservable().Subscribe(_ =>
{
Destroy(customerObject);
}).AddTo(customerObject);
// customer位置同期
this.UpdateAsObservable().Subscribe(_ =>
{
customerObject.transform.localPosition = customerController.transform.localPosition;
}).AddTo(customerObject);
var customerAnimator = Instantiate(customerController.CustomerPrefab, customerObject.transform);
customerController.CurrentMovingType.Subscribe(x =>
{
customerAnimator.SetTrigger(x);
}).AddTo(customerAnimator);
customerController.IsDefaultSide.Subscribe(x =>
{
customerAnimator.SetSide(x);
}).AddTo(customerAnimator);
}).AddTo(this);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ea50a3e8d99284d0e9e8cc98a40f7dfe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1205,7 +1205,7 @@ Camera:
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 11.04
orthographic size: 12.5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
@ -1262,7 +1262,7 @@ Animator:
m_GameObject: {fileID: 515514728}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 27da499487f76364b90ea28fd658691e, type: 2}
m_Controller: {fileID: 9100000, guid: 5b65ded1862f4476ca46768c377b6f65, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
@ -3038,6 +3038,91 @@ MonoBehaviour:
m_PersistentCalls:
m_Calls: []
eventArray: []
--- !u!1 &1628914677
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1628914679}
- component: {fileID: 1628914678}
- component: {fileID: 1628914680}
m_Layer: 0
m_Name: Manager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1628914678
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1628914677}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ea50a3e8d99284d0e9e8cc98a40f7dfe, type: 3}
m_Name:
m_EditorClassIdentifier:
startObject: {fileID: 1863899077}
customerInterval:
value: 10
customerData: {fileID: 1628914680}
customerControllerPrefab: {fileID: 5715829407227760309, guid: 6fbb038c9aae840f2bea57bce30740f7,
type: 3}
--- !u!4 &1628914679
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1628914677}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.8154201, y: -0.8670571, z: -6.4536376}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1628914680
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1628914677}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: eee40f4ea08e42fab5bf3ea8810f972a, type: 3}
m_Name:
m_EditorClassIdentifier:
normalCustomerList:
- {fileID: 2081206165642927681, guid: 8c6dcd9482c51504e89ba42234369eda, type: 3}
- {fileID: 3417146906192995648, guid: af261bf183461af4b92b31a8649f1255, type: 3}
- {fileID: 7335308589943261866, guid: 8119ab8ce92a2484e83fa24bd7e91a7f, type: 3}
- {fileID: 413810629974474182, guid: b2e16ea88a942194fba4f20587f878d6, type: 3}
- {fileID: 7387534375894606070, guid: d7cea2d0458d10045a554a2fd1d5fde6, type: 3}
- {fileID: 2956205987963330084, guid: 2500a61ff79089d4da546f201f081e47, type: 3}
- {fileID: 4003975052009544272, guid: 324a7da4fcc328b4f86c4b8187774494, type: 3}
- {fileID: 6611440640265939248, guid: 7b6b18cba9150a1489f4b43c7dc96d01, type: 3}
- {fileID: 4805680105836285077, guid: 52eaa7893b55de0429402c694cde7077, type: 3}
- {fileID: 1961958092796897608, guid: 2d382a736a77d094ab8bd5337378ef12, type: 3}
- {fileID: 5217128672583935175, guid: 2b6084fdf652c6243b87c13c91f3b853, type: 3}
- {fileID: 1495806834793429147, guid: aee5c283a9302b749b3d37a96fcfdda2, type: 3}
- {fileID: 6205875053208953292, guid: 82c0cba8f34403145be5233f1a5c3068, type: 3}
- {fileID: 1289510962161473022, guid: 362f5d085a6f03448ab7123ee6592fc5, type: 3}
- {fileID: 3410656625090842591, guid: d3e920d4dcd68904db3aee438806ccc9, type: 3}
- {fileID: 8951347046735010126, guid: db654393793a67d45a7d0b70a68b73a6, type: 3}
- {fileID: 5939373664598446035, guid: d822fed75e272b5478a8ba9c9c591435, type: 3}
- {fileID: 5110027364233171103, guid: c07d09141aed9ea4d8f5fb012b316b43, type: 3}
- {fileID: 2961800609380067762, guid: fce9702bad3abf54691591f9720488fa, type: 3}
- {fileID: 1134751513859088931, guid: 09a4786fa1ab00e4b9c5bf9cebf256bc, type: 3}
specialCustomerList:
- {fileID: 5301193561386860206, guid: 72f4243f8f258bc48b42e3ae5e1ba2b5, type: 3}
--- !u!1 &1650380469
GameObject:
m_ObjectHideFlags: 0

View File

@ -18,7 +18,7 @@ public enum ShopState
public class Market : SingletonMonoBehaviour<Market>
{
public static readonly int ShopStockCount = 20;
private static readonly (int want, float weight)[] customerWeightTable = {
private static readonly (int want, float weight)[] CustomerWeightTable = {
(1, 70f),
(2, 20f),
(3, 3f),
@ -338,7 +338,7 @@ public class Market : SingletonMonoBehaviour<Market>
}
private (bool isSpecial, int orderCount) GetCustomerData (bool isCustomer)
public static (bool isSpecial, int orderCount) GetCustomerData (bool isCustomer)
{
var isSpecial = isCustomer ? Random.value < .01f : Random.value < .03f;
@ -347,10 +347,10 @@ public class Market : SingletonMonoBehaviour<Market>
}
// お客さん出現パターン確率計算と行動パターン計算
private int GetOrderCount()
private static int GetOrderCount()
{
var randomPoint = Random.value * customerWeightTable.Sum(x => x.weight);
foreach (var value in customerWeightTable)
var randomPoint = Random.value * CustomerWeightTable.Sum(x => x.weight);
foreach (var value in CustomerWeightTable)
{
if (randomPoint < value.weight)
{
@ -358,7 +358,7 @@ public class Market : SingletonMonoBehaviour<Market>
}
randomPoint -= value.weight;
}
return customerWeightTable.Last().want;
return CustomerWeightTable.Last().want;
}
private CustomerController SpawnCustomer()