Example #1
0
                /// <summary>
                /// Actually add a node to the scene.
                /// </summary>
                /// <param name="camera"></param>
                private void DoAddNode(Camera camera)
                {
                    Debug.Assert(fromNode != null);

                    if (inGame.UnderBudget)
                    {
                        if (fromNode != node)
                        {
                            Click(ModeChange.Add);
                            if (node != null)
                            {
                                WayPoint.CreateNewEdge(fromNode, node);
                                fromNode = node;
                            }
                            else
                            {
                                Vector3 pos = AddPosition(camera, fromNode);
                                fromNode = WayPoint.CreateNewNode(fromNode, inGame.shared.curObjectColor, pos);
                            }
                            Changed();
                        }
                        else
                        {
                            mode     = Mode.None;
                            fromNode = null;
                        }
                    }
                    else
                    {
                        Click(ModeChange.NoBudget);
                    }
                }
Example #2
0
                /// <summary>
                /// Actually add a node to the scene.
                /// </summary>
                /// <param name="camera"></param>
                private void DoAddNode(Camera camera)
                {
                    Debug.Assert(fromNode != null);

                    if (inGame.UnderBudget)
                    {
                        if (fromNode != node)
                        {
                            Click(ModeChange.Add);
                            if (node != null)
                            {
                                WayPoint.CreateNewEdge(fromNode, node);
                                fromNode = node;
                            }
                            else
                            {
                                Vector3 pos = AddPosition(camera, fromNode);
                                fromNode = WayPoint.CreateNewNode(fromNode, inGame.shared.curObjectColor, pos);
                                //in touch mode, when we place a new node, have it highlighted, since there is no mouse over equivalent
                                node = fromNode;
                            }
                            Changed();
                        }
                        else if (TouchGestureManager.Get().DoubleTapGesture.WasRecognized)
                        {
                            //allow finish by double tapping selected node
                            node     = null;
                            mode     = Mode.None;
                            fromNode = null;
                        }
                    }
                    else
                    {
                        Click(ModeChange.NoBudget);
                    }
                }
Example #3
0
        }   // end of FromGame()

        /// <summary>
        /// Hand off copies the objects in this XmlLevelData object
        /// into AddThing.
        /// </summary>
        /// <param name="gameThingList"></param>
        public void ToGame(InGame.AddThingDelegate AddThing)
        {
            WayPoint.ClearPaths();

            GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

            // Copy local data to sim classes.

            // Copy waypoint data to sim classes.

            // In with the new.
            for (int i = 0; i < waypoints.paths.Count; i++)
            {
                XmlData.Path  p    = (XmlData.Path)waypoints.paths[i];
                WayPoint.Path path = new WayPoint.Path(p.color);
                path.RoadName = p.roadName;

                // Create nodes.
                for (int j = 0; j < p.nodes.Count; j++)
                {
                    XmlData.Node  n    = (XmlData.Node)p.nodes[j];
                    WayPoint.Node node = new WayPoint.Node(path, new Vector3(n.position, n.height));
                }

                // Create edges.
                for (int j = 0; j < p.edges.Count; j++)
                {
                    XmlData.Edge  e  = (XmlData.Edge)p.edges[j];
                    WayPoint.Node n0 = (WayPoint.Node)path.Nodes[e.node0];
                    WayPoint.Node n1 = (WayPoint.Node)path.Nodes[e.node1];
                    WayPoint.CreateNewEdge(n0, n1, (WayPoint.Edge.Direction)e.direction);
                }

                path.RecalcHeights(onLoad: true);
                if (path.Road != null)
                {
                    path.Road.Build();
                }
            }

            for (int i = 0; i < actor.Count; ++i)
            {
                XmlData.Actor srcActor = (XmlData.Actor)actor[i];
                GameActor     dstActor = ActorFromString(srcActor.typename);
                if (dstActor != null)
                {
                    srcActor.ToActor(dstActor);

                    dstActor = (GameActor)AddThing(dstActor);
                    if (dstActor != null)
                    {
                        // Init InsideGlassWalls.
                        // TODO (****) Right now we're doing this by checking the height of the terrain.
                        // We should also be able to do this by checking the material index BUT it appears
                        // that when we erase terrain we only set the height to 0 without resetting the material.
                        // I think...
                        dstActor.Chassis.InsideGlassWalls = Terrain.GetTerrainAndPathHeight(dstActor.Movement.Position) > 0;
                    }
                }
            }
        }   // end of ToGame()