Ejemplo n.º 1
0
    // METHODS

    // MONOBEHAVIOUR METHODS (mouse over collider detection)
    void Awake()
    {
        Instance     = this;
        col          = GetComponent <BoxCollider>();
        rightSlotCol = rightSlot.GetComponent <BoxCollider>();
        leftSlotCol  = leftSlot.GetComponent <BoxCollider>();

        /*if (owner == AreaPosition.Top) { ownerPlayer = Player.Players[0]; }
         * else if (Player.Players.Length > 1)
         * {
         *  ownerPlayer = Player.Players[1];
         * }*/
        ownerPlayer = Player.Instance;
    }
    // private CreatureLogic _selectedCreatureLogic;

    // Update is called once per frame
    void Update()
    {
        Ray        ray = mainCamera.ScreenPointToRay(Input.mousePosition);
        RaycastHit hitInfo;

        // Does ray hit something? Fill hitInfo.
        if (Physics.Raycast(ray, out hitInfo))
        {
            IDHolder hitIDHolder = hitInfo.collider.transform.parent.gameObject.GetComponent <IDHolder>();

            if (hitIDHolder == null)
            {
                Debug.Log("Mouse Over Something Without ID");
            }
            else
            {
                TableVisual tableVisual = TurnManager.instance.whoseTurn.playerVisual.tableVisual;

                GameObject result = null;
                // Check who this ID belongs to
                if (tableVisual.tileGameObjectsByID.TryGetValue(hitIDHolder.uniqueID, out result))                   // ID belongs to a Tile
                {
                    MouseOverTile(result.GetComponent <Tile>());
                }
                else if (tableVisual.creatureGameObjectsByID.TryGetValue(hitIDHolder.uniqueID, out result))                     // ID belongs to a Creature
                {
                    MouseOverCreature(hitIDHolder.uniqueID);
                }
            }
        }

        if (Input.GetMouseButtonDown(1) && GlobalSettings.instance.CanControlThisPlayer(TurnManager.instance.whoseTurn))
        {
            TurnManager.instance.whoseTurn.cardToBeSummoned = null;
        }
    }