private IEnumerator LevelStartCountdown() { EndLevel(); PlayerSpawner.UnlockSpawner(); OpponentSpawner.UnlockSpawner(); UIManagerService.GetInstance().ShowTilesContainer(); SplashLabel.color = new Color(1f, 1f, 1f); TimerLabel.gameObject.SetActive(true); SplashLabel.gameObject.SetActive(true); SplashLabel.text = "Level Starting In...\n3"; yield return(new WaitForSeconds(1)); SplashLabel.text = "Level Starting In...\n2"; yield return(new WaitForSeconds(1)); SplashLabel.text = "Level Starting In...\n1"; yield return(new WaitForSeconds(1)); SplashLabel.text = "GO!"; TileManagerService.GetInstance().InitTiles(); TileManagerService.GetInstance().IsLocked = false; GroundClaimsService.GetInstance().TrackClaims = true; OpponentScriptedSpawner.StartSpawning(); StartCoroutine(UpdateTimer()); yield return(new WaitForSeconds(1)); SplashLabel.text = ""; }
private IEnumerator SpawnLoop() { float relativeScore = 1f; relativeScore = GroundClaimsService.GetInstance().GetRightTeamCoverageScore() / 100; yield return(new WaitForSeconds(0.3f + ((15f * relativeScore) * 3f))); Spawner.SpawnSoldier(); Spawner.SpawnArcher(); Spawner.SpawnWizard(); SpawnRoutine = StartCoroutine(SpawnLoop()); }
public virtual void Update() { if (IsMidJump && IsDecending()) { IsMidJump = false; } if (RayCasts.IsGroundTileBelowBy(transform, GroundCheckDistance) && !IsMidJump) { if (JumpDirection.x >= 0) { GroundClaimsService.GetInstance().LeftTeamClaimUpdate(transform.localPosition.x); } else { GroundClaimsService.GetInstance().RightTeamClaimUpdate(transform.localPosition.x); } if (AllowMovement) { Jump(); } } //put the breaks on if moving too fast if (Mathf.Abs(Body.velocity.x) > JumpForce.x) { if (JumpDirection.normalized.x > 0) { if (Body.velocity.x > 0) { //slow down Body.AddForce(-JumpDirection.normalized * JumpForce.x); } else { //speed up Body.AddForce(JumpDirection.normalized * JumpForce.x); } } else { if (Body.velocity.x < 0) { //slow down Body.AddForce(-JumpDirection.normalized * JumpForce.x); } else { //speed up Body.AddForce(JumpDirection.normalized * JumpForce.x); } } } }
public void LoadLevel(string SpawnerName) { LoadedChallenge = SpawnerName; Destroy(OpponentScriptedSpawner); Destroy(PlayerScriptedSpawner); CurrentLevelTimeRemaining = LevelTimeRemaining; CurrentPlayerMana = 0f; Type spawner = Type.GetType(SpawnerName); OpponentScriptedSpawner = (ScriptedSpawner)OpponentSpawner.gameObject.AddComponent(spawner); OpponentScriptedSpawner.SetSpawner(OpponentSpawner); GroundClaimsService.GetInstance().ResetCoverage(); StartCoroutine(LevelStartCountdown()); }
private bool IsLevelOver() { float ltcs = GroundClaimsService.GetInstance().GetLeftTeamCoverageScore(); float rtcs = GroundClaimsService.GetInstance().GetRightTeamCoverageScore(); if (ltcs >= 100 || rtcs >= 100) { return(true); } if (CurrentLevelTimeRemaining == 0) { return(true); } return(false); }
private IEnumerator UpdateTimer() { string timerMins = Mathf.Floor(CurrentLevelTimeRemaining / 60).ToString("00"); string timerSeconds = (CurrentLevelTimeRemaining % 60).ToString("00"); TimerLabel.text = timerMins + ":" + timerSeconds; if (IsLevelOver()) { OpponentScriptedSpawner.StopSpawning(); Team Winner = GetWinningTeam(); switch (Winner) { case Team.Left: SplashLabel.color = new Color(0, 0, 1f); SplashLabel.text = "You Win!"; CompletedChallenges.Add(LoadedChallenge); UIManagerService.GetInstance().MarkLevelAsComplete(LoadedChallenge); break; case Team.Right: SplashLabel.color = new Color(1f, 0, 0); SplashLabel.text = "You Lose..."; break; default: SplashLabel.color = new Color(0, 0, 0); SplashLabel.text = "Draw"; break; } EndLevel(); yield return(new WaitForSeconds(3)); TimerLabel.gameObject.SetActive(false); SplashLabel.gameObject.SetActive(false); TileManagerService.GetInstance().RemoveCurrentTiles(); GroundClaimsService.GetInstance().ResetCoverage(); UIManagerService.GetInstance().ShowChallengeMenu(); LoadDemoMode(); } else { yield return(new WaitForSeconds(1)); CurrentLevelTimeRemaining--; StartCoroutine(UpdateTimer()); } }
public void LoadDemoMode() { //assume demo mode here for now GroundClaimsService.GetInstance().ResetCoverage(); GroundClaimsService.GetInstance().TrackClaims = false; var Spawner = PlayerSpawner.gameObject.AddComponent <DemoScriptedSpawner>(); Spawner.Owner = Team.Left; PlayerScriptedSpawner = Spawner; PlayerScriptedSpawner.SetSpawner(PlayerSpawner); PlayerScriptedSpawner.StartSpawning(); Spawner = OpponentSpawner.gameObject.AddComponent <DemoScriptedSpawner>(); Spawner.Owner = Team.Right; OpponentScriptedSpawner = Spawner; OpponentScriptedSpawner.SetSpawner(OpponentSpawner); OpponentScriptedSpawner.StartSpawning(); }
private Team GetWinningTeam() { float ltcs = GroundClaimsService.GetInstance().GetLeftTeamCoverageScore(); float rtcs = GroundClaimsService.GetInstance().GetRightTeamCoverageScore(); if (ltcs > rtcs) { return(Team.Left); } else if (ltcs < rtcs) { return(Team.Right); } else { return(Team.None); } }
private IEnumerator SpawnLoop() { float relativeScore = 1f; if (Owner == Team.Left) { relativeScore = GroundClaimsService.GetInstance().GetLeftTeamCoverageScore() / 100; } else { relativeScore = GroundClaimsService.GetInstance().GetRightTeamCoverageScore() / 100; } Spawner.SpawnSoldier(); yield return(new WaitForSeconds(10f * relativeScore + 1)); Spawner.SpawnArcher(); yield return(new WaitForSeconds(10f * relativeScore + 1)); Spawner.SpawnWizard(); yield return(new WaitForSeconds(10f * relativeScore + 1)); SpawnRoutine = StartCoroutine(SpawnLoop()); }
void Awake() { Instance = this; ResetCoverage(); }