|
@@ -8,21 +8,21 @@ using System.Linq;
|
|
|
|
|
|
|
|
public class StoryM : MonoBehaviour {
|
|
public class StoryM : MonoBehaviour {
|
|
|
|
|
|
|
|
- // 文本
|
|
|
|
|
|
|
+ // 鏂囨湰
|
|
|
public TMPro.TextMeshProUGUI textStory;
|
|
public TMPro.TextMeshProUGUI textStory;
|
|
|
public RectTransform shapeBack;
|
|
public RectTransform shapeBack;
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
- /// 设置旁白,并返回预期时间。旁白字幕将在预期时间后消失。
|
|
|
|
|
|
|
+ /// 璁剧疆鏃佺櫧锛屽苟杩斿洖棰勬湡鏃堕棿銆傛梺鐧藉瓧骞曞皢鍦ㄩ�鏈熸椂闂村悗娑堝け銆�
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
public float SetStoryText(string textCn, string textEn = "English") {
|
|
public float SetStoryText(string textCn, string textEn = "English") {
|
|
|
bool isCn = LocalizationSettings.SelectedLocale.LocaleName == "Chinese (Simplified) (zh-CN)";
|
|
bool isCn = LocalizationSettings.SelectedLocale.LocaleName == "Chinese (Simplified) (zh-CN)";
|
|
|
textStory.text = isCn ? textCn : textEn;
|
|
textStory.text = isCn ? textCn : textEn;
|
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(textStory.rectTransform);
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(textStory.rectTransform);
|
|
|
- // 动画
|
|
|
|
|
|
|
+ // 鍔ㄧ敾
|
|
|
textStory.color = Color.black;
|
|
textStory.color = Color.black;
|
|
|
DOTween.Kill("StoryFont"); textStory.DOColor(Color.white, 0.25f).SetId("StoryFont");
|
|
DOTween.Kill("StoryFont"); textStory.DOColor(Color.white, 0.25f).SetId("StoryFont");
|
|
|
DOTween.Kill("StoryBackground"); shapeBack.DOScaleX((textStory.rectTransform.rect.width + 40f) / 100f, 0.15f).SetId("StoryBackground");
|
|
DOTween.Kill("StoryBackground"); shapeBack.DOScaleX((textStory.rectTransform.rect.width + 40f) / 100f, 0.15f).SetId("StoryBackground");
|
|
|
- // 消失
|
|
|
|
|
|
|
+ // 娑堝け
|
|
|
float time = 1.5f + (isCn ? textCn.Length / 3f : textEn.Split(" ").Length / 3f);
|
|
float time = 1.5f + (isCn ? textCn.Length / 3f : textEn.Split(" ").Length / 3f);
|
|
|
StopCoroutine("WaitForHideStoryText"); StartCoroutine("WaitForHideStoryText", time);
|
|
StopCoroutine("WaitForHideStoryText"); StartCoroutine("WaitForHideStoryText", time);
|
|
|
Debug.Log(time + " -> " + textCn);
|
|
Debug.Log(time + " -> " + textCn);
|
|
@@ -38,10 +38,10 @@ public class StoryM : MonoBehaviour {
|
|
|
DOTween.Kill("StoryBackground"); shapeBack.DOScaleX(0, 0.2f).SetId("StoryBackground");
|
|
DOTween.Kill("StoryBackground"); shapeBack.DOScaleX(0, 0.2f).SetId("StoryBackground");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 刷怪
|
|
|
|
|
|
|
+ // 鍒锋€�
|
|
|
private Dictionary<Spawner.EnemyType, List<Spawner>> spawners = null;
|
|
private Dictionary<Spawner.EnemyType, List<Spawner>> spawners = null;
|
|
|
public void Spawn(Spawner.EnemyType type, int count = 1) {
|
|
public void Spawn(Spawner.EnemyType type, int count = 1) {
|
|
|
- // 初始化
|
|
|
|
|
|
|
+ // 鍒濆�鍖�
|
|
|
if (spawners == null) {
|
|
if (spawners == null) {
|
|
|
spawners = new();
|
|
spawners = new();
|
|
|
foreach (Spawner spawner in FindObjectsOfType<Spawner>()) {
|
|
foreach (Spawner spawner in FindObjectsOfType<Spawner>()) {
|
|
@@ -52,7 +52,7 @@ public class StoryM : MonoBehaviour {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // 实际刷怪
|
|
|
|
|
|
|
+ // 瀹為檯鍒锋€�
|
|
|
spawners[type].Shuffle();
|
|
spawners[type].Shuffle();
|
|
|
for (int i = 0; i < count; i++) {
|
|
for (int i = 0; i < count; i++) {
|
|
|
if (i >= spawners[type].Count) i = 0;
|
|
if (i >= spawners[type].Count) i = 0;
|
|
@@ -60,9 +60,9 @@ public class StoryM : MonoBehaviour {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 流程控制
|
|
|
|
|
|
|
+ // 娴佺▼鎺у埗
|
|
|
IEnumerator WaitUntilClear(int remain = 0) {
|
|
IEnumerator WaitUntilClear(int remain = 0) {
|
|
|
- while (FindObjectsOfType<EnemyBase>().Length - FindObjectsOfType<EnemyArrow>().Length > remain) { // 要算上自己
|
|
|
|
|
|
|
+ while (FindObjectsOfType<EnemyBase>().Length - FindObjectsOfType<EnemyArrow>().Length > remain) { // 瑕佺畻涓婅嚜宸�
|
|
|
yield return new WaitForSeconds(0.1f);
|
|
yield return new WaitForSeconds(0.1f);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -72,7 +72,7 @@ public class StoryM : MonoBehaviour {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 故事
|
|
|
|
|
|
|
+ // 鏁呬簨
|
|
|
public int stage = 0;
|
|
public int stage = 0;
|
|
|
void Start() {
|
|
void Start() {
|
|
|
StartCoroutine(test());
|
|
StartCoroutine(test());
|
|
@@ -83,23 +83,23 @@ public class StoryM : MonoBehaviour {
|
|
|
while (true) {
|
|
while (true) {
|
|
|
canSpawnArrow = true;
|
|
canSpawnArrow = true;
|
|
|
Spawn(Spawner.EnemyType.Mover, 3);
|
|
Spawn(Spawner.EnemyType.Mover, 3);
|
|
|
- SetStoryText("先刷几个瞎晃悠的", "");
|
|
|
|
|
|
|
+ SetStoryText("鍏堝埛鍑犱釜鐬庢檭鎮犵殑", "");
|
|
|
yield return new WaitForSeconds(3f);
|
|
yield return new WaitForSeconds(3f);
|
|
|
|
|
|
|
|
Spawn(Spawner.EnemyType.Shooter);
|
|
Spawn(Spawner.EnemyType.Shooter);
|
|
|
- SetStoryText("炮塔!", "");
|
|
|
|
|
|
|
+ SetStoryText("鐐��锛�", "");
|
|
|
yield return new WaitForSeconds(2f);
|
|
yield return new WaitForSeconds(2f);
|
|
|
|
|
|
|
|
Spawn(Spawner.EnemyType.Heavy, 2);
|
|
Spawn(Spawner.EnemyType.Heavy, 2);
|
|
|
- SetStoryText("最后是两个贼硬的……", "");
|
|
|
|
|
|
|
+ SetStoryText("鏈€鍚庢槸涓や釜璐肩‖鐨勨€︹€�", "");
|
|
|
yield return StartCoroutine(WaitUntilClear(2));
|
|
yield return StartCoroutine(WaitUntilClear(2));
|
|
|
|
|
|
|
|
canSpawnArrow = false;
|
|
canSpawnArrow = false;
|
|
|
InputM.DropDice(Modules.RandomOne(InputM.keyTypes.ToList()));
|
|
InputM.DropDice(Modules.RandomOne(InputM.keyTypes.ToList()));
|
|
|
- SetStoryText("来一个骰子吧……?", "");
|
|
|
|
|
|
|
+ SetStoryText("鏉ヤ竴涓��瀛愬惂鈥︹€︼紵", "");
|
|
|
yield return StartCoroutine(WaitUntilPickDice());
|
|
yield return StartCoroutine(WaitUntilPickDice());
|
|
|
|
|
|
|
|
- yield return StartCoroutine(WaitForStoryText("准备好,下一轮要来了!", ""));
|
|
|
|
|
|
|
+ yield return StartCoroutine(WaitForStoryText("鍑嗗�濂斤紝涓嬩竴杞��鏉ヤ簡锛�", ""));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
IEnumerator spawnArrow() {
|
|
IEnumerator spawnArrow() {
|
|
@@ -109,4 +109,4 @@ public class StoryM : MonoBehaviour {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
+}
|