protected virtual void CombineComponents() { foreach (Model.Group group in componentList.Groups) { List <Components> combined = new List <Components>(); Components last = null; foreach (Components c in group.CList) { if (last == null) { last = c; } else if (last.Part.ManufacturerPartNumber. Equals(c.Part.ManufacturerPartNumber)) { last.AddComponent(c); } else { combined.Add(last); last = c; } } combined.Add(last); group.CList = combined; } }
public Plane() { transform = (Transform)Components.AddComponent(new Transform()); transform.Position = new Vector2(100, 300); Active = true; transform.Velocity.Y = 8; }
private void AddComponents() { SpriterReader reader = new SpriterReader(); SpriterImporter importer = new SpriterImporter(); var model = reader.Read(importer.Import(Path.Combine("Content\\Spriter", "player.scml")), null, game.Content, game.GraphicsDevice); Animator = new FarmPlayerAnimator(this, model, "player"); //Animator.AnimationEnded += Animator_AnimationEnded; Animator.Scale = 1.0f; animationComponent = new AnimationComponent(this, Animator, "idle_down"); Components.AddComponent(animationComponent); Components.AddComponent(new ExclamationMarkDrawer(game, this)); Components.AddComponent(new MessageBoxComponent(game, this)); Components.AddComponent(Inventory = new PlayerInventory(this)); Components.AddComponent(viewComponent = new ViewComponent(new Vector2(0, 1))); CreateTools(); WidgetManager widgets = new WidgetManager(game, this); widgets.AddWidget(new ItemWidget(game, this, widgets, "Tool widget")); widgets.AddWidget(new TimeWidget(game, this, widgets, "Time and date widget")); Components.AddComponent(widgets); }
public override void RegisterDefault() { var posComponent = Components.GetComponent <PositionComponent>() ?? new PositionComponent() { Position = new Coordinate(0, new Index3(0, 0, 200), new Vector3(0, 0, 0)) }; Components.AddComponent(posComponent); Components.AddComponent(new GravityComponent()); Components.AddComponent(new BodyComponent() { Mass = 50f, Height = 2f, Radius = 1.5f }); Components.AddComponent(new BodyPowerComponent() { Power = 600f, JumpTime = 120 }); Components.AddComponent(new MoveableComponent()); Components.AddComponent(new BoxCollisionComponent()); Components.AddComponent(new ControllableComponent()); Components.AddComponent(new RenderComponent() { Name = "Wauzi", ModelName = "dog", TextureName = "texdog", BaseZRotation = -90 }, true); Components.AddComponent(new LocalChunkCacheComponent(posComponent.Planet.GlobalChunkCache, 2, 1)); }
private void Initialize(BuildingDataset dataset) { if (dataset != null) { texture = game.Content.Load <Texture2D>(Path.Combine(@"Buildings", dataset.AssetName)); size = dataset.Size; color = Color.White; Doors = new Door[dataset.Doors.Length]; for (int doorIndex = 0; doorIndex < dataset.Doors.Length; doorIndex++) { var doorDataset = dataset.Doors[doorIndex]; Door door = new Door(game, this, doorDataset, mapContainedIn); Doors[doorIndex] = door; } world.WorldObjects.AddGameObjects(Doors); } else { Doors = new Door[0]; size = new Size(128, 64); texture = KhvGame.Temp; color = Color.Brown; } Collider = new BoxCollider(world, this); MapLocator mapLocator; Components.AddComponent(mapLocator = new MapLocator(world, this, mapContainedIn)); mapLocator.ContainingMapActive += new MapLocatorEventHandler(mapLocator_ContainedMapActive); mapLocator.ContainingMapChanged += new MapLocatorEventHandler(mapLocator_ContainedMapChanged); }
private void AddComponents() { Components.AddComponent(new InactivityTimeout(seconds: 60, lookForOperations: false)); var userProfileTracker = Components.AddComponent(new UserProfileTracker(userId, ServerType.GameServerProvider, isUserProfileChanged: true)); userProfileTracker.ChangeUserProfileProperties(); }
public void InitializeFromDataset(ToolDataset dataset) { try { Texture = game.Content.Load <Texture2D>(Path.Combine("Tools", dataset.AssetName)); } catch { Texture = null; } PowerUpComponent powComponent = new PowerUpComponent(this, dataset.MinPow, dataset.MaxPow, dataset.PowTimestep); //TODO temp Size = new Size(32, 32); Components.AddComponent(powComponent); ScriptEngine scriptEngine = game.Components.First( c => c is ScriptEngine) as ScriptEngine; Behaviour = scriptEngine.GetScript <ToolBehaviourScript>( new ScriptBuilder(dataset.Behaviour, new object[] { game, this })); Behaviour.Initialize(); }
protected override void OnAwake() { base.OnAwake(); Components.AddComponent(new PhysicsCollision()); CreateBody(); }
private void InitializeLocator() { MapLocator mapLocator = new MapLocator(world, this, MapContainedIn); mapLocator.ContainingMapActive += new MapLocatorEventHandler(mapLocator_ContainingMapActive); mapLocator.ContainingMapChanged += new MapLocatorEventHandler(mapLocator_ContainingMapChanged); Components.AddComponent(mapLocator); }
private void SetOperationRequestsHandler() { var logOperationsRequest = (bool)Config.Global.Log.OperationsRequest; var logOperationsResponse = (bool)Config.Global.Log.OperationsResponse; var coroutinesManager = Components.AddComponent(new CoroutinesManager(new FiberCoroutinesExecutor(ClientPeerWrapper.Peer.Fiber, 100))); // A coroutines executor is necessary to handle async operation handlers OperationHandlerRegister = new OperationRequestsHandler <TOperationCode>(ClientPeerWrapper.Peer.OperationRequestNotifier, ClientPeerWrapper.Peer.OperationResponseSender, logOperationsRequest, logOperationsResponse, coroutinesManager); }
protected override void OnInitialize() { // 1x1 white texture. Texture2D temp = Content.Load <Texture2D>("temp"); Components.AddComponent(new BorderRenderer(this, temp)); Components.AddComponent(new Grid(this, temp, new Point(tileEngine.TileSizeInPixels.X, tileEngine.TileSizeInPixels.Y))); InitializeInput(); }
public RemoteEntity(Entity originEntity) { var sendableComponents = Components.Where(c => c.Sendable); foreach (var component in sendableComponents) { Components.AddComponent(component); } Id = originEntity.Id; }
protected override void OnAwake() { base.OnAwake(); var executor = Components.GetComponent <ISceneOrderExecutor>().AssertNotNull(); executor.GetUpdateExecutor().StartCoroutine(SimulateWorld()); Components.AddComponent(new PhysicsWorldProvider(world)); }
private void AddComponents() { playerGameObject.Components.AddComponent(new PeerIdGetter(ClientPeerWrapper.PeerId)); Components.AddComponent(new InactivityTimeout(seconds: 240, lookForOperations: true)); Components.AddComponent(new UserProfileTracker(userId, ServerType.Game, isUserProfileChanged: true)); Components.AddComponent(new PlayerGameObjectGetter(playerGameObject)); Components.AddComponent(new InterestManagementNotifier()); Components.AddComponent(new CharacterSender()); Components.AddComponent(new PositionChangesListener()); }
public FeedDispinserInformer(KhvGame game, AnimalFeedDispenser owner) : base(game) { this.owner = owner; size = new Size(32, 32); position = new Vector2(owner.Position.X + size.Width, owner.Position.Y); Components.AddComponent(new DispenserInformerComponent(owner)); texture = game.Content.Load <Texture2D>(Path.Combine("Entities", "info")); Components.AddComponent(new DispenserInformerComponent(owner)); }
public void InitializeFromMapData(MapObjectArguments mapObjectArguments) { MapObjectArgumentReader reader = new MapObjectArgumentReader(mapObjectArguments); world = (game.GameStateManager.Current as GameplayScreen).World; mapContainedIn = mapObjectArguments.MapContainedIn; size = reader.ReadSize(); position = mapObjectArguments.Origin; FeedType = reader.ReadFeedType(); Collider = new BoxCollider(world, this); Components.AddComponent(new FeedingTrayInteractionComponent(this)); }
public Door(KhvGame game, Building owningBuilding, DoorDataset doorDataset, string mapContainedIn) : base(game) { this.mapContainedIn = mapContainedIn; OwningBuilding = owningBuilding; InitializeFromDataset(doorDataset); GameplayScreen screen = game.GameStateManager.Current as GameplayScreen; Collider = new BoxCollider(null, this); DoorInteractionComponent doorInteractionComponent = new DoorInteractionComponent(this); Components.AddComponent(doorInteractionComponent); texture = KhvGame.Temp; }
public void InitializeFromMapData(MapObjectArguments mapObjectArguments) { MapObjectArgumentReader reader = new MapObjectArgumentReader(mapObjectArguments); size = new Size(32, 32); FeedType = reader.ReadFeedType(); position = mapObjectArguments.Origin; informer = new FeedDispinserInformer(game, this); world = (game.GameStateManager.Current as GameplayScreen).World; world.MapManager.OnMapChanged += new MapEventHandler(MapManager_OnMapChanged); Components.AddComponent(new FeedDispenserComponent(this)); feedDataset = (game.Components.First(c => c is RepositoryManager) as RepositoryManager).GetDataSet <FeedDataset>(d => d.Type == FeedType); // TODO: Testi AnimalFeedDispenser - InsertFeed(100) InsertFeed(100); }
public override void RegisterDefault() { Components.AddComponent(new PositionComponent() { Position = new Coordinate(0, new Index3(0, 0, 200), new Vector3(0, 0, 0)) }); Components.AddComponent(new GravityComponent()); Components.AddComponent(new BodyComponent() { Mass = 50f, Height = 2f, Radius = 1.5f }); Components.AddComponent(new BodyPowerComponent() { Power = 600f, JumpTime = 120 }); Components.AddComponent(new MoveableComponent()); Components.AddComponent(new BoxCollisionComponent()); Components.AddComponent(new ControllableComponent()); Components.AddComponent(new RenderComponent() { Name = "Wauzi", ModelName = "dog", TextureName = "texdog", BaseZRotation = -90 }, true); }
private void AddComponents() { usersContainer = Components.AddComponent(new UsersContainer()); }
private void AddComponents() { Components.AddComponent(new PortalContainer()); }
protected void AddCommonComponents() { Components.AddComponent(new ClientPeerProvider(ClientPeerWrapper.PeerId, ClientPeerWrapper.Peer)); Components.AddComponent(new EventSenderWrapper(EventSender.AssertNotNull())); }
protected GameObject(string name, TransformDetails transformDetails) : base(GenerateId(), name, transformDetails) { InterestAreaNotifier = Components.AddComponent(new InterestAreaNotifier()); }
private void AddComponents() { Components.AddComponent(new InactivityTimeout(seconds: 15, lookForOperations: false)); }
private void SubscribeToUserProfilePropertiesChanged() { var userProfilePropertiesChangesEventInvoker = Components.AddComponent(new UserProfilePropertiesChangesEventInvoker()); userProfilePropertiesChangesEventInvoker.UserProfilePropertiesChanged += OnUserProfilePropertiesChanged; }
public void CreateBubbleMessageNotifier(string message, int time) { Components.AddComponent(new BubbleMessageNotifier(message, time)); }
private void OnAuthenticated(int userId) { OperationHandlerRegister.Dispose(); Components.AddComponent(new UserProfileTracker(userId, ServerType.Login, isUserProfileChanged: true)); }
private void AddHandlerForChangeUserProfilePropertiesOperation() { userProfilePropertiesChangesNotifier = Components.AddComponent(new UserProfilePropertiesChangesNotifier()); OperationHandlerRegister.SetHandler(UserProfileOperations.ChangeUserProfileProperties, new ChangeUserProfilePropertiesOperationHandler(usersContainer, userProfilePropertiesChangesNotifier)); }
public ConsumableItem(KhvGame game, ConsumableItemDataset itemDataset) : base(game) { Components.AddComponent(new ThrowableComponent(this)); InitializeFromDataset(itemDataset); }
public Portal(Vector2 position, Maps destinationMap) : base("Portal", new TransformDetails(position, Vector2.Zero, Direction.Left)) { Components.AddComponent(new PortalInfoProvider(destinationMap)); }