private static void PrintBehaviorGroup(BehaviorGroup behaviorGroupToPrint, bool draft) { _log.Info("Print Controller printing Behavior Group: " + behaviorGroupToPrint.Artifact.Name); var trimName = behaviorGroupToPrint.Artifact.Name.Replace(" ", "-").ToLower(); _outputFolder = ModelMap.FilePath + ModelMap.BehaviorGroupFolder + ModelMap.FolderSeparator + trimName + ModelMap.FolderSeparator + ModelMap.Latest; _filePath = _outputFolder + ModelMap.FolderSeparator + trimName + ".docx"; try { Directory.CreateDirectory(_outputFolder); InitWorkingDocument(ModelMap.StyleSource); } catch (Exception ex) { _log.Error("Artifact Output Folder: " + _outputFolder + " cannot be created."); _log.Error(ex); return; } // Add a main document part. BehaviorGroupPrinter.PrintBehaviorGroup(_document, behaviorGroupToPrint, false); Utils.InsertCustomWatermark(_document, draft ? ModelMap.DraftWaterMark : ModelMap.WaterMark); Utils.AddFooter(_document, behaviorGroupToPrint.Artifact.Name); Save(); }
public static void PrintBehaviorGroup(WordprocessingDocument document, BehaviorGroup bg, bool book, bool isForAppendix = false) { ArtifactPrinter.AddArtifactContent(document, bg.Artifact, book, isForAppendix); _log.Info("Printing Behavior Group Properties: " + bg.Artifact.Name); var body = document.MainDocumentPart.Document.Body; var aDef = body.AppendChild(new Paragraph()); var adRun = aDef.AppendChild(new Run()); adRun.AppendChild(new Text("Behavior Group Details")); Utils.ApplyStyleToParagraph(document, "Heading1", "Heading1", aDef, JustificationValues.Center); foreach (var br in bg.Behaviors) { BehaviorPrinter.AddBehaviorReferenceProperties(document, br); } if (!book) { return; } var pageBreak = body.AppendChild(new Paragraph()); var pbr = pageBreak.AppendChild(new Run()); pbr.AppendChild(new Text("")); if (pageBreak.ParagraphProperties == null) { pageBreak.ParagraphProperties = new ParagraphProperties(); } pageBreak.ParagraphProperties.PageBreakBefore = new PageBreakBefore(); Utils.ApplyStyleToParagraph(document, "Normal", "Normal", pageBreak); }
// events, OnRegistered, OnUnregistered /// <summary> /// Registers a group under the given name. /// </summary> /// <param name="name">The name this group is registered under.</param> /// <returns></returns> public BehaviorGroup Register(string name) { BehaviorGroup group = new BehaviorGroup(name); group.Coordinator = this; Register(group); return group; }
internal static void OutputBehaviorGroup(string symbol, BehaviorGroup bg) { Log.Warn(" ***BehaviorGroup***"); Log.Info(" -Symbol: "+ symbol); if (bg.Artifact != null) { OutputArtifact(bg.Artifact); OutputBehaviorSymbols(bg.Behaviors); } Log.Warn(" ***BehaviorGroup End***"); }
public static int get_m_singleBehaviors(IntPtr l) { int result; try { BehaviorGroup behaviorGroup = (BehaviorGroup)LuaObject.checkSelf(l); LuaObject.pushValue(l, true); LuaObject.pushValue(l, behaviorGroup.m_luaExportHelper.m_singleBehaviors); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int get_InstanceID(IntPtr l) { int result; try { BehaviorGroup behaviorGroup = (BehaviorGroup)LuaObject.checkSelf(l); LuaObject.pushValue(l, true); LuaObject.pushValue(l, behaviorGroup.InstanceID); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int DoBehavor(IntPtr l) { int result; try { BehaviorGroup behaviorGroup = (BehaviorGroup)LuaObject.checkSelf(l); behaviorGroup.DoBehavor(); LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int set_m_curBehaviorCfg(IntPtr l) { int result; try { BehaviorGroup behaviorGroup = (BehaviorGroup)LuaObject.checkSelf(l); ConfigDataGroupBehavior curBehaviorCfg; LuaObject.checkType <ConfigDataGroupBehavior>(l, 2, out curBehaviorCfg); behaviorGroup.m_luaExportHelper.m_curBehaviorCfg = curBehaviorCfg; LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int set_m_ID(IntPtr l) { int result; try { BehaviorGroup behaviorGroup = (BehaviorGroup)LuaObject.checkSelf(l); int id; LuaObject.checkType(l, 2, out id); behaviorGroup.m_luaExportHelper.m_ID = id; LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int set_m_leader(IntPtr l) { int result; try { BehaviorGroup behaviorGroup = (BehaviorGroup)LuaObject.checkSelf(l); BattleActor leader; LuaObject.checkType <BattleActor>(l, 2, out leader); behaviorGroup.m_luaExportHelper.m_leader = leader; LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int set_m_leaderNormalActionPriority(IntPtr l) { int result; try { BehaviorGroup behaviorGroup = (BehaviorGroup)LuaObject.checkSelf(l); int leaderNormalActionPriority; LuaObject.checkType(l, 2, out leaderNormalActionPriority); behaviorGroup.m_luaExportHelper.m_leaderNormalActionPriority = leaderNormalActionPriority; LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int SetBahvior(IntPtr l) { int result; try { BehaviorGroup behaviorGroup = (BehaviorGroup)LuaObject.checkSelf(l); int bahvior; LuaObject.checkType(l, 2, out bahvior); behaviorGroup.SetBahvior(bahvior); LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int AddActor(IntPtr l) { int result; try { BehaviorGroup behaviorGroup = (BehaviorGroup)LuaObject.checkSelf(l); BattleActor actor; LuaObject.checkType <BattleActor>(l, 2, out actor); behaviorGroup.AddActor(actor); LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int set_m_singleBehaviors(IntPtr l) { int result; try { BehaviorGroup behaviorGroup = (BehaviorGroup)LuaObject.checkSelf(l); List <int> singleBehaviors; LuaObject.checkType <List <int> >(l, 2, out singleBehaviors); behaviorGroup.m_luaExportHelper.m_singleBehaviors = singleBehaviors; LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int CreateGroup(IntPtr l) { int result; try { BattleTeam battleTeam = (BattleTeam)LuaObject.checkSelf(l); int id; LuaObject.checkType(l, 2, out id); BehaviorGroup o = battleTeam.m_luaExportHelper.CreateGroup(id); LuaObject.pushValue(l, true); LuaObject.pushValue(l, o); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int GetGroup(IntPtr l) { int result; try { BattleTeam battleTeam = (BattleTeam)LuaObject.checkSelf(l); int groupID; LuaObject.checkType(l, 2, out groupID); BehaviorGroup group = battleTeam.m_luaExportHelper.GetGroup(groupID); LuaObject.pushValue(l, true); LuaObject.pushValue(l, group); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int constructor(IntPtr l) { int result; try { int id; LuaObject.checkType(l, 2, out id); BattleTeam team; LuaObject.checkType <BattleTeam>(l, 3, out team); BehaviorGroup o = new BehaviorGroup(id, team); LuaObject.pushValue(l, true); LuaObject.pushValue(l, o); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
protected override void Initialize() { uint version = 0; FMOD.RESULT result; result = FMOD.Factory.System_Create(ref SoundSystem); ERRCHECK(result); result = SoundSystem.getVersion(ref version); ERRCHECK(result); if (version < FMOD.VERSION.number) { System.Diagnostics.Debug.WriteLine("Error! You are using an old version of FMOD " + version.ToString("X") + ". This program requires " + FMOD.VERSION.number.ToString("X") + "."); } result = SoundSystem.init(32, FMOD.INITFLAG.NORMAL, (IntPtr)null); ERRCHECK(result); VectorRenderer = new VectorRenderComponent(this, Content, "Content\\Effects\\VectorLineEffect"); this.Components.Add(VectorRenderer); sprite = new SpriteBatch(Graphics.GraphicsDevice); font = Content.Load <SpriteFont>("Content\\Tahoma"); fontBold = Content.Load <SpriteFont>("Content\\TahomaBold"); gamepad = Content.Load <Texture2D>("Content\\Textures\\Controls_Gamepad"); keyboard = Content.Load <Texture2D>("Content\\Textures\\Controls_Keyboard"); mouse = Content.Load <Texture2D>("Content\\Textures\\Controls_Mouse"); //////////////////// // register groups BehaviorGroup camera = Scene.Coordinator.Register("Camera"); camera.Associate(new LookAtCamera());//new Camera()); camera.Associate(new CameraController()); BehaviorGroup field = Scene.Coordinator.Register("Playing Field"); field.Associate(new PlayingField(20, 0.25f, 10)); field.Associate(new PlayingFieldVisual()); BehaviorGroup player1 = Scene.Coordinator.Register("Player"); player1.Associate(new SpringSkeleton()); player1.Associate(new PlayerController(PlayerIndex.One, ControlScheme.Gamepad)); player1.Associate(new PlayerVisual()); player1.Associate(new PlayerTailRepresentation()); BehaviorGroup player2 = Scene.Coordinator.Register("Player"); player2.Associate(new SpringSkeleton()); player2.Associate(new PlayerController(PlayerIndex.Two, ControlScheme.Mouse)); player2.Associate(new PlayerVisual()); player2.Associate(new PlayerTailRepresentation()); BehaviorGroup ball = Scene.Coordinator.Register("Ball"); ball.Associate(new BallVisual()); ball.Associate(new BallController()); ball.Associate(new BallRepresentation()); BehaviorGroup player1Score = Scene.Coordinator.Register("Score Counter"); player1Score.Associate(new ScoreCount()); player1Score.Associate(new ScoreVisual()); BehaviorGroup goal1 = Scene.Coordinator.Register("Goal"); goal1.Associate(new GoalRepresentation(PlayerIndex.One)); goal1.Associate(new GoalVisual()); BehaviorGroup goal2 = Scene.Coordinator.Register("Goal"); goal2.Associate(new GoalRepresentation(PlayerIndex.Two)); goal2.Associate(new GoalVisual()); BehaviorGroup advertisement1 = Scene.Coordinator.Register("Commercial"); advertisement1.Associate(new BarrierVisual()); BehaviorGroup advertisement2 = Scene.Coordinator.Register("Commercial"); advertisement2.Associate(new BarrierVisual()); BehaviorGroup collisionChecks = Scene.Coordinator.Register("Collision Check"); collisionChecks.Associate(new CollisionCheck()); //////////////////// // set defaults camera.Get <Transform>().Position = new Vector3(0, 12.5f, 14); collisionChecks.Get <CollisionCheck>().OwnGoal += new EventHandler <OwnGoalEventArgs>(Collision_OwnGoal); advertisement1.Get <Transform>().Position = new Vector3(-(field.Get <PlayingField>().Width / 4), 0.75f, -(field.Get <PlayingField>().Depth / 2)); advertisement1.Get <Transform>().Scale = new Vector3((field.Get <PlayingField>().Width / 2) - 0.5f, 1, 1); advertisement1.Get <Transform>().Rotation = Matrix.CreateRotationX(MathHelper.ToRadians(-35)); advertisement1.Get <BarrierVisual>().Advertisement = Content.Load <Texture2D>("Content\\Textures\\Groov"); advertisement2.Get <Transform>().Position = new Vector3((field.Get <PlayingField>().Width / 4), 0.75f, -(field.Get <PlayingField>().Depth / 2)); advertisement2.Get <Transform>().Scale = new Vector3((field.Get <PlayingField>().Width / 2) - 0.5f, 1, 1); advertisement2.Get <Transform>().Rotation = Matrix.CreateRotationX(MathHelper.ToRadians(-35)); advertisement2.Get <BarrierVisual>().Advertisement = Content.Load <Texture2D>("Content\\Textures\\Midget"); goal1.Get <Transform>().Position = new Vector3(-(field.Get <PlayingField>().Width / 2) - (goal1.Get <GoalRepresentation>().Extents.X / 2) + 0.5f, goal1.Get <GoalRepresentation>().Extents.Y / 2, 0); goal2.Get <Transform>().Position = new Vector3((field.Get <PlayingField>().Width / 2) + (goal2.Get <GoalRepresentation>().Extents.X / 2) - 0.5f, goal2.Get <GoalRepresentation>().Extents.Y / 2, 0); // player1 SpringSkeleton skeleton = player1.Get <SpringSkeleton>(); skeleton.Coefficient = 0.3f; skeleton.Elasticity = 0.01f; skeleton.EnergyLoss = 0.86f; skeleton.Enabled = true; SpringHelper.CreateChain(skeleton, 5, 0.35f, new Vector3(-1, 0, 0), false); skeleton.Nodes[skeleton.Nodes.Count - 1].Mass = 2; player1.Get <PlayerController>().Head = skeleton.Nodes[0]; player1.Get <PlayerController>().Tail = skeleton.Nodes[skeleton.Nodes.Count - 1]; // player2 SpringSkeleton skeleton2 = player2.Get <SpringSkeleton>(); skeleton2.Coefficient = 0.3f; skeleton2.Elasticity = 0.01f; skeleton2.EnergyLoss = 0.86f; skeleton2.Enabled = true; SpringHelper.CreateChain(skeleton2, 5, 0.35f, new Vector3(1, 0, 0), true); skeleton2.Nodes[skeleton2.Nodes.Count - 1].Mass = 2; player2.Get <PlayerController>().Head = skeleton2.Nodes[0]; player2.Get <PlayerController>().Tail = skeleton2.Nodes[skeleton2.Nodes.Count - 1]; base.Initialize(); Scene.Start(); // hack - this is because the dependency to the PlayingField behavior has not been injected before Scene.Start() ball.Get <BallController>().Reset(); }
public static void Main(string[] args) { Utils.InitLog(); _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); if (args.Length == 6 || args.Length == 8 || args.Length == 10 || args.Length == 4) { for (var i = 0; i < args.Length; i++) { var arg = args[i]; switch (arg) { case "--p": i++; ArtifactPath = args[i]; continue; case "--n": i++; ArtifactName = args[i]; continue; case "--t": i++; var t = Convert.ToInt32(args[i]); ArtifactType = (ArtifactType)t; continue; case "--b": i++; var b = Convert.ToInt32(args[i]); BaseType = (TokenType)b; continue; case "--c": i++; var c = Convert.ToInt32(args[i]); TemplateType = (TemplateType)c; continue; case "--v": i++; var v = args[i]; TaxonomyVersion = new TaxonomyVersion { Id = Guid.NewGuid().ToString(), Version = v }; continue; default: continue; } } } else { if (args.Length == 0) { _log.Info( "Usage: dotnet factgen --p [PATH_TO_ARTIFACTS FOLDER] --t [ARTIFACT_TYPE: 0 = Base, 1 = Behavior, 2 = BehaviorGroup, 3 = PropertySet, 4 - TemplateFormula or 5 - TemplateDefinition] --n [ARTIFACT_NAME],"); _log.Info( "--b [baseTokenType: 0 = fungible, 1 = non-fungible, 2 = hybrid]"); _log.Info( "--c [templateType: 0 = singleToken, 1 = hybrid] Is required for a Template Type"); _log.Info( "To update the TaxonomyVersion: dotnet factgen --v [VERSION_STRING] --p [PATH_TO_ARTIFACTS FOLDER]"); return; } _log.Error( "Required arguments --p [path-to-artifact folder] --n [artifactName] --t [artifactType: 0 = Base, 1 = Behavior, 2 = BehaviorGroup, 3 = PropertySet or 4 - TokenTemplate],"); _log.Error( "--b [baseTokenType: 0 = fungible, 1 = non-fungible, 2 = hybrid-fungibleBase, 3 = hybrid-non-fungibleBase, 4 = hybrid-fungibleBase-hybridChildren, 5 = hybrid-non-fungibleBase-hybridChildren]"); _log.Error( "To update the TaxonomyVersion: dotnet factgen --v [VERSION_STRING] --p [PATH_TO_ARTIFACTS FOLDER]"); throw new Exception("Missing required parameters."); } _log.Info("Generating Artifact: " + ArtifactName + " of type: " + ArtifactType); var folderSeparator = "/"; var fullPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (Os.IsWindows()) { fullPath += "\\" + ArtifactPath + "\\"; folderSeparator = "\\"; } else { fullPath += "/" + ArtifactPath + "/"; } Latest = folderSeparator + "latest"; string artifactTypeFolder; var jsf = new JsonFormatter(new JsonFormatter.Settings(true)); if (string.IsNullOrEmpty(ArtifactPath)) { throw new Exception("Missing value for --p."); } if (TaxonomyVersion != null) { _log.Info("Updating Taxonomy Version Only."); var tx = new Taxonomy { Version = TaxonomyVersion }; var txVersionJson = jsf.Format(tx); var formattedTxJson = JToken.Parse(txVersionJson).ToString(); //test to make sure formattedJson will Deserialize. try { JsonParser.Default.Parse <Taxonomy>(formattedTxJson); _log.Info("Taxonomy: " + TaxonomyVersion.Version + " successfully deserialized."); } catch (Exception e) { _log.Error("Json failed to deserialize back into Taxonomy"); _log.Error(e); return; } _log.Info("Creating Taxonomy: " + formattedTxJson); var txStream = File.CreateText(fullPath + "Taxonomy.json"); txStream.Write(formattedTxJson); txStream.Close(); _log.Info("Creating Formula and Grammar Definitions"); var formula = GenerateFormula(); var formulaJson = jsf.Format(formula); var formattedFormulaJson = JToken.Parse(formulaJson).ToString(); //test to make sure formattedJson will Deserialize. try { JsonParser.Default.Parse <FormulaGrammar>(formattedFormulaJson); _log.Info("FormulaGrammar successfully deserialized."); } catch (Exception e) { _log.Error("Json failed to deserialize back into FormulaGrammar."); _log.Error(e); return; } var formulaStream = File.CreateText(fullPath + "FormulaGrammar.json"); formulaStream.Write(formattedFormulaJson); formulaStream.Close(); return; } if (string.IsNullOrEmpty(ArtifactName)) { throw new Exception("Missing value for --n "); } string artifactJson; DirectoryInfo outputFolder; var artifact = new Artifact { Name = ArtifactName, ArtifactSymbol = new ArtifactSymbol { Id = Guid.NewGuid().ToString(), Type = ArtifactType, Tooling = "", Visual = "", Version = "1.0" }, ArtifactDefinition = new ArtifactDefinition { BusinessDescription = "This is a " + ArtifactName + " of type: " + ArtifactType, BusinessExample = "", Comments = "", Analogies = { new ArtifactAnalogy { Name = "Analogy 1", Description = ArtifactName + " analogy 1 description" } } }, Maps = new Maps { CodeReferences = { new MapReference { MappingType = MappingType.SourceCode, Name = "Code 1", Platform = TargetPlatform.Daml, ReferencePath = "" } }, ImplementationReferences = { new MapReference { MappingType = MappingType.Implementation, Name = "Implementation 1", Platform = TargetPlatform.ChaincodeGo, ReferencePath = "" } }, Resources = { new MapResourceReference { MappingType = MappingType.Resource, Name = "Regulation Reference 1", Description = "", ResourcePath = "" } } }, IncompatibleWithSymbols = { new ArtifactSymbol { Type = ArtifactType, Tooling = "", Visual = "" } }, Dependencies = { new SymbolDependency { Description = "", Symbol = new ArtifactSymbol() } }, Aliases = { "alias1", "alias2" } }; switch (ArtifactType) { case ArtifactType.Base: artifactTypeFolder = "base"; outputFolder = Directory.CreateDirectory( fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest); var artifactBase = new Base { Artifact = AddArtifactFiles(outputFolder, folderSeparator, artifact, "Base"), TokenType = BaseType }; artifactBase.Artifact.InfluencedBySymbols.Add(new SymbolInfluence { Description = "Whether or not the token class will be divisible will influence the decimals value of this token. If it is non-divisible, the decimals value should be 0.", Symbol = new ArtifactSymbol { Id = "d5807a8e-879b-4885-95fa-f09ba2a22172", Type = ArtifactType.Behavior, Tooling = "~d", Visual = "<i>~d</i>", Version = "" } }); artifactBase.Artifact.InfluencedBySymbols.Add(new SymbolInfluence { Description = "Whether or not the token class will be divisible will influence the decimals value of this token. If it is divisible, the decimals value should be greater than 0.", Symbol = new ArtifactSymbol { Id = "6e3501dc-5800-4c71-b59e-ad11418a998c", Type = ArtifactType.Behavior, Tooling = "d", Visual = "<i>d</i>", Version = "" } }); artifactBase.TokenType = BaseType; artifactJson = jsf.Format(artifactBase); break; case ArtifactType.Behavior: artifactTypeFolder = "behaviors"; outputFolder = Directory.CreateDirectory( fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest); var artifactBehavior = new Behavior { Artifact = AddArtifactFiles(outputFolder, folderSeparator, artifact, "Behaviors"), Invocations = { new Invocation { Name = "InvocationRequest1", Description = "Describe the what the this invocation triggers in the behavior", Request = new InvocationRequest { ControlMessageName = "InvocationRequest", Description = "The request", InputParameters = { new InvocationParameter { Name = "Input Parameter 1", ValueDescription = "Contains some input data required for the invocation to work." } } }, Response = new InvocationResponse { ControlMessageName = "InvocationResponse", Description = "The response", OutputParameters = { new InvocationParameter { Name = "Output Parameter 1", ValueDescription = "One of the values that the invocation should return." } } } } } }; artifactBehavior.Properties.Add(new Property { Name = "Property1", ValueDescription = "Some Value", TemplateValue = "", PropertyInvocations = { new Invocation { Name = "PropertyGetter", Description = "The property value.", Request = new InvocationRequest { ControlMessageName = "GetProperty1Request", Description = "", InputParameters = { new InvocationParameter { Name = "input1", ValueDescription = "value" } } }, Response = new InvocationResponse { ControlMessageName = "GetProperty1Response", Description = "Return value", OutputParameters = { new InvocationParameter { Name = "Output1", ValueDescription = "value of property" } } } } } }); artifactBehavior.Artifact.InfluencedBySymbols.Add(new SymbolInfluence { Description = "", Symbol = new ArtifactSymbol { Tooling = "", Visual = "" } }); artifactBehavior.Artifact.Dependencies.Add(new SymbolDependency { Description = "", Symbol = new ArtifactSymbol { Tooling = "", Visual = "" } }); artifact.IncompatibleWithSymbols.Add(new ArtifactSymbol()); artifactJson = jsf.Format(artifactBehavior); break; case ArtifactType.BehaviorGroup: artifactTypeFolder = "behavior-groups"; outputFolder = Directory.CreateDirectory( fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest); var artifactBehaviorGroup = new BehaviorGroup { Artifact = AddArtifactFiles(outputFolder, folderSeparator, artifact, "BehaviorGroups") }; artifactBehaviorGroup.Behaviors.Add(new BehaviorReference { Reference = new ArtifactReference { Id = "", ReferenceNotes = "", Type = ArtifactType.Behavior, Values = new ArtifactReferenceValues { ControlUri = "" } }, Properties = { new Property { Name = "", TemplateValue = "", ValueDescription = "" } } }); artifactJson = jsf.Format(artifactBehaviorGroup); break; case ArtifactType.PropertySet: artifactTypeFolder = "property-sets"; outputFolder = Directory.CreateDirectory( fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest); var artifactPropertySet = new PropertySet { Artifact = AddArtifactFiles(outputFolder, folderSeparator, artifact, "PropertySets"), Properties = { new Property { Name = "Property1", ValueDescription = "This is the property required to be implemented and should be able to contain data of type X.", TemplateValue = "", PropertyInvocations = { new Invocation { Name = "Property1 Getter", Description = "Request the value of the property", Request = new InvocationRequest { ControlMessageName = "GetProperty1Request", Description = "The request" }, Response = new InvocationResponse { ControlMessageName = "GetProperty1Response", Description = "The response", OutputParameters = { new InvocationParameter { Name = "Property1.Value", ValueDescription = "Returning the value of the property." } } } }, new Invocation { Name = "Property1 Setter", Description = "Set the Value of the Property, note if Roles should be applied to the Setter.", Request = new InvocationRequest { ControlMessageName = "SetProperty1Request", Description = "The request", InputParameters = { new InvocationParameter { Name = "New Value of Property", ValueDescription = "The data to set the property to." } } }, Response = new InvocationResponse { ControlMessageName = "SetProperty1Response", Description = "The response", OutputParameters = { new InvocationParameter { Name = "Result, true or false", ValueDescription = "Returning the value of the set request." } } } } } } } }; artifactPropertySet.Artifact.InfluencedBySymbols.Add(new SymbolInfluence { Description = "", Symbol = new ArtifactSymbol { Tooling = "", Visual = "" } }); artifactJson = jsf.Format(artifactPropertySet); break; case ArtifactType.TemplateFormula: artifactTypeFolder = "token-templates/formulas"; outputFolder = Directory.CreateDirectory( fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest); var templateFormula = new TemplateFormula { Artifact = AddArtifactFiles(outputFolder, folderSeparator, artifact, "TemplateFormulas"), TokenBase = GetTemplateBase(fullPath, folderSeparator), TemplateType = TemplateType, Behaviors = { new TemplateBehavior { Behavior = new ArtifactSymbol { Type = ArtifactType.Behavior } } }, BehaviorGroups = { new TemplateBehaviorGroup { BehaviorGroup = new ArtifactSymbol { Type = ArtifactType.BehaviorGroup } } }, PropertySets = { new TemplatePropertySet { PropertySet = new ArtifactSymbol { Type = ArtifactType.PropertySet } } } }; artifactJson = jsf.Format(templateFormula); break; case ArtifactType.TemplateDefinition: artifactTypeFolder = "token-templates/definitions"; outputFolder = Directory.CreateDirectory( fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest); var templateDefinition = new TemplateDefinition { Artifact = AddArtifactFiles(outputFolder, folderSeparator, artifact, "TemplateDefinition"), TokenBase = GetBaseReference(fullPath, folderSeparator), Behaviors = { new BehaviorReference { Reference = new ArtifactReference { Type = ArtifactType.Behavior, Id = "a guid", ReferenceNotes = "" }, ConstructorType = "", IsExternal = true, Invocations = { new Invocation() }, InfluenceBindings = { new InfluenceBinding { InfluencedId = "", InfluencedInvocationId = "", InfluenceType = InfluenceType.Intercept, InfluencingInvocation = new Invocation(), InfluencedInvocation = new Invocation() } }, Properties = { new Property { TemplateValue = "definition value" } } } }, BehaviorGroups = { new BehaviorGroupReference { Reference = new ArtifactReference { Type = ArtifactType.BehaviorGroup, Id = "a guid", ReferenceNotes = "" } } }, PropertySets = { new PropertySetReference { Reference = new ArtifactReference { Type = ArtifactType.PropertySet, Id = "a guid", ReferenceNotes = "" }, Properties = { new Property { TemplateValue = "template value" } } } } }; templateDefinition.FormulaReference = new ArtifactReference(); artifactJson = jsf.Format(templateDefinition); break; default: _log.Error("No matching type found for: " + ArtifactType); throw new ArgumentOutOfRangeException(); } _log.Info("Artifact Destination: " + outputFolder); var formattedJson = JToken.Parse(artifactJson).ToString(); //test to make sure formattedJson will Deserialize. try { switch (ArtifactType) { case ArtifactType.Base: var testBase = JsonParser.Default.Parse <Base>(formattedJson); _log.Info("Artifact type: " + ArtifactType + " successfully deserialized: " + testBase.Artifact.Name); break; case ArtifactType.Behavior: var testBehavior = JsonParser.Default.Parse <Behavior>(formattedJson); _log.Info("Artifact type: " + ArtifactType + " successfully deserialized: " + testBehavior.Artifact.Name); break; case ArtifactType.BehaviorGroup: var testBehaviorGroup = JsonParser.Default.Parse <BehaviorGroup>(formattedJson); _log.Info("Artifact type: " + ArtifactType + " successfully deserialized: " + testBehaviorGroup.Artifact.Name); break; case ArtifactType.PropertySet: var testPropertySet = JsonParser.Default.Parse <PropertySet>(formattedJson); _log.Info("Artifact type: " + ArtifactType + " successfully deserialized: " + testPropertySet.Artifact.Name); break; case ArtifactType.TemplateFormula: break; case ArtifactType.TemplateDefinition: break; default: throw new ArgumentOutOfRangeException(); } } catch (Exception e) { _log.Error("Json failed to deserialize back into: " + ArtifactType); _log.Error(e); return; } _log.Info("Creating Artifact: " + formattedJson); var artifactStream = File.CreateText(outputFolder.FullName + folderSeparator + ArtifactName + ".json"); artifactStream.Write(formattedJson); artifactStream.Close(); _log.Info("Complete"); }
// because of this overload, it is possible to register a group under multiple names // possibly an un-wanted feature // update: for now, keep it private /// <summary> /// Registers a specific group under the given name. /// </summary> /// <param name="name"></param> /// <param name="group"></param> // experiment: made internal so that a group can register itself if instantiated with a constructor that takes a coordinator internal void Register(BehaviorGroup group) { // exceptions are not thrown before the group has actually been instanciated // this means garbage can potentially be made constantly. best solution // would be to check before creating the new instance if (registrants.ContainsKey(group.Name)) { registrants[group.Name].Add( group); } else { registrants.Add( group.Name, new List<BehaviorGroup>( new BehaviorGroup[] { group })); } }
// with this method we wish to unregiser a specific instance // it is very likely that this method should be removed /// <summary> /// Unregisters a specific group. /// </summary> /// <param name="group">The reference to the group instance to unregister.</param> public void Unregister(BehaviorGroup group) { List<BehaviorGroup> groups = registrants[group.Name]; if (groups.Contains(group)) { groups.Remove(group); // nullify the reference to the coordinator, as it is no longer registered group.Coordinator = null; } }
public override void Update(TimeSpan elapsed) { foreach (BehaviorGroup group in GameContainer.Scene.Coordinator.Select("Player")) { BehaviorGroup field = GameContainer.Scene.Coordinator.Select("Playing Field")[0]; float offset = 0.3f; float floor = field.Get <Transform>().Position.Y + (field.Get <PlayingField>().Height / 2) + offset; foreach (SpringNode node in group.Get <SpringSkeleton>().Nodes) { node.Velocity *= 1.1f; // ice skating! if (node.Position.Y <= floor) { node.Position = new Vector3(node.Position.X, floor, node.Position.Z); } } PlayerTailRepresentation tail = group.Get <PlayerTailRepresentation>(); if (tail.BoundingSphere.Intersects(ball.BoundingSphere)) { ball.Group.Get <BallController>().Push(Vector3.Normalize(ball.BoundingSphere.Center - tail.BoundingSphere.Center), elapsed); lastPlayerThatHit = tail.Group.Get <PlayerController>().PlayerIndex; GameContainer.SoundSystem.playSound(FMOD.CHANNELINDEX.FREE, (r.Next(0, 2) > 0 ? hit2 : hit3), false, ref GameContainer.SoundChannel); } } foreach (BehaviorGroup group in GameContainer.Scene.Coordinator.Select("Goal")) { GoalRepresentation goal = group.Get <GoalRepresentation>(); if (!scored) { if (ball.BoundingSphere.Intersects(goal.BoundingBox)) { GameContainer.Scene.Coordinator.Select("Score Counter")[0].Get <ScoreCount>().IncreaseScore( goal.PlayerIndex == PlayerIndex.One ? PlayerIndex.Two : PlayerIndex.One); if (!scored) { scored = true; from = DateTime.Now; GameContainer.SoundSystem.playSound(FMOD.CHANNELINDEX.FREE, score, false, ref GameContainer.SoundChannel); if (lastPlayerThatHit == goal.PlayerIndex) { OnOwnGoal(goal.PlayerIndex); } } } } foreach (SpringNode node in group.Get <SpringSkeleton>().Nodes) { ContainmentType ct = default(ContainmentType); ct = ball.BoundingSphere.Contains(node.Position); if (ct == ContainmentType.Contains || ct == ContainmentType.Intersects) { ball.Group.Get <BallController>().velocity *= 0.75f; node.Velocity += (Vector3.Normalize(node.Position - ball.BoundingSphere.Center) * 8) * (float)elapsed.TotalSeconds; //node.Position = ClosestPointOnSphericalSurface(ball.BoundingSphere.Center, ball.BoundingSphere.Radius, node.Position); } /* i dont get why this doesnt work * foreach (BehaviorGroup player in GameContainer.Scene.Coordinator.Select("Player")) { * PlayerTailRepresentation tail = player.Get<PlayerTailRepresentation>(); * * ct = tail.BoundingSphere.Contains(node.Position); * * if (ct == ContainmentType.Contains || ct == ContainmentType.Intersects) { * node.Velocity += (Vector3.Normalize(node.Position - tail.BoundingSphere.Center) * 8) * (float)elapsed.TotalSeconds; * } * }*/ } } if (scored) { TimeSpan since = DateTime.Now - from; if (since.TotalSeconds > winWaitSeconds) { scored = false; ball.Group.Get <BallController>().Reset(); } } }