Merge branch 'develop' of bitbucket.org:usaya/popcorn into develop
This commit is contained in:
commit
4b108bde78
|
|
@ -8878,7 +8878,7 @@ MonoBehaviour:
|
|||
cornMissMeter: {fileID: 1871878300}
|
||||
missTextSpawnTransform: {fileID: 676036207}
|
||||
cornSpawnCount: 50
|
||||
maxFailedCornCount: 10
|
||||
maxFailedCornCount: 25
|
||||
baseGrowSpeed: 1
|
||||
coldGrowSpeed: 0.1
|
||||
hotGrowSpeed: 2
|
||||
|
|
|
|||
|
|
@ -67,10 +67,7 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 175dce409df2f4d3aa1941a08822e03e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
spriteRenderer: {fileID: 8958880017665793879}
|
||||
cornSeedSprite: {fileID: 21300000, guid: 97ac0328246620745b8881e07f709ce7, type: 3}
|
||||
cornSimpleSprite: {fileID: 21300000, guid: 041ad2539ff56d945ab2da4be6a02f04, type: 3}
|
||||
cornBurntSprite: {fileID: 21300000, guid: a9d669186411b2b4da1511f59a91b4c9, type: 3}
|
||||
cornSkin: {fileID: 7130900939474693981}
|
||||
effectBurnt: {fileID: 3984349228049242719, guid: 02298b5aac4434a4c81aec58ad2caa9d,
|
||||
type: 3}
|
||||
animator: {fileID: 5972257590091015193}
|
||||
|
|
@ -121,6 +118,7 @@ GameObject:
|
|||
m_Component:
|
||||
- component: {fileID: 9198528551727453440}
|
||||
- component: {fileID: 8958880017665793879}
|
||||
- component: {fileID: 7130900939474693981}
|
||||
m_Layer: 0
|
||||
m_Name: Image_corn
|
||||
m_TagString: Untagged
|
||||
|
|
@ -192,6 +190,22 @@ SpriteRenderer:
|
|||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!114 &7130900939474693981
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3431194784518736845}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: c466f7c9f9e84d04b4a0afae69c08384, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
spriteRenderer: {fileID: 8958880017665793879}
|
||||
cornSeedSprite: {fileID: 21300000, guid: 97ac0328246620745b8881e07f709ce7, type: 3}
|
||||
cornSimpleSprite: {fileID: 21300000, guid: 041ad2539ff56d945ab2da4be6a02f04, type: 3}
|
||||
cornBurntSprite: {fileID: 21300000, guid: a9d669186411b2b4da1511f59a91b4c9, type: 3}
|
||||
--- !u!1 &4761356856374534614
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ public enum CornCondition
|
|||
Seed,
|
||||
Simple,
|
||||
Burnt,
|
||||
Spilled
|
||||
}
|
||||
|
||||
[RequireComponent(typeof(Rigidbody2D))]
|
||||
|
|
@ -20,11 +19,8 @@ public class Corn : MonoBehaviour
|
|||
private static readonly int HashCornGrow = Animator.StringToHash("CornGrow");
|
||||
private static readonly int HashCornBurn = Animator.StringToHash("CornBurn");
|
||||
private static readonly int HashWaitOffset = Animator.StringToHash("WaitOffset");
|
||||
|
||||
[SerializeField] private SpriteRenderer spriteRenderer;
|
||||
[SerializeField] private Sprite cornSeedSprite;
|
||||
[SerializeField] private Sprite cornSimpleSprite;
|
||||
[SerializeField] private Sprite cornBurntSprite;
|
||||
|
||||
[SerializeField] private CornSkin cornSkin;
|
||||
[SerializeField] private GameObject effectBurnt;
|
||||
[SerializeField] private Animator animator;
|
||||
|
||||
|
|
@ -38,6 +34,8 @@ public class Corn : MonoBehaviour
|
|||
|
||||
public IReadOnlyReactiveProperty<CornCondition> Condition => condition;
|
||||
private readonly ReactiveProperty<CornCondition> condition = new ReactiveProperty<CornCondition>(CornCondition.Seed);
|
||||
public IReadOnlyReactiveProperty<bool> Spilled => spilled;
|
||||
private readonly ReactiveProperty<bool> spilled = new ReactiveProperty<bool>();
|
||||
|
||||
|
||||
// 角度調整
|
||||
|
|
@ -48,9 +46,8 @@ public class Corn : MonoBehaviour
|
|||
{
|
||||
condition.AddTo(this);
|
||||
rigidbody = GetComponent<Rigidbody2D>();
|
||||
spriteRenderer.sprite = cornSeedSprite;
|
||||
|
||||
spriteTransform = spriteRenderer.transform;
|
||||
|
||||
spriteTransform = cornSkin.transform;
|
||||
rotationResolverTransform = spriteTransform.parent.parent;
|
||||
|
||||
animator.SetFloat(HashWaitOffset, Random.value/2);
|
||||
|
|
@ -58,17 +55,26 @@ public class Corn : MonoBehaviour
|
|||
|
||||
private void Start()
|
||||
{
|
||||
rigidbody.MovePosition(new Vector2(Random.value * 2 - 1, Random.value * 2 - 1));
|
||||
rigidbody.SetRotation(Random.value * 360);
|
||||
rigidbody.MovePosition(Random.insideUnitCircle);
|
||||
rigidbody.SetRotation(Random.rotation);
|
||||
cornSkin.ChangeSkin(condition.Value);
|
||||
|
||||
// コーンが飛んでいく
|
||||
// コーン飛び出し演出
|
||||
this.ObserveEveryValueChanged(x => x.rigidbody.velocity.magnitude)
|
||||
.Where(x => x >= cornSpillSpeed)
|
||||
.ThrottleFirstFrame(30) // 30フレーム間隔開ける
|
||||
.Select(_ => Random.value < .2f) // 演出を出す確率
|
||||
.FirstOrDefault()
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
condition.Value = CornCondition.Spilled;
|
||||
}).AddTo(this);
|
||||
{
|
||||
spilled.Value = true;
|
||||
var clone = Instantiate(cornSkin);
|
||||
clone.ChangeSkin(condition.Value);
|
||||
var cloneRigidBody = clone.gameObject.AddComponent<Rigidbody2D>();
|
||||
cloneRigidBody.gravityScale = 0;
|
||||
cloneRigidBody.AddForce(rigidbody.velocity.normalized * 20f, ForceMode2D.Impulse);
|
||||
this.CallWaitForSeconds(2f, () => Destroy(clone.gameObject));
|
||||
}).AddTo(this);
|
||||
|
||||
condition.Pairwise().Subscribe(x =>
|
||||
{
|
||||
|
|
@ -82,9 +88,6 @@ public class Corn : MonoBehaviour
|
|||
case CornCondition.Burnt:
|
||||
CornBurnt();
|
||||
break;
|
||||
case CornCondition.Spilled:
|
||||
CornSpilled(x.Previous);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(x), x, null);
|
||||
}
|
||||
|
|
@ -101,11 +104,6 @@ public class Corn : MonoBehaviour
|
|||
|
||||
private void Update()
|
||||
{
|
||||
if (condition.Value == CornCondition.Spilled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cornGrowTime += Time.deltaTime * cornGrowSpeed;
|
||||
if (cornGrowTime >= cornBurntTime)
|
||||
{
|
||||
|
|
@ -119,24 +117,20 @@ public class Corn : MonoBehaviour
|
|||
|
||||
private void CornPop()
|
||||
{
|
||||
spriteRenderer.sprite = cornSimpleSprite;
|
||||
rigidbody.AddForce(cornPopSpeed * new Vector2(Random.value * 2 - 1, Random.value * 2 - 1), ForceMode2D.Impulse);
|
||||
cornSkin.ChangeSkin(condition.Value);
|
||||
rigidbody.AddForce(cornPopSpeed * Random.insideUnitCircle, ForceMode2D.Impulse);
|
||||
animator.SetTrigger(HashCornGrow);
|
||||
VibrationManager.Instance.PlayVibrationOnce();
|
||||
}
|
||||
|
||||
private void CornBurnt()
|
||||
{
|
||||
spriteRenderer.sprite = cornBurntSprite;
|
||||
cornSkin.ChangeSkin(condition.Value);
|
||||
animator.SetTrigger(HashCornBurn);
|
||||
var effect = Instantiate(effectBurnt, transform);
|
||||
this.CallWaitForSeconds(.8f, () => Destroy(effect));
|
||||
}
|
||||
|
||||
private void CornSpilled(CornCondition prevCondition)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetCornProperty(float popTime, float burntDuration, float spillSpeed, float popSpeed)
|
||||
{
|
||||
cornPopTime = popTime;
|
||||
|
|
|
|||
|
|
@ -178,15 +178,18 @@ public class CornManager : MonoBehaviour
|
|||
// ミス数加算
|
||||
missCount.Value++;
|
||||
break;
|
||||
case CornCondition.Spilled:
|
||||
// 同時に飛び出したとき用に演出をばらつかせる
|
||||
corn.CallWaitForSeconds(Random.Range(0f, .5f), () => cornSpilledSubject.OnNext(condition.Previous));
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(condition), condition, null);
|
||||
}
|
||||
}).AddTo(compositeDisposable);
|
||||
|
||||
corn.Spilled
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
// 同時に飛び出したとき用に演出をばらつかせる
|
||||
corn.CallWaitForSeconds(Random.Range(0f, .5f), () => cornSpilledSubject.OnNext(corn.Condition.Value));
|
||||
}).AddTo(compositeDisposable);
|
||||
|
||||
cornConditions.Add(corn.Condition);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,6 @@ public class CornMissEffect : MonoBehaviour
|
|||
burntSprite.SetActive(true);
|
||||
spilledSprite.SetActive(false);
|
||||
break;
|
||||
case CornCondition.Spilled:
|
||||
burntSprite.SetActive(false);
|
||||
spilledSprite.SetActive(true);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(condition), condition, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class CornSkin : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private SpriteRenderer spriteRenderer;
|
||||
[SerializeField] private Sprite cornSeedSprite;
|
||||
[SerializeField] private Sprite cornSimpleSprite;
|
||||
[SerializeField] private Sprite cornBurntSprite;
|
||||
|
||||
public void ChangeSkin(CornCondition condition)
|
||||
{
|
||||
switch (condition)
|
||||
{
|
||||
case CornCondition.Seed:
|
||||
spriteRenderer.sprite = cornSeedSprite;
|
||||
break;
|
||||
case CornCondition.Simple:
|
||||
spriteRenderer.sprite = cornSimpleSprite;
|
||||
break;
|
||||
case CornCondition.Burnt:
|
||||
spriteRenderer.sprite = cornBurntSprite;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(condition), condition, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c466f7c9f9e84d04b4a0afae69c08384
|
||||
timeCreated: 1626764991
|
||||
|
|
@ -22,8 +22,6 @@ public class CornSpilled : MonoBehaviour
|
|||
spilledCornRenderer.sprite = spilledBurntCornSprite;
|
||||
spilledCornGrainRenderer.sprite = spilledBurntCornGrainSprite;
|
||||
break;
|
||||
case CornCondition.Spilled:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(condition), condition, null);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue