public void update(GameTime gametime) { if (visible == true) { this.Position = MoveEnemy.GoAhead(this.Position, 1f); //this.Position = MoveEnemy.Seek(this.Position, 2f,0.1f); //this.Position = MoveEnemy.Arrive(this.Position, 0.01f); //****** hamchenin rectangele asli ke baraye barkhord va keshidane havapeyma estefade mishavad ham position va ham andaze texture ra dar moteghayer haye static zarb nemodim EnemyRec = new Rectangle((int)(this.Position.X * Share.StaticVarVector2D.scaleobj_Width), (int)(this.Position.Y * Share.StaticVarVector2D.scaleobj_Height), (int)(this.Texture.Width * Share.StaticVarVector2D.scaleobj_Width), (int)(this.Texture.Height * Share.StaticVarVector2D.scaleobj_Height)); EnemyRecIntersect_1 = new Rectangle((int)(this.Position.X * Share.StaticVarVector2D.scaleobj_Width), (int)(this.Position.Y * Share.StaticVarVector2D.scaleobj_Height), (int)(this.Texture.Width * Share.StaticVarVector2D.scaleobj_Width), (int)(23 * Share.StaticVarVector2D.scaleobj_Height)); EnemyRecIntersect_2 = new Rectangle((int)((this.Position.X + 25) * Share.StaticVarVector2D.scaleobj_Width), (int)((this.Position.Y + 23) * Share.StaticVarVector2D.scaleobj_Height), (int)(169 * Share.StaticVarVector2D.scaleobj_Width), (int)(23 * Share.StaticVarVector2D.scaleobj_Height)); EnemyRecIntersect_3 = new Rectangle((int)((this.Position.X + 56) * Share.StaticVarVector2D.scaleobj_Width), (int)((this.Position.Y + 48) * Share.StaticVarVector2D.scaleobj_Height), (int)(106 * Share.StaticVarVector2D.scaleobj_Width), (int)(21 * Share.StaticVarVector2D.scaleobj_Height)); EnemyRecIntersect_4 = new Rectangle((int)((this.Position.X + 89) * Share.StaticVarVector2D.scaleobj_Width), (int)((this.Position.Y + 71) * Share.StaticVarVector2D.scaleobj_Height), (int)(41 * Share.StaticVarVector2D.scaleobj_Width), (int)(20 * Share.StaticVarVector2D.scaleobj_Height)); EnemyRecIntersect_5 = new Rectangle((int)((this.Position.X + 103) * Share.StaticVarVector2D.scaleobj_Width), (int)((this.Position.Y + 97) * Share.StaticVarVector2D.scaleobj_Height), (int)(14 * Share.StaticVarVector2D.scaleobj_Width), (int)(38 * Share.StaticVarVector2D.scaleobj_Height)); //add kardane yek golole ba textrure va position khase khod timeSinceLastFrame += gametime.ElapsedGameTime.Milliseconds; //dar in chand khat kode dar yek baze zamani yek golole tavasote list baraye enemy dorost mishavad if (timeSinceLastFrame > millisecondsPerFire) { timeSinceLastFrame = 0; PositionBullet = new Vector2((int)(this.Position.X * Share.StaticVarVector2D.scaleobj_Width) + ((int)(this.Texture.Width * Share.StaticVarVector2D.scaleobj_Width) / 2), (int)(this.Position.Y * Share.StaticVarVector2D.scaleobj_Height) + ((int)(this.Texture.Height * Share.StaticVarVector2D.scaleobj_Height) / 2)); //this.TextureBullet = textureBullet; if (this.Position.Y + 160 < Share.StaticVarVector2D.PositionStaticJet.Y) /*in adad va in if ra be dalile in gozashtim ke az ye hadi dige moshak nazane*/ { BulletStatic.AddBomb(TextureBullet, PositionBullet, 2, TextureFlame); } } //payane add kardane be list static } if (visible == false) { // ejraye enfejar baraye doshman if (currentFrame.X == sheetSize.X - 1 && currentFrame.Y == sheetSize.Y - 1) { EnableExplode = 1; if (EnableExplode == 1) { EndObject = 1; } } timeSinceLastFrame += gametime.ElapsedGameTime.Milliseconds; //for delay if (timeSinceLastFrame > millisecondsPerFrame) //for delay { //for delay timeSinceLastFrame = 0; //millisecondsPerFrame; //for delay ++currentFrame.X; if (currentFrame.X >= sheetSize.X) { currentFrame.X = 0; ++currentFrame.Y; if (currentFrame.Y >= sheetSize.Y) { currentFrame.Y = 0; } } } //for delay ExplodeRec = new Rectangle(currentFrame.X * frameSize.X, currentFrame.Y * frameSize.Y, frameSize.X, frameSize.Y); } }
public void update(GameTime gametime) { if (visible == true) { if (this.Position.Y > 0) { this.Position = MoveEnemy.Seek(this.Position, 5f, 2.1f, this.Texture.Width, this.Texture.Height); } else { this.Position = MoveEnemy.GoAhead(this.Position, 2f); } //this.Position = MoveEnemy.Arrive(this.Position, 0.01f); EnemyRec = new Rectangle((int)(this.Position.X /** Share.StaticVarVector2D.scaleobj_Width*/), (int)(this.Position.Y * Share.StaticVarVector2D.scaleobj_Height), (int)(this.Texture.Width * Share.StaticVarVector2D.scaleobj_Width), (int)(this.Texture.Height * Share.StaticVarVector2D.scaleobj_Height)); EnemyRecIntersect_1 = new Rectangle((int)(this.Position.X + (64 * Share.StaticVarVector2D.scaleobj_Width)), (int)(this.Position.Y * Share.StaticVarVector2D.scaleobj_Height), (int)(32 * Share.StaticVarVector2D.scaleobj_Width), (int)(this.Texture.Height * Share.StaticVarVector2D.scaleobj_Height)); EnemyRecIntersect_2 = new Rectangle((int)(this.Position.X /** Share.StaticVarVector2D.scaleobj_Width*/), (int)((this.Position.Y + 11) * Share.StaticVarVector2D.scaleobj_Height), (int)((this.Texture.Width) * Share.StaticVarVector2D.scaleobj_Width), (int)(23 * Share.StaticVarVector2D.scaleobj_Height)); //add kardane yek golole ba textrure va position khase khod timeSinceLastFrame += gametime.ElapsedGameTime.Milliseconds; //dar in chand khat kode dar yek baze zamani yek golole tavasote list baraye enemy dorost mishavad if (timeSinceLastFrame > millisecondsPerFire) { timeSinceLastFrame = 0; //PositionBullet = new Vector2(Position.X + (Texture.Width / 2), Position.Y + (Texture.Height / 2)); PositionBullet = new Vector2((int)(this.Position.X /** Share.StaticVarVector2D.scaleobj_Width*/) + ((int)(this.Texture.Width * Share.StaticVarVector2D.scaleobj_Width) / 2), (int)(this.Position.Y * Share.StaticVarVector2D.scaleobj_Height) + ((int)(this.Texture.Height * Share.StaticVarVector2D.scaleobj_Height) / 2)); //this.TextureBullet = textureBullet; BulletStatic.AddBullet(TextureBullet, PositionBullet); } //payane add kardane be list static } if (visible == false) { // ejraye enfejar baraye doshman if (currentFrame.X == sheetSize.X - 1 && currentFrame.Y == sheetSize.Y - 1) { EnableExplode = 1; if (EnableExplode == 1) { EndObject = 1; } } timeSinceLastFrame += gametime.ElapsedGameTime.Milliseconds; //for delay if (timeSinceLastFrame > millisecondsPerFrame) //for delay { //for delay timeSinceLastFrame = 0; //millisecondsPerFrame; //for delay ++currentFrame.X; if (currentFrame.X >= sheetSize.X) { currentFrame.X = 0; ++currentFrame.Y; if (currentFrame.Y >= sheetSize.Y) { currentFrame.Y = 0; } } } //for delay ExplodeRec = new Rectangle(currentFrame.X * frameSize.X, currentFrame.Y * frameSize.Y, frameSize.X, frameSize.Y); } }