예제 #1
0
파일: SolveInput.cs 프로젝트: SSSSShark/May
    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);
            //}
        }
    }