コード例 #1
0
ファイル: GameManager.cs プロジェクト: linck5/barrels_game
    public void HandleBarrelHit(GameObject barrelObjHit)
    {
        HandleBarrelBeat(barrelObjHit);

        float rotationDuration = DifficultyManager.MoveDurationBasedOnDifficulty();

        Barrel barrelObjHitBarrelScript = barrelObjHit.gameObject.GetComponent <Barrel>();

        barrelObjHitBarrelScript.HoldPlayer();

        int potentialNextBarrelIndex = barrels.IndexOf(barrelHolingPlayer) + 1;

        nextBarrel = potentialNextBarrelIndex < barrels.Count ? barrels[potentialNextBarrelIndex] : null;

        if (barrelsToJump > 0)
        {
            barrelObjHitBarrelScript.AutoFire(0.5f);
            barrelsToJump--;
        }
        else
        {
            MoveBehaviour barrelObjHitMoveBehaviour = barrelObjHit.gameObject.GetComponent <MoveBehaviour>();
            barrelObjHitMoveBehaviour.Activate(); //barrel will only move after the move duration, witch is the rotation duration
            barrelObjHitMoveBehaviour.RotateToInitialAngle(rotationDuration);
        }



        if (nextBarrel)
        {
            FocusCameraOnBarrel(nextBarrel);
        }

        HandleBarrelsJumped();
    }