畑チュートリアル追加

This commit is contained in:
kimura 2021-10-26 12:34:24 +09:00
parent be61ac5532
commit fa100b99e8
2 changed files with 267 additions and 56 deletions

View File

@ -1793,7 +1793,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 134.89282, y: 302.00003}
m_AnchoredPosition: {x: 134.89258, y: 302}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &525465089
@ -2288,6 +2288,7 @@ MonoBehaviour:
- {fileID: 1656378502}
- {fileID: 1192216301}
- {fileID: 556316131}
cornFieldMask: {fileID: 971086866}
--- !u!4 &715847676
Transform:
m_ObjectHideFlags: 0
@ -2640,6 +2641,18 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 42}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &971086866 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 5131953687285211373, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
m_PrefabInstance: {fileID: 2074297239}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4a8efaaa187d4865a1b4cabfa40ab6e9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &973728754
GameObject:
m_ObjectHideFlags: 0
@ -2759,7 +2772,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 134.89282, y: 91}
m_AnchoredPosition: {x: 134.89258, y: 91}
m_SizeDelta: {x: 300, y: 202}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &974444276
@ -14667,6 +14680,150 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1001 &2074297239
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 387414334}
m_Modifications:
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_RootOrder
value: 12
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_AnchorMax.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820480, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820543, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_Name
value: TutorialObjectMask
objectReference: {fileID: 0}
- target: {fileID: 4293843006989820543, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4293843007976718249, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_SizeDelta.x
value: 1130.8464
objectReference: {fileID: 0}
- target: {fileID: 4293843007976718249, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_SizeDelta.y
value: 806.6114
objectReference: {fileID: 0}
- target: {fileID: 4293843007976718249, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 11.8
objectReference: {fileID: 0}
- target: {fileID: 4293843007976718249, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 173.4
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1c993e9707f1a4fada56020be27dde28, type: 3}
--- !u!1 &2124911062 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2041305253, guid: caaa748dbeed576499e8cae74d33f689,

View File

@ -36,6 +36,8 @@ public class CornField : MonoBehaviour
[SerializeField] private Transform animationTarget;
[Space]
[SerializeField] private List<PlantLine> plantLines = new List<PlantLine>();
[Space] [SerializeField] private TutorialObjectMask cornFieldMask;
private static readonly int maxPeriod = 60;
private static readonly int minPeriod = 45;
private static readonly int harvestedFrameInterval = 3;
@ -61,6 +63,21 @@ public class CornField : MonoBehaviour
SoundManager.Instance.PlayBGM("bgm_Main");
// データ
var gameData = GameDataManager.GameData;
if (gameData.isFirstPlay)
{
promoteGrowthButton.gameObject.SetActive(false);
TutorialManager.Instance.ShowTutorialConversation(3, () =>
{
// コーンスワイプ指示
cornFieldMask.gameObject.SetActive(true);
});
}
else
{
cornFieldMask.gameObject.SetActive(false);
}
CoinManager.Instance.ChangeCoin(gameData.Coin);
HeartMeter.Instance.Initialize(gameData.ViewedShopLevel, gameData.Heart);
GameDataObserver.Instance.ShopLevelUpdate
@ -227,16 +244,45 @@ public class CornField : MonoBehaviour
// コーン株の進行度初回データ作成
foreach (var lineData in gameData.PlantLineDataList)
{
// コーン株の進行度初回データ作成
if (!gameData.SeedlingDataList.Exists(data => data.type == lineData.Type))
if (gameData.SeedlingDataList.Exists(data => data.type == lineData.Type))
{
var plantLine = plantLines.First(line => line.LineName == lineData.Type);
gameData.SeedlingDataList.Add(new SeedlingProgressData
{
type = lineData.Type,
Seedlings = Enumerable.Range(0, plantLine.Seedlings.Count).Select(_ => GenerateSeedlingGene(lineData.Level)).ToList()
});
continue;
}
var plantLine = plantLines.First(line => line.LineName == lineData.Type);
gameData.SeedlingDataList.Add(new SeedlingProgressData
{
type = lineData.Type,
Seedlings = Enumerable.Range(0, plantLine.Seedlings.Count).Select(_ => GenerateSeedlingGene(lineData.Level)).ToList()
});
}
if (gameData.isFirstPlay)
{
// 既に収穫できる状態にする
var plantLine = gameData.SeedlingDataList.First(data => data.type == PlantLineType.Center);
foreach (var seedling in plantLine.Seedlings)
{
seedling.FirstTime = DateTime.MinValue;
}
Observable.Merge(plantLines.SelectMany(line => line.Seedlings).Select(seedling => seedling.Harvested))
.Take(3)
.Subscribe(_ => { }, () =>
{
this.CallWaitForSeconds(4f, () =>
{
cornFieldMask.gameObject.SetActive(false);
TutorialManager.Instance.ShowTutorialConversation(4, () =>
{
// gameData.SeedlingDataList.Clear();
var go = FindObjectOfType<FooterManager>().transform;
go.transform.FindChildByName("Button_Purchasing", t =>
{
TutorialManager.Instance.ShowTutorialMask(go.parent, t as RectTransform);
});
});
});
}).AddTo(compositeDisposable);
}
GameDataManager.SaveGameData();
@ -244,10 +290,12 @@ public class CornField : MonoBehaviour
// セーブデータから畑を復元
foreach (var plantLine in plantLines)
{
if (gameData.PlantLineDataList.FirstOrDefault(data => data.Type == plantLine.LineName) is PlantLineData plantLineData)
if (!(gameData.PlantLineDataList.FirstOrDefault(data => data.Type == plantLine.LineName) is PlantLineData plantLineData))
{
plantLine.gameObject.SetActive(true);
plantLine.SetFieldLevel(plantLineData.Level);
continue;
}
plantLine.gameObject.SetActive(true);
plantLine.SetFieldLevel(plantLineData.Level);
for (int i = 0; i < plantLine.Seedlings.Count; i++)
{
@ -260,61 +308,67 @@ public class CornField : MonoBehaviour
seedling.SetSeedlingGene(progressData.FirstTime, progressData.Period / 3, progressData.Level);
}
#endif
// 収穫通知
seedling.Harvested.Subscribe(_ =>
// 収穫通知
seedling.Harvested.Subscribe(_ =>
{
VibrationManager.Instance.PlayVibrationOnce();
var harvestCount = fieldData.FirstOrDefault(x => x.Type == CornFieldUpgradeType.FieldCenter && x.level == (int)progressData.Level)?.harvested ?? 1;
var harvestedCorn = fieldData.FirstOrDefault(x => x.Type == CornFieldUpgradeType.Machine && x.level == gameData.MachineLevel)?.harvested ?? 20;
gameData.CornSeed += harvestedCorn * harvestCount;
var seedlingTransform = seedling.transform;
var harvestEffect = Instantiate(harvestEffectPrefab, seedlingTransform);
Destroy(harvestEffect, 1f);
for (int j = 0; j < harvestCount; j++)
{
VibrationManager.Instance.PlayVibrationOnce();
var harvestCount = fieldData.FirstOrDefault(x => x.Type == CornFieldUpgradeType.FieldCenter && x.level == (int)progressData.Level)?.harvested ?? 1;
var harvestedCorn = fieldData.FirstOrDefault(x => x.Type == CornFieldUpgradeType.Machine && x.level == gameData.MachineLevel)?.harvested ?? 20;
gameData.CornSeed += harvestedCorn * harvestCount;
var seedlingTransform = seedling.transform;
var harvestEffect = Instantiate(harvestEffectPrefab, seedlingTransform);
Destroy(harvestEffect, 1f);
for (int j = 0; j < harvestCount; j++)
// 株の位置調整
var pos = seedlingTransform.position;
if (harvestCount > 1)
{
// 株の位置調整
var pos = seedlingTransform.position;
if (harvestCount > 1)
pos += Vector3.right * (j - 1) * harvestedDistance + Vector3.forward * (j - 1);
}
this.CallWaitForFrame(harvestedFrameInterval * j, () =>
{
var harvestAnimation = Instantiate(harvestPrefab, pos, Quaternion.identity, harvestSpawnTarget);
this.CallWaitForSeconds(.5f, () =>
{
pos += Vector3.right * (j - 1) * harvestedDistance + Vector3.forward * (j - 1);
}
this.CallWaitForFrame(harvestedFrameInterval * j, () =>
{
var harvestAnimation = Instantiate(harvestPrefab, pos, Quaternion.identity, harvestSpawnTarget);
this.CallWaitForSeconds(.5f, () =>
this.CallLerp(.4f, f =>
{
this.CallLerp(.4f, f =>
{
harvestAnimation.transform.position = Vector3.Lerp(pos, harvestInsertPosition.position, f.EaseInQuadratic());
}, () =>
{
// コーン排出
cornHarvester.AddCount(harvestedCorn);
Destroy(harvestAnimation);
});
harvestAnimation.transform.position = Vector3.Lerp(pos, harvestInsertPosition.position, f.EaseInQuadratic());
}, () =>
{
// コーン排出
cornHarvester.AddCount(harvestedCorn);
Destroy(harvestAnimation);
});
});
}
// 新しい苗
var newGene = GenerateSeedlingGene(plantLineData.Level);
});
}
// 新しい苗
var newGene = GenerateSeedlingGene(plantLineData.Level);
#if DEVELOPMENT_BUILD || UNITY_EDITOR
if (UsayaStorageManager.LoadOrDefault(UsayaStorageFilename.Settings_Data, "DebugFastGrowing", false))
{
newGene.Period = newGene.Period / 3;
}
#endif
if (useFertilizer)
{
newGene.Period = Random.Range(2, 4);
}
seedling.SetSeedlingGene(newGene.FirstTime, newGene.Period, newGene.Level);
progressData.Level = newGene.Level;
progressData.Period = newGene.Period;
progressData.FirstTime = newGene.FirstTime;
GameDataManager.SaveGameData();
}).AddTo(compositeDisposable);
}
if (useFertilizer)
{
newGene.Period = Random.Range(2, 4);
}
seedling.SetSeedlingGene(newGene.FirstTime, newGene.Period, newGene.Level);
progressData.Level = newGene.Level;
progressData.Period = newGene.Period;
progressData.FirstTime = newGene.FirstTime;
GameDataManager.SaveGameData();
// チュートリアル時新しい苗を隠す
if (gameData.isFirstPlay)
{
seedling.SetSeedlingGene(DateTime.MaxValue, Int32.MaxValue, newGene.Level);
}
}).AddTo(compositeDisposable);
}
}