Beispiel #1
0
    //----------------------------------------------------------------------
    // ゴールのメッシュに当たったらその時点でゴール
    //----------------------------------------------------------------------
    // @Param	collider    当たったオブジェクトの当たり判定
    // @Return	none
    // @Date	2014/12/9  @Update 2014/12/9  @Author T.Kawashita
    //----------------------------------------------------------------------
    void OnTriggerEnter(Collider collider)
    {
        if (collider.transform.tag == "SoccerBall")
        {
            // グローバルのゴールのデータに追加
            TeamData.AddLog(CGameManager.m_nowTime, CSoccerBallManager.m_shootPlayerNo, CSoccerBallManager.m_shootTeamNo, 0, true);
            CGameManager.m_bluePoint++;

            CGameManager.m_nowStatus = CGameManager.eSTATUS.eGOAL;

            // サポーター追加
            int redSupporter  = 0;
            int blueSupporter = 0;

            // オウンゴールではない場合
            if (CSoccerBallManager.m_shootTeamNo != 1)
            {
                // 同点に追いつくシュート
                if (TeamData.GetTeamScore(0) == TeamData.GetTeamScore(1))
                {
                    blueSupporter += CSupporterData.m_getDrawPointSupporter;
                }

                // 同点から逆転するシュート
                else if (TeamData.GetTeamScore(1) - 1 == TeamData.GetTeamScore(0))
                {
                    blueSupporter += CSupporterData.m_getDrawReversPointSupporter;
                }

                blueSupporter += CSupporterData.m_getPointSupporter;
            }

            // オウンゴールの場合は点数は入る
            else if (CSoccerBallManager.m_shootTeamNo == 2)
            {
                redSupporter += CSupporterData.m_getPointSupporter;
            }

            // 最後にサポーター追加
            CSupporterManager.AddSupporter(redSupporter, blueSupporter, true);

            collider.gameObject.GetComponent <CSoccerBall>().StopTrail();
        }
    }
    //----------------------------------------------------------------------
    // ゲーム終了待機状態
    //----------------------------------------------------------------------
    // @Param	none
    // @Return	none
    // @Date	2014/10/28  @Update 2014/10/28  @Author T.Kawashita
    // @Update  2014/11/18  ゲーム終了待機状態に変更
    //----------------------------------------------------------------------
    private void GameEndWait()
    {
        // 60Fたったかどうか計算
        m_frame += Time.deltaTime;
        if (m_frame >= 1.0f)
        {
            m_frame = 0;
            CGameData.m_gameEndTime--;

            // ここで何か終わりの表示
            if (CGameData.m_gameEndTime <= 0)
            {
                // ゲーム終了待機が終わったらフェードアウトさせる
                m_nowStatus = eSTATUS.eFADEOUT;
                m_soundPlayer.PlayBGMFadeOut(0.02f);

                int teamPoint     = 0;
                int redSupporter  = 0;
                int blueSupporter = 0;
                if (TeamData.GetWinTeamNo() == 0)
                {
                    redSupporter += CSupporterData.m_winSupporter;

                    // 得点差を求める
                    teamPoint = TeamData.GetTeamScore(0) - TeamData.GetTeamScore(1);
                    if (teamPoint >= 2)
                    {
                        redSupporter += CSupporterData.m_point2WinSupporter;
                    }

                    blueSupporter += CSupporterData.m_loseSupporter;
                }
                else if (TeamData.GetWinTeamNo() == 1)
                {
                    blueSupporter += CSupporterData.m_winSupporter;
                    // 得点差を求める
                    teamPoint = TeamData.GetTeamScore(1) - TeamData.GetTeamScore(0);
                    if (teamPoint >= 2)
                    {
                        blueSupporter += CSupporterData.m_point2WinSupporter;
                    }

                    redSupporter += CSupporterData.m_loseSupporter;
                }
                else if (TeamData.GetWinTeamNo() == 2)
                {
                    redSupporter  += CSupporterData.m_drowSupporter;
                    blueSupporter += CSupporterData.m_drowSupporter;

                    teamPoint = TeamData.GetTeamScore(0);
                    if (teamPoint >= 2)
                    {
                        redSupporter  += CSupporterData.m_point2Drow;
                        blueSupporter += CSupporterData.m_point2Drow;
                    }
                }

                // 最後にサポーター追加
                CSupporterManager.AddSupporter(redSupporter, blueSupporter, true);
            }
        }
    }
    //----------------------------------------------------------------------
    // ボールの当たり判定
    //----------------------------------------------------------------------
    // @Param	none
    // @Return	none
    // @Date	2014/12/7  @Update 2014/12/7  @Author T.Kawashita
    // @Update  2014/12/29 ボールを取った瞬間にあがるスピードの準備
    //----------------------------------------------------------------------
    void OnTriggerEnter(Collider obj)
    {
        GameObject      player          = obj.gameObject;
        CPlayer         playerScript    = obj.GetComponent <CPlayer> ();
        CapsuleCollider capsuleCollider = obj as CapsuleCollider;

        // プレイヤーとの当たり判定
        // 同じチームの場合は取れない
        if (capsuleCollider != null && playerScript.m_isBall == false && m_isPlayer == true &&
            playerScript.m_status != CPlayerManager.ePLAYER_STATUS.eTACKLEDAMAGE &&
            playerScript.m_status != CPlayerManager.ePLAYER_STATUS.eDASHCHARGE &&
            playerScript.m_status != CPlayerManager.ePLAYER_STATUS.eSHOOTCHARGE &&
            playerScript.m_playerData.m_teamNo != this.transform.parent.GetComponent <CPlayer>().m_playerData.m_teamNo)
        {
            // 現在持っているプレイヤーのステータス変更
            CPlayer ballPlayer = this.transform.parent.GetComponent <CPlayer> ();
            this.transform.parent.transform.parent.GetComponent <CPlayerAnimator> ().TackleDamage();
            ballPlayer.m_isBall = false;
            if (ballPlayer.m_status == CPlayerManager.ePLAYER_STATUS.eOVERRIMIT)
            {
                ballPlayer.m_oldStatus = CPlayerManager.ePLAYER_STATUS.eOVERRIMIT;
            }
            else
            {
                ballPlayer.m_oldStatus = CPlayerManager.ePLAYER_STATUS.eNONE;
            }

            ballPlayer.m_status = CPlayerManager.ePLAYER_STATUS.eTACKLEDAMAGE;
            ballPlayer.m_action.InitTackleDamage(ballPlayer.m_human.m_stealDamageLength, 0.0f, ballPlayer.m_human.m_stealDamageLength);

            // 当たった方のプレイヤーに持ち主を変更
            // プレイヤーのボールに設定
            Vector3 pos = new Vector3(0.0f, -0.13f, 0.14f);
            if (obj.gameObject.tag == "RedTeam")
            {
                this.SetTrailRed();
            }
            if (obj.gameObject.tag == "BlueTeam")
            {
                this.SetTrailBlue();
            }

            CPlayerManager.m_soccerBallManager.ChangeOwner(player.transform, pos);
            CSoccerBallManager.m_shootPlayerNo = playerScript.m_playerData.m_playerNo;
            CSoccerBallManager.m_shootTeamNo   = playerScript.m_playerData.m_teamNo;
            playerScript.m_isBall = true;

            // ボールを取った後スピードを速くする準備
            playerScript.m_action.InitGetBall(playerScript.m_human.m_getBallAccSpeedDupRate,
                                              playerScript.m_human.m_getBallAccDurationFrame,
                                              playerScript.m_human.m_getBallAccDecFrame);
            playerScript.m_isGetBall = true;

            // 相手のボールの場合サポーター追加
            int supporter = 0;
            supporter += CSupporterData.m_getBallSupporter;

            if (playerScript.m_playerData.m_teamNo != ballPlayer.m_playerData.m_teamNo)
            {
                supporter += CSupporterData.m_takeBallSupporter;
            }

            if (playerScript.m_status == CPlayerManager.ePLAYER_STATUS.eDASH)
            {
                if (playerScript.m_playerData.m_teamNo != ballPlayer.m_playerData.m_teamNo)
                {
                    supporter += CSupporterData.m_takeBallDashSupporter;
                }

                supporter += CSupporterData.m_getBallDashSupporter;
            }
            CSupporterManager.AddSupporter(playerScript.m_playerData.m_teamNo, supporter);
            playerScript.m_playerSE.PlaySE("game/supoter_up");
        }
    }
    //----------------------------------------------------------------------
    // 当たり判定
    //----------------------------------------------------------------------
    // @Param   Collider    ぶつかったもののGameObject
    // @Return	none
    // @Other   CallBack
    // @Date	2014/11/28  @Update 2014/11/28  @Author T.Kawashita
    // @Update  2014/12/29  ボールを取った瞬間の時の処理追加
    //----------------------------------------------------------------------
    void OnTriggerEnter(Collider obj)
    {
        // ボールとぶつかった時の判定
        if (obj.gameObject.tag == "SoccerBall" && this.GetComponent <CPlayer>().m_isBall == false &&
            this.GetComponent <CPlayer>().m_status != CPlayerManager.ePLAYER_STATUS.eTACKLEDAMAGE &&
            this.GetComponent <CPlayer>().m_status != CPlayerManager.ePLAYER_STATUS.eSHOOT &&
            this.GetComponent <CPlayer>().m_status != CPlayerManager.ePLAYER_STATUS.eSMASHSHOOT)
        {
            // オーバーリミット状態のシュートならそれに応じて変更
            if (obj.transform.parent == GameObject.Find("BallGameObject").transform&&
                CSoccerBallManager.m_isOverRimitShoot == true)
            {
                switch (CSoccerBallManager.m_team)
                {
                // イングランドの場合は加速を止める
                case TeamData.TEAM_NATIONALITY.ENGLAND:
                    CSoccerBallManager.m_isOverRimitShoot = false;
                    CSoccerBallManager.m_team             = TeamData.TEAM_NATIONALITY.NONE;
                    break;

                // スペインはあたったらプレイヤーが吹っ飛ぶ
                case TeamData.TEAM_NATIONALITY.ESPANA:
                    // 相手を吹っ飛ばされモーションに変更
                    CPlayer colPlayerScript = this.GetComponent <CPlayer>();
                    if (colPlayerScript.m_playerData.m_teamNo != CSoccerBallManager.m_shootTeamNo)
                    {
                        this.transform.LookAt(obj.transform);
                        this.transform.parent.GetComponent <CPlayerAnimator>().TackleDamage();
                        colPlayerScript.m_status = CPlayerManager.ePLAYER_STATUS.eTACKLEDAMAGE;

                        colPlayerScript.m_action.InitTackleDamage(colPlayerScript.m_human.m_tackleDamageMotionLength,
                                                                  colPlayerScript.m_human.m_tackleDamageInitSpeed,
                                                                  colPlayerScript.m_human.m_tackleDamageDecFrame);

                        CSoccerBallManager.m_isOverRimitShoot = false;
                        CSoccerBallManager.m_team             = TeamData.TEAM_NATIONALITY.NONE;
                        return;
                    }
                    break;
                }
            }


            // 浮いているボールの場合は自分のボールになる
            if (obj.transform.parent == GameObject.Find("BallGameObject").transform&&
                (CSoccerBallManager.m_isOverRimitShoot == false ||
                 (CSoccerBallManager.m_isOverRimitShoot == true &&
                  this.GetComponent <CPlayer>().m_playerData.m_teamNo == CSoccerBallManager.m_shootTeamNo)))
            {
                CPlayer playerScript = this.GetComponent <CPlayer>();

                // ダッシュチャージ中にボールを取ったらウェイトアニメーションに変更
                if (playerScript.m_status == CPlayerManager.ePLAYER_STATUS.eDASHCHARGE)
                {
                    playerScript.m_animator.Wait();
                    playerScript.m_status = CPlayerManager.ePLAYER_STATUS.eNONE;
                }

                // ボールの位置をセット
                Vector3 pos = new Vector3(0.0f, -0.13f, 0.14f);
                if (this.gameObject.tag == "RedTeam")
                {
                    obj.GetComponent <CSoccerBall>().SetTrailRed();
                }
                if (this.gameObject.tag == "BlueTeam")
                {
                    obj.GetComponent <CSoccerBall>().SetTrailBlue();
                }
                CGameManager.m_soundPlayer.ChangeSEVolume(1.0f);
                CGameManager.m_soundPlayer.PlaySE("game/boll_totta");

                // プレイヤーのボールに設定
                CPlayerManager.m_soccerBallManager.ChangeOwner(this.transform, pos);
                CSoccerBallManager.m_shootPlayerNo = this.GetComponent <CPlayer>().m_playerData.m_playerNo;
                CSoccerBallManager.m_shootTeamNo   = this.GetComponent <CPlayer>().m_playerData.m_teamNo;
                this.gameObject.GetComponent <CPlayer>().m_isBall = true;

                // ボールの判定をトリガーにする
                obj.GetComponent <SphereCollider>().isTrigger = true;

                // ボールを取った後スピードを速くする準備
                playerScript.m_action.InitGetBall(playerScript.m_human.m_getBallAccSpeedDupRate,
                                                  playerScript.m_human.m_getBallAccDurationFrame,
                                                  playerScript.m_human.m_getBallAccDecFrame);
                playerScript.m_isGetBall = true;

                // サポーター追加
                int supporter = 0;
                // プレイヤーのステータスがダッシュだったらサポーター増加
                if (playerScript.m_status == CPlayerManager.ePLAYER_STATUS.eDASH)
                {
                    supporter += CSupporterData.m_getBallDashSupporter;
                }

                // 味方が蹴ったボール
                if (CSoccerBallManager.m_shootTeamNo == playerScript.m_playerData.m_teamNo)
                {
                    supporter += CSupporterData.m_getBallPassSupporter;
                }

                supporter += CSupporterData.m_getBallSupporter;
                CSupporterManager.AddSupporter(playerScript.m_playerData.m_teamNo, supporter);
//				playerScript.m_playerSE.PlaySE("game/supoter_up");
            }
        }

        // タックルの当たり判定
        if (this.GetComponent <CPlayer>().m_status == CPlayerManager.ePLAYER_STATUS.eTACKLE &&
            ((obj.gameObject.tag == "RedTeam") || (obj.gameObject.tag == "BlueTeam")))
        {
            CPlayer playerScript = this.GetComponent <CPlayer>();

            // アニメーション変更
            // 相手がタックル中だったらくらいモーションに変更
            if (obj.GetComponent <CPlayer>().m_status == CPlayerManager.ePLAYER_STATUS.eTACKLE)
            {
                this.transform.parent.GetComponent <CPlayerAnimator>().TackleDamage();
                playerScript.m_status = CPlayerManager.ePLAYER_STATUS.eTACKLEDAMAGE;
                playerScript.m_action.InitTackleDamage(playerScript.m_human.m_tackleDamageMotionLength,
                                                       playerScript.m_human.m_tackleDamageInitSpeed,
                                                       playerScript.m_human.m_tackleDamageDecFrame);
            }

            // それ以外の場合は成功モーションに変更
            else
            {
                this.transform.parent.GetComponent <CPlayerAnimator>().TackleSuccess();
                playerScript.m_playerSE.StopSE();
                playerScript.m_playerSE.PlaySE("game/tackle_success");
                playerScript.m_status = CPlayerManager.ePLAYER_STATUS.eTACKLESUCCESS;
                playerScript.m_action.InitTackleSuccess(playerScript.m_human.m_tackleHitMotionLength);
            }

            // 相手をやられモーションに変更
            CPlayer colPlayerScript = obj.GetComponent <CPlayer>();
            obj.transform.LookAt(this.transform);
            obj.transform.parent.GetComponent <CPlayerAnimator>().TackleDamage();

            if (colPlayerScript.m_status == CPlayerManager.ePLAYER_STATUS.eOVERRIMIT)
            {
                colPlayerScript.m_oldStatus = CPlayerManager.ePLAYER_STATUS.eOVERRIMIT;
            }
            else
            {
                colPlayerScript.m_oldStatus = CPlayerManager.ePLAYER_STATUS.eNONE;
            }
            colPlayerScript.m_status = CPlayerManager.ePLAYER_STATUS.eTACKLEDAMAGE;
            colPlayerScript.m_playerSE.StopSE();

            colPlayerScript.m_action.InitTackleDamage(colPlayerScript.m_human.m_tackleDamageMotionLength,
                                                      colPlayerScript.m_human.m_tackleDamageInitSpeed,
                                                      colPlayerScript.m_human.m_tackleDamageDecFrame);

            int supporter = 0;
            // ボールを持っている場合は飛ばす
            if (colPlayerScript.m_isBall == true)
            {
                GameObject soccerBall = obj.transform.FindChild("SoccerBall").gameObject;
                soccerBall.GetComponent <CSoccerBall>().BlownOff(this.transform);
                colPlayerScript.m_isBall = false;
                obj.transform.FindChild("SoccerBall").GetComponent <CSoccerBall>().SetTrailYellow();
                obj.transform.FindChild("SoccerBall").parent = GameObject.Find("BallGameObject").transform;
                supporter += CSupporterData.m_damageTackleOnBallSupporter;
            }

            if (playerScript.m_playerData.m_teamNo != colPlayerScript.m_playerData.m_teamNo)
            {
                // サポーター追加
                supporter += CSupporterData.m_damageTackleSupporter;
                CSupporterManager.AddSupporter(playerScript.m_playerData.m_teamNo, supporter);
                playerScript.m_playerSE.PlaySE("game/supoter_up");
            }
        }
    }