private void OnTriggerEnter2D(Collider2D collision) { Debug.Log("Collision detected with tag: " + collision.tag); if (collision.gameObject.CompareTag("Player")) { SwapSprite(); Debug.Log("Execute switch!"); switchableElement.Switch(); } }
public void Switch(bool on) { SwitchableObject.Switch(); IsOn = on; if (on) { BitmapPath = @"Button_ON.png"; } else { BitmapPath = @"Button_OFF.png"; } }
public void Resolve(MovableGameObject mgo1, GameObject o2) { MovableGameObject mgo2 = o2 as MovableGameObject; if (mgo1.Subtype != null || o2.Subtype != null) { if (ResolveSubtype(mgo1, o2)) { return; } } // both objects are movable if (mgo2 != null) { // TODO : Recheck this code (cases where both objects are movable) for future functionality SetPinballReaction(mgo1, o2); if (mgo2.Type == GameObjectType.Enemy) { } return; } else // only one object is movable { // other object interactions ISwitchable switcher = o2 as ISwitchable; if (switcher != null && switcher.SwitchOnCollision() && (o2 as MovableGameObject) == null) // prevents from switching twice per turn { switcher.Switch(); } if (!( o2.Type == GameObjectType.Agent || o2.Type == GameObjectType.ClosedDoor || o2.Type == GameObjectType.Obstacle || o2.Type == GameObjectType.Teacher || o2.Type == GameObjectType.None)) { return; } if (mgo1.GameObjectStyle == GameObjectStyleType.Platformer) // Collision outcome depends on the GameObjectStyleType { SetPlattformerReaction(mgo1, o2); } else if (mgo1.GameObjectStyle == GameObjectStyleType.Pinball) { SetPinballReaction(mgo1, o2); } else if (mgo1.GameObjectStyle == GameObjectStyleType.None) { } return; } throw new ArgumentException("For given objects doesn't exist confict resolution. " + "Did you forget to implement overriding class for StandardConflictResolver?"); }
public void Execute() { _target.Switch(); }