示例#1
0
    void TouchCell(Vector3 position)
    {
        HexCoordinates coordinates = HexCoordinates.FromPosition(position);
        HexCell        cell        = FindCell(coordinates);

        //保存保存下一格数据,方便对比
        NextCell = cell;
        //判断点击格是否是当前格的周围且不能是当前格
        if (((Mathf.Abs(NextCell.coordinates.X - CurrentCell.coordinates.X) + Mathf.Abs(NextCell.coordinates.Y - CurrentCell.coordinates.Y) + Mathf.Abs(NextCell.coordinates.Z - CurrentCell.coordinates.Z)) < 3) &&
            ((NextCell.coordinates.X != CurrentCell.coordinates.X) || (NextCell.coordinates.Z != CurrentCell.coordinates.Z) || (NextCell.coordinates.Y != CurrentCell.coordinates.Y)))
        {
            //if (NextCell.coordinates.X> Math.Ceiling((double)-NextCell.coordinates.Z/2)&& NextCell.coordinates.X < Math.Ceiling((double)16 -NextCell.coordinates.Z / 2)-1
            //    && NextCell.coordinates.Z>0&& NextCell.coordinates.Z<grid.height-1)
            //{
            lastHitPoint = position;
            footCount++;
            //走到新格子就加一
            if (NextCell.status != 3)
            {
                StepCount++;
            }

            cell.color = grid.CellColor[1];
            grid.hexMesh.Triangulate(grid.cells); //以新的颜色重新渲染单元格,每一次只要需要改变格子颜色
                                                  //都需要这句话来重新渲染
            playerPos = cell.transform.position;
            //使被点击格与摄像头Y轴一致并移动
            //Vector3 CellPos = cell.transform.position;
            //CellPos.y = start.transform.position.y;
            //Debug.Log(CellPos);

            //移动
            //start.transform.position = Vector3.MoveTowards(start.transform.position, CellPos, speed * Time.deltaTime); ;
            //更新当前格
            PrintArround(grid.CellColor[0], CurrentCellAround);
            UpdateArround(NextCell, NextCellAround, NextTextAround);
            PrintArround(grid.CellColor[2], NextCellAround);
            PrintCell(grid.CellColor[3], CurrentCell);
            CurrentCell = NextCell;

            //方政言加,为实现网格内容探测
            //gridcontent.CoroutineStop();
            gridcontent.lostAround(CurrentTextAround);
            gridcontent.pass(NextText, NextTextAround);
            gridcontent.detectAround(NextTextAround);
            grid.texts[CurrentText].enabled = false;
            gridcontent.JudgePortal(CurrentText);
            CurrentText = NextText;
            Message.IncidentCheck(gridcontent.contents[CurrentText].con, StepCount);
            //方政言加end

            UpdateArround(CurrentCell, CurrentCellAround, CurrentTextAround);
            PrintCell(grid.CellColor[1], CurrentCell);
            //}
        }
    }
示例#2
0
    private void Awake()
    {
        locked = 0;
        grid   = GameObject.FindWithTag("Grid").GetComponent <HexGrid>();
        //于沛琦加,绑定地图探索text
        MapExplore            = GameObject.FindWithTag("MapExplore").GetComponent <Text>();
        ExplorePic            = GameObject.FindWithTag("ExplorePic").GetComponent <Image>();
        ExplorePic.fillAmount = 0.0f;
        //于沛琦加end
        //方政言加,为实现网格内容探测
        gridcontent = GameObject.FindWithTag("Grid").GetComponent <GridContent>();
        //方政言加end
        camera = GameObject.FindWithTag("MainCamera").GetComponent <CameraController>();
        if (camera == null)
        {
            Debug.Log("camera not set");
        }

        myInput = camera.GetComponent <MyInput>();
        //设定初始格,并修改颜色
        int index;

        //for (int i = 0; i < grid.height; i++)
        //{
        //    if (i == 0 || i == grid.height - 1)
        //    {
        //        for (int j = 0; j < grid.width; j++)
        //        {
        //            index = i * grid.height + j;
        //            Cell = grid.cells[index];
        //            Cell.color = grid.CellColor[4];
        //            grid.hexMesh.Triangulate(grid.cells);
        //        }
        //    }
        //    else
        //    {
        //        index = i * grid.height;
        //        Cell = grid.cells[index];
        //        Cell.color = grid.CellColor[4];
        //        grid.hexMesh.Triangulate(grid.cells);
        //        index = (i + 1) * grid.height - 1;
        //        Cell = grid.cells[index];
        //        Cell.color = grid.CellColor[4];
        //        grid.hexMesh.Triangulate(grid.cells);
        //        grid.hexMesh.Triangulate(grid.cells);
        //    }
        //}
        index             = 2 + 5 * grid.width + 5 / 2;
        CurrentCell       = grid.cells[index];
        CurrentCell.color = grid.CellColor[1];
        grid.hexMesh.Triangulate(grid.cells);
        UpdateArround(CurrentCell, CurrentCellAround, CurrentTextAround);
        PrintArround(grid.CellColor[2], CurrentCellAround);

        playerPos = grid.cells[index].transform.position;
        //方政言加,为实现网格内容探测
        CurrentText = index;
        gridcontent.start(CurrentText, CurrentTextAround);
        gridcontent.detectAround(CurrentTextAround);
        viewportalflag = false;
        viewsiflag     = false;
        //方政言加end
    }