private void Collide(VisiblePlatformObject other) { const float Amount = 100f; var asCharacter = other as CharacterObject; if (asCharacter != null) { var enemy = this.Character as Enemy; var otherEnemy = asCharacter.Character as Enemy; if (enemy != otherEnemy) { // 'other' is an enemy to us var x = 0f; var y = 0f; if (this.Position.X < other.Position.X) { x = -Amount; } else { x = Amount; } if (this.Position.Y < other.Position.Y) { y = -Amount; } else { y = Amount; } this.Velocity = new Vector2(x, y); } } }
private IGameObject MakeTree(Point basePos, float z, string asset) { var random = new Random(); var tree = new VisiblePlatformObject(this.Context); tree.Sprite = Store.Instance.Sprites <SingleSpriteTemplate>("Base", asset); tree.Position3D = new Vector3(basePos.X * this.Context.BlockStore.TileSize, basePos.Y * this.Context.BlockStore.TileSize - tree.Sprite.Height - 5f, z); this.Context.AddObject(tree); return(tree); }