Exemplo n.º 1
0
    private void GameBallOutofRange(BombBall ball)
    {
        m_start = false;
        Vector3 position = m_bombBall.GetPosition();

        if (position.y > 0)
        {
            //m_contestData.AddHeart();
            m_aiIndex     = 0;
            m_aiBombTime += 2f;
        }
        else
        {
            //m_contestData.ReduceHeart();
            m_playerIndex     = 0;
            m_playerBombTime += 2f;
        }

        if (m_contestData != null && !m_contestData.m_changeAudio && m_change)
        {
            GameAudioModuel audioModuel = GameStart.GetInstance().AudioModuel;
            audioModuel.StopAudio();
        }

        m_bombBall.ResetVelocity();
        m_bombBall.SetPosition(m_ground.GroundData.GetFireBallPoint(ESide.Player));
        m_aiController.SwitchState(EAIControlState.BackToBornPoint);
//        if (m_contestData.m_heart < 0)
//        {
//            m_player.SetIdle();
//            m_aiController.gameObject.SetActive(false);
//        }
    }
Exemplo n.º 2
0
    public override void EnterState()
    {
        GameEventModuel eventModuel = GameStart.GetInstance().EventModuel;

        eventModuel.RegisterEventListener(GameEventID.TRIGGER_GAME_EVENT, OnTriggerEffectStart);
        eventModuel.RegisterEventListener(GameEventID.END_GAME_EVENT, OnTriggerEffectEnd);

        m_contestData = new GameContestData();

        GameObject ground = GameStart.GetInstance().ResModuel.LoadResources <GameObject>(EResourceType.Ground, "Ground");

        ground   = CommonFunc.Instantiate(ground);
        m_ground = CommonFunc.AddSingleComponent <Ground>(ground);
        GroundData groundData = new GroundData();

        m_ground.InitGround(groundData);

        PlayerData playerData = new PlayerData();

        m_player = new Player(1, playerData);
        m_player.InitPlayerAction(HitBallDelegate);

        GameObject go = new GameObject("Controller");

        m_playerController = go.AddComponent <PlayerController>();
        m_playerController.InitController(m_player);

        BallData ballData = new BallData();

        m_bombBall = new BombBall(ballData, m_ground.BounceLine);
        m_bombBall.SetOutofRangeAction(GameBallOutofRange);
        m_bombBall.SetPosition(groundData.GetFireBallPoint(ESide.Player));

        AIPlayerData aiData = new AIPlayerData();

        m_ai = new Player(2, aiData);
        m_ai.Transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, 180f));
        m_ai.InitPlayerAction(HitBallDelegate);

        m_aiController = go.AddComponent <AIController>();
        m_aiController.SetBomBall(m_bombBall);
        m_aiController.InitController(m_ai);

        m_effect = new GameEffect();

        m_bombUI = GameStart.GetInstance().UIModuel.LoadResUI <GameBombUI>("BombUI");

        GameAudioModuel audioModuel = GameStart.GetInstance().AudioModuel;
        List <string>   list        = new List <string>
        {
            "BGM_tense",
            "lerp",
        };

        audioModuel.PreLoadAudio(list);
        audioModuel.StopAudio();

        m_player.Target = m_bombBall.GetBallInstance().transform;
        m_ai.Target     = m_bombBall.GetBallInstance().transform;

        m_playerBombTime      = 0f;
        m_aiBombTime          = 0f;
        m_playerTotalBombTime = 20f;
        m_aiTotalBombTime     = 20f;
        m_start  = false;
        m_end    = false;
        m_change = false;
    }