public virtual void Fire() { if (AudioSource != null) { AudioSource.Play(); } // if this effect has an explosion force, apply that now CreateExplosion(gameObject.transform.position, ForceRadius, ForceAmount); // start any particle system that is not in the list of manual start particle systems StartParticleSystems(); // If we implement the ICollisionHandler interface, see if any of the children are forwarding // collision events. If they are, hook into them. ICollisionHandler handler = (this as ICollisionHandler); if (handler != null) { FireCollisionForwardScript collisionForwarder = GetComponentInChildren <FireCollisionForwardScript>(); if (collisionForwarder != null) { collisionForwarder.CollisionHandler = handler; } } }
private void getCollider() { if (enemies.Count == 0) { if (type == "Up") { CollisionHandler = new DoorCollisionHandler(this, size.X / 4, size.Y - 16, 0, 0); } else if (type == "Down") { CollisionHandler = new DoorCollisionHandler(this, size.X / 4, size.Y - 16, 0, 0); } else if (type == "Left") { CollisionHandler = new DoorCollisionHandler(this, size.X - 16, size.Y / 4, 0, 0); } else if (type == "Right") { CollisionHandler = new DoorCollisionHandler(this, size.X - 16, size.Y / 4, 0, 0); } } else { CollisionHandler = new DoorCollisionHandler(this, size.X / 4, size.Y / 4, 0, 0); } }
public UsableArrow(Vector2 position, Vector2 direction, IPlayer player) { Position = position; this.player = player; this.direction = direction; if (direction == Vector2.UnitX) { Sprite = UsableItemSpriteFactory.Instance.CreateRightArrowSprite(); CollisionHandler = new UsableItemCollisionHandler(player, this, 32, 8, 0, 0); } else if (direction == -Vector2.UnitX) { Sprite = UsableItemSpriteFactory.Instance.CreateLeftArrowSprite(); CollisionHandler = new UsableItemCollisionHandler(player, this, 32, 8, 0, 0); } else if (direction == Vector2.UnitY) { Sprite = UsableItemSpriteFactory.Instance.CreateDownArrowSprite(); CollisionHandler = new UsableItemCollisionHandler(player, this, 8, 32, 0, 0); } else { Sprite = UsableItemSpriteFactory.Instance.CreateUpArrowSprite(); CollisionHandler = new UsableItemCollisionHandler(player, this, 8, 32, 0, 0); } this.player.ItemCounts[ItemType.Rupee]--; }
private void OnParticleCollision(GameObject other) { ICollisionHandler i = CollisionHandler as ICollisionHandler; if (i != null) { #if UNITY_4 int numCollisionEvents = _particleSystem.GetCollisionEvents(other, collisionEvents); if (numCollisionEvents != 0) { i.HandleCollision(other, collisionEvents, numCollisionEvents); } #elif UNITY_5_3_OR_NEWER int numCollisionEvents = _particleSystem.GetCollisionEvents(other, collisionEvents); if (numCollisionEvents != 0) { i.HandleCollision(other, collisionEvents, numCollisionEvents); } #else int numCollisionEvents = _particleSystem.GetCollisionEvents(other, collisionEvents); if (numCollisionEvents != 0) { i.HandleCollision(other, new List <ParticleCollisionEvent>(collisionEvents), numCollisionEvents); } #endif } }
public void Construct(Settings settings, [Inject(Id = injectId)] IMoveHandler moveHandler, [Inject(Id = injectId)] ICollisionHandler collisionHandler) { this.settings = settings; this.moveHandler = moveHandler; this.collisionHandler = collisionHandler; }
public DeathEffect(Vector2 position) { Position = position; random = new Random(); effectSprite = UsableItemSpriteFactory.Instance.CreateExplosionSprite(); CollisionHandler = new EmptyCollisionHandler(this); }
public SwordBeam(Vector2 position, Vector2 direction, IPlayer player) { Position = position; this.player = player; this.direction = direction; int beamLength = 64; int beamWidth = 24; if (direction == Vector2.UnitX) { Sprite = UsableItemSpriteFactory.Instance.CreateRightSwordBeamSprite(); CollisionHandler = new UsableItemCollisionHandler(player, this, beamLength, beamWidth, 0, 0); } else if (direction == -Vector2.UnitX) { Sprite = UsableItemSpriteFactory.Instance.CreateLeftSwordBeamSprite(); CollisionHandler = new UsableItemCollisionHandler(player, this, beamLength, beamWidth, 0, 0); } else if (direction == Vector2.UnitY) { Sprite = UsableItemSpriteFactory.Instance.CreateDownSwordBeamSprite(); CollisionHandler = new UsableItemCollisionHandler(player, this, beamWidth, beamLength, 0, 0); } else { Sprite = UsableItemSpriteFactory.Instance.CreateUpSwordBeamSprite(); CollisionHandler = new UsableItemCollisionHandler(player, this, beamWidth, beamLength, 0, 0); } }
public Stairs(Vector2 position) { Texture = BlockSpriteFactory.Instance.environment; Position = position; CollisionHandler = new BlockCollisionHandler(this, 60, 60, 0, 0); // RoomBOW RoomB1 }
public ExtendedEngine(int worldWidth, int worldHeight, IObjectGenerator <EnvironmentObject> objectGenerator, ICollisionHandler collisionHandler, IRenderer renderer, IController controller) : base(worldWidth, worldHeight, objectGenerator, collisionHandler, renderer) { this.controller = controller; }
private void getCollider() { if (isBombed[currentRoom]) { if (type == "Up") { CollisionHandler = new DoorCollisionHandler(this, size.X / 4, size.Y - 16, 0, 0); } else if (type == "Down") { CollisionHandler = new DoorCollisionHandler(this, size.X / 4, size.Y - 16, 0, 0); } else if (type == "Left") { CollisionHandler = new DoorCollisionHandler(this, size.X - 16, size.Y / 4, 0, 0); } else if (type == "Right") { CollisionHandler = new DoorCollisionHandler(this, size.X - 16, size.Y / 4, 0, 0); } } else { CollisionHandler = new DoorCollisionHandler(this, size.X / 4, size.Y / 4, 0, 0); } }
public TheGameObjectManager() { marios = new IMario[Players]; blockList = new Collection <IGameObject>(); itemList = new Collection <IGameObject>(); enemyList = new Collection <IGameObject>(); pipeList = new Collection <IGameObject>(); spawnerList = new Collection <IGameObject>(); fireBallList = new Collection <IGameObject>(); fireBallList2 = new Collection <IGameObject>(); backgroundList = new Collection <IGameObject>(); animationList = new Collection <IAnimationInGame>(); collisionHandler = new AllCollisionHandler(); isSinglePlayerGame = true; curShape = new MarioState.MarioShapeEnums[Players]; nextShape_ = new MarioState.MarioShapeEnums[Players]; titleDisplayPanel = new TitleDisplayPanel(); marioLifeDisplayPanel = new MarioLifeDisplayPanel(); gameOverDisplayPanel = new GameOverDisplayPanel(); headsUpDisplayPanel = new HeadsUpDisplayPanel(); competitivePreparingDisplayPanel = new CompetitivePreparingDisplayPanel(); competitiveHeadsUpDisplayPanel = new CompetitiveHeadsUpDisplayPanel(); competitiveEndingDisplayPanel = new CompetitiveEndingDisplayPanel(); player1NameDisplayPanel = new PlayerNameDisplayPanel(); player1NameDisplayPanel.PlayerName.Text = "P1"; player2NameDisplayPanel = new PlayerNameDisplayPanel(); player2NameDisplayPanel.PlayerName.Text = "P2"; spawnManager = new SpawnManager(); }
private void OnTriggerEnter2D(Collider2D collision) { if (!isInited) { Debug.LogError("OnTriggerEnter2D shouldn be called before init"); return; } //Debug.Log("OnTriggerEnter2D " + collision.gameObject.name); ICollisionHandler handler = collision.gameObject.GetComponent <ICollisionHandler>(); bool result = false; if (handler != null) { result = handler.OnCollision( config.Damage, Owner, gameObject, Direction.normalized * config.PushForce); } if (result) { ReturnToPool(); } //Photon.Destroy(); //ReturnToPool(); }
protected virtual void Start() { if (AudioSource != null) { AudioSource.Play(); } // precalculate so we can multiply instead of divide every frame stopTimeMultiplier = 1.0f / StopTime; startTimeMultiplier = 1.0f / StartTime; // if this effect has an explosion force, apply that now CreateExplosion(gameObject.transform.position, ForceRadius, ForceAmount); // start any particle system that is not in the list of manual start particle systems StartParticleSystems(); // If we implement the ICollisionHandler interface, see if any of the children are forwarding // collision events. If they are, hook into them. ICollisionHandler handler = (this as ICollisionHandler); if (handler != null) { FireCollisionForwardScript collisionForwarder = GetComponentInChildren <FireCollisionForwardScript>(); if (collisionForwarder != null) { collisionForwarder.CollisionHandler = handler; } } }
public ExtendedEngine(int worldWidth, int worldHeight, IObjectGenerator<EnvironmentObject> objectGenerator, ICollisionHandler collisionHandler, IRenderer renderer, IController controller) : base(worldWidth, worldHeight, objectGenerator, collisionHandler, renderer) { this.controller = controller; }
public override void Initialize() { base.Initialize(); if (this is ICollidable2D) { m_CollisionHandler = this.Game.Services.GetService <ICollisionHandler>(); } }
public void Destroy() { if (!destroying) { CollisionHandler = new EmptyCollisionHandler(this); effect = new SplittingEffect(Position); destroying = true; } }
public void AddCollisionHandler(ICollisionHandler handler) { if (collisionHandlers.Contains(handler)) { return; } collisionHandlers.Add(handler); }
private static void ParseXMLObject(XmlNode xmlObject, ICollisionHandler collisionHandler) { ObjectType object1Type = (ObjectType)Enum.Parse(typeof(ObjectType), xmlObject["object1"].FirstChild.Value); ObjectType object2Type = (ObjectType)Enum.Parse(typeof(ObjectType), xmlObject["object2"].FirstChild.Value); Object2Side side = (Object2Side)Enum.Parse(typeof(Object2Side), xmlObject["side"].FirstChild.Value); ICollisionCommand command = commandDictionary[xmlObject["command"].FirstChild.Value]; collisionHandler.RegisterCommand(new Tuple <ObjectType, ObjectType, Object2Side>(object1Type, object2Type, side), command); }
public UsableBoomerang(Vector2 position, Vector2 direction, IPlayer player) { Position = position; this.direction = direction; this.player = player; Sprite = UsableItemSpriteFactory.Instance.CreateBoomerangSprite(); SoundFactory.Instance.sfxBoomerang.Play(); CollisionHandler = new UsableItemCollisionHandler(player, this, 32, 32, 0, 0); }
public SplittingEffect(Vector2 position) { Position = position; random = new Random(); topLeft = UsableItemSpriteFactory.Instance.CreateTopLeftEffectSprite(Color.White); topRight = UsableItemSpriteFactory.Instance.CreateTopRightEffectSprite(Color.White); bottomLeft = UsableItemSpriteFactory.Instance.CreateBottomLeftEffectSprite(Color.White); bottomRight = UsableItemSpriteFactory.Instance.CreateBottomRightEffectSprite(Color.White); CollisionHandler = new EmptyCollisionHandler(this); }
public void Start() { _handler = gameObject.RetrieveInHierarchy <ICollisionHandler>(); if (_handler == null) { Log.ErrorFormat("{0} has no associated {1}. Self-destructing", GetType(), typeof(ICollisionHandler)); Destroy(this); } }
public UsableBomb(Vector2 position, IPlayer player) { Position = position; this.player = player; Sprite = UsableItemSpriteFactory.Instance.CreateBombSprite(); SoundFactory.Instance.sfxBombPlace.Play(); CollisionHandler = new UsableItemCollisionHandler(player, this, 32, 32, 0, 0); explosionEffects = new List <IEntity>(); this.player.ItemCounts[ItemType.Bomb]--; }
public ExtendedEngine(int worldWidth, int worldHeight, IObjectGenerator <EnvironmentObject> objectGenerator, ICollisionHandler collisionHandler, IRenderer renderer, IController controller) : base(worldWidth, worldHeight, objectGenerator, collisionHandler, renderer) { this.Controller = controller; this.Controller.Pause += (sender, args) => { this.isPaused = !this.isPaused; }; }
public AdvancedEngine(int worldWidth, int worldHeight, IObjectGenerator<EnvironmentObject> objectGenerator, ICollisionHandler collisionHandler, IRenderer renderer, IController controller) : base(worldWidth, worldHeight, objectGenerator, collisionHandler, renderer) { this.controller = controller; this.AttachCotrollerEvents(); }
/// <summary> /// Checks for collisions with all the collision shapes. /// </summary> /// <param name="collisionObj">The collision shape to check with collision.</param> public void CheckCollisions(ICollisionHandler collisionObj) { for (int i = 0; i < CollisionObjects.Count; i++) { //Check for collision with the objects if (collisionObj.collisionShape.CollidesWith(CollisionObjects[i].collisionShape) == true) { //Invoke the collision event CollisionHandlerEvent?.Invoke(this, CollisionObjects[i].GetCollisionResponse(collisionObj)); } } }
public Engine(int worldWidth, int worldHeight, IObjectGenerator <EnvironmentObject> objectGenerator, ICollisionHandler collisionHandler, IRenderer renderer) { this.objects = new List <EnvironmentObject>(); this.objectGenerator = objectGenerator; this.renderer = renderer; this.collisionHandler = collisionHandler; this.worldBounds = new Rectangle(0, 0, worldWidth, worldHeight); }
public Engine(int worldWidth, int worldHeight, IObjectGenerator<EnvironmentObject> objectGenerator, ICollisionHandler collisionHandler, IRenderer renderer) { this.objects = new List<EnvironmentObject>(); this.objectGenerator = objectGenerator; this.renderer = renderer; this.collisionHandler = collisionHandler; this.worldBounds = new Rectangle(0, 0, worldWidth, worldHeight); }
public static void HandleCollisions(ICollisionHandler collisionHandler, IMario[] marios, Collection <IGameObject> blockList, Collection <IGameObject> enemyList, Collection <IGameObject> itemList, Collection <IGameObject> pipeList, Collection <IGameObject> fireBallList, Collection <IGameObject> fireBallList2) { HandleMarioCollisions(collisionHandler, marios[GameUtilities.Player1], blockList, enemyList, itemList, pipeList); if (marios[GameUtilities.Player2] != null) { HandleMarioCollisions(collisionHandler, marios[GameUtilities.Player2], blockList, enemyList, itemList, pipeList); HandleMarioMarioCollisions(collisionHandler, marios[GameUtilities.Player1], marios[GameUtilities.Player2]); } HandleEnemyCollisions(collisionHandler, blockList, enemyList, pipeList); HandleItemCollisions(collisionHandler, blockList, itemList, pipeList); HandleFireBallCollisions(collisionHandler, blockList, enemyList, pipeList, GameUtilities.GameObjectManager.MarioPlayer2, fireBallList); HandleFireBallCollisions(collisionHandler, blockList, enemyList, pipeList, GameUtilities.GameObjectManager.MarioPlayer1, fireBallList2); }
private static void HandleItemCollisions(ICollisionHandler collisionHandler, Collection <IGameObject> blockList, Collection <IGameObject> itemList, Collection <IGameObject> pipeList) { for (int i = 0; i < itemList.Count; i++) { foreach (IGameObject obj in blockList) { collisionHandler.HandleCollision(itemList[i], obj); } foreach (IGameObject obj in pipeList) { collisionHandler.HandleCollision(itemList[i], obj); } } }
protected virtual void Start() { StartParticleSystems(); ICollisionHandler handler = (this as ICollisionHandler); if (handler != null) { CCollision Checker = GetComponentInChildren <CCollision>(); if (Checker != null) { Checker.CollisionHandler = handler; } } }
public GameState(PlayerLookup players, IGameBehaviourProvider behaviours) { this.players = players; this.requestHandler = behaviours.GetRequestHandler(); this.collisionHandler = behaviours.GetCollisionHandler(this); this.continuousSynchronizer = behaviours.GetContinuousSynchronizer(this); this.deletableDictionaries = new Dictionary <Type, object> { { typeof(IBody), this.bodies }, { typeof(FreeObject), this.freeObjects }, }; this.deletableLists = new Dictionary <Type, object> { { typeof(Economy.Economy), this.economies }, }; }
public void HandleCollision(Collision collision, Level1 level) { ICollisionHandler handler = handlers[collision.entity1.GetType()]; if (handler != null) { handler.HandleCollision(collision, level); } ICollisionHandler secondHandler = handlers[collision.entity2.GetType()]; if (secondHandler != null) { secondHandler.HandleCollision(collision, level); } }
private static void HandleEnemyCollisions(ICollisionHandler collisionHandler, Collection <IGameObject> blockList, Collection <IGameObject> enemyList, Collection <IGameObject> pipeList) { for (int i = 0; i < enemyList.Count; i++) { foreach (IGameObject obj in blockList) { collisionHandler.HandleCollision(enemyList[i], obj); } for (int j = i + 1; j < enemyList.Count; j++) { collisionHandler.HandleCollision(enemyList[i], enemyList[j]); } foreach (IGameObject obj in pipeList) { collisionHandler.HandleCollision(enemyList[i], obj); } } }
// Engine constructor public Engine(IRenderer renderer, IHungryCreature creature, List<IEatable> eatables, ICollisionHandler collisionHandler, IUsersManager usersManager, IUserController controller) { this.userName = usersManager.RequestUserName(renderer); this.foodAmount = eatables.Capacity; this.renderer = renderer; this.controller = controller; this.eatables = eatables; this.creature = creature; this.collisionHandler = collisionHandler; // Clear the console so the username won't be stuck on the scores screen renderer.ClearConsole(); for (int counter = 0; counter < foodAmount; counter++) { this.AddFood(); } }
public ProductGridController(IView<ProductGrid.PropertyEnum> view, float meterWidth, float meterHeight, float tileSize) { utility = new ProductGridUtility(); collisionHandler = new ProductGridCollisionHandler(); // Set parameters to fields this.meterWidth = meterWidth; this.meterHeight = meterHeight; this.tileSize = tileSize; this.view = view; // set controller this.view.SetController(this); legendDictionary = ((Legend) view.Get(ProductGrid.PropertyEnum.Legend)).CategoryColors; // Init fields with default values zoomSize = 50; zoomArea = new Rectangle(0, 0, zoomSize, zoomSize); comboBoxAlgorithms = new List<AlgorithmModel>(); draggingProduct = false; zoomContent = new Bitmap(zoomSize, zoomSize); // Init algorithm combobox PopulateAlgorithms(); }
public EngineExtender(int worldWidth, int worldHeight, IObjectGenerator<EnvironmentObject> objectGenerator, ICollisionHandler collisionHandler, IRenderer renderer) : base(worldWidth, worldHeight, objectGenerator, collisionHandler, renderer) { }
public void MoveProduct(ICollisionHandler<PlacedProduct> handler, PlacedProduct selectedProduct, List<PlacedProduct> placedProducts, int boundWidth, int boundHeight, float realWidth, float realHeight, float x, float y, bool real) { float selectedWidth = selectedProduct.Product.Size.Width, selectedHeight = selectedProduct.Product.Size.Height; float newX = (real) ? x : x/(float) boundWidth*realWidth - selectedWidth/2, newY = (real) ? y : y/(float) boundHeight*realHeight - selectedHeight/2; if (newX <= 0) newX = 0; if (newX + selectedWidth/2 >= realWidth - selectedWidth/2) newX = realWidth - selectedWidth; if (newY <= 0) newY = 0; if (newY + selectedHeight/2 >= realHeight - selectedHeight/2) newY = realHeight - selectedHeight; PointF newLocation = new PointF(newX, newY); selectedProduct.Location = !handler.Collision(selectedProduct, placedProducts) ? newLocation : selectedProduct.OriginalLocation; }