/// <summary> /// Removes all components. /// </summary> /// <param name="context">The context.</param> public static void RemoveAllComponents(this IWorldContext context) { foreach (var c in context.Components) { context.RemoveComponent(c); } }
private Score(Point position, Snake snake, IWorldContext ctx) : base(position, ctx) { snake.FoodEaten += delegate { var effect = new RectangleComponent(snake.Head.Transform.Position, ctx) { Pixel = '+'.DarkRed() }; effect .Transform .MoveTo(Transform.Position, 1f, Easing.OutCubic) .Do(() => { ctx.RemoveComponent(effect); }) .Once(); this .To(points, points + 10, 1f, Easing.InOutQuint, v => points = (int)v) .Once(); }; Transform.CentralizePivot(); }
public override void InitializeRound(IWorldContext context) { m_context.Cycle = context.Cycle; m_roundBot = context.GetBotsWithKindOfAbility <ISortingBotAbility> () [0]; m_ability = context.GetBotAbility <ISortingBotAbility> (m_roundBot); m_ability.Initialize(m_context); }
/// <summary> /// Updates the environment (run a cycle). /// </summary> /// <param name="context">The world context.</param> public override void Update(IWorldContext context) { Play(m_crossBot, m_crossBotAbility, m_crossBotEnviromentContext); if (HasWinner()) { MakeBotsRank(m_crossBot, m_noughtBot, false, context.Cycle); return; } if (IsDrawn()) { MakeBotsRank(m_crossBot, m_noughtBot, true, context.Cycle); return; } Play(m_noughtBot, m_noughtBotAbility, m_noughtBotEnviromentContext); if (HasWinner()) { MakeBotsRank(m_noughtBot, m_crossBot, false, context.Cycle); return; } if (IsDrawn()) { MakeBotsRank(m_noughtBot, m_crossBot, true, context.Cycle); return; } }
/// <summary> /// Initializes a new instance of the <see cref="RectangleComponent"/> class. /// </summary> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="context">The context.</param> public RectangleComponent(float x, float y, IWorldContext context) : base(context) { Transform = new Transform(x, y, context); Pixel = new Pixel('#'); Filled = false; }
/// <summary> /// Initializes a new instance of the <see cref="LineComponent"/> class. /// </summary> /// <param name="pointA">The point a.</param> /// <param name="pointB">The point b.</param> /// <param name="context">The context.</param> public LineComponent(Point pointA, Point pointB, IWorldContext context) : base(context) { Transform = new Transform(pointA.X, pointA.Y, context); PointB = pointB; Pixel = new Pixel('#'); }
/// <summary> /// Opens the scene. /// </summary> /// <typeparam name="TScene">The type of the scene.</typeparam> /// <param name="context">The context.</param> public static void OpenScene <TScene>(this IWorldContext context) where TScene : IScene { var scene = Activator.CreateInstance(typeof(TScene), context) as IScene; context.OpenScene(scene); }
/// <summary> /// The method creates a new entity with the only component that's already attached to it. /// The component is TDisposableComponent. All entities that have that component are destroyed /// at an end of a frame with a special system. /// </summary> /// <param name="worldContext">A reference to IWorldContext implementation</param> /// <param name="name">A name of an entity (optional)</param> /// <returns>The method returns an identifier of created entity</returns> public static EntityId CreateDisposableEntity(this IWorldContext worldContext, string name = null) { IEntity entity = worldContext.GetEntityById(worldContext.CreateEntity(name)); entity.AddComponent <TDisposableComponent>(); return(entity.Id); }
/// <summary> /// Initializes a new instance of the <see cref="Transform"/> class. /// </summary> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="context">The context.</param> public Transform(float x, float y, IWorldContext context) : base(context) { _scale = Point.Zero; _pivot = Point.Zero; _originalBoundingBox = new Rectangle(x, y, 0, 0); Position = new Point(x, y); }
public ImprovedSpawnSystem(IWorldContext worldContext, GameObject prefab, IGameObjectFactory factory) { mWorldContext = worldContext; mPrefab = prefab; mFactory = factory; }
public void InitializeTest() { ctx = Substitute.For <IWorldContext>(); ctx.LogSystem.Returns(Substitute.For <ILogSystem>()); ctx.Time.Returns(Substitute.For <ITime>()); owner = new Transform(ctx); }
public void Init() { mWorldContext = Substitute.For <IWorldContext>(); mWorldContext.GetEntitiesWithAll().ReturnsForAnyArgs(new List <EntityId> { }); mSystemManager = new SystemManager(mWorldContext); }
public static Wall Create(float x, float y, float scaleX, float scaleY, IWorldContext context) { var wall = new Wall((int)x, (int)y, context); wall.Transform.Scale = new Point(scaleX, scaleY); return(wall); }
public PureReactiveSystemAdapter(IWorldContext worldContext, ReactiveSystemFilter systemFilter, ReactiveLambdaSystem lambdaSystem) { mWorldContext = worldContext ?? throw new System.ArgumentNullException("worldContext"); mReactiveLambdaSystem = lambdaSystem ?? throw new System.ArgumentNullException("lambdaSystem"); mReactiveSystemFilter = systemFilter ?? throw new System.ArgumentNullException("systemFilter"); }
/// <summary> /// Initializes a new instance of the <see cref="InGameLogSystem"/> class. /// </summary> /// <param name="bounds">The bounds.</param> /// <param name="context">The context.</param> public InGameLogSystem(Rectangle bounds, IWorldContext context) : base(context) { this._bounds = bounds; Context = context; Enabled = true; Tag = "InGameLogSystem"; context.AddComponent(this); }
public SnakeTile(float x, float y, IWorldContext context, Action onCollisionFood, Action onCollisionTile, Action onCollisionWall) : base(x, y, context) { this.onCollisionFood = onCollisionFood; this.onCollisionTile = onCollisionTile; this.onCollisionWall = onCollisionWall; Pixel = BodyPixel; }
public static Score Create(Point position, Snake snake, IWorldContext ctx) { var textSize = snake.Context.FontSystem.GetFont().GetTextSize("000000"); position -= textSize; position -= new Point(1, 0); return(new Score(position, snake, ctx)); }
/// <summary> /// Removes the components without tag. /// </summary> /// <param name="context">The context.</param> /// <param name="tags">The tags.</param> public static void RemoveComponentsWithoutTag(this IWorldContext context, params string[] tags) { var toRemove = context.Components.GetWithoutTag(tags); foreach (var c in toRemove) { context.RemoveComponent(c); } }
/// <summary> /// Initializes a new instance of the <see cref="CircleComponent"/> class. /// </summary> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="radius">The radius.</param> /// <param name="context">The context.</param> public CircleComponent(float x, float y, float radius, IWorldContext context) : base(context) { Transform = new Transform(x, y, context) { Scale = new Point(radius * 2) }; Pixel = new Pixel('#'); Filled = true; }
public void Respawn(IWorldContext worldContext) { var environment = worldContext.GetOption(WorldOption.Environment); _networkClient.Send(new MessageClientRespawn.Message( environment.Id, _client.Player.GameMode, LevelType )); }
/// <summary> /// Opens the scene if specified key is down. /// </summary> /// <typeparam name="TScene">The type of the scene.</typeparam> /// <param name="context">The context.</param> /// <param name="ifKeyIsDown">If key is down.</param> /// <returns></returns> public static IWorldContext OpenScene <TScene>(this IWorldContext context, Keys ifKeyIsDown) where TScene : IScene { if (context.InputSystem.IsKeyDown(ifKeyIsDown)) { context.OpenScene <TScene>(); } return(context); }
private void Awake() { mWorldContext = new WorldContextFactory().CreateNewWorldInstance(); mSystemManager = new SystemManager(mWorldContext); WorldContextsManagerUtils.CreateWorldContextManager(mWorldContext, "WorldContextManager_System"); SystemManagerObserverUtils.CreateSystemManagerObserver(mSystemManager, "SystemManagerObserver_System"); mSystemManager.Init(); }
/// <summary> /// The method prepares the view for initialization step /// </summary> /// <param name="worldContext">A reference to IWorldContext implementation</param> public void PreInit(IWorldContext worldContext) { WorldContext = worldContext; // create a new event which is an entity with attached component to inform system to register this view in the world's context IEntity registerViewRequestEntity = worldContext.GetEntityById(worldContext.CreateEntity()); registerViewRequestEntity.AddComponent(new TOnViewWaitForInitEventComponent { mView = this }); }
public void Init() { mWorldContext = new WorldContextFactory().CreateNewWorldInstance(); mSystemManager = new SystemManager(mWorldContext); mRegisterViewsSystem = new RegisterViewSystem(mWorldContext); mSystemManager.RegisterSystem(mRegisterViewsSystem); mSystemManager.Init(); }
/// <summary> /// The extension method returns a new allocated manager of world contexts /// </summary> /// <param name="worldContext"></param> /// <param name="name">A name of a game object that will have WorldContextsManager component</param> /// <returns>The extension method returns a new allocated manager of world contexts</returns> public static WorldContextsManager CreateWorldContextManager(this IWorldContext worldContext, string name = null) { GameObject worldContextsManagerGO = new GameObject(name); WorldContextsManager worldContextsManager = worldContextsManagerGO.AddComponent <WorldContextsManager>(); worldContextsManager.WorldContext = worldContext; worldContextsManager.PrepareViews(); return(worldContextsManager); }
public void InitializeTest() { sinceSceneStart = 0; ctx = Substitute.For <IWorldContext>(); ctx.LogSystem.Returns(Substitute.For <ILogSystem>()); var time = Substitute.For <ITime>(); time.SinceSceneStart.Returns(c => sinceSceneStart); ctx.Time.Returns(time); owner = new Transform(ctx); }
public Portal(Point position, IWorldContext ctx) : base(new Point((int)position.X, (int)position.Y), ctx) { Transform.Scale = DefaultScale; teleportEffect = new RectangleComponent(Transform.Position, 3, ctx) { Pixel = '.'.Blue(), Enabled = false }; teleportEffect.Transform.CentralizePivotX(); }
/// <summary> /// Initializes a new instance of the <see cref="T:Doog.ComponentBase"/> class. /// </summary> /// <param name="context">The world context.</param> /// <param name="addToContext">If set to <c>true</c> the component will be added to context.</param> protected ComponentBase(IWorldContext context, bool addToContext) { Context = context; _enabled = true; Tag = GetType().Name; _children = new List <IComponent>(); if (addToContext) { context.AddComponent(this); } }
public void InitializeTest() { sinceSceneStart = 0; ctx = Substitute.For <IWorldContext>(); ctx.LogSystem.Returns(Substitute.For <ILogSystem>()); var time = Substitute.For <ITime>(); time.SinceSceneStart.Returns(c => sinceSceneStart); ctx.Time.Returns(time); owner = new RectangleComponent(5, 10, ctx); owner.Transform.Scale = new Point(20, 70); }
/// <summary> /// Opens the scene with the specified name. /// </summary> /// <param name="context">The context.</param> /// <param name="name">The scene name.</param> /// <exception cref="ArgumentException">Could not find a scene with name '{0}'".With(name)</exception> public static void OpenScene(this IWorldContext context, string name) { var sceneType = Type.GetType(name) ?? context.GetType().Assembly.GetType(name); if (sceneType == null) { throw new ArgumentException($"Could not find a scene with name '{name}'"); } var scene = Activator.CreateInstance(sceneType, context) as IScene; context.OpenScene(scene); }