private static void PrintActor(StringBuilder sb, XActor actor, Game game) { sb.AppendLine($"==={actor.name}==="); sb.AppendLine($"{actor.Description}<br />"); sb.AppendLine($"Id: {actor.id}<br />"); sb.AppendFormat("Object{0}: {1}<br />", (actor.Objects.Object.Count > 1) ? "s" : "", string.Join(", ", actor.Objects.Object)); sb.AppendLine(); PrintComments(sb, actor.Comment); if (actor.Variables.Count > 0) { sb.AppendLine("<br />"); } foreach (XVariable var in actor.Variables) { PrintVariable(sb, var, game); } if (!string.IsNullOrEmpty(actor.CommentOther)) { sb.AppendLine(); PrintComments(sb, actor.CommentOther); } }
public override void LoadFromXML(System.Xml.XmlNode node, ListView scene, ref Dictionary <uint, List <uint> > Depends) { XTools tools = new XTools(X); XActor actor = new XActor(ref X, null, tools.ParseXMLVector3(node.Attributes["Translation"].InnerText), tools.ParseXMLVector3(node.Attributes["Velocity"].InnerText), float.Parse(node.Attributes["Mass_editor"].InnerText)); actor.AutoDraw = bool.Parse(node.Attributes["AutoDraw"].InnerText); actor.DrawOrder = int.Parse(node.Attributes["DrawOrder"].InnerText); actor.Immovable = bool.Parse(node.Attributes["Immovable"].InnerText); actor.Rotation = tools.ParseXMLQuaternion(node.Attributes["Rotation"].InnerText); actor.ComponentID = uint.Parse(node.Attributes["ComponentID"].InnerText); actor.Name = node.Attributes["Name"].InnerText; actor.Scale = tools.ParseXMLVector3(node.Attributes["Scale"].InnerText); actor.CollisionEnabled = bool.Parse(node.Attributes["CollisionEnabled"].InnerText); List <uint> dep = new List <uint>(); dep.Add(uint.Parse(node.Attributes["model_editor"].InnerText)); Depends.Add(actor.ComponentID, dep); X_Editor.Tools.AddXComponentToSceneList(scene, actor, group); }
//private void NewVariableDefinition(GroupCollection groupCollection, XVariable currentVariable) //{ // //Groups: // //Mask type, Mask, Description // currentVariable.maskType = groupCollection[1].Value; // currentVariable.mask = groupCollection[2].Value; // currentVariable.Description = groupCollection[3].Value.Trim(); //} private void NewActorDefinition(GroupCollection groupCollection, XActor currentActor) { //Groups: //actor id hex, object id hex, description (includes multiple objects) currentActor.id = groupCollection[1].Value; currentActor.Objects.Object.Add(groupCollection[2].Value); currentActor.Description = groupCollection[3].Value.Trim(); }
public override ListViewItem SetupListViewItem(ListViewItem item, XComponent component) { XActor actor = new XActor(ref X, null, Vector3.Zero, Vector3.Zero, 1); actor.NoCull = true; actor.Immovable = true; return(base.SetupListViewItem(item, actor)); }
public XActorParser(XActor actor, Game game) { this.game = game; Description = actor.Description; foreach (var item in actor.Variables) { Variables.Add(new XVariableParser(item, game)); } }
private XVariable NoMaskSet(XActor currentActor) { XVariable r = new XVariable(); currentActor.Variables.Add(r); //r.maskType = MaskType.And; //r.mask = "FFFF"; r.Description = "#N/A"; return(r); }
private string expandEmptyTag(string text, int cursor) { int newCursor; int startReplace; int lengthReplace; string replaceWith; XActor.ExpandEmptyTag(text, cursor, out newCursor, out startReplace, out lengthReplace, out replaceWith); return(Replace(text, startReplace, lengthReplace, replaceWith)); }
private void SetActor(XActor actor) { Actor = actor; this.flowLayoutPanel.Controls.Clear(); actorLabel.Text = $"Actor {Actor.id}: {Actor.Description}"; objectsLabel.Text = $"Objects: {string.Join(", ", Actor.Objects.Object)}"; Control commentLabel = this.CreateCommentControl(4); commentLabel.Text = SetComment(Actor.Comment, Actor.CommentOther); flowLayoutPanel.Controls.Add(commentLabel); foreach (var item in Actor.Variables) { //actor.Variables if (!(item.UI.Item is UINone)) // UITypes.none { BaseControl control; switch (item.UI.Item) { case UISelect c /*UITypes.select*/: control = new SelectControl(); break; case UISwitchFlag c /*UITypes.switchflag*/: control = new FlagsControl(); break; case UICollectFlag c /*UITypes.collectflag*/: control = new FlagsControl(); break; case UIChestFlag c /*UITypes.chestflag*/: control = new FlagsControl(); break; default: control = new NumControl(); break; } control.Dock = DockStyle.Fill; control.SetUi(item); flowLayoutPanel.Controls.Add(control); } else { //pass default value } if (item.Comment != null) { Label comment = new Label(); comment.MinimumSize = new Size(350, 0); comment.Text = item.Comment; flowLayoutPanel.Controls.Add(comment); } } //test.SetUi(actor.Variables[0]); //actorPanel.Controls.Add(test); }
private void SetActor(XActor actor) { Actor = actor; this.flowLayoutPanel.Controls.Clear(); actorLabel.Text = string.Format("Actor {0}: {1}", Actor.id, Actor.Description); objectsLabel.Text = string.Format("Objects: {0}", string.Join(", ", Actor.Objects.Object)); Control commentLabel = this.CreateCommentControl(4); commentLabel.Text = SetComment(Actor.Comment, Actor.CommentOther); flowLayoutPanel.Controls.Add(commentLabel); foreach (var item in Actor.Variables) { if (item.UI.name != UITypes.none) { BaseControl control; switch (item.UI.name) { case UITypes.select: control = new SelectControl(); break; case UITypes.switchflag: control = new FlagsControl(); break; case UITypes.collectflag: control = new FlagsControl(); break; case UITypes.chestflag: control = new FlagsControl(); break; default: control = new NumControl(); break; } control.Dock = DockStyle.Fill; control.SetUi(item); flowLayoutPanel.Controls.Add(control); } else { //pass default value } if (item.Comment != null) { Label comment = new Label(); comment.MinimumSize = new Size(350, 0); comment.Text = item.Comment; flowLayoutPanel.Controls.Add(comment); } } //test.SetUi(actor.Variables[0]); //actorPanel.Controls.Add(test); }
public override void UpdateObjectProperties(object Input, PropertyGrid Properties, ListView Scene) { XActor actor = (XActor)Input; if ((actor.PhysicsObject == null) || (actor.PhysicsObject.PhysicsSkin == null) || actor.PhysicsObject.PhysicsSkin.NumPrimitives <= 0) //this XActor we created or model we loaded does not have any collision primitives we can't continue to render this~ { //X.Components.Remove(actor); MessageBox.Show("The XActor " + actor.Name + " ID: " + actor.ComponentID.ToString() + " Does not have a Collision Skin defined. Cannot load into XEngine at this time!", "Missing Component"); return; } base.UpdateObjectProperties(Input, Properties, Scene); }
public override void AssignChildComponents(XComponent parent, ref List <uint> children) { if (children.Count == 1) { XActor xparent = (XActor)parent; XModel child = (XModel)X.Tools.GetXComponentByID(children[0]); if (child.GetType() == typeof(XModel)) { xparent.model_editor = child; xparent.RebuildCollisionSkin(); } } }
void BeOnStage(object o) { XActor target = null; XActorDataClip clip = o as XActorDataClip; if (clip.bUsingID) { target = new XActor((uint)clip.StatisticsID, clip.AppearX, clip.AppearY, clip.AppearZ, clip.Clip); } else { target = new XActor(clip.Prefab, clip.AppearX, clip.AppearY, clip.AppearZ, clip.Clip); } _actors.Add(target); }
private bool completeOnCtrlSpace() { if (XParser.IsInsideComment(_editor.Text, _editor.CaretOffset)) { IList <ICompletionData> data = new List <ICompletionData>(); data.Add(new MyCompletionData("-->")); showCompletion(data); return(true); } if (XParser.IsInsideEmptyElement(_editor.Text, _editor.CaretOffset)) { //replace <test/> --> <test></test> IList <ICompletionData> data = new List <ICompletionData>(); data.Add(new ActionCompletionData("Expand empty tag", null, (textArea, completionSegment, eventArgs) => { int newCursor; int startReplace; int lengthReplace; string replaceWith; XActor.ExpandEmptyTag(_editor.Text, _editor.CaretOffset, out newCursor, out startReplace, out lengthReplace, out replaceWith); textArea.Document.Replace(startReplace, lengthReplace, replaceWith); _editor.CaretOffset = newCursor; })); showCompletion(data); return(true); } { bool result = checkAttributeCompletion(); if (result) { return(true); } } return(false); }
private static void PrintActor(StringBuilder sb, XActor actor) { sb.AppendLine($"Actor: {actor.id} {actor.name}"); sb.AppendLine($"Identity: {actor.Description}"); sb.AppendFormat("Object{0}: {1}", (actor.Objects.Object.Count > 1) ? "s" : "", string.Join(", ", actor.Objects.Object)); sb.AppendLine(); PrintComments(sb, actor.Comment); if (actor.Variables.Count > 0) { sb.AppendLine("Variables:"); } foreach (XVariable var in actor.Variables) { string varType = GetCaptureVarType(var.Capture); //if (varType != "v") //{ // sb.AppendLine(); // if (varType == "rx") // { // sb.AppendLine("X Rotation:"); // } // else if (varType == "ry") // { // sb.AppendLine("Y Rotation:"); // } // else if (varType == "rz") // { // sb.AppendLine("Z Rotation:"); // } // else // sb.AppendLine("//GENERR"); //} PrintVariable(sb, var); } if (!string.IsNullOrEmpty(actor.CommentOther)) { sb.AppendLine(); PrintComments(sb, actor.CommentOther); } }
public override void WriteToXML(System.Xml.XmlWriter writer, object obj) { XActor actor = (XActor)obj; writer.WriteStartElement("sceneitem"); writer.WriteAttributeString("Type", actor.GetType().ToString()); writer.WriteAttributeString("ComponentID", actor.ComponentID.ToString()); writer.WriteAttributeString("AutoDraw", actor.AutoDraw.ToString()); writer.WriteAttributeString("Name", actor.Name); writer.WriteAttributeString("DrawOrder", actor.DrawOrder.ToString()); writer.WriteAttributeString("Immovable", actor.Immovable.ToString()); writer.WriteAttributeString("Mass_editor", actor.Mass.ToString()); writer.WriteAttributeString("model_editor", actor.model_editor.ComponentID.ToString()); writer.WriteAttributeString("Rotation", actor.Rotation.ToString()); writer.WriteAttributeString("Translation", actor.Translation.ToString()); writer.WriteAttributeString("Scale", actor.Scale.ToString()); writer.WriteAttributeString("Velocity", actor.Velocity.ToString()); writer.WriteAttributeString("CollisionEnabled", actor.CollisionEnabled.ToString()); writer.WriteEndElement(); }
public static XActors ParseLines(string[] lines) { XActors root = new XActors(); XActor curActor = null; XVariable curVariable = null; //assume lines are trimmed foreach (var line_untrimmed in lines) { string line = line_untrimmed.Trim(); if (line.StartsWith("==A") || line.StartsWith("Variables:")) //do nothing { continue; } if (line.StartsWith("===0")) //new actor { curActor = new XActor() { id = line.Substring(3, 4) }; root.Actor.Add(curActor); } else if (line.StartsWith("Identity:")) //name { curActor.Description = line.Substring(9).Trim(); } else if (line.StartsWith("Objects:")) { curActor.Objects = new XObjects(); curActor.Objects.Object.Add(line.Substring(8).Trim()); } else if (line.StartsWith("Notes:")) { var comment = line.Substring(6).Trim(); if (comment.Length > 0) { curActor.Comment = comment; } } else if (line.ToLower().StartsWith("x rot:") || line.ToLower().StartsWith("y rot:") || line.ToLower().StartsWith("z rot:")) //capture { string vType = line[0].ToString().ToLower(); string desc = line.Substring(6).Trim(); curVariable = new XVariable() { Capture = $"r{vType} &>> 0x1FF", Description = desc, }; curActor.Variables.Add(curVariable); } else if (line.StartsWith("&")) //new variable { var extract = MaskLine.Match(line); curVariable = new XVariable() { Capture = $"v {extract.Groups[1].Value}>> 0x{extract.Groups[2].Value}", Description = extract.Groups[3].ToString() }; curActor.Variables.Add(curVariable); } else //variable value { var extract = ValueLine.Match(line).Groups; var value = new XVariableValue() { Description = extract[4].ToString(), Data = extract[1].ToString() }; if (extract[2].ToString() == "+") { value.repeat = "+"; } curVariable.Value.Add(value); } } return(root); }
/// <summary> /// Processes user input updates /// </summary> /// <param name="gameTime"></param> public void Update(GameTime gameTime) { if (keyboard.KeyPressed(Keys.OemTilde)) { X.Console.Visible = !X.Console.Visible; } //if console is showing capture all input! if (X.Console.Visible) { X.Console.AcceptInput(keyboard); //return; } // Allows the game to exit //if (gamepad.ButtonDown(Buttons.B)) // parent.Exit(); if (keyboard.KeyPressed(Keys.Escape)) { //toggle physics on/off X.UpdatePhysics = !X.UpdatePhysics; //toggle game menu on/off parent.menus.Toggle(); } if (parent.menus.MenuOpen) { if (keyboard.KeyPressed(Keys.Up)) { parent.menus.SelectPrevious(); } if (keyboard.KeyPressed(Keys.Down)) { parent.menus.SelectNext(); } if (keyboard.KeyPressed(Keys.Enter)) { switch (parent.menus.Current) { case 2: //exit button parent.Exit(); break; default: break; } } return; } //drive car //TODO: Fix the retarded classes here, car is way to many level deep???? or something OMG if (parent.Car != null) { if (keyboard.KeyDown(Keys.Up) || keyboard.KeyDown(Keys.Down)) { if (keyboard.KeyDown(Keys.Up)) { parent.Car.Car.Car.Accelerate = 1.0f; } else { parent.Car.Car.Car.Accelerate = -1.0f; } } else { parent.Car.Car.Car.Accelerate = 0.0f; } if (keyboard.KeyDown(Keys.Left) || keyboard.KeyDown(Keys.Right)) { if (keyboard.KeyDown(Keys.Left)) { parent.Car.Car.Car.Steer = 1.0f; } else { parent.Car.Car.Car.Steer = -1.0f; } } else { parent.Car.Car.Car.Steer = 0.0f; } if (keyboard.KeyDown(Keys.B)) { parent.Car.Car.Car.HBrake = 1.0f; } else { parent.Car.Car.Car.HBrake = 0.0f; } } //Mouse code #if !XBOX parent.freeCamera.Rotate(new Vector3(mouse.Delta.Y * .0016f, mouse.Delta.X * .0016f, 0)); parent.driverCamera.Rotate(new Vector3(mouse.Delta.Y * .0016f, mouse.Delta.X * .0016f, 0)); if (mouse.ButtonPressed(XMouse.Buttons.Left)) { //parent.boxes.Add(new XActor(ref X, parent.model, parent.freeCamera.Position, Vector3.Normalize(parent.freeCamera.Target - parent.freeCamera.Position) * 30, 10)); if (parent.planeActor != null) { parent.planeActor.Disable(); } parent.planeActor = new XActor(ref X, parent.model, parent.freeCamera.Position, Vector3.Normalize(parent.freeCamera.Target - parent.freeCamera.Position) * 30, 10); } if (mouse.ButtonPressed(XMouse.Buttons.Right)) { XProp prop = new XProp(ref X, new XModel(ref X, @"Content\Models\tv"), parent.currentCamera.Position, Vector3.Zero, Matrix.Identity, Vector3.One); prop.Load(X.Content); } #endif //GAME PAD Controls if (gamepad.State(XGamePad.States.Current).IsConnected == true) { parent.freeCamera.Rotate(new Vector3((gamepad.Thumbstick(XGamePad.Thumbsticks.Right).Y * .5f) * (float)gameTime.ElapsedGameTime.TotalSeconds, (-gamepad.Thumbstick(XGamePad.Thumbsticks.Right).X * .5f) * (float)gameTime.ElapsedGameTime.TotalSeconds, 0)); if (gamepad.ButtonPressed(Buttons.A)) { parent.planeActor = new XActor(ref X, parent.model, parent.freeCamera.Position, Vector3.Normalize(parent.freeCamera.Target - parent.freeCamera.Position) * 30, 300); } parent.Car.Car.Car.Accelerate = gamepad.Trigger(XGamePad.Triggers.Left); parent.Car.Car.Car.Steer = gamepad.Thumbstick(XGamePad.Thumbsticks.Left).X * -1; parent.Car.Car.Car.HBrake = gamepad.Trigger(XGamePad.Triggers.Right); //Gamepad driving controls X.Debug.Write("LS: X:" + gamepad.Thumbstick(XGamePad.Thumbsticks.Left).X.ToString() + " Y:" + gamepad.Thumbstick(XGamePad.Thumbsticks.Left).Y.ToString(), false); X.Debug.Write("RS: X:" + gamepad.Thumbstick(XGamePad.Thumbsticks.Right).X.ToString() + " Y:" + gamepad.Thumbstick(XGamePad.Thumbsticks.Right).Y.ToString(), false); X.Debug.Write("LT: " + gamepad.Trigger(XGamePad.Triggers.Left).ToString(), false); X.Debug.Write("RT: " + gamepad.Trigger(XGamePad.Triggers.Right).ToString(), false); } //Camera Movement with KB or Gamepad directional pad float speed = 40f; if (keyboard.KeyDown(Keys.LeftShift)) { speed = 2f; } if (keyboard.KeyDown(Keys.LeftControl)) { speed = 200f; } if (keyboard.KeyDown(Keys.W) || gamepad.ButtonDown(Buttons.DPadUp)) { parent.freeCamera.Translate(Vector3.Forward * speed); } if (keyboard.KeyDown(Keys.S) || gamepad.ButtonDown(Buttons.DPadDown)) { parent.freeCamera.Translate(Vector3.Backward * speed); } if (keyboard.KeyDown(Keys.A) || gamepad.ButtonDown(Buttons.DPadLeft)) { parent.freeCamera.Translate(Vector3.Left * speed); } if (keyboard.KeyDown(Keys.D) || gamepad.ButtonDown(Buttons.DPadRight)) { parent.freeCamera.Translate(Vector3.Right * speed); } //write camera corrds for debug X.Debug.Write("Free Camera: X" + parent.freeCamera.Position.X.ToString() + " Y:" + parent.freeCamera.Position.Y.ToString() + " Z:" + parent.freeCamera.Position.Z.ToString(), false); X.Debug.Write("Driver Camera: X" + parent.driverCamera.Position.X.ToString() + " Y:" + parent.driverCamera.Position.Y.ToString() + " Z:" + parent.driverCamera.Position.Z.ToString(), false); X.Debug.Write("Box Actors in List:" + parent.boxes.Count.ToString(), false); if (keyboard.KeyPressed(Keys.F1)) { } //if (keyboard.KeyDown(Keys.F2)) //parent.sky.Theta -= .5f * (float)gameTime.ElapsedGameTime.TotalSeconds; if (keyboard.KeyPressed(Keys.F3)) { if (parent.water == null) { parent.water = new XWater(ref X, new Vector2(-128, -128), new Vector2(128 * 2, 128 * 2), 3f); parent.water.Load(parent.Content); parent.water.Update(ref gameTime); parent.resources.AddComponent(parent.water); } XWaterFast water = new XWaterFast(ref X, @"Content\XEngine\Textures\Sky\GreenWaterSky"); water.basePosition = new Vector3(0, 1.5f, 0); water.Load(X.Content); } if (keyboard.KeyPressed(Keys.E)) { if (parent.water != null) { parent.water.DoesReflect = !parent.water.DoesReflect; } } if (keyboard.KeyPressed(Keys.R)) { if (parent.water != null) { parent.water.DoesRefract = !parent.water.DoesRefract; } } if (parent.water != null) { //WindDirection if (keyboard.KeyDown(Keys.NumPad4)) { parent.water.WindDirection -= .25f; } if (keyboard.KeyDown(Keys.NumPad6)) { parent.water.WindDirection += .25f; } //WaveHeight if (keyboard.KeyDown(Keys.NumPad2)) { parent.water.WaveHeight -= .01f; } if (keyboard.KeyDown(Keys.NumPad8)) { parent.water.WaveHeight += .01f; } //Wave Length if (keyboard.KeyDown(Keys.NumPad7)) { parent.water.WaveLength -= .01f; } if (keyboard.KeyDown(Keys.NumPad9)) { parent.water.WaveLength += .01f; } //Wind Force if (keyboard.KeyDown(Keys.NumPad1)) { parent.water.WindForce -= .05f; } if (keyboard.KeyDown(Keys.NumPad3)) { parent.water.WindForce += .05f; } } if (keyboard.KeyPressed(Keys.F4)) { for (int x = 0; x < 10; x++) { for (int e = x; e < 10; e++) { parent.boxes.Add(new XActor(ref X, new CapsuleObject(1, 1, Matrix.Identity, new Vector3(20, x * 1.01f + 1, e - 0.5f * x)), parent.model, Vector3.One, Vector3.Zero, 10)); } } } if (keyboard.KeyPressed(Keys.F5)) { List <XActor> chainBoxes = new List <XActor>(); for (int i = 0; i < 25; i++) { XActor actor = new XActor(ref X, new CapsuleObject(1, 1, Matrix.Identity, new Vector3(i + 10, 45 - i, 0)), parent.model, Vector3.One, Vector3.Zero, 10); if (i == 0) { actor.Immovable = true; } chainBoxes.Add(actor); } for (int i = 1; i < 25; i++) { XHingeJoint hinge = new XHingeJoint(ref X, chainBoxes[i - 1], chainBoxes[i], Vector3.Backward, new Vector3(0.5f, -0.5f, 0.0f), 1.0f, 90.0f, 90.0f, 0.2f, 0.2f); } } if (keyboard.KeyPressed(Keys.F6)) { if (parent.currentCamera == parent.chase) { parent.currentCamera = parent.freeCamera; return; } if (parent.currentCamera == parent.freeCamera) { parent.currentCamera = parent.driverCamera; return; } if (parent.currentCamera == parent.driverCamera) { parent.currentCamera = parent.chase; return; } } if (keyboard.KeyPressed(Keys.F7)) { parent.houseactor = new XAnimatedActor(ref X, new BoxObject(new Vector3(5, 5, 1), Matrix.Identity, new Vector3(2, 2, 2)), parent.housemodel, Vector3.One, Vector3.Zero, .1f); parent.houseactor.Load(X.Content); parent.houseactor.Immovable = false; parent.boxes.Add(parent.houseactor); } if (keyboard.KeyPressed(Keys.F8)) { //if (parent.houseactor == null) //{ parent.houseactor = new XAnimatedActor(ref X, new BoxObject(new Vector3(5, 5, 1), Matrix.Identity, new Vector3(2, 2, 2)), parent.housemodel, Vector3.One, Vector3.Zero, .1f); parent.houseactor.Load(X.Content); parent.houseactor.Immovable = false; parent.boxes.Add(parent.houseactor); //} } if (keyboard.KeyPressed(Keys.F9)) { foreach (XActor xa in parent.boxes) { xa.Disable(); } parent.boxes.Clear(); } if (keyboard.KeyPressed(Keys.Add)) { parent.houseactor.AnimationIndex++; } if (keyboard.KeyPressed(Keys.F10)) { XCubeTriggerVolume cv = new XCubeTriggerVolume(ref X, (XPhysicsObject)parent.Car.Car, true, new Vector3(0, 0, 0), new Vector3(10, 10, 10), Vector3.One, Quaternion.Identity, Vector3.One); //XTextureGenerator texGen = new XTextureGenerator(ref X); //texGen.GetMandelBrot(new Vector2(0.25f, 0),3); /* * if (pad.Buttons.A == ButtonState.Pressed) * zoom /= 1.05f; * * if (pad.Buttons.B == ButtonState.Pressed) * zoom *= 1.05f; * * float panSensitivity = 0.01f * (float)Math.Log(zoom + 1); * * pan += new Vector2(pad.ThumbSticks.Left.X, -pad.ThumbSticks.Left.Y) * panSensitivity; */ } if (keyboard.KeyPressed(Keys.PageUp)) { } if (keyboard.KeyPressed(Keys.PageDown)) { } //Example Code /* if (!parent.menus.MenuOpen) * { * X.UpdatePhysics = true; * * if (parent.scene.Ball != null) * { * parent.Camera.TargetPosition = parent.scene.Ball.Position; * * Vector3 ballPos = new Vector3(parent.scene.Ball.Position.X, 0, parent.scene.Ball.Position.Z); * Vector3 camPos = new Vector3(parent.Camera.Position.X, 0, parent.Camera.Position.Z); * Vector3 dir = (ballPos - camPos); * #if XBOX == FALSE * parent.Camera.Rotate(mouse.Delta.X * .008f, mouse.Delta.Y * .008f); * parent.Camera.Zoom(-mouse.ScrollDelta * .015f); * * if (!jumping && keyboard.KeyPressed(Keys.Space)) * { * jumping = true; * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(new Vector3(0, 1200000, 0), Matrix.Invert(parent.scene.Ball.Orientation))); * } * else if (jumping) * { * if (parent.scene.Ball.Actor.Collisions.Count > 0) * jumping = false; * } * * if (parent.scene.Ball.Actor.Collisions.Count > 0) * { * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * (keyboard.KeyDown(Keys.W) ? 1 : 0) * 2800, Matrix.Invert(parent.scene.Ball.Orientation))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(-Vector3.Transform(dir * (keyboard.KeyDown(Keys.S) ? 1 : 0) * 4000, Matrix.Invert(parent.scene.Ball.Orientation))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * (keyboard.KeyDown(Keys.A) ? 1 : 0) * 3300, Matrix.Invert(parent.scene.Ball.Orientation * Matrix.CreateRotationY(MathHelper.ToRadians(-90))))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * (keyboard.KeyDown(Keys.D) ? 1 : 0) * 3300, Matrix.Invert(parent.scene.Ball.Orientation * Matrix.CreateRotationY(MathHelper.ToRadians(90))))); * } * else * { * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * (keyboard.KeyDown(Keys.W) ? 1 : 0) * 1000, Matrix.Invert(parent.scene.Ball.Orientation))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(-Vector3.Transform(dir * (keyboard.KeyDown(Keys.S) ? 1 : 0) * 2000, Matrix.Invert(parent.scene.Ball.Orientation))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * (keyboard.KeyDown(Keys.A) ? 1 : 0) * 1300, Matrix.Invert(parent.scene.Ball.Orientation * Matrix.CreateRotationY(MathHelper.ToRadians(-90))))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * (keyboard.KeyDown(Keys.D) ? 1 : 0) * 1300, Matrix.Invert(parent.scene.Ball.Orientation * Matrix.CreateRotationY(MathHelper.ToRadians(90))))); * } #endif * parent.Camera.Rotate(-Gamepad.Thumbstick(XgamePad.Thumbsticks.Right).X * .04f, Gamepad.Thumbstick(XgamePad.Thumbsticks.Right).Y * .04f); * parent.Camera.Zoom((Gamepad.ButtonDown(Buttons.DPadDown) ? 0.15f : 0) + (Gamepad.ButtonDown(Buttons.DPadUp) ? -0.15f : 0)); * * if (!jumping && Gamepad.ButtonPressed(Buttons.A)) * { * jumping = true; * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(new Vector3(0, 1200000, 0), Matrix.Invert(parent.scene.Ball.Orientation))); * } * else if (jumping) * { * if (parent.scene.Ball.Actor.Collisions.Count > 0) * jumping = false; * } * * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * Gamepad.Thumbstick(XgamePad.Thumbsticks.Left).Y * 1000, Matrix.Invert(parent.scene.Ball.Orientation))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(-Vector3.Transform(dir * -Gamepad.Thumbstick(XgamePad.Thumbsticks.Left).Y * 1000, Matrix.Invert(parent.scene.Ball.Orientation))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * Gamepad.Thumbstick(XgamePad.Thumbsticks.Left).X * 1000, Matrix.Invert(parent.scene.Ball.Orientation * Matrix.CreateRotationY(MathHelper.ToRadians(90))))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(-Vector3.Transform(dir * -Gamepad.Thumbstick(XgamePad.Thumbsticks.Left).X * 1000, Matrix.Invert(parent.scene.Ball.Orientation * Matrix.CreateRotationY(MathHelper.ToRadians(90))))); * } * } * else * { * X.UpdatePhysics = false; * * if (keyboard.KeyPressed(Keys.Up)) * parent.menus.SelectPrevious(); * else if (keyboard.KeyPressed(Keys.Down)) * parent.menus.SelectNext(); * } * * if (keyboard.KeyPressed(Keys.Escape)) * parent.menus.Toggle(); */ }
public XActors ParseLines(String[] lines) { XActors root = new XActors(); String currentComment = string.Empty; XActor currentActor = null; XVariable currentVariable = null; Object commentParent = null; foreach (string line in lines) { string line_nocomment; String lineComment;//comment within the current line //remove comment line_nocomment = StripComment(line, out lineComment); //if line only contains a comment if (line_nocomment.Trim().Length == 0) { //continue the current comment currentComment += (String.IsNullOrEmpty(currentComment)) ? lineComment : Environment.NewLine + lineComment; continue; } //Else match one of three patterns: //Actor/Object id line, //Mask Line //Value line //If Actor/Object id line if (IdLine.IsMatch(line_nocomment)) { //attach currentComment to proper node AddCommentToNode(ref commentParent, ref currentComment, lineComment); //Start a new XActor, attach it currentActor = new XActor(); root.Actor.Add(currentActor); //set new comment node commentParent = currentActor; //null current variable currentVariable = null; NewActorDefinition(IdLine.Matches(line_nocomment)[0].Groups, currentActor); } //mask value line else if (MaskLine.IsMatch(line_nocomment)) { //Push currentComment to proper node AddCommentToNode(ref commentParent, ref currentComment, lineComment); currentVariable = new XVariable(); currentActor.Variables.Add(currentVariable); commentParent = currentVariable; throw new NotImplementedException(); //NewVariableDefinition(MaskLine.Matches(line_nocomment)[0].Groups, currentVariable); } else if (ValueLine.IsMatch(line_nocomment)) { //Push currentComment to proper node AddCommentToNode(ref commentParent, ref currentComment, lineComment); if (currentVariable == null) { currentVariable = NoMaskSet(currentActor); } XVariableValue val = new XVariableValue(); currentVariable.Value.Add(val); commentParent = val; NewVariableValue(ValueLine.Matches(line_nocomment)[0].Groups, val); } else //unknown { currentComment += String.Format("{1}#NOPARSE: {0}", line_nocomment, (String.IsNullOrEmpty(currentComment)) ? string.Empty : Environment.NewLine); continue; } } AddCommentToNode(ref commentParent, ref currentComment, string.Empty); return(root); }
public XStatement(XActor actor, XVerb verb, XObject obj) { this.actor = actor; this.verb = verb; this.obj = obj; }