課程
/Unity 3D
/《小十傳奇》 Unity3D 休閑游戲開發
在第五章結束時候并沒有點擊某一列有方塊直接在底部顯示的邏輯,只是調通了play各個子狀態之間的切換,為什么第六章開始就已經存在這些下落邏輯了,讓我們看得好困擾啊……
2015-07-26
源自:《小十傳奇》 Unity3D 休閑游戲開發 6-1
正在回答
剛才自己試著寫了一個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;
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];
buzheteng
input()之類的方法哪去了?
這視頻做的好不負責任啊
input方法沒有講
確實。。。。有點坑爹
同意嗯
舉報
手把手教你用Unity3D開發休閑游戲,小伙伴們,還等什么
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2015-11-04
剛才自己試著寫了一個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;
? ? }
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];
? ? }
2015-11-04
input()之類的方法哪去了?
2015-10-02
這視頻做的好不負責任啊
2015-09-11
input方法沒有講
2015-09-10
確實。。。。有點坑爹
2015-07-27
同意嗯