// Use this for initialization void Start() { scriptInstance = ScriptableObject.CreateInstance("CardRetrievalFromDeck"); //so you can use the script holder = ScriptableObject.FindObjectOfType <CardRetrievalFromDeck>(); //access to script changePlayer = GameObject.Find("Main Camera").GetComponent <HideShowBoards>(); //to change players cameraHolder = GameObject.Find("Main Camera"); // to access the scripts of the main camera if (GameManager.Instance.round == 1) //will only happen in the first round { for (int i = 0; i < 5; i++) { holder.drawCP3Deck(); //adds the cards to the computers hand //draws a card and puts it into the hand cardParent = GameObject.Find("Computer Three Board/CP3Hand").transform; holder.cardNameHolder = "back_of_card"; generateCardObject(); holder.setSpriteCP1(sr); //generating the card object to be placed into the panel } } round = 0; //starts at 1, goes to 10 sort = 5; //starts at 5 StartCoroutine("computerPerforms"); }
// Use this for initialization void Start() { Cursor.visible = false; //hides the mouse from the user Cursor.lockState = CursorLockMode.Locked; //you cannot use the cursor scriptInstance = ScriptableObject.CreateInstance("CardRetrievalFromDeck"); //so you can use the script holder = ScriptableObject.FindObjectOfType <CardRetrievalFromDeck>(); //access to script changePlayer = GameObject.Find("Main Camera").GetComponent <HideShowBoards>(); //to change players cameraHolder = GameObject.Find("Main Camera"); //sets the object to just the main camera if (GameManager.Instance.round == 1) //only happens in the first round { for (int i = 0; i < 5; i++) { holder.drawCP1Deck(); //adds the cards to the computers hand //draws a card and puts it into the hand cardParent = GameManager.Instance.cp1AI; holder.cardNameHolder = "back_of_card"; generateCardObject(); holder.setSpriteCP1(sr); //generating the card object to be placed into the panel } } StartCoroutine("computerPerforms"); //goes through the function needed for the AI }
public GameObject handShow; //will be used to hide the hand // Use this for initialization void Start() { viewDeckDiscard = GameObject.Find("Deck and Discard Canvas"); //gets the object for the variable GameManager.Instance.check = GameObject.Find("Main Camera").GetComponent <CheckDeckAndDiscardPlayer>(); //gets access to the script board = GameObject.Find("Main Camera").GetComponent <HideShowBoards>(); //gets access to the script handShow = GameObject.Find("Hand"); //gets the hand viewDeckDiscard.SetActive(false); //makes sure it doesnt show on the game start }
//this is what happens whenever the drag ends public void OnEndDrag(PointerEventData eventData) { DraggedInstance.layer = 5; //puts the layer back to the original //discarded = false; /**** THIS WILL MOVE THE CARD FROM THE HAND LIST TO THE APPROPRIATE LIST BASED ON THE TYPE ****/ if (parentReturn.name != "Hand") { if (parentReturn.name == "Discard Pile Placement" && GameManager.Instance.cardDiscarded == false) //checks to make sure it wasnt placed in the discard pile first { for (int i = 0; i < GameManager.Instance.Hand.Count; i++) //used to go through the hand { if (DraggedInstance.name == GameManager.Instance.Hand[i].CardName) { DraggedInstance.transform.localScale = new Vector3(1.0f, 1.0f, 0); //sets the size to fit the placement area GameManager.Instance.DiscardPlacement.Add(GameManager.Instance.Hand[i]); //adds the card to the discard list GameManager.Instance.Hand.Remove(GameManager.Instance.Hand[i]); //removes the card from the hand list GameManager.Instance.cardDiscarded = true; } } changePlayer = GameObject.Find("Main Camera").GetComponent <HideShowBoards>(); //gets the script Destroy(DraggedInstance.GetComponent <Draggable>()); //makes them no longer be abe to be dragged GameManager.Instance.makeButtonVisible(); //makes the button visible again GameManager.Instance.enableTurnButton(); //enables the end turn button } else if (cType == "Region") { for (int i = 0; i < GameManager.Instance.Hand.Count; i++) //used to go through the hand { if (DraggedInstance.name == GameManager.Instance.Hand[i].CardName) { //changes the player score GameManager.Instance.changePlayerScore(GameManager.Instance.Hand[i].PointValue); //will check what the region type is and accesses/changes the variable if (GameManager.Instance.Hand[i].CardName.Contains("Arid")) { GameManager.Instance.playerAridCount++; } else if (GameManager.Instance.Hand[i].CardName.Contains("Forest")) { GameManager.Instance.playerForestCount++; } else if (GameManager.Instance.Hand[i].CardName.Contains("Grasslands")) { GameManager.Instance.playerGrasslandsCount++; } else if (GameManager.Instance.Hand[i].CardName.Contains("Running-Water")) { GameManager.Instance.playerRunningWaterCount++; } else if (GameManager.Instance.Hand[i].CardName.Contains("Salt-Water")) { GameManager.Instance.playerSaltWaterCount++; } else if (GameManager.Instance.Hand[i].CardName.Contains("Standing-Water")) { GameManager.Instance.playerStandingWaterCount++; } else if (GameManager.Instance.Hand[i].CardName.Contains("Sub-Zero")) { GameManager.Instance.playerSubZeroCount++; } DraggedInstance.transform.localScale = new Vector3(1f, 1f, 0); //sets the size to fit the placement area Destroy(DraggedInstance.GetComponent <Draggable>()); //makes them no longer be abe to be dragged GameManager.Instance.RegionPlacement.Add(GameManager.Instance.Hand[i]); //adds the card to the region list GameManager.Instance.Hand.Remove(GameManager.Instance.Hand[i]); //removes the card from the hand list //this is where the card actions are checked and executed /*for (int j = 0; j < GameManager.Instance.HumanPlacement.Count; j++) //gets length of array * { * if (DraggedInstance.name == GameManager.Instance.HumanPlacement[j].CardName) * { * if (GameManager.Instance.HumanPlacement[j].ActionID.Count != 0) //only goes in if there are action * { * cardAction = GameObject.Find("Main Camera").GetComponent<Actions>(); //gets the script * Debug.Log(GameManager.Instance.HumanPlacement[j].CardName); * cardAction.checkAction(GameManager.Instance.HumanPlacement[j]); //executes cards actions * } * else * { * break; //just gets out of the loop and continues * } * } * }*/ } } } else if (cType == "Condition") { for (int i = 0; i < GameManager.Instance.Hand.Count; i++) //used to go through the hand { if (DraggedInstance.name == GameManager.Instance.Hand[i].CardName) { //changes the player score GameManager.Instance.changePlayerScore(GameManager.Instance.Hand[i].PointValue); DraggedInstance.transform.localScale = new Vector3(1f, 1f, 0); //sets the size to fit the placement area Destroy(DraggedInstance.GetComponent <Draggable>()); //makes them no longer be abe to be dragged GameManager.Instance.ConditionPlacement.Add(GameManager.Instance.Hand[i]); //adds the card to the condition list GameManager.Instance.Hand.Remove(GameManager.Instance.Hand[i]); //removes the card from the hand list //this is where the card actions are checked and executed /*for (int j = 0; j < GameManager.Instance.HumanPlacement.Count; j++) //gets length of array * { * if (DraggedInstance.name == GameManager.Instance.HumanPlacement[j].CardName) * { * if (GameManager.Instance.HumanPlacement[j].ActionID.Count != 0) //only goes in if there are action * { * cardAction = GameObject.Find("Main Camera").GetComponent<Actions>(); //gets the script * Debug.Log(GameManager.Instance.HumanPlacement[j].CardName); * cardAction.checkAction(GameManager.Instance.HumanPlacement[j]); //executes cards actions * } * else * { * break; //just gets out of the loop and continues * } * } * }*/ } } } else if (cType == "Plant") { for (int i = 0; i < GameManager.Instance.Hand.Count; i++) //used to go through the hand { if (DraggedInstance.name == GameManager.Instance.Hand[i].CardName) { //changes the player score GameManager.Instance.changePlayerScore(GameManager.Instance.Hand[i].PointValue); DraggedInstance.transform.localScale = new Vector3(1f, 1f, 0); //sets the size to fit the placement area Destroy(DraggedInstance.GetComponent <Draggable>()); //makes them no longer be abe to be dragged GameManager.Instance.PlantPlacement.Add(GameManager.Instance.Hand[i]); //adds the card to the plant list GameManager.Instance.Hand.Remove(GameManager.Instance.Hand[i]); //removes the card from the hand list //this is where the card actions are checked and executed /*for (int j = 0; j < GameManager.Instance.HumanPlacement.Count; j++) //gets length of array * { * if (DraggedInstance.name == GameManager.Instance.HumanPlacement[j].CardName) * { * if (GameManager.Instance.HumanPlacement[j].ActionID.Count != 0) //only goes in if there are action * { * cardAction = GameObject.Find("Main Camera").GetComponent<Actions>(); //gets the script * Debug.Log(GameManager.Instance.HumanPlacement[j].CardName); * cardAction.checkAction(GameManager.Instance.HumanPlacement[j]); //executes cards actions * } * else * { * break; //just gets out of the loop and continues * } * } * }*/ } } } else if (cType == "Invertebrate") { for (int i = 0; i < GameManager.Instance.Hand.Count; i++) //used to go through the hand { if (DraggedInstance.name == GameManager.Instance.Hand[i].CardName) { //changes the player score GameManager.Instance.changePlayerScore(GameManager.Instance.Hand[i].PointValue); DraggedInstance.transform.localScale = new Vector3(1f, 1f, 0); //sets the size to fit the placement area Destroy(DraggedInstance.GetComponent <Draggable>()); //makes them no longer be abe to be dragged GameManager.Instance.InvertebratePlacement.Add(GameManager.Instance.Hand[i]); //adds the card to the invertebrate list GameManager.Instance.Hand.Remove(GameManager.Instance.Hand[i]); //removes the card from the hand list //this is where the card actions are checked and executed /*for (int j = 0; j < GameManager.Instance.HumanPlacement.Count; j++) //gets length of array * { * if (DraggedInstance.name == GameManager.Instance.HumanPlacement[j].CardName) * { * if (GameManager.Instance.HumanPlacement[j].ActionID.Count != 0) //only goes in if there are action * { * cardAction = GameObject.Find("Main Camera").GetComponent<Actions>(); //gets the script * Debug.Log(GameManager.Instance.HumanPlacement[j].CardName); * cardAction.checkAction(GameManager.Instance.HumanPlacement[j]); //executes cards actions * } * else * { * break; //just gets out of the loop and continues * } * } * }*/ } } } else if (cType == "Animal") { for (int i = 0; i < GameManager.Instance.Hand.Count; i++) //used to go through the hand { if (DraggedInstance.name == GameManager.Instance.Hand[i].CardName) { //changes the player score GameManager.Instance.changePlayerScore(GameManager.Instance.Hand[i].PointValue); DraggedInstance.transform.localScale = new Vector3(1f, 1f, 0); //sets the size to fit the placement area Destroy(DraggedInstance.GetComponent <Draggable>()); //makes them no longer be abe to be dragged GameManager.Instance.AnimalPlacement.Add(GameManager.Instance.Hand[i]); //adds the card to the aniaml list GameManager.Instance.Hand.Remove(GameManager.Instance.Hand[i]); //removes the card from the hand list //this is where the card actions are checked and executed /*for (int j = 0; j < GameManager.Instance.HumanPlacement.Count; j++) //gets length of array * { * if (DraggedInstance.name == GameManager.Instance.HumanPlacement[j].CardName) * { * if (GameManager.Instance.HumanPlacement[j].ActionID.Count != 0) //only goes in if there are action * { * cardAction = GameObject.Find("Main Camera").GetComponent<Actions>(); //gets the script * Debug.Log(GameManager.Instance.HumanPlacement[j].CardName); * cardAction.checkAction(GameManager.Instance.HumanPlacement[j]); //executes cards actions * } * else * { * break; //just gets out of the loop and continues * } * } * }*/ } } } else if (cType == "Special Region") { for (int i = 0; i < GameManager.Instance.Hand.Count; i++) //used to go through the hand { if (DraggedInstance.name == GameManager.Instance.Hand[i].CardName) { //checks for the mountin range if (GameManager.Instance.Hand[i].CardName.Contains("Mountain")) { GameManager.Instance.playerMountainRange++; } //changes the player score GameManager.Instance.changePlayerScore(GameManager.Instance.Hand[i].PointValue); DraggedInstance.transform.localScale = new Vector3(1f, 1f, 0); //sets the size to fit the placement area Destroy(DraggedInstance.GetComponent <Draggable>()); //makes them no longer be abe to be dragged GameManager.Instance.SpecialRegionPlacement.Add(GameManager.Instance.Hand[i]); //adds the card to the Special Region list GameManager.Instance.Hand.Remove(GameManager.Instance.Hand[i]); //removes the card from the hand list //this is where the card actions are checked and executed for (int j = 0; j < GameManager.Instance.SpecialRegionPlacement.Count; j++) //gets length of array { if (DraggedInstance.name == GameManager.Instance.SpecialRegionPlacement[j].CardName) { if (GameManager.Instance.SpecialRegionPlacement[j].ActionID.Count != 0) //only goes in if there are action { //Debug.Log("im in"); standingActions = GameObject.Find("Main Camera").GetComponent <ActionsStanding>(); //gets the script standingActions.checkStandingAction(GameManager.Instance.SpecialRegionPlacement[j]); //executes cards actions } else { break; //just gets out of the loop and continues } } } } } } else if (cType == "Multi-Player") { for (int i = 0; i < GameManager.Instance.Hand.Count; i++) //used to go through the hand { if (DraggedInstance.name == GameManager.Instance.Hand[i].CardName) { //changes the player score GameManager.Instance.changePlayerScore(GameManager.Instance.Hand[i].PointValue); DraggedInstance.transform.localScale = new Vector3(1f, 1f, 0); //sets the size to fit the placement area Destroy(DraggedInstance.GetComponent <Draggable>()); //makes them no longer be abe to be dragged GameManager.Instance.MultiPlacement.Add(GameManager.Instance.Hand[i]); //adds the card to the Multiplayer list GameManager.Instance.Hand.Remove(GameManager.Instance.Hand[i]); //removes the card from the hand list } } } else if (cType == "Human") { for (int i = 0; i < GameManager.Instance.Hand.Count; i++) //used to go through the hand { if (DraggedInstance.name == GameManager.Instance.Hand[i].CardName) { //GameManager.Instance.DraggedCard = DraggedInstance; //changes the player score GameManager.Instance.changePlayerScore(GameManager.Instance.Hand[i].PointValue); DraggedInstance.transform.localScale = new Vector3(1f, 1f, 0); //sets the size to fit the placement area Destroy(DraggedInstance.GetComponent <Draggable>()); //makes them no longer be abe to be dragged GameManager.Instance.HumanPlacement.Add(GameManager.Instance.Hand[i]); //adds the card to the Human list GameManager.Instance.Hand.Remove(GameManager.Instance.Hand[i]); //removes the card from the hand list //this is where the card actions are checked and executed for (int j = 0; j < GameManager.Instance.HumanPlacement.Count; j++) //gets length of array { if (DraggedInstance.name == GameManager.Instance.HumanPlacement[j].CardName) { if (GameManager.Instance.HumanPlacement[j].ActionID.Count != 0) //only goes in if there are action { standingActions = GameObject.Find("Main Camera").GetComponent <ActionsStanding>(); //gets the script standingActions.checkStandingAction(GameManager.Instance.HumanPlacement[j]); //executes cards actions } else { break; //just gets out of the loop and continues } } } } } } else if (cType == "Microbe") { for (int i = 0; i < GameManager.Instance.Hand.Count; i++) //used to go through the hand { if (DraggedInstance.name == GameManager.Instance.Hand[i].CardName) { //changes the player score GameManager.Instance.changePlayerScore(GameManager.Instance.Hand[i].PointValue); DraggedInstance.transform.localScale = new Vector3(1f, 1f, 0); //sets the size to fit the placement area Destroy(DraggedInstance.GetComponent <Draggable>()); //makes them no longer be abe to be dragged GameManager.Instance.MicrobePlacement.Add(GameManager.Instance.Hand[i]); //adds the card to the Microbe list GameManager.Instance.Hand.Remove(GameManager.Instance.Hand[i]); //removes the card from the hand list //this is where the card actions are checked and executed /*for (int j = 0; j < GameManager.Instance.HumanPlacement.Count; j++) //gets length of array * { * if (DraggedInstance.name == GameManager.Instance.HumanPlacement[j].CardName) * { * if (GameManager.Instance.HumanPlacement[j].ActionID.Count != 0) //only goes in if there are action * { * cardAction = GameObject.Find("Main Camera").GetComponent<Actions>(); //gets the script * Debug.Log(GameManager.Instance.HumanPlacement[j].CardName); * cardAction.checkAction(GameManager.Instance.HumanPlacement[j]); //executes cards actions * } * else * { * break; //just gets out of the loop and continues * } * } * }*/ } } } else if (cType == "Fungi") { for (int i = 0; i < GameManager.Instance.Hand.Count; i++) //used to go through the hand { if (DraggedInstance.name == GameManager.Instance.Hand[i].CardName) { //changes the player score GameManager.Instance.changePlayerScore(GameManager.Instance.Hand[i].PointValue); DraggedInstance.transform.localScale = new Vector3(1f, 1f, 0); //sets the size to fit the placement area Destroy(DraggedInstance.GetComponent <Draggable>()); //makes them no longer be abe to be dragged GameManager.Instance.FungiPlacement.Add(GameManager.Instance.Hand[i]); //adds the card to the Fungi list GameManager.Instance.Hand.Remove(GameManager.Instance.Hand[i]); //removes the card from the hand list //this is where the card actions are checked and executed /*for (int j = 0; j < GameManager.Instance.HumanPlacement.Count; j++) //gets length of array * { * if (DraggedInstance.name == GameManager.Instance.HumanPlacement[j].CardName) * { * if (GameManager.Instance.HumanPlacement[j].ActionID.Count != 0) //only goes in if there are action * { * cardAction = GameObject.Find("Main Camera").GetComponent<Actions>(); //gets the script * Debug.Log(GameManager.Instance.HumanPlacement[j].CardName); * cardAction.checkAction(GameManager.Instance.HumanPlacement[j]); //executes cards actions * } * else * { * break; //just gets out of the loop and continues * } * } * }*/ } } } } //double click will not work on cards in your hand or in the discard pile if (parentReturn.name != "Hand" && parentReturn.name != "Discard Pile Placement") { DraggedInstance.AddComponent <DoubleClickDescription>(); //once placed, adds the option to be double clicked } this.transform.SetParent(parentReturn); //sets the parent //to make sure there are no sorting issues so that the cards are positioned properly DraggedInstance.GetComponent <SpriteRenderer>().sortingOrder = GameManager.Instance.sortingOrder; GameManager.Instance.sortingOrder++; DraggedInstance = null; //drops object _offsetToMouse = Vector3.zero; if (requirementsWork == false && discardHalo != null) { discardHalo.GetType().GetProperty("enabled").SetValue(discardHalo, false, null); //sets the glow to false } else if (DraggedInstance == null) { if (placementHalo != null) { placementHalo.GetType().GetProperty("enabled").SetValue(placementHalo, false, null); //sets the glow to false } if (discardHalo != null) { discardHalo.GetType().GetProperty("enabled").SetValue(discardHalo, false, null); //sets the glow to false } } if (GameManager.Instance.cardDiscarded == false) { if (GameManager.Instance.Hand.Count == 0) //if you play your last card and dont have anymore, automatically goes { changePlayer = GameObject.Find("Main Camera").GetComponent <HideShowBoards>(); //gets the script GameManager.Instance.makeButtonVisible(); //makes the button visible GameManager.Instance.enableTurnButton(); //enables the end turn button } } //WHERE THE DISCARD PILE WILL BE CHECKED FOR CARDS WITH CERTAIN ACTIONS THAT NEED CHANGED for (int i = 0; i < GameManager.Instance.DiscardPlacement.Count; i++) //to go through the discard pile { if (GameManager.Instance.DiscardPlacement[i].CardName == "Human-Two-Sisters-In-The-Wild") { GameManager.Instance.playerProtectedFromExtinction = false; //player is no longer protected from extinction } else if (GameManager.Instance.DiscardPlacement[i].CardName == "Human-Biologist") { GameManager.Instance.playerProtectedFromInvasiveAnimal = false; //player is no longer protected } else if (GameManager.Instance.DiscardPlacement[i].CardName == "Human-Botanist") { GameManager.Instance.playerProtectedFromInvasivePlant = false; //no longer protected from the invaiev plant } else if (GameManager.Instance.DiscardPlacement[i].CardName == "Human-Explorer") { GameManager.Instance.playerNoConditionRequirements = false; //no longer able to place condition cards without requirements } } }