/* * @name OnBeginDrag * @purpose Once you begin draging requirements are checked and halos are assigned * * @return Void */ public void OnBeginDrag(PointerEventData eventData) { //this instantiates an game object of the class to use as an object and access methods //creates a gameobjects ReqGO = new GameObject("Req"); //assigns the script to the game object ReqGO.AddComponent <Requirements>(); //assigns the game object to the script withe the game object Req = GameObject.Find("Req").GetComponent <Requirements>(); ParentReturn = this.transform.parent; //gets original parent panel - the hand //this makes sure the current card being draggeds return is the hand this.transform.SetParent(this.transform.parent.parent); /**** CODE BELOW USED FOR MOUSE MOVEMENT AND DRAGGING ****/ if (Input.touchCount > 1) { return; } DraggedInstance = gameObject; //determines initial positiong of the cards _startPosition = transform.position; _zDistanceToCamera = Mathf.Abs(_startPosition.z - Camera.main.transform.position.z); _offsetToMouse = _startPosition - Camera.main.ScreenToWorldPoint( new Vector3(Input.mousePosition.x, Input.mousePosition.y, _zDistanceToCamera)); DraggedInstance.layer = 2; //sets the layer to ignore raycast gameObject.GetComponent <SpriteRenderer>().sortingOrder = 10; CardAction = DraggedInstance.GetComponent <Actions>(); //to access the actions scripts /**** CODE BELOW USED TO MAKE THE CORRECT HALO GLOW FOR THE PLACEMENTS ****/ /**** USES A LOT OF IF STATEMENTS BUT MAKES IT A LITTLE EASIER TO UNDERSTAND WITH JUST USING ONE TYPE VARIABLE ****/ SceneCheck = GameObject.Find("Game Board Container/Player Board").GetComponent <CanvasGroup>(); //need this to check the alpha //this is used so many time so i just took it out and pout it up here to organize DiscardPlacement = GameObject.Find(GameManager.Instance.Person.DiscardGameObject); //gets discard placement DiscardHalo = DiscardPlacement.GetComponent("Halo"); //gets discard halo component if (SceneCheck.alpha == 1) //if this is not 1 it means that the player board is not the visible one { //this is where the requirements will be checked //loop through each card in the human hand for (int z = 0; z < GameManager.Instance.Person.Hand.Count; z++) { //if the current card being dagged matches the card in the hand if (gameObject.name == GameManager.Instance.Person.Hand[z].CardName) //finds the card you are working with { //part of requirement checking bool executeReqs = true; //to handle executing the reqs if (GameManager.Instance.Person.Hand[z].CardType == "Condition") //determines if the standing action for the explorer is active { if (GameManager.Instance.Person.NoConditionRequirements == true) { executeReqs = false; } } //this is the basic requirement check routine if (executeReqs == true) { //if the card has requrements associated with it if (GameManager.Instance.Person.Hand[z].ReqID.Count != 0) { //calls the method in requirements and passes in the current card being draged and the current object player //and gets a true/false value to determine if requirements work if (Req.RequirementCheck(GameManager.Instance.Person.Hand[z], GameManager.Instance.Person.CurrentPlayer) == true) { RequirementsWork = true; } //if the requirements dont work then set the bool else { RequirementsWork = false; } } //if the card has no rewuirements associated with it then continue else { RequirementsWork = true; //allows it to be played break; } } else if (executeReqs == false) //so if there is no need to execute the requirements due to actions, will just say they are true { RequirementsWork = true; } } } /*********************************************************************************************************/ //From here on enables the halo glows if (RequirementsWork == true) //if the requirements work { for (int j = 0; j < GameManager.Instance.Person.Hand.Count; j++) //the for loop is used to just go through the hand and find the right card { //will check the name of the game object with the hand to get the correct index if (gameObject.name == GameManager.Instance.Person.Hand[j].CardName) { CType = GameManager.Instance.Person.Hand[j].CardType; //stores the card type for future use } //will go through each card type and check to see if the halo should light up if (CType == "Region") { HaloGlow(GameManager.Instance.Person.RegionGameObject); } else if (CType == "Condition") { HaloGlow(GameManager.Instance.Person.ConditionGameObject); } else if (CType == "Plant") { HaloGlow(GameManager.Instance.Person.PlantGameObject); } else if (CType == "Invertebrate") { HaloGlow(GameManager.Instance.Person.InvertebrateGameObject); } else if (CType == "Animal") { HaloGlow(GameManager.Instance.Person.AnimalGameObject); } else if (CType == "Special Region") { HaloGlow(GameManager.Instance.Person.SpecialRegionGameObject); } else if (CType == "Multi-Player") { HaloGlow(GameManager.Instance.Person.MultiplayerGameObject); } else if (CType == "Human") { HaloGlow(GameManager.Instance.Person.HumanGameObject); } else if (CType == "Microbe") { HaloGlow(GameManager.Instance.Person.MicrobeGameObject); } else if (CType == "Fungi") { HaloGlow(GameManager.Instance.Person.FungiGameObject); } } } else if (GameManager.Instance.Person.CardDiscarded == false) //discard pile should still work { DiscardHalo.GetType().GetProperty("enabled").SetValue(DiscardHalo, true, null); //sets the glow } } }
//where the card things will take place IEnumerator ComputerPerforms() //public void ComputerPerforms() { //this instantiates an game object of the class to use as an object and access methods //creates a gameobjects ReqGO = new GameObject("Req"); //assigns the script to the game object ReqGO.AddComponent <Requirements>(); //assigns the game object to the script withe the game object Req = GameObject.Find("Req").GetComponent <Requirements>(); //this determinines how many cards the computer draws DrawAmount(); //draws the appropriate amount of cards Draw(DrawCount); //this is where the requirements will be checked for (int z = Hand.Count - 1; z > -1; z--) //done this way to avoid exception { //creates time using the coroutine yield return(new WaitForSeconds(5)); //if the current card has requirements associated with it if (Hand[z].ReqID.Count != 0) { //call the function in requirements to check and pass in the current card and the current instance of the player if (Req.RequirementCheck(Hand[z], CurrentPlayer)) { RequirementsWork = true; } else { RequirementsWork = false; } } //if there are no requirements then the card can automatically be played, usually this is the case with region cards else { RequirementsWork = true; } //if the requirement works then the card is placed in the proper area and move to the correct list if (RequirementsWork == true) { if (Hand[z].CardType == "Region") //puts the card into the region placement { //checks the region type and changes the variable accordingly if (Hand[z].CardName.Contains("Arid")) { AridCount++; } else if (Hand[z].CardName.Contains("Forest")) { ForestCount++; } else if (Hand[z].CardName.Contains("Grasslands")) { GrasslandsCount++; } else if (Hand[z].CardName.Contains("Running-Water")) { RunningWaterCount++; } else if (Hand[z].CardName.Contains("Salt-Water")) { SaltWaterCount++; } else if (Hand[z].CardName.Contains("Standing-Water")) { StandingWaterCount++; } else if (Hand[z].CardName.Contains("Sub-Zero")) { SubZeroCount++; } //calls the method to asssigning the correct sprite and update score and passes in z so it knows which card to work with MoveCard(z, RegionGameObject, RegionPlacement); } else if (Hand[z].CardType == "Condition") //puts the card into the condition card { //calls the method to asssigning the correct sprite and update score and passes in z so it knows which card to work with MoveCard(z, ConditionGameObject, ConditionPlacement); } else if (Hand[z].CardType == "Plant") //puts the card into the plant type { //calls the method to asssigning the correct sprite and update score and passes in z so it knows which card to work with MoveCard(z, PlantGameObject, PlantPlacement); } else if (Hand[z].CardType == "Invertebrate") //puts the card into the invertebrate pile { //calls the method to asssigning the correct sprite and update score and passes in z so it knows which card to work with MoveCard(z, InvertebrateGameObject, InvertebratePlacement); } else if (Hand[z].CardType == "Animal") //puts the cards into the animal pile { //calls the method to asssigning the correct sprite and update score and passes in z so it knows which card to work with MoveCard(z, AnimalGameObject, AnimalPlacement); } else if (Hand[z].CardType == "Special Region") //puts the card into the special region pile { //calls the method to asssigning the correct sprite and update score and passes in z so it knows which card to work with MoveCard(z, SpecialRegionGameObject, SpecialRegionPlacement); } else if (Hand[z].CardType == "Multi-Player") //puts the card into the multiplayer pile { //calls the method to asssigning the correct sprite and update score and passes in z so it knows which card to work with MoveCard(z, MultiplayerGameObject, MultiPlacement); } else if (Hand[z].CardType == "Microbe") //puts the card into the microbe pile { //calls the method to asssigning the correct sprite and update score and passes in z so it knows which card to work with MoveCard(z, MicrobeGameObject, MicrobePlacement); } else if (Hand[z].CardType == "Fungi") //puts the card into the fungi pile { //calls the method to asssigning the correct sprite and update score and passes in z so it knows which card to work with MoveCard(z, FungiGameObject, FungiPlacement); } } } if (Hand.Count != 0) //if there is a card left in the hand, it will discad the firsts one { //calls the method to asssigning the correct sprite and update score and passes in z so it knows which card to work with MoveCard(0, DiscardGameObject, DiscardPlacement); yield return(new WaitForSeconds(2)); } else //if there are no cards left in the hand, will just automatically go to the next player { yield return(new WaitForSeconds(2)); } //calls the game manager instane to change the players turn and passes imn this instances name so we know which player goes nect GameManager.Instance.NextPlayer(PlayerName); }