/// <summary> /// Create Helix at the specified position with a specific gun. /// </summary> /// <param name="position">Helix's starting position.</param> /// <param name="weaponName">Helix's starting weapon.</param> public Helix( Vector2 position, String weaponName) : base(weaponName) { try { Engine.lua["helix"] = this; } catch (LuaInterface.LuaException e) { SnailsPace.debug(e.Message); } name = "Helix"; affectedByGravity = true; Objects.Sprite walk = new Objects.Sprite(); walk.image = new Objects.Image(); walk.image.filename = "Resources/Textures/HelixTable"; walk.image.blocks = new Vector2(4.0f, 5.0f); walk.image.size = new Vector2(128.0f, 128.0f); walk.visible = true; walk.effect = "Resources/Effects/effects"; Objects.Sprite fly = new Objects.Sprite(); fly.image = walk.image; fly.visible = false; fly.effect = walk.effect; sprites.Add("Walk", walk); sprites["Walk"].animationStart = 0; sprites["Walk"].animationEnd = 7; sprites["Walk"].frame = 0; sprites["Walk"].animationDelay = 1.0f / 15.0f; sprites["Walk"].timer = 0f; sprites.Add("Fly", fly); sprites["Fly"].animationStart = 8; sprites["Fly"].animationEnd = 11; sprites["Fly"].frame = 8; sprites["Fly"].animationDelay = 1.0f / 15.0f; sprites["Fly"].timer = 0f; // TODO: Make hover it's own animation sprites.Add("Hover", fly.clone()); sprites["Hover"].animationStart = 12; sprites["Hover"].animationEnd = 12; sprites["Hover"].frame = 12; sprites["Hover"].animationDelay = 1.0f / 7.0f; sprites["Hover"].timer = 0f; sprites.Add("NoFuel", fly.clone()); sprites["NoFuel"].animationStart = 12; sprites["NoFuel"].animationEnd = 13; sprites["NoFuel"].frame = 12; sprites["NoFuel"].animationDelay = 1.0f / 4.0f; sprites["NoFuel"].timer = 0f; // TODO: Make animations for taking damage sprites.Add("WalkDamage", fly.clone()); sprites["WalkDamage"].animationStart = 16; sprites["WalkDamage"].animationEnd = 17; sprites["WalkDamage"].frame = 16; sprites["WalkDamage"].animationDelay = 1.0f / 15.0f; sprites["WalkDamage"].timer = 0f; sprites.Add("FlyDamage", fly.clone()); sprites["FlyDamage"].animationStart = 18; sprites["FlyDamage"].animationEnd = 19; sprites["FlyDamage"].frame = 18; sprites["FlyDamage"].animationDelay = 1.0f / 15.0f; sprites["FlyDamage"].timer = 0f; maxVelocity = walkingMaxVelocity; maxFuel = 30; fuel = maxFuel; layer = 0; size = walk.image.size; Vector2[] points = { new Vector2(0.0f, 28.0f), new Vector2(20.0f, 18.0f), new Vector2(28.0f, 0.0f), new Vector2(28.0f, -34.0f), new Vector2(-28.0f, -34.0f), new Vector2(-28.0f, 0.0f), new Vector2(-20.0f, 18.0f) }; bounds = new Objects.GameObjectBounds(points); this.position = position; startPosition = position; maxHealth = 20; health = 20; Weapon wep = weapon; inventory = new Weapon[5]; if (weaponName != "generic") { AddWeapon(Weapon.load("generic")); } AddWeapon(wep); }
/// <summary> /// Pobiera wymagane atrybuty. /// </summary> /// <param name="owner"></param> public override void OnInit() { this._Position = this.Owner.Attributes.GetOrCreate<Vector2>("Position"); this._Position.PropertyChanged += (a, b) => this._Sprite.Position = this.Position; this._Size = this.Owner.Attributes.GetOrCreate<Vector2>("Size"); this._Size.PropertyChanged += (a, b) => { this._Sprite.Size = this.Size; if (this._Sprite.Size != this.Size) //Nadzorujemy aspect ratio { this.Size = this._Sprite.Size; } }; this._Rotation = this.Owner.Attributes.GetOrCreate<float>("Rotation"); this._Rotation.PropertyChanged += (a, b) => this._Sprite.Rotation = this.Rotation; this._Sprite = new Objects.Sprite(this._Texture, this.Position, this.Size); }