public override void OnComponentAdded(BaseComponent c) { if (c is StartGameComponent) { ShowGame(); SetupNextRound(); SetIsPlaying(true); GameObject.Destroy(c); } else if (c is EndGameComponent) { HideGame(); GameObject.Destroy(RoundSystem.GetExistingMatch()); SetIsPlaying(false); GameObject.Destroy(c); } else if (c is MatchComponent) { this.OnMatch(c.gameObject); } else if (c is LossComponent) { this.OnLoss(c.gameObject); } }
/* * - Start, set last color and therefore set background * - game should exist but all game objects should be inactive * - on start, we initialize the game w/ prev color and next color, show game objects * - play * - on end game, we hide all the things and then turn off the game objects * - on restart, we start game again w/ prev color and next color, show game objects * - on end total, we hide all the things and then turn off the game objects * * - tutorial * - inherit from roundsystem with tutorialroundsystem, overriding some things * - use queue of colors, or hardcode them per level in color chooser function */ public override void Update() { GameController gc = (Controller() as GameController); if (!gc.isPlaying) { return; } if (gc.initializeGame) { gc.initializeGame = false; GameObject.Destroy(RoundSystem.GetExistingMatch()); ClearCubes(); Reset(gc.round); } if (GetExistingMatch() != null) { return; } List <BaseComponent> matchableComponents = Pool.Instance.ComponentsForType(typeof(MatchableComponent)); MatchableComponent target = null; bool hasMatch = true; foreach (MatchableComponent mac in matchableComponents) { ColorableComponent cac = mac.GetComponent <ColorableComponent>(); if (target == null) { target = mac; continue; } Color targetColor = target.GetComponent <ColorableComponent>().color; if (targetColor != cac.color) { hasMatch = false; } } if (target) { if (hasMatch) { BaseObject.AddComponent <MatchComponent>(); } } }