private void ParseMapFile(InitializeParameters p) { // read file XResourceBundle r = (XResourceBundle)this.Parent; string mapFilePath = Path.ChangeExtension(this.Source, "xml"); mapFilePath = Path.Combine(Directory.GetCurrentDirectory(), p.Content.RootDirectory, r.RootFolder.Replace('/', Path.DirectorySeparatorChar), mapFilePath); if (!File.Exists(mapFilePath)) { throw new InvalidOperationException(string.Format("Could not find spritesheet map file: {0}", mapFilePath)); } XmlDocument doc = new XmlDocument(); doc.Load(mapFilePath); foreach (XmlElement spriteNode in doc.DocumentElement.ChildNodes) { this.Map.Add( Path.GetFileNameWithoutExtension(spriteNode.GetAttribute("n")), new System.Drawing.RectangleF( float.Parse(spriteNode.GetAttribute("x")), float.Parse(spriteNode.GetAttribute("y")), float.Parse(spriteNode.GetAttribute("w")), float.Parse(spriteNode.GetAttribute("h")) ) ); } }
public override void InitializeMainThread(InitializeParameters p) { base.InitializeMainThread(p); if (this.soundEffect != null) return; this.soundEffect = LoadResource<SoundEffect>(p.Content, "SoundEffectProcessor", "wav", "xnb"); if (this.NumberOfInstances > 0) { // number of instances will be limited this.instanceOwners = new Dictionary<SoundEffectInstance, int>(this.NumberOfInstances); this.instanceCheckoutTimes = new Dictionary<SoundEffectInstance, int>(this.NumberOfInstances); for(int i = 0; i < this.NumberOfInstances; i++) { var soundEffectInstance = this.soundEffect.CreateInstance(); this.instanceOwners.Add(soundEffectInstance, 0); this.instanceCheckoutTimes.Add(soundEffectInstance, 0); } } else this.ownerInstances = new Dictionary<int, SoundEffectInstance>(); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); object1 = new ObjectProxy(FindObject(ObjectId1)); object2 = new ObjectProxy(FindObject(ObjectId2)); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); if (string.IsNullOrEmpty(this.FontId)) { throw new InvalidOperationException("Font is not specified for text field"); } this.font = this.FindGlobal(this.FontId) as XFontResource; if (this.font == null) { throw new InvalidOperationException("Font wasn't found: " + this.FontId); } if (this.Text != null && this.Text.StartsWith("=")) { this.strValueReader = Compiler.CompileExpression <string>(this, "system.Str(" + this.Text.Substring(1) + ")"); } if (this.font == null) { throw new InvalidOperationException(string.Format( "Font was not found. Text ID:{0} FontId:{1}", this.Id, this.FontId )); } }
public override void InitializeMainThread(InitializeParameters p) { base.InitializeMainThread(p); if (this.soundEffect != null) { return; } this.soundEffect = LoadResource <SoundEffect>(p.Content, "SoundEffectProcessor", "wav", "xnb"); if (this.NumberOfInstances > 0) { // number of instances will be limited this.instanceOwners = new Dictionary <SoundEffectInstance, int>(this.NumberOfInstances); this.instanceCheckoutTimes = new Dictionary <SoundEffectInstance, int>(this.NumberOfInstances); for (int i = 0; i < this.NumberOfInstances; i++) { var soundEffectInstance = this.soundEffect.CreateInstance(); this.instanceOwners.Add(soundEffectInstance, 0); this.instanceCheckoutTimes.Add(soundEffectInstance, 0); } } else { this.ownerInstances = new Dictionary <int, SoundEffectInstance>(); } }
private void ParseMapFile(InitializeParameters p) { // read file XResourceBundle r = (XResourceBundle)this.Parent; string mapFilePath = Path.ChangeExtension(this.Source, "xml"); mapFilePath = Path.Combine(Directory.GetCurrentDirectory(), p.Content.RootDirectory, r.RootFolder.Replace('/', Path.DirectorySeparatorChar), mapFilePath); if (!File.Exists(mapFilePath)) throw new InvalidOperationException(string.Format("Could not find spritesheet map file: {0}", mapFilePath)); XmlDocument doc = new XmlDocument(); doc.Load(mapFilePath); foreach (XmlElement spriteNode in doc.DocumentElement.ChildNodes) { this.Map.Add( Path.GetFileNameWithoutExtension(spriteNode.GetAttribute("n")), new System.Drawing.RectangleF( float.Parse(spriteNode.GetAttribute("x")), float.Parse(spriteNode.GetAttribute("y")), float.Parse(spriteNode.GetAttribute("w")), float.Parse(spriteNode.GetAttribute("h")) ) ); } }
public override void InitializeMainThread(InitializeParameters p) { base.InitializeMainThread(p); if (this.image != null) { return; } for (int i = 0; i < p.Game.SpriteSheets.Count; i++) { var spriteSheet = p.Game.SpriteSheets[i]; if (spriteSheet.Map.ContainsKey(this.Source)) { this.SourceRectangle = spriteSheet.Map[this.Source]; this.image = spriteSheet.Image; return; } } try { image = LoadResource <Texture2D>(p.Content, "TextureProcessor", "png", "xnb"); }catch (Exception ex) { ex = ex; throw; } }
public override void InitializeMainThread(InitializeParameters p) { base.InitializeMainThread(p); if (this.image != null) return; for(int i = 0; i < p.Game.SpriteSheets.Count; i++) { var spriteSheet = p.Game.SpriteSheets[i]; if (spriteSheet.Map.ContainsKey(this.Source)) { this.SourceRectangle = spriteSheet.Map[this.Source]; this.image = spriteSheet.Image; return; } } try { image = LoadResource<Texture2D>(p.Content, "TextureProcessor", "png", "xnb"); }catch(Exception ex) { ex = ex; throw; } }
public void Initialize(InitializeParameters parameters) { using (TransactionScope scope = new TransactionScope()) { using (IDbConnection connection = new DbConnection(ConnectionString)) { connection.Open(); using (IDbCommand command = connection.CreateCommand()) { command.CommandText = "UIMessageHandler.Initialize"; ((OracleCommand)command).BindByName = true; foreach (IDbDataParameter parameter in InitializeTranslator.TranslateParameters(parameters)) { command.Parameters.Add(parameter); } command.Prepare(); command.CommandType = CommandType.StoredProcedure; command.ExecuteNonQuery(); } } scope.Complete(); } }
public override void Initialize(InitializeParameters p) { this.Exploding = new List <XElement>(); base.Initialize(p); this.EnqueueEvent(GameEventType.LevelLoaded); }
public override void Initialize(InitializeParameters p) { if (EnableTrace) { this.trace = new List <Tuple <double, double> >(2048); } if (!string.IsNullOrEmpty(this.From)) { // Use the From/To properties this.CreateSubcomponents(); this.Subcomponents.Add(new XKeyFrame() { Time = "0", Value = this.From, Smoothing = this.Smoothing }); this.Subcomponents.Add(new XKeyFrame() { Time = this.Duration, Value = this.To, Smoothing = this.Smoothing }); } base.Initialize(p); PerfMon.Start("Other-Ani"); // get targets GenerateTargets(); startValues = new List <double?>(new double?[targets.Count]); // collect keyFrames and check for consistency keyFrames = this.GetComponents <XKeyFrame>().ToList(); if (keyFrames.Any(k => k.CurveKeys.Count != targets.Count)) { throw new InvalidOperationException("Number of values in key frames must match number of targets."); } if (keyFrames.Count < 2) { throw new InvalidOperationException("Number of key frames must be 2 or more."); } lastFrame = keyFrames[keyFrames.Count - 1]; // create curves curves = new List <TimeCurve>(targets.Count); for (int i = 0; i < targets.Count; i++) { var curve = new TimeCurve(); curve.PostLoop = this.Autoreverse ? CurveLoopType.Oscillate : CurveLoopType.Cycle; curve.PreLoop = this.Autoreverse ? CurveLoopType.Oscillate : CurveLoopType.Cycle; for (int j = 0; j < keyFrames.Count; j++) { curve.Keys.Add(keyFrames[j].CurveKeys[i]); } curves.Add(curve); } PerfMon.Stop("Other-Ani"); }
public override void InitializeMainThread(InitializeParameters p) { base.InitializeMainThread(p); if (this.song != null) return; this.song = LoadResource<Song>(p.Content, "SongProcessor", "mp3", "wma", "Mp3Importer"); }
public override void InitializeMainThread(InitializeParameters p) { base.InitializeMainThread(p); if (this.font != null) return; font = LoadResource<SpriteFont>(p.Content, "FontDescriptionProcessor", "spritefont", "xnb"); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); PerfMon.Start("Other-Do"); actions = Compiler.CompileStatements(this, this.Action); PerfMon.Stop("Other-Do"); }
public override void InitializeMainThread(InitializeParameters p) { base.InitializeMainThread(p); if (this.song != null) { return; } this.song = LoadResource <Song>(p.Content, "SongProcessor", "mp3", "wma", "Mp3Importer"); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); int textureWidth = this.SourceRectangle.HasValue ? (int)this.SourceRectangle.Value.Width : this.texture.Image.Width; if (this.FrameBounds.Width * FrameCount > textureWidth) throw new InvalidOperationException("Specified FrameCount exceeds the Width of the texture"); this.originalSourceRectangle = this.SourceRectangle; }
public override void InitializeMainThread(InitializeParameters p) { base.InitializeMainThread(p); if (this.font != null) { return; } font = LoadResource <SpriteFont>(p.Content, "FontDescriptionProcessor", "spritefont", "xnb"); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); int textureWidth = this.SourceRectangle.HasValue ? (int)this.SourceRectangle.Value.Width : this.texture.Image.Width; if (this.FrameBounds.Width * FrameCount > textureWidth) { throw new InvalidOperationException("Specified FrameCount exceeds the Width of the texture"); } this.originalSourceRectangle = this.SourceRectangle; }
protected void InitializeParametersFunction() { if (!(ReceivedEvent is InitializeParametersEvent @event)) { throw new ArgumentException("Event type is incorrect: " + ReceivedEvent.GetType().Name); } InitializeParameters initParam = @event.Payload as InitializeParameters; interfaceName = initParam.InterfaceName; self = new PMachineValue(Id, receives.ToList()); RaiseEvent(GetConstructorEvent(initParam.Payload), initParam.Payload); }
public override void InitializeMainThread(InitializeParameters p) { base.InitializeMainThread(p); if (this.Map != null) return; this.Map = new Dictionary<string,System.Drawing.RectangleF>(StringComparer.InvariantCultureIgnoreCase); ParseMapFile(p); p.Game.SpriteSheets.Add(this); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); this.ParentElement = this.FindAncestor(o => o is XElement) as XElement; var exploding = this as IExploding; if (exploding != null && exploding.IsExploding) { ((XLevel)this.GetScreen()).Exploding.Add(this); } }
public override void Initialize(InitializeParameters p) { base.Initialize(p); PerfMon.Start("Other-Tap"); p.ScreenEngine.tapAreas.Add(this); InitActions(this.Action, ref this.pressActions); InitActions(this.MoveAction, ref this.moveActions); InitActions(this.ReleaseAction, ref this.releaseActions); PerfMon.Stop("Other-Tap"); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); PerfMon.Start("Other-KeyFrame"); animation = (XNumAnimation)this.Parent; GenerateValueReaders(); this.timeReader = Compiler.CompileExpression <double>(this.Parent, this.Time); this.CurrentTime = 0f; PerfMon.Stop("Other-KeyFrame"); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); if (!string.IsNullOrWhiteSpace(this.Probabilities)) { probabilities = new ProbabilityList(this.random, this.Probabilities.Split(',').Select(s => double.Parse(s))); if (probabilities.Count != runnables.Count) { throw new InvalidOperationException(string.Format("Number of probabilities must match the number of runnables - {0} != {1}", probabilities.Count, runnables)); } } }
/// <summary> /// This method represents the second stage of the four primary stages of the component lifecycle /// (hierarchy building, component initialization, update and draw, dispose). /// <remarks> /// The <see cref="Initialize"/> method is called when after the object hierarchy is built and allows /// for component-specific initialization of parameters. Examles include finding related objects in the hierarchy, /// setting default values, pre-calculation of certain values. /// </remarks> /// </summary> public virtual void Initialize(InitializeParameters p) { if (this.Subcomponents == null) { return; } for (int i = 0; i < this.Subcomponents.Count; i++) { var subcomponent = this.Subcomponents[i]; subcomponent.Initialize(p); } }
public override void Initialize(InitializeParameters p) { for (int i = 0; i < this.LevelSeries.Count; i++) { var series = this.LevelSeries[i]; for (int j = 0; j < series.Levels.Count; j++) { series.Levels[j].SeriesNumber = i; series.Levels[j].LevelNumber = j; } } base.Initialize(p); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); if (this.Value == "0") { value2Reader = NumConstant.Zero; } else { value2Reader = Compiler.CompileExpression <double>(this, this.Value); } compareFunc = compareFuncs[this.Compare]; }
public override void InitializeMainThread(InitializeParameters p) { base.InitializeMainThread(p); if (this.Map != null) { return; } this.Map = new Dictionary <string, System.Drawing.RectangleF>(StringComparer.InvariantCultureIgnoreCase); ParseMapFile(p); p.Game.SpriteSheets.Add(this); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); if (this.Action != null) { this.actions = Compiler.CompileStatements(this, this.Action); } if (this.EnterAction != null) { this.enterActions = Compiler.CompileStatements(this, this.EnterAction); } if (this.ExitAction != null) { this.exitActions = Compiler.CompileStatements(this, this.ExitAction); } }
public override void Initialize(InitializeParameters p) { base.Initialize(p); var pairs = this.Ranges.Split(','); eplodingElements = new List <XElement>(pairs.Length); rangeNames = new List <string>(pairs.Length); rangeValuesSquared = new List <double>(pairs.Length); pairs.ForEach(s => { var parts = s.Split('='); rangeNames.Add(parts[0]); var rangeValue = double.Parse(parts[1], CultureInfo.InvariantCulture); rangeValuesSquared.Add(rangeValue * rangeValue); }); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); GameEngine.Instance.PauseLevelSoundEffects += HandleSystemPause; GameEngine.Instance.StopLevelSoundEffects += HandleSystemStop; PerfMon.Start("Other-Sfx"); this.soundFile = (XSoundResource)this.FindGlobal(this.FileId); if (this.soundFile == null) throw new InvalidOperationException(string.Format("Sound effect resource with id '{0}' was not found", this.FileId)); this.soundFile.CheckOutInstance(this); PerfMon.Stop("Other-Sfx"); }
public override void Initialize (InitializeParameters p) { base.Initialize (p); if (string.IsNullOrEmpty(this.TextureId)) throw new InvalidOperationException(string.Format( "TextureId must be specified. Image: '{0}'", this.Id )); this.texture = this.FindGlobal(this.TextureId) as XTextureResource; if (this.texture == null) throw new InvalidOperationException(string.Format( "Texture was not found. Image: '{0}' TextureId: '{1}'", this.Id, this.TextureId )); this.SourceRectangle = this.texture.SourceRectangle; }
public override void Initialize(InitializeParameters p) { base.Initialize(p); string internalTypeName = "Lunohod.Objects.X" + this.TypeFilter; this.TypeFilterType = this.GetType().Assembly.GetType(internalTypeName); if (this.TypeFilterType == null) { throw new InvalidOperationException("Iterator could not find type: " + internalTypeName); } if (this.ObjectIds != null) { this.objects = this.ObjectIds.Split(',').Select(id => FindObject(id, p.ScreenEngine.RootComponent)).ToList(); } }
public override void Initialize(InitializeParameters p) { base.Initialize(p); p.LevelEngine.Hero = this; this.DefaultHealth = p.LevelEngine.LevelInfo.HeroHealth; this.Health = this.DefaultHealth; this.DefaultBombCount = p.LevelEngine.LevelInfo.BombCount; this.BombCount = this.DefaultBombCount; if (this.DefaultSpeed == 0) { this.DefaultSpeed = this.Speed; } distanceToTower = double.MaxValue; }
public override void Initialize(InitializeParameters p) { base.Initialize(p); GameEngine.Instance.PauseLevelSoundEffects += HandleSystemPause; GameEngine.Instance.StopLevelSoundEffects += HandleSystemStop; PerfMon.Start("Other-Sfx"); this.soundFile = (XSoundResource)this.FindGlobal(this.FileId); if (this.soundFile == null) { throw new InvalidOperationException(string.Format("Sound effect resource with id '{0}' was not found", this.FileId)); } this.soundFile.CheckOutInstance(this); PerfMon.Stop("Other-Sfx"); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); PerfMon.Start("Other-SetBase"); runnables = new List <IRunnable>(); CollectRunnables(this, runnables); for (int i = 0; i < runnables.Count; i++) { runnables[i].InProgress = false; } if (this.inProgress) { this.Start(); } PerfMon.Stop("Other-SetBase"); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); if (string.IsNullOrEmpty(this.TextureId)) { throw new InvalidOperationException(string.Format( "TextureId must be specified. Image: '{0}'", this.Id )); } this.texture = this.FindGlobal(this.TextureId) as XTextureResource; if (this.texture == null) { throw new InvalidOperationException(string.Format( "Texture was not found. Image: '{0}' TextureId: '{1}'", this.Id, this.TextureId )); } this.SourceRectangle = this.texture.SourceRectangle; }
public override void Initialize(InitializeParameters p) { base.Initialize(p); if (string.IsNullOrEmpty(this.FontId)) throw new InvalidOperationException("Font is not specified for text field"); this.font = this.FindGlobal(this.FontId) as XFontResource; if (this.font == null) throw new InvalidOperationException("Font wasn't found: " + this.FontId); if (this.Text != null && this.Text.StartsWith("=")) { this.strValueReader = Compiler.CompileExpression<string>(this, "system.Str(" + this.Text.Substring(1) + ")"); } if (this.font == null) throw new InvalidOperationException(string.Format( "Font was not found. Text ID:{0} FontId:{1}", this.Id, this.FontId )); }
public static IList <IDbDataParameter> TranslateParameters(InitializeParameters parameters) { IList <IDbDataParameter> parameterList = new List <IDbDataParameter>(); OracleParameter dbParameter; dbParameter = new OracleParameter(); dbParameter.ParameterName = "ERRWARNXML_I"; dbParameter.OracleDbType = OracleDbType.Clob; dbParameter.Direction = ParameterDirection.Input; if (parameters == null || string.IsNullOrEmpty(parameters.MessageXML)) { dbParameter.Value = DBNull.Value; } else { dbParameter.Value = parameters.MessageXML; } parameterList.Add(dbParameter); return(parameterList); }
public async Task HandleInitializeRequest() { // Setup: // ... Create an initialize handler and register it in the service host var mockHandler = new Mock <Func <InitializeParameters, IEventSender, Task> >(); mockHandler.Setup(f => f(It.IsAny <InitializeParameters>(), It.IsAny <IEventSender>())) .Returns(Task.FromResult(true)); var sh = GetServiceHost(); sh.RegisterInitializeTask(mockHandler.Object); sh.RegisterInitializeTask(mockHandler.Object); // ... Set a dummy value to return as the initialize response var ir = new InitializeResponse(); // ... Create a mock request that will handle sending a result // TODO: Replace with event flow validation var initParams = new InitializeParameters(); var bc = new BlockingCollection <Message>(); var mockContext = new RequestContext <InitializeResponse>(Message.CreateRequest(InitializeRequest.Type, CommonObjects.MessageId, initParams), bc); // If: I handle an initialize request await sh.HandleInitializeRequest(initParams, mockContext); // Then: // ... The mock handler should have been called twice mockHandler.Verify(h => h(initParams, mockContext), Times.Exactly(2)); // ... There should have been a response sent var outgoing = bc.ToArray(); Assert.Single(outgoing); Assert.Equal(CommonObjects.MessageId, outgoing[0].Id); Assert.Equal(JToken.FromObject(ir), JToken.FromObject(ir)); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); p.LevelEngine.Tower = this; }
public override void Initialize(InitializeParameters p) { base.Initialize(p); }
public override void Initialize(InitializeParameters p) { base.Initialize(p); p.LevelEngine.Hero = this; this.DefaultHealth = p.LevelEngine.LevelInfo.HeroHealth; this.Health = this.DefaultHealth; this.DefaultBombCount = p.LevelEngine.LevelInfo.BombCount; this.BombCount = this.DefaultBombCount; if (this.DefaultSpeed == 0) this.DefaultSpeed = this.Speed; distanceToTower = double.MaxValue; }
public override void Initialize(InitializeParameters p) { base.Initialize(p); this.game = p.Game; }