public void Win() { TotalScore += Score; AnalyticsGame.Won(TotalScore); // TODO : Adding condition Application.LoadLevel("Exit"); }
public void SetCurrentClub(ClubScript clubScript) { //Instantiate the new Club with the properties of the old one GameObject club = Club.InstantiateNewClub(clubScript.gameObject); Club = club.GetComponent <ClubScript>(); Player.SetCurrentClub(club); AnalyticsGame.ChangeClub(clubScript.GetName()); }
private void InitPlayer() { //Set the player on the first hole if (Global.LoadHoleNumber != -1) { Holes.SetHole(Global.LoadHoleNumber); } Ball.transform.position = Holes.CurrentHole.BeginPosition.transform.position; Player.transform.position = Ball.transform.position; Bag.MoveToTheBall(Ball.transform.position, Holes.CurrentHole.transform.position); var rigidBody = Ball.GetComponent <Rigidbody> (); rigidBody.velocity = new Vector3(0f, 0f, 0f); rigidBody.drag = 100f; rigidBody.angularDrag = 100f; GetCurrentHole().Enable(true); AnalyticsGame.ChangeClub(Club.GetName()); AnalyticsGame.BeginHole(GetCurrentHole().GetName()); }
/* * Events */ public void EnterHole() { currentAction = ActionState.Won; applause.Play(); var prevHole = GetPreviousHole(); var currHole = GetCurrentHole(); Global.SavedData.UnlockedLevel = currHole.HoleNumber; Grade grade = Global.SavedData.SetScore(prevHole.HoleNumber, prevHole.ParScore, Score); Global.SaveGame(); Debug.Log("Grade unlocked ! :" + grade); //TODO Show grade to player AnalyticsGame.EndHole(); AnalyticsGame.BeginHole(currHole.GetName()); TotalScore += Score; Score = 0; }
/* * Action */ void FixedUpdate() { switch (currentAction) { case ActionState.Idle: if (watchBallLock) { currentAction = ActionState.Locking; } break; case ActionState.Locking: if (!watchBallLock) { currentAction = ActionState.UnLocking; } else { if (Hud.Locking()) { Ball.WatchBall.SetActive(true); currentAction = ActionState.Loading; } } break; case ActionState.UnLocking: if (watchBallLock) { currentAction = ActionState.Locking; } if (Hud.UnLocking()) { currentAction = ActionState.Idle; } break; case ActionState.Loading: if (!watchBall && !watchBallLock) { currentAction = ActionState.Firing; firingOrientation = Player.transform.eulerAngles.y; Ball.WatchBall.SetActive(false); } Club.Load(); Hud.SetPowerBarAmount(Club.LoadingAmount()); break; case ActionState.Firing: Hud.SetPowerBarAmount(0); Club.Fire(); if (!Ball.IsShooted() && Club.HasShooted()) //Shoot now { Ball.Shoot(Club.LoadingTime * Club.clubForceCoef, Club.clubAngle, firingOrientation); Hud.UpdateScore(Score++); } else if (Club.IsFired()) { currentAction = ActionState.Fired; AnalyticsGame.Shoot(); } break; case ActionState.Fired: if (Ball.IsOutOfBound()) { currentAction = ActionState.OutOfBound; break; } if (Ball.IsStopped()) { Hud.FadeOut(); currentAction = ActionState.MoveToTheBall; } break; case ActionState.Won: Ball.StopAndMove(Holes.CurrentHole.BeginPosition.transform.position); //Go to next hole //BallInfo.ShowInformation(Ball.transform.position, Localization.Hole); Hud.FadeOut(); currentAction = ActionState.MoveToTheBall; break; case ActionState.OutOfBound: BallInfo.ShowInformation(Ball.transform.position, Localization.OutOfZone); Ball.StopAndGetBackToOldPos(); Hud.UpdateScore(Score++); Hud.FadeOut(); currentAction = ActionState.MoveToTheBall; AnalyticsGame.OutOfBound(); break; case ActionState.MoveToTheBall: if (Hud.IsFadingIn()) { Bag.MoveToTheBall(Ball.transform.position, Holes.CurrentHole.transform.position); Player.transform.position = Ball.transform.position; Club.Reset(); SetWind(); Hud.EnableReticle(true); currentAction = ActionState.Idle; locked = false; } break; } }