// static void Create() { Debug.Log("DEBUG: GameCounter [case3]: Create new GameCounter Object"); GameObject gameCounterObject = new GameObject("GameCounter"); s_Instance = gameCounterObject.AddComponent <GameCounter> (); }
/// <summary> /// Called when the <see cref="CurrentGame"/> is over. /// </summary> public void CurrentGameFinished() { Game <TTeam> endingGame = CurrentGame; Games.Add(endingGame); if (endingGame.WinnerTeam == TeamA) { GameCounter.IncrementA(); } else if (endingGame.WinnerTeam == TeamB) { GameCounter.IncrementB(); } (GameCountA, GameCountB) = (GameCounter.GameCountA, GameCounter.GameCountB); //ServiceRight.OnGameOver(); if (GameCounter.IsSetOver) { _ = OnCurrentGameFinished(endingGame); if (GameCountA == GameCountB) { throw new InvalidProgramException("Cannot win the set while in tie!"); } Winner = GameCountA < 0 ? TeamA : TeamB; OnSetOver(); Match.CurrentSetFinished(); } else { CurrentGame = OnCurrentGameFinished(endingGame); } }
// Use this for initialization void Start() { gameCounter = GameObject.Find("GameCounter"); gc = gameCounter.GetComponent <GameCounter>(); mTrackableBehaviour = GetComponent <TrackableBehaviour>(); if (mTrackableBehaviour) { mTrackableBehaviour.RegisterTrackableEventHandler(this); } }
/* * */ void OnMouseDown() { gc = GameObject.Find("CamManager").GetComponent <GameCounter>(); gc.score++; for (int i = 0; i < 2; i++) { sources[i].clip = clips[i]; AudioSource.PlayClipAtPoint(clips[i], Camera.main.transform.position); } Destroy(gameObject); }
// Use this for initialization void Start() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
public bool TryUpdateMaxValue(GameCounter maxValue, int newValue) { Debug.Assert(IsMaxCounter(maxValue)); if (newValue <= Counters[(int)maxValue]) { return(false); } Counters[(int)maxValue] = newValue; return(true); }
/* * */ void OnMouseDown() { if (!exploded) { top.AddComponent <Rigidbody>(); middle.AddComponent <Rigidbody>(); bottom.AddComponent <Rigidbody>(); gc = GameObject.Find("SceneManager").GetComponent <GameCounter>(); gc.snowmanCounter++; exploded = !exploded; } //Destroy(gameObject); }
/// <summary> /// Cancels the previous game. /// Used when the previous set's information was incorrect. /// </summary> public (IEnumerable <Receive>, Game <TTeam>) CancelPreviousGame() { if (Games.Count < 1) { throw new InvalidOperationException("Cannot rollback from empty state!"); } var g = CurrentGame = Games.Last(); Games.Remove(g); GameCounter.Rollback(); (GameCountA, GameCountB) = (GameCounter.GameCountA, GameCounter.GameCountB); //ServiceRight.OnGameCancelled(); OnPreviousGameCanceled(g); return(g.CancelRally(), g); }
public static string ActionDisplayString(GameCounter counter) { switch (counter) { case GameCounter.unlocked_paintball: return("Paintball required (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Player_Death: return("Look On The Bright Side Of Death (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Kill_Any: return("Kill Enemies Of Any Type (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Kill_BigWalker: return("Kill Big Enemies (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Kill_Caster: return("Kill Caster Enemies (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Score_Nursery_Sum: return("Score a Total Of <#ffffff>{1}</color> at Orc Nursery (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Score_Earth_Sum: return("Score a Total Of <#ffffff>{1}</color> at Plane Of Earth (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Score_Wind_Sum: return("Score a Total Of <#ffffff>{1}</color> at Plane Of Wind (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Score_Fire_Sum: return("Score a Total Of <#ffffff>{1}</color> at Plane Of Fire (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Score_Storm_Sum: return("Score a Total Of <#ffffff>{1}</color> at Perfect Storm (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.score_Harmony_Sum: return("Score a Total Of <#ffffff>{1}</color> at Plane Of Harmony (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Score_Any_Sum: return("Score a Total Of <#ffffff>{1}</color> Anywhere (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Max_Score_Nursery: return("Reach a Score Of <#ffffff>{1}</color> at Orc Nursery (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Max_Score_Earth: return("Reach a Score Of <#ffffff>{1}</color> at Plane Of Earth (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Max_Score_Wind: return("Reach a Score Of <#ffffff>{1}</color> at Plane Of Wind (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Max_Score_Fire: return("Reach a Score Of <#ffffff>{1}</color> at Plane Of Fire (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Max_Score_Storm: return("Reach a Score Of <#ffffff>{1}</color> at Perfect Storm (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Max_score_Harmony: return("Reach a Score Of <#ffffff>{1}</color> at Plane Of Harmony (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); case GameCounter.Max_Score_Any: return("Reach a Score Of <#ffffff>{1}</color> Anywhere (<#ffffff>{0}</color>/<#ffffff>{1}</color>)"); default: return("Unknown: " + counter.ToString()); } }
// Use this for initialization void Start() { anim = GetComponent <Animator>(); gameCounter = GameObject.Find("GameCounter"); gc = gameCounter.GetComponent <GameCounter>(); }
public int GetCounter(GameCounter counter) { return(Counters[(int)counter]); }
public void SetCounter(GameCounter counter, int amount) { Counters[(int)counter] = amount; }
public void UpdateCounter(GameCounter counter, int amount) { Debug.Assert(!IsMaxCounter(counter)); Counters[(int)counter] += amount; }
public bool ReqMet(int req, GameCounter counter) { return(Counters[(int)counter] >= req); }
public bool IsMaxCounter(GameCounter counter) { return(counter > GameCounter.Max_First && counter < GameCounter.Max_Last); }
// Important: All counter events must go through here so unlocks can be checked public static void CounterEvent(GameCounter counter, int amount) { if (GameManager.Instance.CurrentDeedData.Deed == DeedEnum.Sandbox) { // Seems ok to do this check here. Sandbox events do not count towards unlocks. return; } if (SaveGame.Members.IsMaxCounter(counter)) { SaveGame.Members.TryUpdateMaxValue(counter, amount); } else { SaveGame.Members.UpdateCounter(counter, amount); } const float DisplayTime = 3.0f; var blink = GameManager.Instance.TextNewUnlock.GetComponent <TextBlinkScript>(); var blinkTrans = GameManager.Instance.TextNewUnlock.transform; // This is all pretty ugly. Redundant formatting in dam, overwriting each other etc. // Check for new damage var newDamage = Unlocks.UnlockEarnedDamage(onlyExactMatch: true); foreach (var newDam in newDamage) { blink.SetText(string.Format("{0} Unlocked!", string.Format("+{0}% Damage", newDam.Amount), SaveGame.Members.ReqMet(newDam.Requirement, newDam.Counter)), DisplayTime); } // Check for new weapons var newWeps = Unlocks.UnlockEarnedWeapons(onlyExactMatch: true); foreach (var newWep in newWeps) { blink.SetText(string.Format("{0} Unlocked!", WeaponBase.WeaponDisplayName(newWep.Type)), DisplayTime); } // Check for new game modes var newModes = Unlocks.UnlockEarnedGameModes(onlyExactMatch: true); foreach (var newMode in newModes) { blink.SetText(string.Format("{0} Unlocked!", GameModeDisplayName(newMode.GameMode)), DisplayTime); } // Check for new heroes var newHeroes = Unlocks.UnlockEarnedHeroes(onlyExactMatch: true); foreach (var newHero in newHeroes) { blink.SetText(string.Format("{0} Unlocked!", newHero.Name), DisplayTime); } GameManager.Instance.RoundUnlockCount += newDamage.Count + newWeps.Count + newModes.Count + newHeroes.Count; bool hadNewUnlock = newDamage.Count > 0 || newWeps.Count > 0 || newModes.Count > 0 || newHeroes.Count > 0; if (hadNewUnlock) { Unlocks.LatestUnlockText = blink.Text.text; float basePos = GameManager.Instance.TextUnlockBasePos; ((RectTransform)blinkTrans).DOAnchorPosY(basePos - 300, 0.0f); ((RectTransform)blinkTrans).DOAnchorPosY(basePos, 0.5f); blinkTrans.DOScale(0.5f, 0.0f); blinkTrans.DOScale(1.0f, 0.5f); } // TODO PE: This is sort of hacked. It might be ok for now. If X was present in the newly unlocked weapons then set the corresponding GameCounter. UpdateUnlockCounters(newWeps, WeaponType.Paintball, GameCounter.unlocked_paintball); UpdateUnlockCounters(newWeps, WeaponType.ShotgunSlug, GameCounter.unlocked_slug); UpdateUnlockCounters(newWeps, WeaponType.Rambo, GameCounter.unlocked_rambo); UpdateUnlockCounters(newWeps, WeaponType.Staff, GameCounter.unlocked_staff); }
static void UpdateUnlockCounters(List <WeaponUnlockInfo> newWeapons, WeaponType ifThisWasJustUnlocked, GameCounter thenSetThisCounter) { if (newWeapons.Where(wep => wep.Type == ifThisWasJustUnlocked).Count() == 1) { GameEvents.CounterEvent(thenSetThisCounter, 1); } }
// Use this for initialization public void Start() { gameCounter = GameObject.Find("GameCounter").GetComponent <GameCounter>(); GameController = GameObject.Find("GameController").GetComponent <GameController>(); }