private GameObject[] bomb_Gages; // ボムゲージ配列 void Start() { Instance = this; ControllSetting.LoadKeyConfig(); GameObject under = uiCanvas.transform.GetChild(2).gameObject; // ライフセット life = maxLife; life_Gages = new GameObject[maxLife]; for (int i = 0; i < maxLife; i++) { life_Gages[i] = Instantiate(lifeGage); life_Gages[i].transform.SetParent(under.transform, false); Image img = life_Gages[i].GetComponent <Image>(); img.rectTransform.anchoredPosition = new Vector2(i * 60.0f + 160.0f, 12.0f); } // ボンバーセット bomb = maxBomb; bomb_Gages = new GameObject[maxBomb]; for (int i = 0; i < maxBomb; i++) { bomb_Gages[i] = Instantiate(bombGage); bomb_Gages[i].transform.SetParent(under.transform, false); Image img = bomb_Gages[i].GetComponent <Image>(); img.rectTransform.anchoredPosition = new Vector2(i * -60.0f - 160.0f, 12.0f); } // キャンバス非アクティブ uiCanvas.SetActive(false); // スコアセット scoreText.text = score.ToString(); gameRankText.text = "Rank:" + gameRank.ToString("D3"); // フェードイン StartCoroutine(FadeScreen(false)); // メインカメラ取得 Camera mainCamera = Camera.main; // 画面左上の座標取得 window_LUPos = mainCamera.ViewportToWorldPoint(Vector3.zero); window_LUPos.Scale(new Vector3(1f, -1f, 1f)); // 画面右下の座標取得 window_RBPos = mainCamera.ViewportToWorldPoint(new Vector3(1.0f, 1.0f, 0.0f)); window_RBPos.Scale(new Vector3(1f, -1f, 1f)); Debug.Log("Window_LUPosition:" + window_LUPos); Debug.Log("Window_RBPosition:" + window_RBPos); score = 0; if (!DebugMode) { // ステージデータセット SetStageData(stageJson.ToString()); } }
// キー登録コルーチン private IEnumerator SetKeyConfig(string key) { StartCoroutine(CursorSelect()); keySetting = true; configText[(int)state - 3].text = "Press Use Key..."; yield return(new WaitForSeconds(0.5f)); while (true) { if (Input.anyKey) { foreach (KeyCode code in Enum.GetValues(typeof(KeyCode))) { if (Input.GetKey(code)) { PlaySE(select_SE); ControllSetting.keyConfig[key] = code; Debug.Log(ControllSetting.keyConfig[key].ToString()); ControllSetting.SaveKeyConfig(); SetKeyConfigText(); break; } } break; } yield return(null); } yield return(new WaitForSeconds(0.5f)); keySetting = false; }
// 弾発射関数 void ShotBullets() { if (shotCT <= 0) { if (ControllSetting.GetKey("Shot")) { audio.PlayOneShot(AudioManager.Instance.se_shot); // 共通ショット Vector3[] shotPos = new Vector3[2]; shotPos[0] = this.transform.position + new Vector3(0.4f, 0, 0); shotPos[1] = this.transform.position + new Vector3(-0.4f, 0, 0); for (int i = 0; i < 2; i++) { GameObject bullet = Instantiate(bulletObj, shotPos[i], Quaternion.identity); PlayerBullets pb = bullet.GetComponent <PlayerBullets>(); pb.SetSpeed(param.defaultShot_speed); } if (!slowMove) { TypeShot(shotType_Primary, slowMove); } else { TypeShot(shotType_Secondary, slowMove); } shotCT = param.shotInterval; } } else { shotCT -= Time.deltaTime; } }
private void Update() { if (!gameEnd) { // ポーズ設定 if (Input.GetKeyDown(KeyCode.Escape) || ControllSetting.GetKeyDown("Pose")) { PoseMenu.Instance.PoseChange(); } } }
// ボム発射関数 void UseBomber() { if (GameController.Instance.bomb > 0 && GameController.Instance.bomber_time <= 0.0f) { if (ControllSetting.GetKey("Bomb")) { audio.PlayOneShot(AudioManager.Instance.se_expL); EffectManager.Instance.InstantiateEffect(EffectManager.Effects.Bomber, this.transform.position); GameController.Instance.UseBomber(); } } }
// 移動関数 void Moving() { Vector3 moveVector = new Vector3(0, 0, 0); // 低速移動 float spd = param.moveSpeed; if (ControllSetting.GetKey("Slow")) { spd *= 0.7f; slowMove = true; } else { slowMove = false; } // 横軸入力 float hori = Input.GetAxisRaw("Horizontal"); if (hori > 0.0f) { hori = 1.0f; } else if (hori < 0.0f) { hori = -1.0f; } // 縦軸入力 float vert = Input.GetAxisRaw("Vertical"); if (vert > 0.0f) { vert = 1.0f; } else if (vert < 0.0f) { vert = -1.0f; } moveVector.x = spd * Time.deltaTime * hori; moveVector.y = spd * Time.deltaTime * vert; // 斜め移動時に補正をかける if (!(hori == 0 ^ vert == 0)) { moveVector *= correctionValue; } this.transform.position += moveVector; }
private Menu_State state = Menu_State.GameStart; // カーソル位置 void Start() { Instance = this; animated = true; ControllSetting.LoadKeyConfig(); SetKeyConfigText(); audioSource = this.GetComponent <AudioSource>(); if (atFirst) { Camera.main.gameObject.layer = 0; StartCoroutine(nameof(StartUpAnimation)); } else { bgm_spec.audio.Play(); startLogo.SetActive(false); StartCoroutine(nameof(SceneStartAnimation)); } }
void FixedUpdate() { if (!player) { player = GameController.Instance.playerObj.GetComponent <Player>(); player.shotType_Primary = prim_shot; player.shotType_Secondary = seco_shot; AudioManager.Instance.bgm_as.clip = AudioManager.Instance.bgm_standby; AudioManager.Instance.bgm_as.volume = 0; AudioManager.Instance.bgm_as.Play(); AudioManager.Instance.AudioFadeIn(AudioManager.Instance.bgm_as, 0.5f); } if (!animated) { if (ControllSetting.GetKeyDown("Shot")) { AudioManager.Instance.se_as.PlayOneShot(AudioManager.Instance.se_select); StartCoroutine(GameStart()); } else { float vert = Input.GetAxisRaw("Vertical"); if (vert < 0.0f || vert > 0.0f) { AudioManager.Instance.se_as.PlayOneShot(AudioManager.Instance.se_cursor); StartCoroutine(SlideCursor()); } else { float hori = Input.GetAxisRaw("Horizontal"); if (hori < 0.0f || hori > 0.0f) { AudioManager.Instance.se_as.PlayOneShot(AudioManager.Instance.se_cursor); if (hori < 0.0f) { ShotChange(-1); } else { ShotChange(1); } primary.GetComponent <Text>().text = prim_shot.ToString(); secondary.GetComponent <Text>().text = seco_shot.ToString(); player.shotType_Primary = prim_shot; player.shotType_Secondary = seco_shot; } } } } if (setting) { if (demoCT >= 0.5f) { player.ShotBullets_Demo(select_prim); } demoCT += Time.deltaTime; if (demoCT >= 1.5f) { demoCT = 0.0f; } } }
void Update() { if (!animated) { float vert = Input.GetAxisRaw("Vertical"); switch (state) { case Menu_State.Resume: if (Input.GetKey(KeyCode.Return) || ControllSetting.GetKey("Shot")) { AudioManager.Instance.se_as.PlayOneShot(AudioManager.Instance.se_select); PoseChange(); } else if (vert < 0.0f || vert > 0.0f) { AudioManager.Instance.se_as.PlayOneShot(AudioManager.Instance.se_cursor); if (vert > 0.0f) { state = Menu_State.ReturnTitle; } else if (vert < 0.0f) { state = Menu_State.Restart; } StartCoroutine(CursorSlide()); } break; case Menu_State.Restart: if (Input.GetKey(KeyCode.Return) || ControllSetting.GetKey("Shot")) { AudioManager.Instance.se_as.PlayOneShot(AudioManager.Instance.se_select); StartCoroutine(RealyCheck("RESTART GAME ?")); } else if (vert < 0.0f || vert > 0.0f) { AudioManager.Instance.se_as.PlayOneShot(AudioManager.Instance.se_cursor); if (vert > 0.0f) { state = Menu_State.Resume; } else if (vert < 0.0f) { state = Menu_State.ReturnTitle; } StartCoroutine(CursorSlide()); } break; case Menu_State.ReturnTitle: if (Input.GetKey(KeyCode.Return) || ControllSetting.GetKey("Shot")) { AudioManager.Instance.se_as.PlayOneShot(AudioManager.Instance.se_select); StartCoroutine(RealyCheck("RETURN TO TITLE ?")); } else if (vert < 0.0f || vert > 0.0f) { AudioManager.Instance.se_as.PlayOneShot(AudioManager.Instance.se_cursor); if (vert > 0.0f) { state = Menu_State.Restart; } else if (vert < 0.0f) { state = Menu_State.Resume; } StartCoroutine(CursorSlide()); } break; } } }
// 確認画面コルーチン private IEnumerator RealyCheck(string menu) { animated = true; realyWindow.SetActive(true); bool realy = false; Text title = realyWindow.transform.GetChild(0).GetComponent <Text>(); title.text = menu; RectTransform rt = realyWindow.transform.GetChild(3).GetComponent <RectTransform>(); rt.anchoredPosition = new Vector2(0.0f, -60.0f); float time = 0.0f; while (time <= 0.3f) { time += Time.unscaledDeltaTime; yield return(null); } bool slided = false; while (true) { if (!slided) { if (Input.GetKey(KeyCode.Return) || ControllSetting.GetKey("Shot")) { break; } else if (Input.GetKey(KeyCode.Escape) || ControllSetting.GetKey("Pose")) { AudioManager.Instance.se_as.PlayOneShot(AudioManager.Instance.se_cancel); realy = false; break; } else { float vert = Input.GetAxisRaw("Vertical"); if (vert > 0.0f || vert < 0.0f) { AudioManager.Instance.se_as.PlayOneShot(AudioManager.Instance.se_cursor); realy = !realy; slided = true; } } } else { float first = rt.anchoredPosition.y; float end = 0.0f; if (!realy) { end = -60.0f; } time = 0.0f; while (time <= 0.2f) { float y_pos = Easing.Ease_Out_Quad(first, end, time / 0.2f); rt.anchoredPosition = new Vector2(rt.anchoredPosition.x, y_pos); time += Time.unscaledDeltaTime; yield return(null); } slided = false; } yield return(null); } if (realy) { switch (state) { case Menu_State.Restart: AudioManager.Instance.se_as.PlayOneShot(AudioManager.Instance.se_select); GameController.Instance.MoveScene("Game"); break; case Menu_State.ReturnTitle: AudioManager.Instance.se_as.PlayOneShot(AudioManager.Instance.se_select); GameController.Instance.MoveScene("Title"); break; } } else { AudioManager.Instance.se_as.PlayOneShot(AudioManager.Instance.se_cancel); Animator anim = realyWindow.GetComponent <Animator>(); anim.SetTrigger("Close"); time = 0.0f; while (time <= 0.3f) { time += Time.unscaledDeltaTime; yield return(null); } animated = false; realyWindow.SetActive(false); yield return(null); } }
public IEnumerator Credit_Coroutine(bool thanks = true) { credit_base = this.GetComponent <CanvasGroup>(); yield return(StartCoroutine(CanvasFadeIn(credit_base, 0.5f))); float time = 0.0f; while (time <= 4.0f) { if (Input.GetKey(KeyCode.Return) || ControllSetting.GetKey("Shot")) { break; } time += Time.deltaTime; yield return(null); } var f_out = StartCoroutine(CanvasFadeOut(credit_1, 0.5f)); var f_in = StartCoroutine(CanvasFadeIn(credit_2, 0.5f)); yield return(f_in); yield return(f_out); time = 0.0f; while (time <= 4.0f) { if (Input.GetKey(KeyCode.Return) || ControllSetting.GetKey("Shot")) { break; } time += Time.deltaTime; yield return(null); } if (thanks) { f_out = StartCoroutine(CanvasFadeOut(credit_2, 0.5f)); f_in = StartCoroutine(CanvasFadeIn(credit_3, 0.5f)); yield return(f_in); yield return(f_out); time = 0.0f; while (time <= 4.0f) { if (Input.GetKey(KeyCode.Return) || ControllSetting.GetKey("Shot")) { break; } time += Time.deltaTime; yield return(null); } } else { yield return(CanvasFadeOut(credit_2, 0.5f)); yield return(CanvasFadeOut(credit_base, 0.5f)); credit_1.alpha = 1.0f; credit_2.alpha = 0.0f; credit_3.alpha = 0.0f; yield return(null); } }
// メニュー操作 private void MenuControll() { if (!animated) { float vert = Input.GetAxisRaw("Vertical"); switch (state) { case Menu_State.GameStart: if (Input.GetKey(KeyCode.Return) || ControllSetting.GetKey("Shot")) { PlaySE(select_SE); StartCoroutine(nameof(MoveGameScene)); } else { if (vert < 0.0f || vert > 0.0f) { if (vert < 0.0f) { PlaySE(cursor_SE); state = Menu_State.SettingMenu; StartCoroutine(nameof(CursorSlide), (int)state * -100.0f - 80.0f); } else if (vert > 0.0f) { PlaySE(cursor_SE); state = Menu_State.Credit; StartCoroutine(nameof(CursorSlide), (int)state * -100.0f - 80.0f); } } } break; case Menu_State.SettingMenu: if (Input.GetKey(KeyCode.Return) || ControllSetting.GetKey("Shot")) { PlaySE(select_SE); StartCoroutine(nameof(SlideKeyConfig), true); } else if (vert < 0.0f || vert > 0.0f) { if (vert < 0.0f) { PlaySE(cursor_SE); state = Menu_State.Credit; StartCoroutine(nameof(CursorSlide), (int)state * -100.0f - 80.0f); } else if (vert > 0.0f) { PlaySE(cursor_SE); state = Menu_State.GameStart; StartCoroutine(nameof(CursorSlide), (int)state * -100.0f - 80.0f); } } break; case Menu_State.Credit: if (Input.GetKey(KeyCode.Return) || ControllSetting.GetKey("Shot")) { PlaySE(select_SE); StartCoroutine(CreditView()); } else if (vert < 0.0f || vert > 0.0f) { if (vert < 0.0f) { PlaySE(cursor_SE); state = Menu_State.GameStart; StartCoroutine(nameof(CursorSlide), (int)state * -100.0f - 80.0f); } else if (vert > 0.0f) { PlaySE(cursor_SE); state = Menu_State.SettingMenu; StartCoroutine(nameof(CursorSlide), (int)state * -100.0f - 80.0f); } } break; } } }
// キーコンフィグ操作 private void ConfigMenuControll() { if (!animated) { float vert = Input.GetAxisRaw("Vertical"); if (Input.GetKey(KeyCode.Backspace) || ControllSetting.GetKey("Bomb")) { PlaySE(cancel_SE); StartCoroutine(nameof(SlideKeyConfig), false); } else { switch (state) { case Menu_State.ShotKey: if (Input.GetKey(KeyCode.Return) || ControllSetting.GetKey("Shot")) { PlaySE(select_SE); StartCoroutine(nameof(SetKeyConfig), "Shot"); } else { if (vert < 0.0f) { PlaySE(cursor_SE); state = Menu_State.BombKey; StartCoroutine(nameof(CursorSlide), ((int)state - 3) * -100.0f + 40.0f); } else if (vert > 0.0f) { PlaySE(cursor_SE); state = Menu_State.PoseKey; StartCoroutine(nameof(CursorSlide), ((int)state - 3) * -100.0f + 40.0f); } } break; case Menu_State.BombKey: if (Input.GetKey(KeyCode.Return) || ControllSetting.GetKey("Shot")) { PlaySE(select_SE); StartCoroutine(nameof(SetKeyConfig), "Bomb"); } else { if (vert < 0.0f) { PlaySE(cursor_SE); state = Menu_State.SlowKey; StartCoroutine(nameof(CursorSlide), ((int)state - 3) * -100.0f + 40.0f); } else if (vert > 0.0f) { PlaySE(cursor_SE); state = Menu_State.ShotKey; StartCoroutine(nameof(CursorSlide), ((int)state - 3) * -100.0f + 40.0f); } } break; case Menu_State.SlowKey: if (Input.GetKey(KeyCode.Return) || ControllSetting.GetKey("Shot")) { PlaySE(select_SE); StartCoroutine(nameof(SetKeyConfig), "Slow"); } else { if (vert < 0.0f) { PlaySE(cursor_SE); state = Menu_State.PoseKey; StartCoroutine(nameof(CursorSlide), ((int)state - 3) * -100.0f + 40.0f); } else if (vert > 0.0f) { PlaySE(cursor_SE); state = Menu_State.BombKey; StartCoroutine(nameof(CursorSlide), ((int)state - 3) * -100.0f + 40.0f); } } break; case Menu_State.PoseKey: if (Input.GetKey(KeyCode.Return) || ControllSetting.GetKey("Shot")) { PlaySE(select_SE); StartCoroutine(nameof(SetKeyConfig), "Pose"); } else { if (vert < 0.0f) { PlaySE(cursor_SE); state = Menu_State.ShotKey; StartCoroutine(nameof(CursorSlide), ((int)state - 3) * -100.0f + 40.0f); } else if (vert > 0.0f) { PlaySE(cursor_SE); state = Menu_State.SlowKey; StartCoroutine(nameof(CursorSlide), ((int)state - 3) * -100.0f + 40.0f); } } break; } } } }