private IMovementBehavior GetMovementBehavior(BirdData data, BirdMetaData metaData) { switch (metaData.MovementBehaviorType) { case "Straight": return new StraightMovementBehavior { Position = data.Position, Velocity = new Vector2(float.Parse(metaData.MovementBehaviorProperties["VelocityX"]), float.Parse(metaData.MovementBehaviorProperties["VelocityY"])), Acceleration = new Vector2(float.Parse(metaData.MovementBehaviorProperties["AccelerationX"]), float.Parse(metaData.MovementBehaviorProperties["AccelerationY"])), }; case "Wavey": return new WaveyMovementBehavior { Position = data.Position, Velocity = new Vector2(float.Parse(metaData.MovementBehaviorProperties["VelocityX"]), float.Parse(metaData.MovementBehaviorProperties["VelocityY"])), Acceleration = new Vector2(float.Parse(metaData.MovementBehaviorProperties["AccelerationX"]), float.Parse(metaData.MovementBehaviorProperties["AccelerationY"])), Period = TimeSpan.FromSeconds(float.Parse(metaData.MovementBehaviorProperties["Period"])), Radius = new Vector2(float.Parse(metaData.MovementBehaviorProperties["RadiusX"]), float.Parse(metaData.MovementBehaviorProperties["RadiusY"])), }; case "Gravity": return new GravityMovementBehavior { Position = data.Position, Velocity = new Vector2(float.Parse(metaData.MovementBehaviorProperties["VelocityX"]), float.Parse(metaData.MovementBehaviorProperties["VelocityY"])), Acceleration = new Vector2(float.Parse(metaData.MovementBehaviorProperties["AccelerationX"]), float.Parse(metaData.MovementBehaviorProperties["AccelerationY"])), TargetEntity = this.Bee, }; default: throw new ArgumentException(); } }
private IShootingBehavior GetShootingBehavior(BirdData data, BirdMetaData metaData) { switch (metaData.ShootingBehaviorType) { case "Passive": return new PassiveShooting(); case "SingleBullet": return new SingleBulletShooting { BulletDamage = int.Parse(metaData.ShootingBehaviorProperties["BulletDamage"]), BulletDirection = new Vector2(float.Parse(metaData.ShootingBehaviorProperties["BulletDirectionX"]), float.Parse(metaData.ShootingBehaviorProperties["BulletDirectionY"])), BulletSpeed = float.Parse(metaData.ShootingBehaviorProperties["BulletSpeed"]), BulletTexture = this.ContentManager.Load<Texture2D>(metaData.ShootingBehaviorProperties["TexturePath"]), FireRate = TimeSpan.FromSeconds(double.Parse(metaData.ShootingBehaviorProperties["FireRate"])), FireBullet = this.BulletFired, }; case "DoubleBullet": return new DoubleBulletShooting { BulletDamage = int.Parse(metaData.ShootingBehaviorProperties["BulletDamage"]), BulletDirection = new Vector2(float.Parse(metaData.ShootingBehaviorProperties["BulletDirectionX"]), float.Parse(metaData.ShootingBehaviorProperties["BulletDirectionY"])), BulletSpeed = float.Parse(metaData.ShootingBehaviorProperties["BulletSpeed"]), BulletTexture = this.ContentManager.Load<Texture2D>(metaData.ShootingBehaviorProperties["TexturePath"]), FireRate = TimeSpan.FromSeconds(double.Parse(metaData.ShootingBehaviorProperties["FireRate"])), FireBullet = this.BulletFired, Spread = float.Parse(metaData.ShootingBehaviorProperties["Spread"]), }; case "TripleBullet": return new TripleBulletShooting { BulletDamage = int.Parse(metaData.ShootingBehaviorProperties["BulletDamage"]), BulletDirection = new Vector2(float.Parse(metaData.ShootingBehaviorProperties["BulletDirectionX"]), float.Parse(metaData.ShootingBehaviorProperties["BulletDirectionY"])), BulletSpeed = float.Parse(metaData.ShootingBehaviorProperties["BulletSpeed"]), BulletTexture = this.ContentManager.Load<Texture2D>(metaData.ShootingBehaviorProperties["TexturePath"]), FireRate = TimeSpan.FromSeconds(double.Parse(metaData.ShootingBehaviorProperties["FireRate"])), FireBullet = this.BulletFired, Spread = float.Parse(metaData.ShootingBehaviorProperties["Spread"]), }; case "Tracking": return new TrackingShooting { BulletDamage = int.Parse(metaData.ShootingBehaviorProperties["BulletDamage"]), BulletDirection = new Vector2(float.Parse(metaData.ShootingBehaviorProperties["BulletDirectionX"]), float.Parse(metaData.ShootingBehaviorProperties["BulletDirectionY"])), BulletSpeed = float.Parse(metaData.ShootingBehaviorProperties["BulletSpeed"]), BulletTexture = this.ContentManager.Load<Texture2D>(metaData.ShootingBehaviorProperties["TexturePath"]), FireRate = TimeSpan.FromSeconds(double.Parse(metaData.ShootingBehaviorProperties["FireRate"])), FireBullet = this.BulletFired, TargetAtraction = float.Parse(metaData.ShootingBehaviorProperties["TargetAtraction"]), TargetEntity = this.Bee, }; default: throw new ArgumentException(); } }
private IRenderer CreateBirdRenderer(BirdMetaData metaData) { return new CompositeRenderer( new[] { new CompositeRendererItem(this.TextureLegs, new Vector2(17, 36)), new CompositeRendererItem(this.TextureBody, new Vector2(9, 0), metaData.BodyColor), new CompositeRendererItem(this.TextureHead, new Vector2(5, 10), metaData.HeadColor), new CompositeRendererItem(this.TextureFace, new Vector2(0, 15)), new CompositeRendererItem(this.TextureEyelids, new Vector2(17, 39), metaData.BodyColor), }); }