public static void Main() { Console.OutputEncoding = Encoding.UTF8; //components graphics Components graphicsCardRadeon = new Components("XFX Radeon HD 5450 1GB 64-bit DDR3", 51.22m); Components graphicsCardASUS = new Components("ASUS HD6450-SL-1GD3-BRK", 75.00m); Components graphicsCardGigabyte = new Components("Gigabyte GV-N660WF2-2GD", 345.00m); //Processors Components processorIntel = new Components("Intel Celeron G1820", 64.09m); Components processorAMD = new Components("AMD A4-Series X2 4020", 78.00m); Components processorIntelCorei5 = new Components("Intel Core i5-4460 (6M Cache, up to 3.40 GHz)", 360.00m); //Motherboard Components motherboardASROCK = new Components("ASROCK AM1B-M", 50.00m); Components motherboardASROCK2 = new Components("ASROCK FM2A55M-VG3+", 81.00m); Components motherboardASUS = new Components("ASUS GRYPHON Z87", 263.00m); //Computers Computer computer1 = new Computer("Lenovo", new List<Components> { graphicsCardRadeon, processorIntel, motherboardASROCK }); Computer computer2 = new Computer("ASUS", new List<Components> { graphicsCardASUS, processorAMD, motherboardASROCK2 }); Computer computer3 = new Computer("ASUS", new List<Components> { graphicsCardGigabyte, processorIntelCorei5, motherboardASUS }); List<Computer> computers = new List<Computer> { computer1, computer2, computer3 }; computers.OrderByDescending(computer => computer.Price).ToList() .ForEach(computer => Console.WriteLine(computer.ToString())); }
public static string Render(Components component) { IRenderTarget renderTarget; switch (component) { case Components.JqGrid: renderTarget = new JqGridRenderer(); break; case Components.JqueryGlobalization: renderTarget = new JqueryGlobalizationRenderer(); break; case Components.JqueryUIDatePicker: renderTarget = new JqueryUIDatePickerRenderer(); break; case Components.JqueryUITimePicker: renderTarget = new JqueryUITimePickerRenderer(); break; case Components.ckeditor: renderTarget = new ckeditorRenderer(); break; default: renderTarget = new EmptyRenderer(); break; } return renderTarget.Render(Thread.CurrentThread.CurrentCulture, Thread.CurrentThread.CurrentUICulture); }
DataTable GetStylesheetTable(Components.Settings settings, int portalId) { var returnValue = new DataTable(DataSetTableName.Stylesheets); returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.NameOfSetting, typeof (string))); returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.LocalFilePath, typeof (string))); returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.Stylesheet, typeof (string))); var renderMethod = string.Format("UDT_{0}", settings.RenderingMethod ); var listScript = renderMethod == SettingName.XslUserDefinedStyleSheet ? settings.ScriptByRenderingMethod( renderMethod ) : string.Empty; if (listScript.Length > 0) { var row = returnValue.NewRow(); row[StylesheetTableColumn.NameOfSetting] = SettingName.XslUserDefinedStyleSheet; row[StylesheetTableColumn.LocalFilePath] = listScript; row[StylesheetTableColumn.Stylesheet] = Utilities.ReadStringFromFile(listScript, portalId); returnValue.Rows.Add(row); } var trackingSkript = settings.TrackingScript; if (trackingSkript.Length > 0 && trackingSkript != "[AUTO]") { var row = returnValue.NewRow(); row[StylesheetTableColumn.NameOfSetting] = SettingName.TrackingScript; row[StylesheetTableColumn.LocalFilePath] = trackingSkript; row[StylesheetTableColumn.Stylesheet] = Utilities.ReadStringFromFile(trackingSkript, portalId); returnValue.Rows.Add(row); } return returnValue; }
public override void Initialize(Game game, SpriteBatch spriteBatch, Components.ICamera2D camera) { SpriteBatch = spriteBatch; DrawRectangle = new Rectangle(0, 0, (int) camera.ViewportWidth, (int) camera.ViewportHeight); Texture = new Texture2D(game.GraphicsDevice, 1, 1); Texture.SetData(new[] { new Color(255, 255, 255, 0) }); }
public Sword(Components.Player player) { Player = player; BaseDamage = 10; CollisionPoints.Add(new Vector2(0,10f)); CollisionPoints.Add(new Vector2(0,50f)); }
/// <summary> /// Initializes a new instance of the <see cref="BasicComponentTest"/> class. /// </summary> public BasicComponentTest() { this.components = new Components(); this.logger = new Mock<ILog>(); this.parametersManager = new Mock<IInternalParametersManager>(); this.testee = new BasicComponantImplementation(this.components, this.parametersManager.Object, this.logger.Object); }
static void Main(string[] args) { var mySearch = new Search(); List<string> myList= new List<string>(); myList=mySearch.SplitString("din mor er en mand"); foreach (string s in myList) { Console.WriteLine(s); } var component1 = new Component(); component1._name = "myComponent"; var component2 = new Component(); component2._name = "myComponent"; var myComponentsList=new List<Component>(); myComponentsList.Add(component1); myComponentsList.Add(component2); var myComponents = new Components(myComponentsList); Console.WriteLine(myComponents.GetAvaiableQuantity("myComponent")); }
static void Main(string[] args) { Components ram1 = new Components("2GB RAM", 20); Components ram2 = new Components("6GB RAM", 60); Components hdd1 = new Components("1TB HHD", 350); Components hdd2 = new Components("250GB HDD", 131); Components hdd3 = new Components("2TB SSD", 640); Components gpu1 = new Components("No Info", 0); Components gpu2 = new Components("ATI Radeon HD 5500", 65); Components gpu3 = new Components("NVidia GTX Titan", 650); Components cpu1 = new Components("Intel Core i3 2.4 GHz", 65); Components cpu2 = new Components("Intel Core i7 4.0 GHz", 315); Components cpu3 = new Components("Intel Core i5 3.2 GHz", 135); Components motherboard = new Components("Motherboard :AMD",200); Components motherboard2 = new Components("Motherboard Intel", 500); Computer PC1 = new Computer("PC1", new List<Components>() { ram2, hdd1, gpu1, cpu1,motherboard2 }); Computer PC2 = new Computer("PC2", new List<Components>() { ram1, hdd2, gpu2, cpu2,motherboard }); Computer PC3 = new Computer("PC4", new List<Components>() { ram1, hdd3, gpu3, cpu3,motherboard }); Computer PC4 = new Computer("UnknownTrash"); List<Computer> myList = new List<Computer>() { PC1, PC2, PC3, PC4 }; myList = myList.OrderBy(pr => pr.Price).ToList(); foreach (var pc in myList) { Console.WriteLine(pc.ToString()); } }
internal static void OnComponentMoved(Components.Component c) { if (onComponentMoved != null) { onComponentMoved.Invoke(c); } }
/// <summary> /// Initializes a new instance of the <see cref="BasicComponent"/> class. /// </summary> /// <param name="components">The components.</param> /// <param name="parametersManager">The parameters manager.</param> /// <param name="logger">The logger.</param> protected BasicComponent(Components components, IParametersManager parametersManager, ILog logger) { this.Logger = logger; this.components = components; this.components.Add(this); this.InternalParametersManager = (IInternalParametersManager)parametersManager; }
/// <summary> /// Filter out defunct submissions, null if no non-defunct submissions exist /// </summary> private Components.Submission GetLatestNonDefunct(Components.Submission.SubmissionList subs) { foreach (Components.Submission sub in subs) { if (sub.Status != Components.Submission.DEFUNCT) return sub; } return null; }
public override void Initialize(Game game, Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Components.ICamera2D camera) { base.Initialize(game, spriteBatch, camera); Content.AddAnimationRule("Flash", () => IsShooting); Content.AddAnimationRule("botHandDeactivated", () => !IsShooting); Content.AddAnimationRule("botHandActivated", () => IsShooting); }
/// <summary> /// Constructor that accepts values for all mandatory fields /// </summary> ///<param name="refId">GUID assigned to this LearningResource.</param> ///<param name="language">A Language</param> ///<param name="name">Name of learning resource.</param> ///<param name="components">A lesson or activity-sized portion of a resource.</param> /// public LearningResource( string refId, LanguageCode language, string name, Components components ) : base(Adk.SifVersion, InstrDTD.LEARNINGRESOURCE) { this.RefId = refId; this.SetLanguage( language ); this.Name = name; this.Components = components; }
public AABB(float x1, float y1, float x2, float y2, Components.Component p) { this.x1 = x1; this.x2 = x2; this.y1 = y1; this.y2 = y2; parent = p; SortCoords(); }
public override bool SetGlobalMenu (Components.Commands.CommandManager commandManager, string commandMenuAddinPath, string appMenuAddinPath) { // Only store this information. Release it when creating the main toolbar. this.commandManager = commandManager; this.commandMenuAddinPath = commandMenuAddinPath; this.appMenuAddinPath = appMenuAddinPath; return true; }
public override void Initialize(Microsoft.Xna.Framework.Game game, SpriteBatch spriteBatch, Components.ICamera2D camera) { camera.FocusedAt = null; camera.Position = new Vector2(StartPosition, 0); _targetScale = camera.Scale; camera.Scale = 1f; base.Initialize(game, spriteBatch, camera); }
public AABB(Vector2 a, Vector2 b, Components.Component p) { this.x1 = a.X; this.y1 = a.Y; this.x2 = b.X; this.y2 = b.Y; parent = p; SortCoords(); }
void CreateNewCarts(object sender, Components.GameTimeEventArgs e) { foreach (var tunnelTile in _tunnelTiles) { var cart = new Cart(_game); cart.Position = tunnelTile.Position - new Vector2(0, cart.BoundingBox.Height - tunnelTile.Dimensions.Y); _newCarts.Add(cart); } }
public Settings(ref Components.Settings setting) { InitializeComponent(); if (setting != null) SettingsComponent = setting; else SettingsComponent = new Components.Settings(); loadSettings(); }
internal static void OnComponentPlacedByPlayer(Components.Component c) { if (c is Components.Properties.ICollidable) (c as Components.Properties.ICollidable).RegisterColliders(); Sound.SoundPlayer.ComponentPlaced(); if (onComponentPlacedByPlayer != null) { onComponentPlacedByPlayer.Invoke(c); } }
public Components( Components data ) { CommMode = data.CommMode; SelectByte = data.SelectByte; CommLog = data.CommLog; ReceiveStream = data.ReceiveStream; DutVersion = data.DutVersion; DumpData = data.DumpData; }
/// <summary> /// Adapts the specified experiment into runnable experiment. /// Adapt method validates given experiment and builds runnable experiment which is going to be executed by the experiment runner. /// During adapation the experiment is validated. /// In case of detected error in the experiment, this method returns empty RunnableExperimentBase with no nodes and no edges. /// There are several errors that can be detected. /// There are nodes connected to start, but not to graph end. /// Loops without decisions nodes. /// Input mappings are incorrect. /// Failed component load or instantiation, especially in case of incorrect configuration values. /// </summary> /// <param name="experiment">The experiment which is going to be adapted into RunnableExperiment..</param> /// <param name="nodesFactory">The nodes factory, by which all nodes in runnable experiment are created..</param> /// <param name="library">The library of components.</param> /// <param name="workspaceTypeDirectories">The workspace type directories.</param> /// <returns> /// Runnable experiment that experiment is going to execute, pruned from nodes that are not connected to main flow beginning at Start node. /// In case of detected error in the experiment, this method returns empty RunnableExperimentBase with no nodes and no edges. /// </returns> public static RunnableExperimentBase Adapt(IExperiment experiment, IRunnableNodeFactory nodesFactory, Components.ComponentsLibrary library, List<string> workspaceTypeDirectories) { LoggerNameRoot loggerNameRoot = new LoggerNameRoot(experiment.ExperimentInfo.Id); // Create the new domain for the runnable experiment with whatever current security evidence we're running with. // The components app domain is the app domain which components assemblies are going to be loaded into. var helper = new TraceLab.Core.Components.LibraryHelper(workspaceTypeDirectories); AppDomain componentsAppDomain = helper.CreateDomain(experiment.ExperimentInfo.Id); return Adapt(experiment, loggerNameRoot, nodesFactory, library, workspaceTypeDirectories, componentsAppDomain, new System.Threading.ManualResetEvent(false), true); }
/// <summary> /// Add a component to a pass. This takes it out of the unsorted layer, and puts it in whatever you specify. /// </summary> /// <param name="r"></param> /// <param name="PassIDs"></param> public void AddComponentToPass(Components.IRenderable r, params String[] PassIDs) { m_RenderPasses["Unsorted"].RemoveComponent(r); foreach(String passID in PassIDs) { if( !m_RenderPasses.ContainsKey(passID) ) { // Err: Pass doesn't exist, creating default pass. m_RenderPasses.Add(passID, new RenderPass()); } m_RenderPasses[passID].RegisterComponent(r); } }
/// <summary> /// Adapts the specified experiment into runnable experiment. /// Adapt method validates given experiment and builds runnable experiment which is going to be executed by the experiment runner. /// During adapation the experiment is validated. /// In case of detected error in the experiment, this method returns empty RunnableExperimentBase with no nodes and no edges. /// There are several errors that can be detected. /// There are nodes connected to start, but not to graph end. /// Loops without decisions nodes. /// Input mappings are incorrect. /// Failed component load or instantiation, especially in case of incorrect configuration values. /// </summary> /// <param name="experiment">The experiment which is going to be adapted into RunnableExperiment..</param> /// <param name="loggerNameRoot">The logger name root - needed so that the logs are specific per experiment and experiment window.</param> /// <param name="nodesFactory">The nodes factory, by which all nodes in runnable experiment are created..</param> /// <param name="library">The library of components.</param> /// <param name="workspaceTypeDirectories">The workspace type directories.</param> /// <param name="componentsAppDomain">The components app domain is the app domain which components assemblies are going to be loaded into.</param> /// <param name="terminateExperimentExecutionResetEvent">The event that allows signalling termination of the experiment</param> /// <returns> /// Runnable experiment that experiment is going to execute, pruned from nodes that are not connected to main flow beginning at Start node. /// In case of detected error in the experiment, this method returns empty RunnableExperimentBase with no nodes and no edges. /// </returns> public static RunnableExperimentBase Adapt(IExperiment experiment, LoggerNameRoot loggerNameRoot, IRunnableNodeFactory nodesFactory, Components.ComponentsLibrary library, List<string> workspaceTypeDirectories, AppDomain componentsAppDomain, System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent, bool validateInputMapping) { RunnableExperimentBase runnableExperiment = new RunnableExperiment(nodesFactory, library, componentsAppDomain, terminateExperimentExecutionResetEvent); List<ExperimentNode> vertices; List<ExperimentNodeConnection> edges; bool noErrors = ExperimentValidator.ValidateExperiment(experiment, out vertices, out edges, workspaceTypeDirectories, validateInputMapping, loggerNameRoot); if (noErrors) { foreach (ExperimentNode node in vertices) { try { runnableExperiment.AddNode(node.ID, node.Data.Metadata, loggerNameRoot); } catch (TraceLab.Core.Exceptions.IncorrectSubTemplateException ex) { runnableExperiment.Clear(); noErrors = false; NLog.LogManager.GetCurrentClassLogger().Error(ex.Message); node.SetError(ex.Message); break; } catch (Exception ex) { runnableExperiment.Clear(); noErrors = false; string msg = "Unable to initialize component: " + ex.Message; NLog.LogManager.GetCurrentClassLogger().Error(msg, ex); node.SetError(msg); break; } } } if (noErrors) { foreach (ExperimentNodeConnection edge in edges) { runnableExperiment.AddDirectedEdge(edge.Source.ID, edge.Target.ID); } } return runnableExperiment; }
/// <summary> /// Initializes a new instance of the <see cref="ExperimentFactoryReader"/> class. /// </summary> /// <param name="library">The library.</param> /// <param name="experimentLocationRoot">The experiment location root - it can be null in case the experiment belongs to composite component.</param> public ExperimentFactoryReader(Components.IComponentsLibrary library, IEnumerable<IPackageReference> references, string experimentLocationRoot) { if (library == null) throw new ArgumentNullException("library"); m_library = library.GetPackageAwareLibrary(references); m_experimentLocationRoot = experimentLocationRoot; //Create our own namespaces for the output var ns = new System.Xml.Serialization.XmlSerializerNamespaces(); //Add an empty namespace and empty value ns.Add("", ""); m_nodeSerializer = TraceLab.Core.Serialization.XmlSerializerFactory.GetSerializer(typeof(SerializedVertexData), null); m_nodeSerializerWithSize = TraceLab.Core.Serialization.XmlSerializerFactory.GetSerializer(typeof(SerializedVertexDataWithSize), null); }
//public ModuleSecurity(int moduleId, int tabId, Hashtable settings) //{ // var moduleController = new ModuleController(); // var s = settings ?? moduleController.GetModuleSettings(moduleId); // Settings = new Settings(s); // return this.ModuleSecurity(moduleId, tabId, Settings); //} public ModuleSecurity(int moduleId, int tabId, Components.Settings settings) { var moduleController = new ModuleController(); Settings = settings ?? new Settings(moduleController.GetModuleSettings(moduleId)); var moduleInfo = moduleController.GetModule(moduleId, tabId); if (moduleInfo == null) return; var mp = moduleInfo.ModulePermissions; _hasEditRowPermission = ModulePermissionController.HasModulePermission(mp, PermissionName.HasEditRowPermission); _hasDeleteRowPermission = ModulePermissionController.HasModulePermission(mp, PermissionName.HasDeleteRowPermission); _hasAddRowPermission = ModulePermissionController.HasModulePermission(mp,PermissionName.HasAddRowPermission); _hasEditPrivateColumnsPermission = ModulePermissionController.HasModulePermission(mp,PermissionName.EditRestricedFieldsPermission); _hasShowAllUserDefinedColumnsPermission = ModulePermissionController.HasModulePermission(mp,PermissionName.ShowAllUserDefinedColumnsPermission); _canEditModuleContent = ModulePermissionController.CanEditModuleContent(moduleInfo); _canManageModule = ModulePermissionController.CanManageModule(moduleInfo); _hasViewListPermission = ModulePermissionController.HasModulePermission(mp, PermissionName.ShowListPermission); _isOnlyAllowedToManipulateHisOwnData = Settings.EditOnlyOwnItems; }
public Components( Components data ) { CommunicationMode = data.CommunicationMode; CommPort = data.CommPort; CommBaudRate = data.CommBaudRate; NetIP = data.NetIP; NetPort = data.NetPort; Password = data.Password; CommActiveFlg = data.CommActiveFlg; CustomizingModeFlg = data.CustomizingModeFlg; CellVisibleFlg = data.CellVisibleFlg; ValidMapPath = data.ValidMapPath; ValidMapLastWrittenDate = data.ValidMapLastWrittenDate; MapList = data.MapList; ViewSettingList = data.ViewSettingList; SettingName = data.SettingName; SettingVer = data.SettingVer; TargetVer = data.TargetVer; }
public static bool CanReach(Components.Joint from, Components.Joint to) { if (from == null || to == null) return false; Components.Joint t = null; Components.Joint[] ta; List<Components.Joint> open = new List<Components.Joint>(); int curOpenInd = 0; open.Add(from); int i, j; while (open.Count > curOpenInd && (t = open[curOpenInd]) != to) { for (i = 0; i < t.ContainingComponents.Count; i++)//find connections through components { ta = t.ContainingComponents[i].FindAccessibleJoints(t); for (j = 0; j < ta.Length; j++) if (!open.Contains(ta[j])) open.Add(ta[j]); } for (i = 0; i < t.ConnectedWires.Count; i++)//find connections through wire if (t.ConnectedWires[i].Graphics.Visible && t.ConnectedWires[i].IsConnected) if (t.ConnectedWires[i].J1 == t) { if (t.ConnectedWires[i].Direction != Components.Wire.WireDirection.J2ToJ1 && !open.Contains(t.ConnectedWires[i].J2)) open.Add(t.ConnectedWires[i].J2); } else if (t.ConnectedWires[i].Direction != Components.Wire.WireDirection.J1ToJ2 && !open.Contains(t.ConnectedWires[i].J1)) open.Add(t.ConnectedWires[i].J1); curOpenInd++; } return t == to; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here Components.Add(new TimerComponent(this)); base.Initialize(); }
public LevelSection(string texture, Rectangle bounds) { Components.Add(new Spatial(bounds.X, bounds.Y)); Components.Add(new Renderable(texture, new Rectangle(0, 0, bounds.Width, bounds.Height))); Components.Add(new LevelRenderable()); }
/// <summary> /// Returns a list of bodies that are inside the given screen rectangle. /// </summary> /// <param name="screenRectangle">A rectangle on the screen (in pixls)</param> /// <returns>The list of bodies whose screen-space bounding boxes intersect the rectangle.</returns> public List <Body> SelectBodies(Rectangle screenRectangle) { return(Components.SelectRootBodiesOnScreen(screenRectangle, CameraController)); }
public NPP() : base("NPP", new Size(400, 400)) { Point center = new Point(200, 200); Components.Add(new GaugeImage("{Helios}/Gauges/MiG-21/NPP/deviation_card.xaml", new Rect(145, 145, 110, 110))); Components.Add(new GaugeImage("{Helios}/Gauges/MiG-21/NPP/black_blinker.xaml", new Rect(170, 170, 10, 20))); Components.Add(new GaugeImage("{Helios}/Gauges/MiG-21/NPP/black_blinker.xaml", new Rect(220, 210, 10, 20))); //course (3, K -“kurs”) and glide slope (8, G - “glisada”) _kFlagImage = new GaugeImage("{Helios}/Gauges/MiG-21/NPP/k_flag.xaml", new Rect(170, 170, 10, 20)); Components.Add(_kFlagImage); _kFlag = new HeliosValue(this, new BindingValue(false), "", "Course (K) flag", "White when lit", "True if displayed.", BindingValueUnits.Boolean); _kFlag.Execute += KFlag_Execute; Actions.Add(_kFlag); _gFlagImage = new GaugeImage("{Helios}/Gauges/MiG-21/NPP/g_flag.xaml", new Rect(220, 210, 10, 20)); Components.Add(_gFlagImage); _gFlag = new HeliosValue(this, new BindingValue(false), "", "Glide (G) flag", "White when lit", "True if displayed.", BindingValueUnits.Boolean); _gFlag.Execute += GFlag_Execute; Actions.Add(_gFlag); _glideslopeDeviationNeedle = new GaugeNeedle("{Helios}/Gauges/MiG-21/NPP/glideslope_deviation_needle.xaml", center, new Size(120, 5), new Point(60, 2.5)); Components.Add(_glideslopeDeviationNeedle); _glideslopeDeviation = new HeliosValue(this, new BindingValue(1d), "", "Glideslope Deviaiton", "Offset of the glideslope deviation needle from center.", "-1 to 1 where -1 is full down.", BindingValueUnits.Numeric); _glideslopeDeviation.Execute += new HeliosActionHandler(GlideslopeDeviation_Execute); Actions.Add(_glideslopeDeviation); _courseDeviationNeedle = new GaugeNeedle("{Helios}/Gauges/MiG-21/NPP/course_deviation_needle.xaml", center, new Size(5, 120), new Point(3, 60)); Components.Add(_courseDeviationNeedle); _courseDeviation = new HeliosValue(this, BindingValue.Empty, "", "Course Deviaiton Needle", "Offset of the course deviation needle from center.", "-1 to 1 where -1 is full right.", BindingValueUnits.Numeric); _courseDeviation.Execute += new HeliosActionHandler(CourseDeviation_Execute); Actions.Add(_courseDeviation); Components.Add(new GaugeImage("{Helios}/Gauges/MiG-21/NPP/compass_card_bezel.xaml", new Rect(73, 73, 254, 254))); _compassCard = new GaugeNeedle("{Helios}/Gauges/MiG-21/NPP/compass_card.xaml", center, new Size(251, 251), new Point(125.5, 125.5)); Components.Add(_compassCard); _heading = new HeliosValue(this, BindingValue.Empty, "", "Heading", "Current heading of the aircraft", "", BindingValueUnits.Degrees); _heading.Execute += Heading_Execute; Actions.Add(_heading); _bearingNeedle = new GaugeNeedle("{Helios}/Gauges/MiG-21/NPP/bearing_needle.xaml", center, new Size(42, 238), new Point(21, 128)); Components.Add(_bearingNeedle); _bearing = new HeliosValue(this, BindingValue.Empty, "", "Bearing", "Current direction the bearing needle is pointing.", "", BindingValueUnits.Degrees); _bearing.Execute += Bearing_Execute; Actions.Add(_bearing); _courseNeedle = new GaugeNeedle("{Helios}/Gauges/MiG-21/NPP/course_needle.xaml", center, new Size(42, 238), new Point(21, 128)); Components.Add(_courseNeedle); _course = new HeliosValue(this, BindingValue.Empty, "", "Commanded Course", "Current commanded course.", "", BindingValueUnits.Degrees); _course.Execute += Course_Execute; Actions.Add(_course); _innerBezelMarkers = new GaugeNeedle("{Helios}/Gauges/MiG-21/NPP/inner_bezel_markers.xaml", center, new Size(166, 166), new Point(83, 83)); Components.Add(_innerBezelMarkers); Components.Add(new GaugeImage("{Helios}/Gauges/MiG-21/NPP/outer_bezel.xaml", new Rect(0, 0, 400, 400))); }
public CommProtocol() { myComponents = new Components(); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(SpriteBlendMode.AlphaBlend); if (gameState == GameState.SplashScreen) { Vector2 pos = new Vector2(ScreenWidth / 2, ScreenHeight / 2); spriteBatch.Draw(splashscreen, pos, null, Color.White, 0.0f, new Vector2(splashscreen.Width / 2, splashscreen.Height / 2), 1.0f, SpriteEffects.None, 1.0f); } else if (gameState == GameState.GameWin) { Vector2 pos = new Vector2(ScreenWidth / 2, ScreenHeight / 2); spriteBatch.Draw(endscreen, pos, null, Color.White, 0.0f, new Vector2(endscreen.Width / 2, endscreen.Height / 2), 1.0f, SpriteEffects.None, 1.0f); } else { lvl.Draw(spriteBatch); // Get sorted list so UpdateOrder also defines render order IEnumerable <GameComponent> sortedComponents = Components.Cast <GameComponent>().OrderBy(gameComponent => gameComponent.UpdateOrder); foreach (GameObject gameObject in sortedComponents) { if (gameObject != null) { gameObject.Draw(spriteBatch); } } if (gameState == GameState.LevelWin) { Vector2 pos = new Vector2(ScreenWidth / 2, ScreenHeight / 2); spriteBatch.Draw(winLevel, pos, null, Color.White, 0.0f, new Vector2(winLevel.Width / 2, winLevel.Height / 2), 1.0f, SpriteEffects.None, 1.0f); } else if (gameState == GameState.LevelLoose) { Vector2 pos = new Vector2(ScreenWidth / 2, ScreenHeight / 2); spriteBatch.Draw(loseLevel, pos, null, Color.White, 0.0f, new Vector2(loseLevel.Width / 2, loseLevel.Height / 2), 1.0f, SpriteEffects.None, 1.0f); } } spriteBatch.End(); base.Draw(gameTime); }
public Game1() { graphics = new GraphicsDeviceManager(this); screenManager = Components.Add <ScreenManager>(); }
} // AddComponent #endregion #region Remove Component /// <summary> /// Removes a component to the game object. /// </summary> /// <remarks> /// A component is not really destroyed, is recycled, it returns to the component pool. /// </remarks> /// <typeparam name="TComponentType">Component Type</typeparam> public override void RemoveComponent <TComponentType>() { #region Transform if (typeof(TComponentType) == typeof(Transform3D)) { throw new ArgumentException("Game Object 3D: Unable to remove the 3D transform component. The transform component can’t be replaced or removed."); } if (typeof(TComponentType) == typeof(Transform2D)) { throw new ArgumentException("Game Object 3D: Unable to remove the 2D transform component. A 3D Game Object does not work in 2D."); } #endregion #region Model Filter if (typeof(TComponentType) == typeof(ModelFilter)) { if (modelFilterAccessor == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the model filter component. There is not one."); } ModelFilter.Uninitialize(); Components.Remove(ModelFilter); ModelFilter.ComponentPool.Release(modelFilterAccessor); ModelFilter = null; modelFilterAccessor = null; } #endregion #region Model Renderer if (typeof(TComponentType) == typeof(ModelRenderer)) { if (modelRendererAccessor == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the model renderer component. There is not one."); } ModelRenderer.Uninitialize(); Components.Remove(ModelRenderer); ModelRenderer.ComponentPool.Release(modelRendererAccessor); ModelRenderer = null; modelRendererAccessor = null; } #endregion #region Animation if (typeof(TComponentType) == typeof(RootAnimations)) { if (rootAnimationAccessor == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the root animation component. There is not one."); } RootAnimations.Uninitialize(); Components.Remove(RootAnimations); RootAnimations.ComponentPool.Release(rootAnimationAccessor); RootAnimations = null; rootAnimationAccessor = null; } if (typeof(TComponentType) == typeof(ModelAnimations)) { if (modelAnimationAccessor == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the model animation component. There is not one."); } ModelAnimations.Uninitialize(); Components.Remove(ModelAnimations); ModelAnimations.ComponentPool.Release(modelAnimationAccessor); ModelAnimations = null; modelAnimationAccessor = null; } #endregion #region Camera if (typeof(TComponentType) == typeof(Camera)) { if (cameraAccessor == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the camera component. There is not one."); } Camera.Uninitialize(); Components.Remove(Camera); Camera.ComponentPool.Release(cameraAccessor); Camera = null; cameraAccessor = null; Camera.SortCamerasByRenderingOrder(); } #endregion #region Light if (typeof(Light).IsAssignableFrom(typeof(TComponentType))) { if (Light == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the light component. There is not one."); } Light.Uninitialize(); if (typeof(TComponentType) == typeof(DirectionalLight)) { DirectionalLight.ComponentPool.Release(directionalLightAccessor); directionalLightAccessor = null; DirectionalLight = null; } else if (typeof(TComponentType) == typeof(PointLight)) { PointLight.ComponentPool.Release(pointLightAccessor); pointLightAccessor = null; PointLight = null; } else if (typeof(TComponentType) == typeof(SpotLight)) { SpotLight.ComponentPool.Release(spotLightAccessor); spotLightAccessor = null; SpotLight = null; } else { throw new InvalidOperationException("Game Object 3D: Unable to remove the light component."); } Components.Remove(Light); Light = null; } #endregion #region Particle Emitter if (typeof(TComponentType) == typeof(ParticleEmitter)) { if (particleEmitterAccessor == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the particle emitter component. There is not one."); } ParticleEmitter.Uninitialize(); Components.Remove(ParticleEmitter); ParticleEmitter.ComponentPool.Release(particleEmitterAccessor); ParticleEmitter = null; particleEmitterAccessor = null; } #endregion #region Particle Renderer if (typeof(TComponentType) == typeof(ParticleRenderer)) { if (particleRendererAccessor == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the particle renderer component. There is not one."); } ParticleRenderer.Uninitialize(); Components.Remove(ParticleRenderer); ParticleRenderer.ComponentPool.Release(particleRendererAccessor); ParticleRenderer = null; particleRendererAccessor = null; } #endregion #region Script if (typeof(Script).IsAssignableFrom(typeof(TComponentType))) { Component script = XNAFinalEngine.Components.Script.ContainScript <TComponentType>(this); if (script == null) { throw new ArgumentException("Game Object 3D: Unable to remove the script component. There is not one."); } script.Uninitialize(); Components.Remove(script); scripts.Remove((Script)script); } #endregion #region Sound Emitter if (typeof(TComponentType) == typeof(SoundEmitter)) { if (soundEmitterAccessor == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the sound emitter component. There is not one."); } SoundEmitter.Uninitialize(); Components.Remove(SoundEmitter); SoundEmitter.ComponentPool.Release(soundEmitterAccessor); SoundEmitter = null; soundEmitterAccessor = null; } #endregion #region Sound Listener if (typeof(TComponentType) == typeof(SoundListener)) { if (soundListenerAccessor == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the sound listener component. There is not one."); } SoundListener.Uninitialize(); Components.Remove(SoundListener); SoundListener.ComponentPool.Release(soundListenerAccessor); SoundListener = null; soundListenerAccessor = null; } #endregion #region HUD Text if (typeof(TComponentType) == typeof(HudText)) { if (hudTextAccessor == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the HUD text component. There is not one."); } HudText.Uninitialize(); Components.Remove(HudText); HudText.ComponentPool3D.Release(hudTextAccessor); HudText = null; hudTextAccessor = null; } #endregion #region HUD Texture if (typeof(TComponentType) == typeof(HudTexture)) { if (hudTextureAccessor == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the HUD texture component. There is not one."); } HudTexture.Uninitialize(); Components.Remove(HudTexture); HudTexture.ComponentPool3D.Release(hudTextureAccessor); HudTexture = null; hudTextureAccessor = null; } #endregion #region Line Renderer if (typeof(TComponentType) == typeof(LineRenderer)) { if (lineRendererAccessor == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the line renderer component. There is not one."); } LineRenderer.Uninitialize(); Components.Remove(LineRenderer); LineRenderer.ComponentPool3D.Release(lineRendererAccessor); LineRenderer = null; lineRendererAccessor = null; } #endregion #region Rigid Body if (typeof(TComponentType) == typeof(RigidBody)) { if (rigidBodyAccessor == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the rigid body component. There is not one."); } RigidBody.Uninitialize(); Components.Remove(RigidBody); RigidBody.ComponentPool.Release(rigidBodyAccessor); RigidBody = null; rigidBodyAccessor = null; } #endregion #region Static Collider if (typeof(TComponentType) == typeof(StaticCollider)) { if (staticColliderAccessor == null) { throw new InvalidOperationException("Game Object 3D: Unable to remove the static collider component. There is not one."); } StaticCollider.Uninitialize(); Components.Remove(StaticCollider); StaticCollider.ComponentPool.Release(staticColliderAccessor); StaticCollider = null; staticColliderAccessor = null; } #endregion } // RemoveComponent
public static void Release(ref Components components) { PoolClass <Components> .Recycle(ref components); }
/// <summary> /// Sets the role instance count /// </summary> /// <param name="paths">The service paths</param> /// <param name="roleName">The name of the role to change its instance count</param> /// <param name="instances"></param> public void SetRoleInstances(CloudProjectPathInfo paths, string roleName, int instances) { Components.SetRoleInstances(roleName, instances); Components.Save(paths); }
/// <summary> /// Sets the role VMSize /// </summary> /// <param name="paths">The service paths</param> /// <param name="roleName">The name of the role to change its vm size</param> /// <param name="VMSize">The new role vm size</param> public void SetRoleVMSize(CloudProjectPathInfo paths, string roleName, string VMSize) { Components.SetRoleVMSize(roleName, VMSize); Components.Save(paths); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here walls.LoadContent(Content); var spritesheet = Content.Load <Texture2D>("character"); player = new Player(spritesheet, this); // Parallax Implementation START // Load Textures var backgroundTexture = Content.Load <Texture2D>("background"); var starsTexture = Content.Load <Texture2D>("stars"); var farPlanetsTexture = Content.Load <Texture2D>("farPlanets"); var bigPlanetTexture = Content.Load <Texture2D>("bigPlanet"); var ringPlanetTexture = Content.Load <Texture2D>("ringPlanet"); var mazeTexture = Content.Load <Texture2D>("wall"); var font = Content.Load <SpriteFont>("Calibri"); // Create corresponding StaticSprites var backgroundSprite = new StaticSprite(backgroundTexture, new Vector2(0, 0)); var starsSprite = new StaticSprite(starsTexture, new Vector2(0, 0)); var farPlanetsSprite = new StaticSprite(farPlanetsTexture, new Vector2(100, 200)); var bigPlanetSprite = new StaticSprite(bigPlanetTexture, new Vector2(300, 300)); var ringPlanetSprite = new StaticSprite(ringPlanetTexture, new Vector2(800, 200)); var mazeSprites = new List <StaticSprite>(); foreach (BoundingRectangle wall in walls.Maze) { // set staticsprite for each wall of the maze and give it corresponding position (mazeTexture, wall.Position) var position = new Vector2(wall.X, wall.Y); var sprite = new StaticSprite(mazeTexture, position, wall.Width, wall.Height); mazeSprites.Add(sprite); } var offset = new Vector2(750, 500); offset.X -= player.bounds.X; offset.Y -= player.bounds.Y; var textOffset1 = offset * -1; textOffset1.X += 5; textOffset1.Y += 5; var textOffset2 = offset * -1; textOffset2.X += 5; textOffset2.Y += 35; var fontSpriteFont1 = new FontSpriteTest(font, "Reach the goal in the bottom-right corner using the arrow keys (or WASD keys)", textOffset1, this.player); var fontSpriteFont2 = new FontSpriteTest(font, "Don't touch the walls", textOffset2, this.player); // Create corresponding Parallax Layers var backgroundLayer = new ParallaxLayer(this); var starsLayer = new ParallaxLayer(this); var farPlanetsLayer = new ParallaxLayer(this); var bigPlanetLayer = new ParallaxLayer(this); var playerLayer = new ParallaxLayer(this); var ringPlanetLayer = new ParallaxLayer(this); var mazeLayer = new ParallaxLayer(this); foreach (var sprite in mazeSprites) { mazeLayer.Sprites.Add(sprite); } var fontLayer = new ParallaxLayer(this); // Add sprites to corresponding layers backgroundLayer.Sprites.Add(backgroundSprite); starsLayer.Sprites.Add(starsSprite); farPlanetsLayer.Sprites.Add(farPlanetsSprite); bigPlanetLayer.Sprites.Add(bigPlanetSprite); playerLayer.Sprites.Add(player); ringPlanetLayer.Sprites.Add(ringPlanetSprite); fontLayer.Sprites.Add(fontSpriteFont1); fontLayer.Sprites.Add(fontSpriteFont2); if (player.gameState == GameState.Over) { var textOffsetGameOver = offset * -1; textOffsetGameOver.X += 750; textOffsetGameOver.Y += 500; var fontSpriteFont3 = new FontSpriteTest(font, "Game Over", textOffsetGameOver, this.player); fontLayer.Sprites.Add(fontSpriteFont3); } else if (player.gameState == GameState.Win) { var textOffsetWin = offset * -1; textOffsetWin.X += 750; textOffsetWin.Y += 500; var fontSpriteFont3 = new FontSpriteTest(font, "You Win", textOffsetWin, this.player); fontLayer.Sprites.Add(fontSpriteFont3); } // Create Draw Order (back to front) backgroundLayer.DrawOrder = 0; starsLayer.DrawOrder = 1; farPlanetsLayer.DrawOrder = 2; bigPlanetLayer.DrawOrder = 3; ringPlanetLayer.DrawOrder = 4; playerLayer.DrawOrder = 5; mazeLayer.DrawOrder = 5; fontLayer.DrawOrder = 6; // Add parallax layers to components Components.Add(backgroundLayer); Components.Add(starsLayer); Components.Add(farPlanetsLayer); Components.Add(bigPlanetLayer); Components.Add(playerLayer); Components.Add(ringPlanetLayer); Components.Add(mazeLayer); Components.Add(fontLayer); // SCROLLING WITH PLAYER (PART 8 IN LAB TUTORIAL) backgroundLayer.ScrollController = new PlayerTrackingScrollController(player, 0.1f); starsLayer.ScrollController = new PlayerTrackingScrollController(player, 0.2f); farPlanetsLayer.ScrollController = new PlayerTrackingScrollController(player, 0.3f); bigPlanetLayer.ScrollController = new PlayerTrackingScrollController(player, 0.4f); playerLayer.ScrollController = new PlayerTrackingScrollController(player, 1.0f); ringPlanetLayer.ScrollController = new PlayerTrackingScrollController(player, 0.5f); mazeLayer.ScrollController = new PlayerTrackingScrollController(player, 1.0f); fontLayer.ScrollController = new PlayerTrackingScrollController(player, 1.0f); }
public void Update() { MouseState mouse = Mouse.GetState(); KeyboardState keyboard = Keyboard.GetState(); if (!Enabled) { return; } if (keyboard.IsKeyDown(Keys.LeftAlt) || keyboard.IsKeyDown(Keys.RightAlt)) { BoxYOffset += (float)(mouse.ScrollWheelValue - LastMouseWheel) * 0.01f; LastMouseWheel = mouse.ScrollWheelValue; } else { LastMouseWheel = mouse.ScrollWheelValue; } MouseOverTimer.Update(DwarfTime.LastTime); if (MouseOverTimer.HasTriggered) { List <Body> selected = SelectBodies(new Rectangle(mouse.X - 10, mouse.Y - 10, 20, 20)); if (selected.Count > 0) { OnMouseOver(selected); } } if (isLeftPressed) { if (mouse.LeftButton == ButtonState.Released) { isLeftPressed = false; SelectionBuffer = Components.SelectRootBodiesOnScreen(SelectionRectangle, CameraController); LeftReleased.Invoke(); } else { Vector3 screenPoint = CameraController.Project(ClickPoint3D); ClickPoint = new Point((int)screenPoint.X, (int)screenPoint.Y); UpdateSelectionRectangle(mouse.X, mouse.Y); } } else if (mouse.LeftButton == ButtonState.Pressed) { isLeftPressed = true; ClickPoint = new Point(mouse.X, mouse.Y); ClickPoint3D = PlayState.CursorLightPos; SelectionRectangle = new Rectangle(mouse.X, mouse.Y, 0, 0); } if (AllowRightClickSelection) { if (isRightPressed) { if (mouse.RightButton == ButtonState.Released) { isRightPressed = false; SelectionBuffer = Components.SelectRootBodiesOnScreen(SelectionRectangle, CameraController); RightReleased.Invoke(); } else { Vector3 screenPoint = CameraController.Project(ClickPoint3D); ClickPoint = new Point((int)screenPoint.X, (int)screenPoint.Y); UpdateSelectionRectangle(mouse.X, mouse.Y); } } else if (mouse.RightButton == ButtonState.Pressed) { isRightPressed = true; ClickPoint = new Point(mouse.X, mouse.Y); ClickPoint3D = PlayState.CursorLightPos; SelectionRectangle = new Rectangle(mouse.X, mouse.Y, 0, 0); } } }
private void InitializePhyics() { this.IsMouseVisible = false; world = new PhysicsSystem(); world.CollisionSystem = new CollisionSystemSAP(); world.Gravity = new Vector3(0, -400, 0); intro introduction = new intro(this, "cloudMap"); c1 = new Character(this, new Vector3(0, 650, 40), Vector3.One); _navMesh = new NavMesh(this, "navMesh"); PistolGun pistol = new PistolGun(this, new Vector3(19, -15, 10)); MachineGun machine = new MachineGun(this, new Vector3(20, -15, 20)); Knife knife = new Knife(this, new Vector3(17, -15, 10)); Overlay hud = new Overlay(this, GraphicsDevice); Overlay crosshair = new Overlay(this, GraphicsDevice); boxtest b1 = new boxtest(this, "box", new Vector3(0, 10, 20), new Vector3(10, 10, 10), false); b1.TakesDamage = true; b1.CurLife = 100; Room room = new Room(this, Vector3.Down * 63, Vector3.One); _camera = new Camera(this, c1, 10.0f, 6 / 8f); _camera.Lookat = c1.Body.Position; _camera.CameraMode = Camera.CameraModes.FIRST_PERSON; SkyDome sky = new SkyDome(this, "dome", "white", Vector3.Up * -150, new Vector3(390, 8500, 390)); introduction.DrawOrder = 500; squid s; BillBoarding billy = new BillBoarding(this, "explosionSpriteSheet", new Vector3(0, -40, 0), Vector2.One, new Vector2(5, 5), 50f); Components.Add(billy); for (int i = 0; i < 0; i++) { s = new squid(this, "cone2", new Vector3(r.Next(-500, 500), r.Next(0, 800), r.Next(-500, 500)), Vector3.One, 50, 50); Components.Add(s); } hud.DrawOrder = 2; crosshair.DrawOrder = 2; Components.Add(_navMesh); Components.Add(introduction); Components.Add(_camera); Components.Add(sky); Components.Add(hud); Components.Add(crosshair); Components.Add(pistol); Components.Add(machine); Components.Add(knife); Components.Add(b1); Components.Add(c1); Components.Add(room); c1.PickUpWeapon(pistol); c1.PickUpWeapon(machine); c1.PickUpWeapon(knife); }
public PheggPlayer(GameObject player) { if (player == null) { throw new Exception("Cannot create PheggPlayer from null game object"); } else if (player.GetComponent <CharacterClassManager>().isLocalPlayer) { Base.Debug("Cannot create PheggPlayer for server"); return; } else { try { #region components _CharacterClassManager = player.GetComponent <CharacterClassManager>(); _serverRoles = player.GetComponent <ServerRoles>(); _nicknameSync = player.GetComponent <NicknameSync>(); _queryProcessor = player.GetComponent <QueryProcessor>(); _handcuffs = player.GetComponent <Handcuffs>(); _playerStats = player.GetComponent <PlayerStats>(); _ammoBox = player.GetComponent <AmmoBox>(); _inventory = player.GetComponent <Inventory>(); _plyMovementSync = player.GetComponent <PlayerMovementSync>(); _banPlayer = player.GetComponent <BanPlayer>(); _networkConnection = player.GetComponent <NetworkConnection>(); _broadcast = player.GetComponent <Broadcast>(); #endregion name = _nicknameSync.MyNick; nameClean = _filterNames.Replace(name, string.Empty); userId = _CharacterClassManager.UserId; domain = _CharacterClassManager.UserId.Split('@')[1].ToUpper(); ipAddress = _nicknameSync.connectionToClient.address; playerId = _queryProcessor.PlayerId; gameObject = player; commonComponents = new Components { ccm = _CharacterClassManager, sr = _serverRoles, ns = _nicknameSync, qp = _queryProcessor, hc = _handcuffs, ps = _playerStats, ab = _ammoBox, inv = _inventory, pms = _plyMovementSync, bp = _banPlayer, nc = _networkConnection, bc = _broadcast }; } catch (Exception e) { throw new Exception(e.ToString()); } } }
public void RemoveComponent(IUValueComponent component) { Components.Remove(component); }
protected override void Initialize() { Components.Add(gameConsole = new GameConsole(this)); base.Initialize(); }
protected override void Initialize() { #region ロギング logger.Info("Initialize"); EnvironmentLog.Info(); GraphicsAdapterLog.Info(); #endregion #region FPS カウンタ var fpsCounter = new FpsCounter(this); fpsCounter.Content.RootDirectory = "Content"; fpsCounter.HorizontalAlignment = DebugHorizontalAlignment.Right; fpsCounter.SampleSpan = TimeSpan.FromSeconds(2); //fpsCounter.Enabled = false; //fpsCounter.Visible = false; Components.Add(fpsCounter); #endregion #region タイム ルーラ timeRuler = new TimeRuler(this); timeRuler.BackgroundColor = Color.Black; timeRuler.Visible = false; Components.Add(timeRuler); #endregion #region モニタ monitorListener = new TimeRulerMonitorListener(timeRuler); Instrument.Listeners.Add(monitorListener); int barIndex = 0; monitorListener.CreateMarker(InstrumentUpdate, barIndex, Color.White); barIndex++; monitorListener.CreateMarker(PartitionManager.InstrumentUpdate, barIndex, Color.Cyan); barIndex++; monitorListener.CreateMarker(PartitionManager.InstrumentCheckPassivations, barIndex, Color.Orange); monitorListener.CreateMarker(PartitionManager.InstrumentCheckActivations, barIndex, Color.Green); monitorListener.CreateMarker(PartitionManager.InstrumentPassivate, barIndex, Color.Red); barIndex++; monitorListener.CreateMarker(ChunkManager.InstrumentProcessProcessBuildVerticesRequests, barIndex, Color.Green); barIndex++; monitorListener.CreateMarker(ChunkManager.InstrumentProcessChunkTaskRequests, barIndex, Color.Yellow); barIndex++; monitorListener.CreateMarker(ChunkManager.InstrumentUpdateMeshBuffers, barIndex, Color.Magenta); barIndex++; monitorListener.CreateMarker(RegionManager.InstrumentUpdate, barIndex, Color.White); barIndex++; monitorListener.CreateMarker(InstrumentDraw, barIndex, Color.White); barIndex++; monitorListener.CreateMarker(SceneManager.InstrumentDraw, barIndex, Color.Cyan); barIndex++; monitorListener.CreateMarker(SceneManager.InstrumentDrawShadowMap, barIndex, Color.Cyan); monitorListener.CreateMarker(SceneManager.InstrumentDrawScene, barIndex, Color.Orange); monitorListener.CreateMarker(SceneManager.InstrumentOcclusionQuery, barIndex, Color.Green); monitorListener.CreateMarker(SceneManager.InstrumentDrawSceneObjects, barIndex, Color.Red); monitorListener.CreateMarker(SceneManager.InstrumentDrawParticles, barIndex, Color.Yellow); monitorListener.CreateMarker(SceneManager.InstrumentPostProcess, barIndex, Color.Magenta); #endregion #region テクスチャ ディスプレイ textureDisplay = new TextureDisplay(this); textureDisplay.Visible = false; Components.Add(textureDisplay); #endregion base.Initialize(); }
public void Dispose() { Components.Clear(); InternalCache[Type].Enqueue((IList)Components); }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { SyncFlag = true; base.Init(objectBuilder, cubeGrid); var builder = (MyObjectBuilder_OxygenTank)objectBuilder; IsStockpiling = builder.IsStockpiling; InitializeConveyorEndpoint(); NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME; if (MyFakes.ENABLE_INVENTORY_FIX) { FixSingleInventory(); if (this.GetInventory() != null) { this.GetInventory().Constraint = BlockDefinition.InputInventoryConstraint; } } if (this.GetInventory() == null) { MyInventory inventory = new MyInventory(BlockDefinition.InventoryMaxVolume, BlockDefinition.InventorySize, MyInventoryFlags.CanReceive); inventory.Constraint = BlockDefinition.InputInventoryConstraint; Components.Add <MyInventoryBase>(inventory); inventory.Init(builder.Inventory); } Debug.Assert(this.GetInventory().Owner == this, "Ownership was not set!"); m_autoRefill = builder.AutoRefill; var sourceDataList = new List <MyResourceSourceInfo> { new MyResourceSourceInfo { ResourceTypeId = BlockDefinition.StoredGasId, DefinedOutput = 0.05f * BlockDefinition.Capacity }, }; SourceComp.Init(BlockDefinition.ResourceSourceGroup, sourceDataList); SourceComp.OutputChanged += Source_OutputChanged; SourceComp.Enabled = Enabled; var sinkDataList = new List <MyResourceSinkInfo> { new MyResourceSinkInfo { ResourceTypeId = MyResourceDistributorComponent.ElectricityId, MaxRequiredInput = BlockDefinition.OperationalPowerConsumption, RequiredInputFunc = ComputeRequiredPower }, new MyResourceSinkInfo { ResourceTypeId = BlockDefinition.StoredGasId, MaxRequiredInput = Capacity, RequiredInputFunc = ComputeRequiredGas }, }; ResourceSink.Init( BlockDefinition.ResourceSinkGroup, sinkDataList); ResourceSink.IsPoweredChanged += PowerReceiver_IsPoweredChanged; ResourceSink.CurrentInputChanged += Sink_CurrentInputChanged; m_lastOutputUpdateTime = MySession.Static.GameplayFrameCounter; m_lastInputUpdateTime = MySession.Static.GameplayFrameCounter; m_nextGasTransfer = 0f; ChangeFilledRatio(builder.FilledRatio); ResourceSink.Update(); AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint)); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; IsWorkingChanged += MyOxygenTank_IsWorkingChanged; }
} // DisposeManagedResources #endregion #region Add Component /// <summary> /// Adds a component of type TComponentType to the game object. /// </summary> /// <typeparam name="TComponentType">Component Type</typeparam> public override Component AddComponent <TComponentType>() { Component result = null; #region Transform // Get from a pool or create the component. if (typeof(TComponentType) == typeof(Transform3D)) { throw new ArgumentException("Game Object 3D: Unable to create the 3D transform component. The transform component can’t be replaced or removed."); } if (typeof(TComponentType) == typeof(Transform2D)) { throw new ArgumentException("Game Object 3D: Unable to create the 2D transform component. A 3D Game Object does not work in 2D."); } #endregion #region Model Filter if (typeof(TComponentType) == typeof(ModelFilter)) { if (modelFilterAccessor != null) { throw new ArgumentException("Game Object 3D: Unable to create the model filter component. There is one already."); } // Search for an empty component in the pool. modelFilterAccessor = ModelFilter.ComponentPool.Fetch(); // A component is a reference value, so no problem to do this. ModelFilter = ModelFilter.ComponentPool[modelFilterAccessor]; // Initialize the component to the default values. ModelFilter.Initialize(this); result = ModelFilter; } #endregion #region Model Renderer if (typeof(TComponentType) == typeof(ModelRenderer)) { if (modelRendererAccessor != null) { throw new ArgumentException("Game Object 3D: Unable to create the model renderer component. There is one already."); } // Search for an empty component in the pool. modelRendererAccessor = ModelRenderer.ComponentPool.Fetch(); // A component is a reference value, so no problem to do this. ModelRenderer = ModelRenderer.ComponentPool[modelRendererAccessor]; // Initialize the component to the default values. ModelRenderer.Initialize(this); result = ModelRenderer; } #endregion #region Root Animation if (typeof(TComponentType) == typeof(RootAnimations)) { if (rootAnimationAccessor != null) { throw new ArgumentException("Game Object 3D: Unable to create the root animation component. There is one already."); } // Search for an empty component in the pool. rootAnimationAccessor = RootAnimations.ComponentPool.Fetch(); // A component is a reference value, so no problem to do this. RootAnimations = RootAnimations.ComponentPool[rootAnimationAccessor]; // Initialize the component to the default values. RootAnimations.Initialize(this); result = RootAnimations; } #endregion #region Model Animation if (typeof(TComponentType) == typeof(ModelAnimations)) { if (modelAnimationAccessor != null) { throw new ArgumentException("Game Object 3D: Unable to create the model animation component. There is one already."); } // Search for an empty component in the pool. modelAnimationAccessor = ModelAnimations.ComponentPool.Fetch(); // A component is a reference value, so no problem to do this. ModelAnimations = ModelAnimations.ComponentPool[modelAnimationAccessor]; // Initialize the component to the default values. ModelAnimations.Initialize(this); result = ModelAnimations; } #endregion #region Camera if (typeof(TComponentType) == typeof(Camera)) { if (cameraAccessor != null) { throw new ArgumentException("Game Object 3D: Unable to create the camera component. There is one already."); } // Search for an empty component in the pool. cameraAccessor = Camera.ComponentPool.Fetch(); // A component is a reference value, so no problem to do this. Camera = Camera.ComponentPool[cameraAccessor]; // Initialize the component to the default values. Camera.Initialize(this); result = Camera; } #endregion #region Light if (typeof(Light).IsAssignableFrom(typeof(TComponentType))) { if (Light != null) { throw new ArgumentException("Game Object 3D: Unable to create the light component. There is one already."); } if (typeof(TComponentType) == typeof(DirectionalLight)) { // Search for an empty component in the pool. directionalLightAccessor = DirectionalLight.ComponentPool.Fetch(); // A component is a reference value, so no problem to do this. Light = DirectionalLight.ComponentPool[directionalLightAccessor]; DirectionalLight = DirectionalLight.ComponentPool[directionalLightAccessor]; } else if (typeof(TComponentType) == typeof(PointLight)) { // Search for an empty component in the pool. pointLightAccessor = PointLight.ComponentPool.Fetch(); // A component is a reference value, so no problem to do this. Light = PointLight.ComponentPool[pointLightAccessor]; PointLight = PointLight.ComponentPool[pointLightAccessor]; } else if (typeof(TComponentType) == typeof(SpotLight)) { // Search for an empty component in the pool. spotLightAccessor = SpotLight.ComponentPool.Fetch(); // A component is a reference value, so no problem to do this. Light = SpotLight.ComponentPool[spotLightAccessor]; SpotLight = SpotLight.ComponentPool[spotLightAccessor]; } else { throw new ArgumentException("Game Object 3D: Unable to create the light component."); } // Initialize the component to the default values. Light.Initialize(this); result = Light; } #endregion #region Particle Emitter if (typeof(ParticleEmitter).IsAssignableFrom(typeof(TComponentType))) { if (ParticleEmitter != null) { throw new ArgumentException("Game Object 3D: Unable to create the particle emitter component. There is one already."); } // Search for an empty component in the pool. particleEmitterAccessor = ParticleEmitter.ComponentPool.Fetch(); // A component is a reference value, so no problem to do this. ParticleEmitter = ParticleEmitter.ComponentPool[particleEmitterAccessor]; // Initialize the component to the default values. ParticleEmitter.Initialize(this); result = ParticleEmitter; } #endregion #region Particle Renderer if (typeof(TComponentType) == typeof(ParticleRenderer)) { if (particleRendererAccessor != null) { throw new ArgumentException("Game Object 3D: Unable to create the particle renderer component. There is one already."); } // Search for an empty component in the pool. particleRendererAccessor = ParticleRenderer.ComponentPool.Fetch(); // A component is a reference value, so no problem to do this. ParticleRenderer = ParticleRenderer.ComponentPool[particleRendererAccessor]; // Initialize the component to the default values. ParticleRenderer.Initialize(this); result = ParticleRenderer; } #endregion #region Script if (typeof(Script).IsAssignableFrom(typeof(TComponentType))) { Component script = XNAFinalEngine.Components.Script.ContainScript <TComponentType>(this); if (script != null) { throw new ArgumentException("Game Object 3D: Unable to create the script component. There is one already."); } script = XNAFinalEngine.Components.Script.FetchScript <TComponentType>(); if (script == null) { script = new TComponentType(); XNAFinalEngine.Components.Script.ScriptList.Add((Script)script); } script.Initialize(this); scripts.Add((Script)script); result = script; } #endregion #region Sound Emitter if (typeof(TComponentType) == typeof(SoundEmitter)) { if (soundEmitterAccessor != null) { throw new ArgumentException("Game Object 3D: Unable to create the sound emitter component. There is one already."); } // Search for an empty component in the pool. soundEmitterAccessor = SoundEmitter.ComponentPool.Fetch(); // A component is a reference value, so no problem to do this. SoundEmitter = SoundEmitter.ComponentPool[soundEmitterAccessor]; // Initialize the component to the default values. SoundEmitter.Initialize(this); result = SoundEmitter; } #endregion #region Sound Listener if (typeof(TComponentType) == typeof(SoundListener)) { if (soundListenerAccessor != null) { throw new ArgumentException("Game Object 3D: Unable to create the sound listener component. There is one already."); } // Search for an empty component in the pool. soundListenerAccessor = SoundListener.ComponentPool.Fetch(); // A component is a reference value, so no problem to do this. SoundListener = SoundListener.ComponentPool[soundListenerAccessor]; // Initialize the component to the default values. SoundListener.Initialize(this); result = SoundListener; } #endregion #region HUD Text if (typeof(TComponentType) == typeof(HudText)) { if (hudTextAccessor != null) { throw new ArgumentException("Game Object 3D: Unable to create the HUD text component. There is one already."); } // Search for an empty component in the pool. hudTextAccessor = HudText.ComponentPool3D.Fetch(); // A component is a reference value, so no problem to do this. HudText = HudText.ComponentPool3D[hudTextAccessor]; // Initialize the component to the default values. HudText.Initialize(this); result = HudText; } #endregion #region HUD Texture if (typeof(TComponentType) == typeof(HudTexture)) { if (hudTextureAccessor != null) { throw new ArgumentException("Game Object 3D: Unable to create the HUD texture component. There is one already."); } // Search for an empty component in the pool. hudTextureAccessor = HudTexture.ComponentPool3D.Fetch(); // A component is a reference value, so no problem to do this. HudTexture = HudTexture.ComponentPool3D[hudTextureAccessor]; // Initialize the component to the default values. HudTexture.Initialize(this); result = HudTexture; } #endregion #region Line Renderer if (typeof(TComponentType) == typeof(LineRenderer)) { if (lineRendererAccessor != null) { throw new ArgumentException("Game Object 3D: Unable to create the line renderer component. There is one already."); } // Search for an empty component in the pool. lineRendererAccessor = LineRenderer.ComponentPool3D.Fetch(); // A component is a reference value, so no problem to do this. LineRenderer = LineRenderer.ComponentPool3D[lineRendererAccessor]; // Initialize the component to the default values. lineRenderer.Initialize(this); result = lineRenderer; } #endregion #region Rigid Body if (typeof(TComponentType) == typeof(RigidBody)) { if (StaticCollider != null) { throw new ArgumentException("Game Object 3D: Unable to create the rigid body component. There is one static collider component already."); } if (rigidBodyAccessor != null) { throw new ArgumentException("Game Object 3D: Unable to create the rigid body component. There is one already."); } // Search for an empty component in the pool. rigidBodyAccessor = RigidBody.ComponentPool.Fetch(); // A component is a reference value, so no problem to do this. RigidBody = RigidBody.ComponentPool[rigidBodyAccessor]; // Initialize the component to the default values. rigidBody.Initialize(this); result = rigidBody; } #endregion #region Static Collider if (typeof(TComponentType) == typeof(StaticCollider)) { if (RigidBody != null) { throw new ArgumentException("Game Object 3D: Unable to create the static collider component. There is one rigid body component already."); } if (staticColliderAccessor != null) { throw new ArgumentException("Game Object 3D: Unable to create the static collider component. There is one already."); } // Search for an empty component in the pool. staticColliderAccessor = StaticCollider.ComponentPool.Fetch(); // A component is a reference value, so no problem to do this. StaticCollider = StaticCollider.ComponentPool[staticColliderAccessor]; // Initialize the component to the default values. staticCollider.Initialize(this); result = staticCollider; } #endregion if (result == null) { throw new ArgumentException("Game Object 3D: Unknown component type."); } Components.Add(result); return(result); } // AddComponent
public bool IsComponent <T>() where T : IComponent => Components.Any(component => component is T);
protected GameObject(string name, TransformDetails transformDetails) : base(GenerateId(), name, transformDetails) { InterestAreaNotifier = Components.AddComponent(new InterestAreaNotifier()); }
public ParallaxObject(Vector2D pos, Rectangle sourceBounds, Vector2D speed, double scale = 1) { Components.Get <Transform>().Position = pos; this.Components.Add(new Parallax("parallax_bg", sourceBounds, speed, scale)); }
public void AddComponent(IUValueComponent component) { Components.Add(component); }
protected override void InitializeAI() { AI = new HumanAI(this); Components.Add(AI); }
private void InitializeMotionAnimator() { MotionAnimator = new MotionAnimatorComponent(this); Components.Add(MotionAnimator); }
private void InitializeJobHandler() { JobHandlerComponent = new JobHandlerComponent(this); Components.Add(JobHandlerComponent); }
public void SetGlobalLight(Components.Light light) { _drawingManager.SetGlobalLight(light.ToInternalLight()); }
private void InitializeInventory() { InventoryComponent = new InventoryComponent(this); Components.Add(InventoryComponent); }
/// <summary> /// /// </summary> public HsbModel() : base() { Components.Add(new HComponent(this)); Components.Add(new SComponent(this)); Components.Add(new BComponent(this)); }
public void Add(string comp) => Components.Add(comp);