Esempio n. 1
0
    void HoverAction()
    {
        Ray        camRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit mouseHit;
        int        id       = -1;
        selectable type     = selectable.none;
        CityBlock  block    = null;
        Building   building = null;
        Human      human    = null;

        if (EventSystem.current.IsPointerOverGameObject() == false &&
            Physics.Raycast(camRay, out mouseHit, 100f, LayerMask.GetMask("Clickable")))
        {
            gridMousePosition.x = Mathf.FloorToInt(mouseHit.point.x);
            gridMousePosition.y = Mathf.FloorToInt(mouseHit.point.z);

            human = mouseHit.collider.GetComponent <Human>();
            if (human != null)
            {
                id   = human.id;
                type = selectable.hero;
            }
            else
            {
                block    = mouseHit.collider.transform.parent.GetComponent <CityBlock> ();
                building = mouseHit.collider.transform.parent.GetComponent <Building> ();

                if (block != null)
                {
                    type = selectable.streetTile;
                    id   = block.GetTileId(gridMousePosition % block.width);
                }
                else if (building != null)
                {
                    block = building.GetComponentInParent <CityBlock> ();
                    if (building.ShowingInteriorView() == true)
                    {
                        type = selectable.buildingTile;
                        id   = building.GetTileId(gridMousePosition % block.width);
                    }
                    else
                    {
                        type = selectable.building;
                        id   = building.id;
                    }
                }
            }
        }

        if (type != hoveredType || id != hoveredID || block != hoveredBlock || building != hoveredBuilding)
        {
            SwitchHovered(false);
            hoveredType     = type;
            hoveredID       = id;
            hoveredBlock    = block;
            hoveredBuilding = building;
            SwitchHovered(true);
        }
    }
Esempio n. 2
0
    // Start is called before the first frame update
    void Start()
    {
        List <string> deck = GMScript.CreateDeck();

        gm  = FindObjectOfType <GMScript>();
        SSC = FindObjectOfType <SortingAndSetCreating>();
        SOG = FindObjectOfType <MyGameStates>();
        ET  = FindObjectOfType <EnemyTest>();
        int i = 0;

        foreach (string card in deck)
        {
            if (this.name == card)
            {
                Cardfaces = gm.Cards[i];

                break;
            }
            i++;
        }
        Sprender   = GetComponent <SpriteRenderer>();
        selectable = GetComponent <selectable>();
    }