扫雷小游戏难点总结

扫雷小游戏难点总结:
1 布雷的生成算法
2 难易度调节,离散空间数据靠近程度 <- 这部分基本没做
3 空白区域的递归算法(或队列的搜索)

4 输赢的判断

u3d上, ui为NGUI

代码   部分  ,写得比较乱  也懒得整理了





using UnityEngine;
using System.Collections;
using System;

public class SaoLei2 : MonoBehaviour
{
    public GameObject gamePanel;
    public GameObject ShowLable;

    public GameObject _Qizi;

    public GameObject _Chacha;
    public GameObject ScoreLabel;

    public int BoxWidth = 10;
    public int BoxHeight = 10;
    public int TwohengWidth = 50;

    private int[,] BoxMatrix;

    private Vector3 OriginPoint;//左下角原点

    public GameObject[,] mQizi;

    private int WinnerPlayer = 0;//1圈赢 -1叉赢

    private int TotleBlock;//现在下的步骤0,0
    private int TotleLandmine;//现在下的步骤0,0
    private string scoreStr;
    enum GameState
    {
        MyStep = 0,
        ChaCha = 1,
        GameOver,
    }

    GameState gameState = GameState.MyStep;

    public int landmine = 10;

    void Start()
    {
        TotleBlock = BoxHeight * BoxWidth ; //剩余的格子
        TotleLandmine = landmine;//剩余的旗子
        scoreStr = "left : " + TotleBlock + "      landmine : " + TotleLandmine;

        _Chacha.transform.localPosition = new Vector3(420,192,0);//new Vector3(Screen.width/2 +50 ,Screen.height/2 ,0);

        //左上角为原点
        OriginPoint = new Vector3(-(BoxWidth - 1) * 0.5f * TwohengWidth, -(BoxHeight - 1) * 0.5f * TwohengWidth, 0);

        //儿子
        BoxMatrix = new int[BoxHeight,BoxWidth];//0 表示空,1表示圈,-1表示叉
        mQizi = new GameObject[BoxHeight,BoxWidth];
        for (int i = 0; i < BoxHeight; i++)
        {
            for (int j = 0; j < BoxWidth; j++)
            {
                BoxMatrix[i, j] = 0;
                mQizi[i, j] = Instantiate(_Qizi) as GameObject;
                mQizi[i, j].name = "qizi_" + i + "_" + j;
                mQizi[i, j].transform.parent = _Qizi.transform.parent;
                mQizi[i, j].transform.localPosition = new Vector3(OriginPoint.x + (j) * TwohengWidth, OriginPoint.y + (i) * TwohengWidth, 0);
                mQizi[i, j].transform.localScale = new Vector3(1, 1, 1);
            }
        }
        _Qizi.transform.localPosition = new Vector3(-1000, 0, 0);

        //构建一个雷区
        //取得10个不重复的随机数
        //landmine = 10;
        //将2维展开成1维,
        int[] ran

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值