示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Enemy"/> class.
        /// </summary>
        /// <param name="info">The sprite information.</param>
        public Enemy(SpriteInfo info)
            : base(info, CollidableType.Impassable)
        {
            var setting = info.Settings.FirstOrDefault(s => s.Key.Equals("EnemyName", StringComparison.OrdinalIgnoreCase));

            this._enemyName = setting.Value;

            setting = info.Settings.FirstOrDefault(s => s.Key.Equals("OnPatrol", StringComparison.OrdinalIgnoreCase));
            if ((setting != null) && !string.IsNullOrWhiteSpace(setting.Value))
            {
                this.IsOnPatrol = setting.Value.Equals("1") ||
                                  setting.Value.Equals("true", StringComparison.OrdinalIgnoreCase);
            }

            setting = info.Settings.FirstOrDefault(s => s.Key.Equals("CanRespawn", StringComparison.OrdinalIgnoreCase));
            if ((setting != null) && !string.IsNullOrWhiteSpace(setting.Value))
            {
                this.CanRespawn = setting.Value.Equals("1") ||
                                  setting.Value.Equals("true", StringComparison.OrdinalIgnoreCase);
            }

            setting = info.Settings.FirstOrDefault(s => s.Key.Equals("SecondsToRespawn", StringComparison.OrdinalIgnoreCase));
            if ((setting != null) && !string.IsNullOrWhiteSpace(setting.Value))
            {
                this._secondsToRespawn = int.Parse(setting.Value);
            }

            this._isAlive          = true;
            this._basePosition     = info.Position;
            this._nextPosition     = info.Position;
            this._transitionHelper = new TransitionHelper(TimeSpan.FromSeconds(SECONDS_TO_SPAWN), TransitionHelper.TransitionDirection.Up);
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WinnerScreen" /> class.
 /// </summary>
 /// <param name="selectedCharacterName">Name of the selected character.</param>
 /// <param name="score">The score.</param>
 public LoserScreen(string selectedCharacterName, int score)
     : base("")
 {
     this._selectedCharacterName = selectedCharacterName;
     this._score            = score;
     this._transitionTime   = TimeSpan.FromSeconds(3);
     this._transitionHelper = new TransitionHelper(this._transitionTime, TransitionHelper.TransitionDirection.Up);
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WinnerScreen" /> class.
 /// </summary>
 /// <param name="selectedCharacterName">Name of the selected character.</param>
 /// <param name="score">The score.</param>
 /// <param name="timeToLive">The time to live.</param>
 /// <param name="maxTimeAllowed">The maximum time allowed.</param>
 public WinnerScreen(string selectedCharacterName, int score, TimeSpan timeToLive, int maxTimeAllowed)
     : base("")
 {
     this._selectedCharacterName = selectedCharacterName;
     this._score            = score;
     this._timeToLive       = timeToLive;
     this._maxTimeAllowed   = maxTimeAllowed;
     this._transitionTime   = TimeSpan.FromSeconds(3);
     this._transitionHelper = new TransitionHelper(this._transitionTime, TransitionHelper.TransitionDirection.Up);
 }
示例#4
0
 /// <summary>
 /// Constructs a new Enemy.
 /// </summary>
 /// <param name="site">The site.</param>
 /// <param name="position">The position.</param>
 /// <param name="enemyName">The sprite set.</param>
 /// <param name="canRespawn">if set to <c>true</c> the enemy can respawn.</param>
 /// <param name="secondsToRespawn">The seconds to respawn after dying.</param>
 public Enemy(IServiceProvider site, Vector2 position, string enemyName, bool canRespawn = false, int secondsToRespawn = DEFAULT_SECONDS_TO_RESPAWN)
     : base(site, position, CollidableType.Impassable)
 {
     this._basePosition     = position;
     this._nextPosition     = position;
     this._enemyName        = enemyName;
     this._isAlive          = true;
     this.CanRespawn        = canRespawn;
     this._secondsToRespawn = secondsToRespawn;
     this._transitionHelper = new TransitionHelper(TimeSpan.FromSeconds(SECONDS_TO_SPAWN), TransitionHelper.TransitionDirection.Up);
 }