void Awake() { if (Instance != null && Instance != this) { Destroy(this.gameObject); return; } else { Instance = this; } }
public void Initialize() { CombatSceneController controller = CombatSceneController.Instance; int maxDiscardSize = (controller.MaxDeckSize - controller.PlayerSize * (CombatSceneController.MaxPlayerHandSize - 1)) / controller.PlayerSize; TileGO tilePrefab = controller.TilePrefab; float imageWidth = tilePrefab.Image.rectTransform.rect.width; for (int i = 0; i < maxDiscardSize; ++i) { TileGO tileGO = GameObject.Instantiate(tilePrefab); RectTransform rectTrans = tileGO.GetComponent <RectTransform>(); rectTrans.anchorMin = new Vector2(0, rectTrans.anchorMin.y); rectTrans.anchorMax = new Vector2(0, rectTrans.anchorMax.y); rectTrans.localPosition = new Vector2(imageWidth / 2 + i * imageWidth, 0); tileGO.transform.SetParent(this.transform, false); this.discard.Add(tileGO); } }
void OnTriggerStay(Collider c) { if (boxGroup == 1) { if (c.gameObject.tag == "P1Kid") { spawnBlocked = true; } } else if (boxGroup == 2) { if (c.gameObject.tag == "P2Kid") { spawnBlocked = true; } } //questionable checking by name method to prevent ball from scoring if (c.gameObject.name.Contains("kid")) // != "Ball(Clone)" && c.gameObject.name != "Ball"){ { if (boxGroup == 1) { if (c.gameObject.tag == "P2Kid") { Destroy(c.gameObject); CombatSceneController.player2GoalReached(); } } else if (boxGroup == 2) { if (c.gameObject.tag == "P1Kid") { Destroy(c.gameObject); CombatSceneController.player1GoalReached(); } } } }
void OnDestroy() { CombatSceneController.instance = null; }
void Awake() { CombatSceneController.instance = this; this.Initialize(); }