【U3D】斗地主

 

设计人:刘莹

 

由于时间太短,

 

游戏运行开始 【开始游戏】

wKiom1UA59PxnZjGAAaIp6-QsKY257.jpg

 

 

 

 

开始游戏 【倒计时出牌】

 

wKioL1UA6Ufz-IGiAAeBfQNGwRk128.jpg

 

 

点击【出牌】

wKioL1UA6bPARFtPAAeEyONNNjM938.jpg

 

设计界面

wKioL1UA6ivjilzTAAbKE1WCrcs073.jpg

 

    /// <summary>
    /// 操作牌
    /// </summary>
    private void GetPuke()
    {
        i++;//出牌顺序控制变量
        int k = Random.Range(0, Globe.pukeList.Count);//随机数0-54
        #region 分割列表内数据
        string value = Globe.pukeList[k].ToString();//取出牌的数据
        string[] str = value.Split(',');//分割
        string pukePaizhi = str[2];//取出牌值
        string pukeHuase = str[0];//取出花色
        string pukeValues = str[1];//取出点数
        #endregion
        Globe.pukeList.RemoveAt(k);//移除数据
        if (Globe.pukeList.Count == 3)//取消调用
        {
            CancelInvoke("GetPuke");
        }
        GameObject pukes = (GameObject)Instantiate(Resources.Load("puke"));//克隆出牌       
        pukes.AddComponent("PukeMoverController");//添加脚本
        pukes.GetComponent<PukeMoverController>()._value = pukeValues;
        pukes.GetComponent<PukeMoverController>()._type = pukeHuase;

        #region 深度、花色控制
        ForClass(pukePaizhi, pukeHuase, pukes);//改变花色
        for (int d = 0; d < pukes.transform.childCount; d++)//循环控制深度
        {
            pukes.transform.GetChild(d).GetComponent<UISprite>().depth = i + 1;//子物体深度+1
        }

        if (i % 3 == 1 || i % 3 == 2)//判断生成牌的位置
        {
            pukes.GetComponent<UISprite>().spriteName = "HLDDZ_MainGame0_2x_197";//改变为暗牌
            pukes.GetComponent<UIButton>().normalSprite = "HLDDZ_MainGame0_2x_197";//改变为暗牌
            pukes.GetComponent<UISprite>().depth = i + 2;//深度大于子物体深度
            pukes.GetComponent<BoxCollider>().enabled = false;
            pukes.GetComponent<UIButton>().enabled = false;
        }
        else
        {
            pukes.GetComponent<UISprite>().depth = i;//深度为i
           
        }
        #endregion

        #region 发牌位置
        if (i % 3 == 0)
        {
            _pukePos1.x -= 30;//位置递增             
            pukes.transform.parent = _pukePanel1;//转换为_pukePos1的子物体
            pukes.transform.localPosition = new Vector3(-_pukePos1.x, _pukePos1.y, _pukePos1.z);//pukes的自身坐标改变
            pukes.transform.localScale = new Vector3(1, 1, 1);//pukes的自身大小还原为1
            pukes.GetComponent<UISprite>().depth = i;//改变克隆牌的深度
        }
        else if (i % 3 == 1)
        {
            _pukePos2.x += 6;//位置递增
            _pukePos2.y += 6;//位置递增
            pukes.transform.parent = _pukePanel2;//转换为_pukePos2的子物体
            pukes.transform.localPosition = new Vector3(-_pukePos2.x, -_pukePos2.y, _pukePos2.z);//pukes的自身坐标改变
            pukes.transform.Rotate(0, 0, -45);//旋转45°
            pukes.transform.localScale = new Vector3(1, 1, 1);//pukes的自身大小还原为1
        }
        else if (i % 3 == 2)
        {
            _pukePos3.x -= 6;//位置递减
            _pukePos3.y += 6;//位置递增
            pukes.transform.parent = _pukePanel3;//转换为_pukePos3的子物体
            pukes.transform.localPosition = new Vector3(-_pukePos3.x, -_pukePos3.y, _pukePos3.z);//pukes的自身坐标改变
            pukes.transform.Rotate(0, 0, 45);//旋转45°
            pukes.transform.localScale = new Vector3(1, 1, 1);//pukes的自身大小还原为1
        }
        #endregion

        if (i==51)
        {
            CallDiZhu();
        }
    }

 

 

 

    /// <summary>
    /// 选择抢地主的人
    /// </summary>
    /// <param name="_id"></param>
    public void SelectPeople(string _id)
    {
        for (int j = 0; j < transform.childCount; j++)
        {
            if (transform.GetChild(j).GetComponent<PeopleController>().Id==_id)
            {
                //计时器启动
                transform.GetChild(j).Find("Clock").gameObject.SetActive(true);
                //计时器状态
                transform.GetChild(j).Find("Clock").GetComponent<StopwatchController>().stopWatchState = true;
               
                //启动计时器
                transform.GetChild(j).Find("Clock").GetComponent<StopwatchController>().Open();

                //抢地主决定行为
                StartCoroutine(transform.GetChild(j).GetComponent<PeopleController>().JueDing());
            }
        }
    }

 

 

 

 

 

 

 

 

你可能感兴趣的:(斗地主)