/// <summary> /// Resets the tank to the original form. /// </summary> /// <param name="proj">Whether or not to reset the projectile.</param> public void Reset( bool proj = true ) { Position = originalPosition; Angle = originalAngle; Scale = originalScale; Texture = originalTexture; Speed = originalSpeed; isTextureAMap = true; if ( proj ) { nextProjectile = OriginalProjectile.Clone(); } IsAlive = true; NumberOfProjectiles = 0; NumberOfFences = 0; RemoveTankController(); Keys = OriginalKeys.Clone(); Controllers = new HashSet<GameController>(); }
private KeySet LoadSetting( string setting, KeySet defaultSetting ) { KeySet set; string keystr = LoadSetting( setting ); if ( keystr == "" ) return defaultSetting; string[] keys = keystr.Replace( " ", string.Empty ).Split( ',' ); set = new KeySet( LoadKey( keys[0], defaultSetting.KeyForward ), LoadKey( keys[2], defaultSetting.KeyBackward ), LoadKey( keys[1], defaultSetting.KeyLeft ), LoadKey( keys[3], defaultSetting.KeyRight ), LoadKey( keys[4], defaultSetting.KeyPlace ), LoadKey( keys[5], defaultSetting.KeyShoot ) ); Settings.Add( setting, Tuple.Create<Type, object>( set.GetType(), set ) ); return set; }
public Tank( string name, Vector2 startPosition, float startAngle, KeySet keys, Colors color, float speed, Projectile originalProjectile, int BulletLimit, int FenceLimit, int FenceTime, float Scale, bool AI, PlayerIndex index ) { this.Name = name; this.Speed = speed; this.originalSpeed = speed; this.originalPosition = startPosition; this.originalAngle = startAngle; this.Keys = keys; this.OriginalKeys = keys; this.TankColor = color; this.OriginalColor = color; this.Origin = new Vector2( 16, 16 ); this.originalProjectile = originalProjectile; this.ProjectileLimit = BulletLimit; this.FenceLimit = FenceLimit; this.originalScale = Scale; this.Scale = Scale; this.FenceLifeTime = FenceTime; this.TurnSpeed = 5; this.AI = AI; this.r = new Random( 10 ); this.index = index; Reset( false ); }