示例#1
0
    /*
     * @name    HaloGlow
     * @purpose this is called to set the glow to the correct placement holder on the player canvas
     *
     * @return  Void
     */
    public void HaloGlow(string pGameObjectPlacement)
    {
        //takes the parameter and find the correct palcement area
        FindPlacement = GameObject.Find(pGameObjectPlacement);
        PlacementHalo = FindPlacement.GetComponent("Halo");                                     //gets the halo component

        if (PlacementHalo != null && DiscardHalo != null)                                       //just to make sure there is actually a halo component
        {
            PlacementHalo.GetType().GetProperty("enabled").SetValue(PlacementHalo, true, null); //sets the glow to true
            if (GameManager.Instance.Person.CardDiscarded == false)
            {
                DiscardHalo.GetType().GetProperty("enabled").SetValue(DiscardHalo, true, null); //sets the glow
            }
        }
    }
示例#2
0
 /*
  * @name    DisableHaloGlow()
  * @purpose Once the dragged object is dropped all glowing halos are turned off. this is called at the on end drag method
  *
  * @return  Void
  */
 public void DisableHaloGlow()
 {
     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
         }
     }
 }
示例#3
0
    /*
     * @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
            }
        }
    }