public void Move(GameObject obj, ShipUpdateInfo info) { if (done) //performance reasons return; done = true; obj.SetRotation(dir); }
public MainMenu() { //Assign the module name base.moduleName = ModuleName.MainMenu; menu = new GameObject[5]; //5 menu buttons menu[0] = new GameObject(Textures.TextureName.MainMenuNewGame); menu[1] = new GameObject(Textures.TextureName.MainMenuOptions); menu[2] = new GameObject(Textures.TextureName.MainMenuInstruction); menu[3] = new GameObject(Textures.TextureName.MainMenuCredits); menu[4] = new GameObject(Textures.TextureName.MainMenuExit); Vector2 v = PROPERTIES.screenCenter; v.Y -= 100; foreach (GameObject o in menu) { o.MoveTo(v); v.Y += 50; } }
//The main loading of the level //Child classes (the actuall level objects) //should call this base method first to Init the basic stuff public virtual void Load(Textures.TextureName levelBackground) { loaded = true; border = new GameObject(Textures.TextureName.LevelBorder); border.LoadContent(); border.CenterIn(bounds); slider = new LevelSlider(levelBackground, bounds); slider.Load(); //Items itemMan = new ItemManager(ref slider); //Init data structures enemyShips = new List<Ship>(); enemyBullets = new List<Bullet>(); items = new List<Item>(); //Link the UpdateInfo to appropriate data SUI = new ShipUpdateInfo(); SUI.viewport = bounds; SUI.npcs = enemyShips; SUI.slider = this.slider; //Position the player ships foreach (Player p in PROP.players) { if (p.ControllerIndex == PlayerIndex.Two) { p.ship.MoveTo(GetPlayerInitPos()); p.ship.position.X += 60; } else p.ship.MoveTo(GetPlayerInitPos()); } }
public void Move(GameObject obj, ShipUpdateInfo info) { obj.moving = false; }
public void Move(GameObject obj, ShipUpdateInfo info) { int time = info.gameTime.ElapsedGameTime.Milliseconds; elapsed -= time; angle = (double)time * rotateSpeed * sign; if (elapsed <= 0) //time to change direction { sign *= -1; //flip sign elapsed = clock; //reset clock } if (obj.position.Y > (info.viewport.Top + 500)) { dir.X += (float)0.002 * info.gameTime.ElapsedGameTime.Milliseconds * sign; obj.SetRotation(dir); obj.speed = 0.35; if (dir.X > sign) { dir.X = 1; return; } return; } obj.Rotate((float)angle); }
public void Move(GameObject obj, ShipUpdateInfo info) { int time = info.gameTime.ElapsedGameTime.Milliseconds; elapsed -= time; angle = (double)time * rotateSpeed * sign; if (elapsed <= 0) //time to change direction { sign *= -1; //flip sign elapsed = clock; //reset clock } obj.Rotate((float)angle); }
public void Move(GameObject obj, ShipUpdateInfo info) { //Get the direction from the player (controller) Vector2 direction = player.input.ShipMoveDirNormal(); //Check is the player is trying to move //Since update (GameObject) will try and move the ship //if player is not trying to move we flag it false if (direction.X == 0 && direction.Y == 0) obj.moving = false; else { obj.moving = true; //re-flag true in case set to false direction.Normalize(); //just in case.... obj.SetRotation(direction); //Since SetRotation() above, also turns the "face" direction //we need to correct this for the human players whose ships //always face directly upwards on the screen obj.SetFaceDir(VecUtil.GetNormUP()); } }
//############################################################################################ //############################################################################################ public static Item CreateItem(ItemType type, GameObject item, ref LevelSlider refSlider) { Item i = new Item(type, item); i.LoadContent(); i.slider = refSlider; return i; }
public void Move(GameObject obj, ShipUpdateInfo info) { //don't need to change anything }
public void Move(GameObject obj, ShipUpdateInfo info) { timer.Update(info.gameTime); switch (timer.Current) { case Timer2.TimerNum.First: obj.SetRotation(VecUtil.GetNormLeft()); break; case Timer2.TimerNum.Second: obj.SetRotation(VecUtil.GetNormRight()); break; } obj.SetFaceDir(VecUtil.GetNormDown()); }
public void Move(GameObject obj, ShipUpdateInfo info) { if (done) return; if (obj.position.X > (info.viewport.Left + 100) && obj.position.X < (info.viewport.Right - 100)) { done = true; obj.SetRotation(VecUtil.GetNormDown()); } }
public void Move(GameObject obj, ShipUpdateInfo info) { if (obj.position.Y > (info.viewport.Top + Y_trigger)) { dir.X += (float)0.002 * info.gameTime.ElapsedGameTime.Milliseconds * sign; obj.SetRotation(dir); obj.speed = speed; if (dir.X > sign) { dir.X = 1; return; } } }
//Constructor public Item(ItemType type, GameObject obj) : base(Textures.TextureName.ItemBg) { this.type = type; content = obj; }
public override void LoadContent() { pauseImg = new GameObject(Textures.TextureName.Pause); pauseImg.LoadContent(); pauseImg.CenterIn(bounds); deadImg = new GameObject(Textures.TextureName.DeadRetry); deadImg.LoadContent(); deadImg.CenterIn(bounds); }
public Credits() { //Setup the background sprite (gameobject) background = new GameObject(Textures.TextureName.CreditsBackground); background.MoveTo(PROPERTIES.screenCenter); }
public void Move(GameObject obj, ShipUpdateInfo info) { switch (state) { case status.linearDown: if (obj.position.Y > (info.viewport.Center.Y + 100)) state = status.upTurn; break; case status.linearUp: break; case status.upTurn: if (turnRad > 180) { obj.SetRotation(new Vector2(-1,-1) ); state = status.linearUp; } turnRad += (float)0.2*info.gameTime.ElapsedGameTime.Milliseconds; obj.SetRotation(MathHelper.ToRadians(turnRad) ); obj.speed = 0.3; break; case status.downTurn: break; case status.End: break; } }
public Options() { background = new GameObject(Textures.TextureName.OptionsBackground); background.MoveTo(PROPERTIES.screenCenter); }