Exemplo n.º 1
0
    /// <summary>
    /// 加载json里面的数据
    /// </summary>
    private void Loadjson()
    {
        string   json     = Resources.Load <TextAsset>("json/pcard").text;
        MuchCard muchCard = JsonMapper.ToObject <MuchCard>(json);

        GameDate.pileList = new List <MapC>();
        foreach (Person a in muchCard.persons)
        {
            GameDate.pileList.Add(a);
        }
        foreach (Prop a in muchCard.props)
        {
            GameDate.pileList.Add(a);
        }
        for (int i = 0; i < GameDate.pileList.Count; i++)
        {
            int index = UnityEngine.Random.Range(0, GameDate.pileList.Count);
            if (index != i)
            {
                MapC temp = GameDate.pileList[i];
                GameDate.pileList[i]     = GameDate.pileList[index];
                GameDate.pileList[index] = temp;
            }
        }

        for (int i = 0; i < GameDate.pileList.Count; i++)
        {
            Debug.Log(GameDate.pileList[i].name);
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 发牌
    /// </summary>
    /// <param name="end"></param>
    private void Deal(Vector3 end)
    {
        GameObject go    = Instantiate <GameObject>(mCard, new Vector3(20, 20, 0), Quaternion.identity);
        int        index = UnityEngine.Random.Range(0, GameDate.pileList.Count);
        MapC       mapC  = GameDate.pileList[index];

        GameDate.pileList.RemoveAt(index);
        MapCard mapCard = go.GetComponent <MapCard>();

        mapCard.Name   = mapC.name;
        mapCard.Sprite = Resources.Load <Sprite>("img/" + mapC.imagePath);
        mapCard.Nature = mapC.nature;
        Tweener tweener = go.transform.DOMove(end, 2f);

        tweener.OnComplete(() => { GameDate.isPlay = false; });
    }