示例#1
0
文件: Grid3D.cs 项目: Paedow/IPOW
        public void Input_PlaceTower(InputEvent @event)
        {
            if (@event is InputEventMouse)
            {
                InputEventMouse mouseEvent = (InputEventMouse)@event;
                var             ray        = new MouseRay(camera, mouseEvent.GlobalPosition);
                Vector3?        pos        = ray.PositionOnPlane(new Plane(new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 0, 1)));
                if (mouseEvent.ButtonMask == 1 && lastButtonMask == 0)
                {
                    if (GUITools.IsPointOnGUI(world.GetNode(new NodePath("GUI")), mouseEvent.GlobalPosition))
                    {
                        return;
                    }
                    if (pos.HasValue && pos.Value.x > 0 && pos.Value.z > 0)
                    {
                        Vector2 gPos = new Vector2(pos.Value.x, pos.Value.z);
                        gPos.x = (int)(gPos.x);
                        gPos.y = (int)(gPos.y);
                        if (Grid[(int)gPos.x, (int)gPos.y].CanPlaceOn)
                        {
                            Tile tile = (Tile)sceneTower.Instance();
                            SetTile(tile, (int)gPos.x, (int)gPos.y);
                            pathUpdaterGround.Update(GetGrid(MovementLayer.Ground), endPoints);
                        }
                    }
                }

                if (pos.HasValue)
                {
                    Vector3 iPos = new Vector3(
                        ((int)pos.Value.x),
                        ((int)pos.Value.y),
                        ((int)pos.Value.z));
                    glowTile.Translation  = iPos;
                    placeTile.Translation = iPos;
                    if (iPos.x < 0 || iPos.z < 0 || iPos.x >= Width || iPos.z >= Height)
                    {
                        glowTile.Visible = false;
                    }
                    else
                    {
                        glowTile.Visible = true;
                        Tile t = Grid[(int)iPos.x, (int)iPos.z];
                        if (t.CanPlaceOn)
                        {
                            glowTile.Call("blue");
                        }
                        else
                        {
                            glowTile.Call("red");
                        }
                    }
                }

                lastButtonMask = mouseEvent.ButtonMask;
            }
        }
示例#2
0
文件: TestGrid.cs 项目: Paedow/IPOW
        public void UpdateGrid()
        {
            /*PathFinder pf = new PathFinder(this, true);
             * pf.Reset();
             * foreach(PointI endP in end)
             *      pf.CalcHops(endP);*/
            pathUpdater.Update(end);

            /*paths.Clear();
             * splinePaths.Clear();
             * foreach(PointI startP in start)
             * {
             *      PointI[] path;
             *      pf.FindPath(out path, startP);
             *      paths.Add(path);
             *      splinePaths.Add(new Spline.Path(path, gridSize, new Vector2(1,1)*gridSize/2f,Spline.InterpolationType.Qubic));
             * }*/
            Update();
        }