public virtual void Rotate(Vector2 v) { v.Normalize(); VecUtil.Rotate((double)VecUtil.GetAngle(ref v), ref faceDir); VecUtil.Rotate((double)VecUtil.GetAngle(ref v), ref moveDir); UpdateRotation(); }
//Screen coordinates where the bullets should appear (orriginate from) public Vector2 GetBulletSpawnPosition() { Vector2 v = this.bulletOffset; VecUtil.Rotate((double)this.rotation, ref v); return(new Vector2(this.position.X + v.X, this.position.Y + v.Y)); }
//Make sure the weapon is positioned and rotated correctly //according to ship position, and AimMethod public void AdjustWeaponPos() { for (int i = 0; i < weapons.Length; i++) { //possibly lost a weapon at some point //Or ship starts with more weapon ports then weapons if (weapons[i] == null) { continue; } //Rotate the weapon position to match ship rotation Vector2 v = weaponPortSave[i]; //get orrignal offset VecUtil.Rotate((double)this.rotation, ref v); //rotate it to match ship rotation this.weaponPort[i] = v; //update real offset //move weapon to new offset weapons[i].MoveTo(new Vector2(position.X + v.X, position.Y + v.Y)); } }
public List <Bullet> GetBullets(Weapon weapon) { List <Bullet> toReturn = new List <Bullet>(); Vector2 v1, v2, v3; v1 = new Vector2(-0.1f, 1); //x degrees left v2 = new Vector2(0, 1); //Striaght up v3 = new Vector2(0.1f, 1); //x degrees right v1.Normalize(); v3.Normalize(); //Rotate the 3 bullets to match (this) weapon rotation VecUtil.Rotate((double)weapon.rotation, ref v1); VecUtil.Rotate((double)weapon.rotation, ref v2); VecUtil.Rotate((double)weapon.rotation, ref v3); toReturn.Add(Creator.CreateBullet(weapon.bulletType, weapon.GetBulletSpawnPosition(), v1)); toReturn.Add(Creator.CreateBullet(weapon.bulletType, weapon.GetBulletSpawnPosition(), v2)); toReturn.Add(Creator.CreateBullet(weapon.bulletType, weapon.GetBulletSpawnPosition(), v3)); return(toReturn); }
public virtual void Rotate(float angle) { VecUtil.Rotate((double)angle, ref faceDir); VecUtil.Rotate((double)angle, ref moveDir); UpdateRotation(); }