//---------------------------------------------------------------------- // AI:シュートされてたと判断したときの判断 //---------------------------------------------------------------------- // @Param none // @Return none // @Date 2014/12/7 @Update 2014/12/7 @Author T.Takeuchi // @Update 2014/12/11 パスアニメーションのためのステータス変更 @Author T.Kawashita //---------------------------------------------------------------------- void Cach() { Vector3 targetPosition = new Vector3(); // ボールを見る targetPosition = GetFuterBallPosition(); this.transform.LookAt(targetPosition); // 移動 Move(new Vector3(0.0f, 0.0f, 1.0f)); // 視点を元に戻す this.transform.LookAt(new Vector3(0.0f, 0.0f, 0.0f)); // ボールをキャッチ(→パス) if (this.m_isBall) { this.gkState = GK_State.PASS; this.m_status = CPlayerManager.ePLAYER_STATUS.ePASS; this.transform.LookAt(this.frendryData[0].transform.position); this.m_action.InitPass(this.m_human.m_passInitSpeed, this.m_human.m_passMotionLength, this.m_human.m_passTakeOfFrame); } // ボールが範囲外に出たら待機へ戻る if (Vector3.Distance(this.HOME_POSITION, this.soccerBallObject.transform.position) >= ARAT_SPACE) { this.gkState = GK_State.STAY; } }
//---------------------------------------------------------------------- // 更新 //---------------------------------------------------------------------- // @Param none // @Return none // @Date 2014/12/7 @Update 2014/12/7 @Author T.Takeuchi // @Update 2014/12/11 アニメーションのための追加 @Author T.Kawashita //---------------------------------------------------------------------- protected void CGoalKeeperUpdate() { if (m_isBall == true) { this.transform.FindChild("SoccerBall").GetComponent <CSoccerBall>().SetPosition(new Vector3(0.0f, 0.05f, 0.1f)); } m_pos = this.transform.localPosition; this.CheckGamePlay(); if (CGameManager.m_nowStatus == CGameManager.eSTATUS.eGAME) { switch (m_status) { case CPlayerManager.ePLAYER_STATUS.eNONE: break; case CPlayerManager.ePLAYER_STATUS.eWAIT: break; case CPlayerManager.ePLAYER_STATUS.ePASS: break; // タックルのやられモーション中 case CPlayerManager.ePLAYER_STATUS.eTACKLEDAMAGE: this.gkState = GK_State.TACKLE_DAMAGE; if (m_action.TackleDamage(ref m_pos, -this.transform.forward) == true) { // やられモーション終了 m_animator.Wait(); m_status = CPlayerManager.ePLAYER_STATUS.eNONE; this.gkState = GK_State.STAY; } break; } switch (this.gkState) { case GK_State.WAIT: Wait(); break; case GK_State.STAY: Stay(); break; case GK_State.ON_ALERT: OnAlert(); break; case GK_State.TAKE_BALL: TakeBall(); break; case GK_State.CAT: Cach(); break; case GK_State.PASS: Pass(); break; case GK_State.TACKLE_DAMAGE: break; case GK_State.BACK_HOME: BackHome(); break; } } else { KeeperRestart(); } }
//---------------------------------------------------------------------- // 初期位置へ戻る //---------------------------------------------------------------------- // @Param none // @Return none // @Date 2014/12/7 @Update 2014/12/7 @Author T.Takeuchi //---------------------------------------------------------------------- void KeeperRestart() { this.Restart(); this.gkState = GK_State.STAY; //this.transform.position = HOME_POSITION; this.transform.LookAt(new Vector3(0.0f, 0.0f, 0.0f)); }
//---------------------------------------------------------------------- // AI:パス中の判断 //---------------------------------------------------------------------- // @Param none // @Return none // @Date 2014/12/7 @Update 2014/12/7 @Author T.Takeuchi // @Update 2014/12/11 パスアニメーションのためのステータス変更 @Author T.Kawashita //---------------------------------------------------------------------- void Pass() { if (this.m_action.Pass(this.gameObject, this.transform.forward, ref this.m_isBall)) { this.gkState = GK_State.WAIT; this.m_status = CPlayerManager.ePLAYER_STATUS.eNONE; } }
//---------------------------------------------------------------------- // AI:AIの停止(ボールが一定数はなれるまで) //---------------------------------------------------------------------- // @Param none // @Return none // @Date 2014/12/7 @Update 2014/12/7 @Author T.Takeuchi //---------------------------------------------------------------------- void Wait() { BackHome(); if (this.soccerBallObject.GetComponent <CSoccerBall>().m_isPlayer == true) { this.gkState = GK_State.STAY; } }
//---------------------------------------------------------------------- // AI:待機中の判断 //---------------------------------------------------------------------- // @Param none // @Return none // @Date 2014/12/7 @Update 2014/12/7 @Author T.Takeuchi //---------------------------------------------------------------------- void Stay() { BackHome(); // ボールの監視 if (Vector3.Distance(this.HOME_POSITION, this.soccerBallObject.transform.position) <= ARAT_SPACE) { this.gkState = GK_State.ON_ALERT; } }
//---------------------------------------------------------------------- // フレーム最後の更新 //---------------------------------------------------------------------- // @Param none // @Return none // @Date 2014/12/7 @Update 2014/12/7 @Author T.Takeuchi // @Update 2014/12/11 アニメーションの関数呼び出し @Author T.Kawashita //---------------------------------------------------------------------- protected void CGoalKeeperLateUpdate() { // アニメーション this.Animation(); m_speed = new Vector3(0.0f, 0.0f, 0.0f); // 最後にスピードを初期化 this.rigidbody.MovePosition(m_pos); switch (this.gkState) { case GK_State.CAT: case GK_State.TAKE_BALL: if (this.soccerBallObject.GetComponent <CSoccerBall>().m_isPlayer) { this.gkState = GK_State.ON_ALERT; } break; } }
//---------------------------------------------------------------------- // AI:警戒態勢中の判断 //---------------------------------------------------------------------- // @Param none // @Return none // @Date 2014/12/7 @Update 2014/12/7 @Author T.Takeuchi //---------------------------------------------------------------------- void OnAlert() { // ボールが範囲外に出たら待機へ戻る if (Vector3.Distance(this.HOME_POSITION, this.soccerBallObject.transform.position) >= ARAT_SPACE) { this.gkState = GK_State.STAY; } // フリーボールが範囲内+敵が近くにいる if ((Vector3.Distance(this.HOME_POSITION, this.enemyData[0].transform.position) <= ARAT_SPACE || Vector3.Distance(this.HOME_POSITION, this.enemyData[1].transform.position) <= ARAT_SPACE || Vector3.Distance(this.HOME_POSITION, this.enemyData[2].transform.position) <= ARAT_SPACE || Vector3.Distance(this.HOME_POSITION, this.enemyData[3].transform.position) <= ARAT_SPACE) && this.soccerBallObject.GetComponent <CSoccerBall>().m_isPlayer == false) { this.gkState = GK_State.CAT; } // フリーボールが範囲内+敵が近くにいない if (Vector3.Distance(this.HOME_POSITION, this.enemyData[0].transform.position) >= ARAT_SPACE && Vector3.Distance(this.HOME_POSITION, this.enemyData[1].transform.position) >= ARAT_SPACE && Vector3.Distance(this.HOME_POSITION, this.enemyData[2].transform.position) >= ARAT_SPACE && Vector3.Distance(this.HOME_POSITION, this.enemyData[3].transform.position) >= ARAT_SPACE && Vector3.Distance(this.HOME_POSITION, this.soccerBallObject.transform.position) <= ARAT_SPACE && this.soccerBallObject.GetComponent <CSoccerBall>().m_isPlayer == false) { if (Vector3.Distance(this.HOME_POSITION, this.soccerBallObject.transform.position) <= TAKE_BALL_SPACE) { // かなりの近距離の場合(普通のカットと同じ動作) this.gkState = GK_State.CAT; } else { // そこそこの距離の場合(普通にとりにいく) this.gkState = GK_State.TAKE_BALL; } } }