void spawnCourse() { GameObject Square_1; int max = UnityEngine.Random.Range(15, 20); int i = 0; int rp = 0; ButtonManager.numPlayers = 1; while (i < max) { int c = UnityEngine.Random.Range(9, 57); //Debug.Log(c); if (WallPlacement.validPlacement(c)) { Square_1 = GameObject.Find(c.ToString()); GameObject SolidWall = (GameObject)Instantiate(Resources.Load("SolidWall")); SolidWall.transform.SetParent(Square_1.transform); SolidWall.GetComponent <Draggable>().enabled = false; i++; rp = 0; } else { rp++; } if (rp == 10) { break; } } }
public void OnEndDrag(PointerEventData eventData) { DropZone.DropZoneType zone = DropZone.zone; //Debug.Log("OnEndDrag"); //Debug.Log(zone); if (zone == DropZone.DropZoneType.BoardZone) { if (this.transform.tag != "SolidWall" && this.transform.tag != "IceWall") { this.transform.SetParent(originParent.transform); } else { if (parentToReturnTo.transform.childCount == 0) { if (this.transform.tag == "SolidWall") { //Debug.Log("Solid wall placed"); this.transform.SetParent(parentToReturnTo); tileChildCount++; if (WallPlacement.validPlacement(Convert.ToInt32(parentToReturnTo.transform.name))) { //Debug.Log("Solid wall placed"); this.transform.SetParent(parentToReturnTo); tileChildCount++; } else { this.transform.SetParent(originParent.transform); } //*/ //not vallid placement } else { //Debug.Log("Ice wall placed"); this.transform.SetParent(parentToReturnTo); tileChildCount++; } } else { this.transform.SetParent(originParent.transform); } //space occupied cant place wall there } this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; Destroy(placeholder); } else if (zone == DropZone.DropZoneType.FunctionZone) { //Debug.Log("in function zone"); if (this.tag != "Forward" && this.tag != "Left" && this.tag != "Right" && this.tag != "Laser" && this.tag != "FCard") { this.transform.SetParent(originParent.transform); this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; Destroy(placeholder); } else { Scene scene = SceneManager.GetActiveScene(); //Debug.Log(scene); if (scene.name == "spgameBoard2") { Debug.Log(scene.name); this.transform.SetParent(parentToReturnTo); this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; this.GetComponent <Draggable>().enabled = false; Destroy(placeholder); } else { this.transform.SetParent(parentToReturnTo); this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; this.GetComponent <Draggable>().enabled = false; Sprite blankCard = Resources.Load <Sprite>("blank_card"); this.GetComponent <Image>().sprite = blankCard; Destroy(placeholder); } } } else if (zone == DropZone.DropZoneType.HandZone) { originParent = GameObject.Find("Hand"); this.transform.SetParent(originParent.transform); //this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; Destroy(placeholder); } else if (zone == DropZone.DropZoneType.DeckZone) { this.transform.SetParent(parentToReturnTo); this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; Destroy(placeholder); } else if (zone == DropZone.DropZoneType.FieldZone) { this.transform.SetParent(parentToReturnTo); this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; Destroy(placeholder); } else if (zone == DropZone.DropZoneType.TileZone) { if (this.transform.tag != "SolidWall" && this.transform.tag != "IceWall") { this.transform.SetParent(originParent.transform); this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; Destroy(placeholder); } else { this.transform.SetParent(parentToReturnTo); this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; Destroy(placeholder); } } else if (zone == DropZone.DropZoneType.DiscardZone) { if (this.tag != "Forward" && this.tag != "Left" && this.tag != "Right" && this.tag != "Laser") { this.transform.SetParent(originParent.transform); this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; Destroy(placeholder); } else { this.transform.SetParent(parentToReturnTo); this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; this.GetComponent <Draggable>().enabled = false; Sprite blankCard = Resources.Load <Sprite>("blank_card"); this.GetComponent <Image>().sprite = blankCard; Destroy(this.gameObject); Destroy(placeholder); } } else if (zone == DropZone.DropZoneType.FCardZone) { if (this.tag != "Forward" && this.tag != "Left" && this.tag != "Right" && this.tag != "Laser") { this.transform.SetParent(originParent.transform); this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; Destroy(placeholder); } else { if (GameObject.Find("FCard").transform.childCount < 5) { this.transform.SetParent(parentToReturnTo); //this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; this.GetComponent <Draggable>().enabled = false; Destroy(placeholder); } else { this.transform.SetParent(originParent.transform); this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; Destroy(placeholder); } } } else { this.transform.SetParent(parentToReturnTo); this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex()); GetComponent <CanvasGroup>().blocksRaycasts = true; Destroy(placeholder); } DropZone.zone = DropZone.DropZoneType.empty; Scene s = SceneManager.GetActiveScene(); if (s.name != "spgameBoard2") { if (tileChildCount > GameObject.Find("TileZone").transform.childCount) { //Debug.Log("Disabling Hand"); GameObject.Find("Function").transform.GetComponent <DropZone>().enabled = false; //Debug.Log("Disabling TileZone"); foreach (Transform child in GameObject.Find("TileZone").transform) { child.GetComponent <Draggable>().enabled = false; } //Debug.Log("Disabling Run Function"); GameObject.Find("runFunctionBUtton").transform.GetComponent <Button>().enabled = false; } if (handChildCount > GameObject.Find("Hand").transform.childCount) { //Debug.Log("Disabling TileZone"); Scene scene = SceneManager.GetActiveScene(); if (scene.name != "spgameBoard2") { foreach (Transform child in GameObject.Find("TileZone").transform) { child.GetComponent <Draggable>().enabled = false; } } GameObject.Find("runFunctionBUtton").transform.GetComponent <Button>().enabled = false; } } }