Example #1
0
    public void OnNewGridCard(Card card, GridSpot spot)
    {
        GridCardUI newCardUI = Instantiate(gridCardUIModel.gameObject, gridCardUIModel.transform.parent).GetComponent <GridCardUI>();

        newCardUI.gameObject.SetActive(true);
        newCardUI.Init(card, spot);
        newCardUI.transform.localPosition = spot.transform.localPosition;
        spot.OnEntityEnters(newCardUI);
    }
Example #2
0
    // Start is called before the first frame update
    void Start()
    {
        spots = new GridSpot[size][];
        for (int i = 0; i < size; i++)
        {
            spots[i] = new GridSpot[size];
        }

        float canvasSize = GetComponent <RectTransform>().rect.width /*.sizeDelta.x*/ - margin;

        GridSpot spotModel = GetComponentInChildren <GridSpot>();

        float spotDefaultSize = spotModel.GetComponent <RectTransform>().sizeDelta.x;
        float spotScale       = canvasSize / (size * spotDefaultSize);

        for (int i = 0; i < size; i++)
        {
            for (int j = 0; j < size; j++)
            {
                GridSpot spot = spotModel;
                if (i > 0 || j > 0)
                {
                    spot = Instantiate(spotModel.gameObject, spotModel.transform.parent).GetComponent <GridSpot>();
                }
                spot.transform.localPosition = new Vector3(i + 0.5f - size / 2f, j + 0.5f - size / 2f, 0f) * canvasSize / size;
                spot.transform.localScale    = Vector3.one * spotScale;
                spots[i][j] = spot;
                spot.Init(i, j);
            }
        }

        fightCreatureModel = GetComponentInChildren <FightCreature>();
        fightCreatureModel.transform.localScale = Vector3.one * spotScale;
        fightCreatureModel.gameObject.SetActive(false);

        gridCardUIModel = GetComponentInChildren <GridCardUI>();
        gridCardUIModel.transform.localScale = Vector3.one * spotScale;
        gridCardUIModel.gameObject.SetActive(false);

        gridFeedbackManager.transform.localScale = Vector3.one * spotScale;
    }