为了账号安全,请及时绑定邮箱和手机立即绑定

第五章与第六章之间有点跳跃啊

在第五章结束时候并没有点击某一列有方块直接在底部显示的逻辑,只是调通了play各个子状态之间的切换,为什么第六章开始就已经存在这些下落逻辑了,让我们看得好困扰啊……

正在回答

6 回答

刚才自己试着写了一个input()方法:

    private void input(int column)

    {

        Debug.Log("点击了按钮:" + column);

        //点击某一列,在列的顶端生成一个随机数字显示出来

        //在模型层修改该列顶端方块的数据

        //取得模型层的一个方块

        SquareModel m = _model.GetSquareModel(0, column);

        if (!m.isEnabled)

        {

            //如果这个方块没有被显示,生成并显示

            m.number = Random.Range(1, 10);

            m.isEnabled = true;

            Square s = _view.play.GetSquare(0, column);

            s.number = m.number;

            s.Show();

            

            //播放下落的动画

            //播放时将顶部的方块隐藏

            s.Hide();


            //到底部显示出来

            m.isEnabled=ShowAtBottom(m,column);

        }

    }

    private bool ShowAtBottom(SquareModel m,int column)

    {

        //从底部开始,检测是否已有方块

        for (int row = 6; row >= 0; row--)

        {

            SquareModel temp = _model.GetSquareModel(row, column);

            //如果在column列,从下往上的某一row没有方块,则将方块放入该位置

            if (!temp.isEnabled)

            {

                temp.number = m.number;

                temp.isEnabled = true;

                Square s = _view.play.GetSquare(row, column);

                s.number = temp.number;

                s.Show();


                //如果方块下落、放入成功,返回False

                return false;

            }

        }

        return true;

    }

http://img1.sycdn.imooc.com//563a111300018de211361050.jpg

Model.cs类里的方法:

public class Model : MonoBehaviour

{

    public SquareModel[] list = null;

    public int column = 4;

    public int row = 7;

    public SquareModel GetSquareModel(int row, int column)

    {

        int index = row * 4 + column;

        return list[index];

    }

}

Play.cs类里的方法:

    public Square GetSquare(int row, int column)

    {

        int index = row*4 + column;

        return list_[index];

    }


0 回复 有任何疑惑可以回复我~
#1

buzheteng

SquareModel.cs [Serializable] public class SquareModel { public int number = 0; public bool isEnabled = false; }
2015-11-04 回复 有任何疑惑可以回复我~

input()之类的方法哪去了?

0 回复 有任何疑惑可以回复我~

这视频做的好不负责任啊

0 回复 有任何疑惑可以回复我~

input方法没有讲

0 回复 有任何疑惑可以回复我~

确实。。。。有点坑爹

0 回复 有任何疑惑可以回复我~

同意嗯



0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
《小十传奇》 Unity3D 休闲游戏开发
  • 参与学习       40232    人
  • 解答问题       123    个

手把手教你用Unity3D开发休闲游戏,小伙伴们,还等什么

进入课程

第五章与第六章之间有点跳跃啊

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信