void Update() { if (Input.GetKeyDown(KeyCode.Space)) { Attack(); } if (Input.GetKeyDown(KeyCode.C)) { Jump(); } if (GetComponent <SpriteRenderer>().isVisible) { player_show = true; } else { player_show = false; } combo_add1 = Skeleton_f.Get_Combo1(); combo_add2 = Skeleton_n.Get_Combo2(); combo_add3 = Skeleton_s.Get_Combo3(); combo_add4 = Skeleton_s_gold.Get_Combo4(); GameStart_f = script.GS_f; if (GameStart_f == true) { if (count > 0) { amountcount = UIobj.fillAmount; UItex.text = string.Format("" + count); super_shot_f = false; gauge_check = 0; if (roop) { //Reduce fill amount over 30 seconds UIobj.fillAmount -= 1.0f / countTime * Time.deltaTime; } else if (!roop) { UIobj.fillAmount += 1.0f / countTime * Time.deltaTime; } if (UIobj.fillAmount == 0 || UIobj.fillAmount == 1) { count = count - 1; UIobj.fillClockwise = !UIobj.fillClockwise; roop = !roop; } } if (count == 0) { UItex.text = string.Format("OK"); } } grounded = Physics2D.Linecast(transform.position, transform.position - transform.up * 100.0f, groundlayer); timer += Time.deltaTime; //ジャンプの処理 if (space_cnt >= 8 && tired_timer <= 2.0f) //2秒間にスペースキーを8回押されると、動けなくなる。 { space_not = true; tired_timer = tired_timer_num; space_cnt = 0; } if (tired_timer > 2.0f && space_not == false) { space_cnt = 0; tired_timer = 0; } if (space_not == true) { Debug.Log("動けない"); UI_obj.SetActive(true); space_check = false; MainSpriteRenderer.sprite = TiredbySprite; tired_timer -= Time.deltaTime; //gauge.GetComponent<Image>().fillAmount = tired_timer / tired_timer_num; float _currentTired = tired_timer / tired_timer_num; float currentTired_percent = _currentTired * 100; if (60.0f <= currentTired_percent) { TiredGauge3.SetActive(true); } if (60.0f > currentTired_percent) { TiredGauge3.SetActive(false); TiredGauge2.SetActive(true); } if (30.0f > currentTired_percent) { TiredGauge2.SetActive(false); TiredGauge1.SetActive(true); } if (currentTired_percent < 0) { UI_obj.SetActive(false); TiredGauge1.SetActive(false); space_not = false; space_cnt = 0; tired_timer = 0; MainSpriteRenderer.sprite = WaitbySprite; } } if (space_cnt >= 1 && space_not == false) { //攻撃処理 tired_timer += Time.deltaTime; } //コンボ文字の非表示処理 if (combo_f == true) { combo_timer += Time.deltaTime; if (combo_timer >= 1.0f) { comboActive.SetActive(false); comboLabelActive.SetActive(false); combo_f = false; combo_timer = 0; TextPlus.SetActive(false); ComboTextPlus.SetActive(false); } } //0.5秒間スペースキーを押さなかった場合 if (timer > 0.5f && space_not == false) { space_check = false; MainSpriteRenderer.sprite = WaitbySprite; } if (hit_check1 == true) {//敵に当たった時、点滅処理 if (Time.time > nextTime && time_cnt < 40 && time_f == true) { ren.enabled = !ren.enabled; nextTime += interval; time_cnt++; if (time_cnt == 40) { time_cnt = 0; time_f = false; hit_check1 = false; vibration_time = 0; } } } if (combo_add1 == true || combo_add2 == true || combo_add3 == true || combo_add4 == true) { //コンボ成立 comboActive.SetActive(true); comboLabelActive.SetActive(true); FindObjectOfType <Combo>().AddPoint(1); TextAnim_ComboLabel.GetComponent <TypefaceAnimator>().Play(); TextAnim_Combo.GetComponent <TypefaceAnimator>().Play(); } }
void Update() { _ComboAdd1 = Skeleton_f.Get_Combo1();//~~~~~コンボ処理のメソッドを書く _ComboAdd2 = Skeleton_n.Get_Combo2(); _ComboAdd3 = Skeleton_s.Get_Combo3(); _ComboAdd4 = Skeleton_s_gold.Get_Combo4(); _GameStartFlag = script.GS_f; _GroundedFlag = Physics2D.Linecast(transform.position, transform.position - transform.up * 100.0f, groundlayer); _timer += Time.deltaTime; _PlayerShowFlag = (GetComponent <SpriteRenderer>().isVisible) ? true : false; //ジャンプ処理 if (_PlayerShowFlag == true && _JumpFlag == false && _NotAttackFlag == false) { //攻撃回数をリセット _AttackCount = 0; rb2d.AddForce(Vector2.up * _flap); MainSpriteRenderer.sprite = Attack1bySprite; audioSources.PlayOneShot(sound01); } //攻撃処理 //動けないパターン //アタックボタンが _attackButtonPressTime 秒間に _MaxAttackCount 回押されたら、動けなくなる。 if (_AttackCount >= _MaxAttackCount && _tiredTimer <= _attackButtonPressTime) { _NotAttackFlag = true; _tiredTimer = _TiredTimerNum; _AttackCount = 0; UI_obj.SetActive(true); _AttackButtonFlag = false; MainSpriteRenderer.sprite = TiredbySprite; _tiredTimer -= Time.deltaTime; gauge.GetComponent <Image>().fillAmount = _tiredTimer / _TiredTimerNum; float _currentTiredPercent = (_tiredTimer / _TiredTimerNum) * 100; if (_currentTiredPercent >= 60.0f) { gauge.GetComponent <Image>().color = Color.red; } if (_currentTiredPercent < 60.0f) { gauge.GetComponent <Image>().color = Color.blue; } if (_currentTiredPercent < 30.0f) { gauge.GetComponent <Image>().color = Color.yellow; } if (_tiredTimer < 0) { UI_obj.SetActive(false); _NotAttackFlag = false; _AttackCount = 0; _tiredTimer = 0; MainSpriteRenderer.sprite = WaitbySprite; } } //動けるパターン if (_AttackCount >= 1 && _NotAttackFlag == false) { _tiredTimer += Time.deltaTime; if (_tiredTimer > _attackButtonPressTime) { _AttackCount = 0; _tiredTimer = 0.0f; } } //0.5秒間スペースキーを押さなかった場合 if (_timer > 0.5f && _NotAttackFlag == false) { _AttackButtonFlag = false; MainSpriteRenderer.sprite = WaitbySprite; } if (_HitCheckFlag == true && Time.time > _nextTime && _FlashCount < 40 && _TimeFlag == true) { ren.enabled = !ren.enabled; _nextTime += _flashInterval; _FlashCount++; if (_FlashCount == 40) { _FlashCount = 0; _TimeFlag = false; _HitCheckFlag = false; _vibrationTime = 0; } } if (_ComboAdd1 == true || _ComboAdd2 == true || _ComboAdd3 == true || _ComboAdd4 == true) { //コンボ成立 comboActive.SetActive(true); comboLabelActive.SetActive(true); FindObjectOfType <Combo>().AddPoint(1); TextAnim_ComboLabel.GetComponent <TypefaceAnimator>().Play(); TextAnim_Combo.GetComponent <TypefaceAnimator>().Play(); } //コンボ文字の非表示処理 if (_ComboFlag == true) { _comboTimer += Time.deltaTime; if (_comboTimer >= 1.0f) { comboActive.SetActive(false); comboLabelActive.SetActive(false); TextPlus.SetActive(false); ComboTextPlus.SetActive(false); _ComboFlag = false; _comboTimer = 0.0f; } } //波動拳処理 if (_Count == 0 && _PlayerShowFlag == true && _NotAttackFlag == false) //波動拳を発動する為のタイマーが0になり、かつ攻撃可能な状態であるなら { //プレファブから波動拳(shot)オブジェクトを作成し、それをshellに格納する。 shell = (GameObject)Instantiate(shot, transform.position, Quaternion.identity); //shellのRigidbodyを取得し、それをshellRigidbodyに格納する。 Rigidbody2D shellRigidbody = shell.GetComponent <Rigidbody2D>(); //shellRigidbodyにZ軸方向の力を加える。 shellRigidbody.AddForce(transform.right * _thrust); audioSources.PlayOneShot(sound03); _GaugeCheck = 1; _SuperShotFlag = true; //波動拳を発動する為のタイマーを初期値である「2」に戻す。 _Count = 2; } }