public void StaticStateChange(String location, Item item, IStaticObject staticObject) { if (location == GameValues.CollisionDirectionTop) { new GenericStaticGroundCollisionCommand(item, staticObject).Execute(); } else if (location == GameValues.CollisionDirectionBottom) { if (item.ItemState.ToString() == "SuperMario.ItemStates.Star") { item.Velocity = new Vector2(item.Velocity.X, Vector2.Zero.Y); item.InAir = false; } new GenericStaticBottomCollisionCommand(item, staticObject).Execute(); } else if ((location == GameValues.CollisionDirectionRight || location == GameValues.CollisionDirectionLeft) && staticObject.ToString() != "SuperMario.FloorTile") { new GenericSideCollisionCommand(item).Execute(); } else { new GenericStaticBottomCollisionCommand(item, staticObject).Execute(); item.InAir = false; } }
private GameController() { Borders = new IStaticObject[4]; ServerShips = new ClientShip[10]; CurrentShips = new ClientShip[10]; ClientWindVane = new ClientWindVane(); }
private MineTask CreateTaskByHands(IActor actor, IStaticObject staticObject) { var handMineDepositMethod = new HandMineDepositMethod(_mineDepositMethodRandomSource); var map = SectorManager.CurrentSector.Map; return(new MineTask(actor, staticObject, handMineDepositMethod, map)); }
public void StaticStateChange(String location, IStaticObject staticObject, Enemy enemy) { if (location == GameValues.CollisionDirectionTop) { enemy.Position = new Vector2(enemy.Position.X, staticObject.CollisionRectangle.Top - enemy.CollisionRectangle.Height); enemy.CollisionRectangle = new Rectangle((int)enemy.Position.X, (int)enemy.Position.Y, enemy.CollisionRectangle.Width, enemy.CollisionRectangle.Height); } else if (location == GameValues.CollisionDirectionBottom) { enemy.Position = new Vector2(enemy.Position.X, staticObject.CollisionRectangle.Top - enemy.CollisionRectangle.Height); enemy.CollisionRectangle = new Rectangle((int)enemy.Position.X, (int)enemy.Position.Y, enemy.CollisionRectangle.Width, enemy.CollisionRectangle.Height); enemy.InAir = false; } else if (location == GameValues.CollisionDirectionRight) { enemy.Position = new Vector2(staticObject.CollisionRectangle.Left - enemy.CollisionRectangle.Width, enemy.Position.Y); enemy.CollisionRectangle = new Rectangle((int)enemy.Position.X, (int)enemy.Position.Y, enemy.CollisionRectangle.Width, enemy.CollisionRectangle.Height); enemy.Velocity = new Vector2(enemy.Velocity.X * (-1), enemy.Velocity.Y); enemy.ChangeState(enemy.EnemyState.ToString()); } else if (location == GameValues.CollisionDirectionLeft) { enemy.Position = new Vector2(staticObject.CollisionRectangle.Right, enemy.Position.Y); enemy.CollisionRectangle = new Rectangle((int)enemy.Position.X, (int)enemy.Position.Y, enemy.CollisionRectangle.Width, enemy.CollisionRectangle.Height); enemy.Velocity = new Vector2(enemy.Velocity.X * (-1), enemy.Velocity.Y); enemy.ChangeState(enemy.EnemyState.ToString()); } }
public StaticObjectViewModel(Game game, IStaticObject staticObject, SpriteBatch spriteBatch) { _game = game; StaticObject = staticObject; _spriteBatch = spriteBatch; var graphics = new StaticObjectGraphics(game, staticObject); var worldCoords = HexHelper.ConvertToWorld(((HexNode)StaticObject.Node).OffsetCoords); var hexSize = MapMetrics.UnitSize / 2; var staticObjectPosition = new Vector2( (int)Math.Round(worldCoords[0] * hexSize * Math.Sqrt(3), MidpointRounding.ToEven), (int)Math.Round(worldCoords[1] * hexSize * 2 / 2, MidpointRounding.ToEven) ); _rootSprite = new SpriteContainer { Position = staticObjectPosition }; var shadowTexture = _game.Content.Load <Texture2D>("Sprites/game-objects/simple-object-shadow"); _rootSprite.AddChild(new Sprite(shadowTexture) { Position = new Vector2(0, 0), Origin = new Vector2(0.5f, 0.5f), Color = new Color(Color.White, 0.5f) }); _rootSprite.AddChild(graphics); }
private MineTask CreateTaskByInstrument(IActor actor, IStaticObject staticObject, Equipment equipedTool) { var toolMineDepositMethod = new ToolMineDepositMethod(equipedTool, _mineDepositMethodRandomSource); var map = SectorManager.CurrentSector.Map; return(new MineTask(actor, staticObject, toolMineDepositMethod, map)); }
public void HandleStaticCollision(string collisionDirection, IStaticObject staticObjectState) { if (Mario.Instance.PlayableObjectState.ToString() != "SuperMario.MarioStates.DeadMario") { PlayableObjectStateTransitionMachine.StaticStateChange(collisionDirection, staticObjectState); } }
private MineTask CreateTaskByInstrument(IActor actor, IStaticObject staticObject, Equipment equipedTool) { var toolMineDepositMethod = new ToolMineDepositMethod(equipedTool, _mineDepositMethodRandomSource); var taskContext = new ActorTaskContext(_player.SectorNode.Sector); return(new MineTask(actor, taskContext, staticObject, toolMineDepositMethod)); }
//Public wrapper for OnStaticObjectChanged public void ChangedStaticObject (Floor tile, IStaticObject Obj) { StaticObjectChangedArgs a = new StaticObjectChangedArgs(); a.x = tile.X; a.y = tile.Y; a.SObject = Obj; OnStaticObjectChanged(a); }
private OpenContainerTask CreateTask(IActor actor, IStaticObject staticObject) { var openMethod = new HandOpenContainerMethod(); var taskContext = new ActorTaskContext(_player.SectorNode.Sector); return(new OpenContainerTask(actor, taskContext, staticObject, openMethod)); }
public MineTask(IActor actor, IActorTaskContext context, IStaticObject staticObject, IMineDepositMethod method) : base(actor, context) { _staticObject = staticObject ?? throw new ArgumentNullException(nameof(staticObject)); _method = method ?? throw new ArgumentNullException(nameof(method)); }
private MineTask CreateTaskByHands(IActor actor, IStaticObject staticObject) { var handMineDepositMethod = new HandMineDepositMethod(_mineDepositMethodRandomSource); var taskContext = new ActorTaskContext(_player.SectorNode.Sector); return(new MineTask(actor, taskContext, staticObject, handMineDepositMethod)); }
public OpenContainerTask([NotNull] IActor actor, [NotNull] IActorTaskContext context, [NotNull] IStaticObject staticObject, [NotNull] IOpenContainerMethod method) : base(actor, context) { _staticObject = staticObject ?? throw new ArgumentNullException(nameof(staticObject)); _method = method ?? throw new ArgumentNullException(nameof(method)); }
public OpenContainerTask([NotNull] IActor actor, [NotNull] IStaticObject staticObject, [NotNull] IOpenContainerMethod method, [NotNull] ISectorMap map) : base(actor) { _staticObject = staticObject ?? throw new ArgumentNullException(nameof(staticObject)); _method = method ?? throw new ArgumentNullException(nameof(method)); _map = map ?? throw new ArgumentNullException(nameof(map)); }
/// <summary> /// Non physical Collision response /// Passed to the Behaviour states only if the other object is a static object /// </summary> /// <param name="_otherObj">Other object collided with</param> public void Collision(ICollidable _otherObj) { IStaticObject asInterface = _otherObj as IStaticObject; if (asInterface != null) { mCurrentState.Collision(_otherObj); } }
public static TStaticObjectModule GetModule <TStaticObjectModule>(this IStaticObject staticObject) where TStaticObjectModule : IStaticObjectModule { if (staticObject is null) { throw new ArgumentNullException(nameof(staticObject)); } return(staticObject.GetModule <TStaticObjectModule>(typeof(TStaticObjectModule).Name)); }
public static TStaticObjectModule GetModuleSafe <TStaticObjectModule>(this IStaticObject source) where TStaticObjectModule : IStaticObjectModule { if (source is null) { throw new ArgumentNullException(nameof(source)); } if (!source.HasModule <TStaticObjectModule>()) { return(default);
/// <summary> /// Проверяем, что сундук не на клетке с выходом. /// </summary> private static void ValidateTransitionOverlap(ISector sector, IStaticObject container) { var transitionNodes = sector.Map.Transitions.Keys; var chestOnTransitionNode = transitionNodes.Contains(container.Node); if (chestOnTransitionNode) { throw new SectorValidationException(); } }
/*Branch – Our branches always have exactly two children (known as left and right) and are assigned an AABB that is large enough to contain all of it’s descendants. * Leaf – Our leaves are associated with a game world object and through that have an AABB. A leaf’s AABB must fit entirely within it’s parents AABB and due to how our branches are defined that means it fits in every ancestors AABB. * Root – Our root may be a branch or a leaf*/ public virtual void Insert(IStaticObject myStaticObject) { if (IsReadonly) { throw new Exception("Someone was either stuck processing or didn't properly dispose of Enumerator for AABBTree."); } IAABBNode myNewNode = new AABBStaticDataNode(myStaticObject.Bounds, this, myStaticObject); this.StaticNodeLookup.Add(myStaticObject, myNewNode); Insert(myNewNode); }
public DepositLifetimeModule(IStaticObjectManager staticObjectManager, IStaticObject parentStaticObject) { _staticObjectManager = staticObjectManager ?? throw new ArgumentNullException(nameof(staticObjectManager)); _parentStaticObject = parentStaticObject ?? throw new ArgumentNullException(nameof(parentStaticObject)); _depositModule = _parentStaticObject.GetModule <IPropDepositModule>(); _containerModule = _parentStaticObject.GetModule <IPropContainer>(); _depositModule.Mined += DepositModule_Mined; _containerModule.ItemsRemoved += ContainerModule_ItemsRemoved; }
public bool Contains(IStaticObject myItem) { foreach (var A in myViewedTree) { if (A.Contains(myItem)) { return(true); } } return(false); }
public StaticObjectGraphics(Game game, IStaticObject staticObject) { var textureName = GetTextureNameByPurpose(staticObject.Purpose); var staticObjectTexture = game.Content.Load <Texture2D>($"Sprites/game-objects/Environment/{textureName}"); var staticObjectSprite = new Sprite(staticObjectTexture) { Origin = new Vector2(0.5f, 0.75f) }; AddChild(staticObjectSprite); }
public static TStaticObjectModule GetModuleSafe <TStaticObjectModule>(this IStaticObject source) where TStaticObjectModule : IStaticObjectModule { if (source is null) { throw new ArgumentNullException(nameof(source)); } if (!source.HasModule <TStaticObjectModule>()) { #pragma warning disable CS8603 // Possible null reference return. return(default);
private static IActorTask TakeAllFromContainerTask(IActor actor, IStaticObject container) { var inventoryTransfer = new PropTransfer(actor.Person.GetModule <IInventoryModule>(), container.GetModule <IPropContainer>().Content.CalcActualItems(), System.Array.Empty <IProp>()); var containerTransfer = new PropTransfer(container.GetModule <IPropContainer>().Content, System.Array.Empty <IProp>(), container.GetModule <IPropContainer>().Content.CalcActualItems()); return(new TransferPropsTask(actor, new[] { inventoryTransfer, containerTransfer })); }
void StaticObjectSetSprite(int x, int y, IStaticObject obj) { GameObject staticObject_go = new GameObject(); go_StaticObjects.Add(obj, staticObject_go); staticObject_go.name = "SO_" + obj.StaticObjectType + "_" + x + "_" + y; staticObject_go.transform.position = new Vector3(x, y); staticObject_go.transform.SetParent(this.transform, true); SpriteRenderer tile_sr = staticObject_go.AddComponent<SpriteRenderer>(); tile_sr.sortingLayerName = "StaticObjects"; SetSaticObjectSprite(x, y, staticObject_go); }
internal void Init(IStaticObject container) { var person = _uiState.ActiveActor?.Actor?.Person; if (person is null) { throw new InvalidOperationException("Active person must be selected before this dialog was opened."); } //InitInventory(person); InitContainerContent(container); }
private static ContainerVm GetLootViewModel(IStaticObject lootInNode) { var viewModels = FindObjectsOfType <ContainerVm>(); foreach (var viewModel in viewModels) { if (viewModel.Container == lootInNode) { return(viewModel); } } return(null); }
public void StaticStateChange(String location, Fireball fireball, IStaticObject staticObject) { if (location == GameValues.CollisionDirectionTop || location == GameValues.CollisionDirectionBottom || staticObject.ToString() == "SuperMario.FloorTile") { fireball.Position = new Vector2(fireball.Position.X, staticObject.CollisionRectangle.Top - fireball.CollisionRectangle.Height); fireball.CollisionRectangle = new Rectangle((int)fireball.Position.X, (int)fireball.Position.Y, fireball.CollisionRectangle.Width, fireball.CollisionRectangle.Height); fireball.Velocity = new Vector2(fireball.Velocity.X, fireball.Velocity.Y * (-1)); } else { fireball.IsAlive = false; } }
private OpenContainerTask CreateTask(IActor actor, IStaticObject staticObject) { var openMethod = new HandOpenContainerMethod(); var sector = _player.SectorNode.Sector; if (sector is null) { throw new InvalidOperationException(); } var taskContext = new ActorTaskContext(sector); return(new OpenContainerTask(actor, taskContext, staticObject, openMethod)); }
private MineTask CreateTaskByHands(IActor actor, IStaticObject staticObject) { var handMineDepositMethod = new HandMineDepositMethod(_mineDepositMethodRandomSource); var sector = _player.SectorNode.Sector; if (sector is null) { throw new InvalidOperationException(); } var taskContext = new ActorTaskContext(sector); return(new MineTask(actor, taskContext, staticObject, handMineDepositMethod)); }
private MineTask CreateTaskByInstrument(IActor actor, IStaticObject staticObject, Equipment equipedTool) { var toolMineDepositMethod = new ToolMineDepositMethod(equipedTool, _mineDepositMethodRandomSource); var sector = _player.SectorNode.Sector; if (sector is null) { throw new InvalidOperationException(); } var taskContext = new ActorTaskContext(sector); return(new MineTask(actor, taskContext, staticObject, toolMineDepositMethod)); }
public void MineDeposit(IStaticObject deposit, IMineDepositMethod method) { if (deposit is null) { throw new ArgumentNullException(nameof(deposit)); } if (method is null) { throw new ArgumentNullException(nameof(method)); } var openResult = method.TryMine(deposit.GetModule <IPropDepositModule>()); DoMineDeposit(deposit, openResult); }
public GenericStaticGroundCollisionCommand(IDynamicObject dynamicObject, IStaticObject staticObject) { this.dynamicObject = dynamicObject; this.staticObject = staticObject; }
public void HandleStaticCollision(string collisionLocation, IStaticObject staticObject) { itemStateTransitionMachine.StaticStateChange(collisionLocation, this, staticObject); }