// must call somewhere public static void Init(AssetContext assets) { breeds = new Dictionary <string, BulletBreed>(); BulletBreed b = new BulletBreed() { sprite = new Sprite(assets.GetTexture("bullet_light_green")), startSpeed = Constants.BULLET_START_SPEED, textureIntersectionOffset = 30, slugLength = 5 }; b.sprite.Scale = new Vector2f(0.5f, 0.5f); b.sprite.Origin = new Vector2f(b.sprite.TextureRect.Width - b.textureIntersectionOffset, b.sprite.TextureRect.Height / 2.0f); breeds.Add("simple-bullet", b); BulletBreed b2 = new BulletBreed() { sprite = new Sprite(assets.GetTexture("bullet3")), startSpeed = 250, textureIntersectionOffset = 1, slugLength = 1 }; b2.sprite.Scale = new Vector2f(0.7f, 0.7f); b2.sprite.Origin = new Vector2f(b2.sprite.TextureRect.Width, b2.sprite.TextureRect.Height / 2.0f); breeds.Add("turret-bullet", b2); }
/// <summary> /// /// </summary> /// <param name="scene"></param> /// <param name="pos">position</param> /// <param name="owner">owner gameobject ex. cCharacter</param> /// <param name="direction">normalized vector of direction</param> public cBullet(cGameObject owner, BulletBreed breed, Vector2f pos, Vector2f direction) : base(owner.Scene, pos) { this.owner = owner; this.breed = breed; this.alive = true; this.alpha = 255.0f; // proci határozza meg, hogy milyen alaplap foglalat és milyen RAM!! this.heading = direction; this.Bounds = new AABB(); this.Bounds.SetDims(new Vector2f(1.0f, 1.0f)); this.oppositeDir = new Vector2f(-this.heading.X * breed.slugLength, -this.heading.Y * breed.slugLength); this.intersection = new Vector2f(0.0f, 0.0f); this.Bounds.SetPosByTopLeft(pos); this.velocity.X = this.heading.X * breed.startSpeed; this.velocity.Y = this.heading.Y * breed.startSpeed; orientation = AppMath.GetAngleOfVector(heading); this.sprite = new Sprite(this.breed.sprite); // bullet_yellow_sm; bullet_light_gree this.sprite.Rotation = (float)AppMath.RadianToDegress(this.orientation); }