Пример #1
0
        /// <summary>
        /// Returns true if the Treasure given is the same as this one
        /// </summary>
        public bool Equals(Treasure other)
        {
            if (other == null)
            {
                return(false);
            }

            return(this.Id == other.Id);
        }
Пример #2
0
 /// <summary>
 /// Creates a new treasure based on the Treasure given
 /// </summary>
 public Treasure(Treasure other)
     : this(other.Id, other.Location, other.State, other.CarryingPirate, other.Value)
 {
 }
Пример #3
0
        /// <summary>
        /// Updates this pirate
        /// </summary>
        public void Update(Pirates.Pirate p)
        {
            this.nativeObject = p;

            // updates the pirate's state
            if (p.IsLost)
            {
                this.state = PirateState.Lost;
            }
            else if (p.TurnsToSober > 0)
            {
                this.state = PirateState.Drunk;
            }
            else if (p.HasTreasure)
            {
                this.state = PirateState.CarryingTreasure;
            }
            else
            {
                this.state = PirateState.Free;
            }

            // updates the pirate's location, but ONLY if the new location can possibly be inside the map
            if (p.Location != null && p.Location.Row >= 0 && p.Location.Col >= 0)
            {
                this.location = new Location(p.Location);
            }

            // updates counters
            this.turnsToSober         = p.TurnsToSober;
            this.turnsToRevive        = p.TurnsToRevive;
            this.turnsToAttackReload  = p.ReloadTurns;
            this.turnsToDefenseReload = p.DefenseReloadTurns;
            this.defenseDuration      = p.DefenseExpirationTurns;

            // updates carried treasure; should be updated to not-null manually every turn
            this.carriedTreasure = null;

            // updates powerups
            if (p.Powerups != null)
            {
                this.powerups = new List <string>(p.Powerups);
            }
            else
            {
                this.powerups = new List <string>();
            }

            // calculate current speed limit
            if (this.State == PirateState.CarryingTreasure)
            {
                this.maxSpeed = p.CarryTreasureSpeed;
            }
            else
            {
                this.maxSpeed = this.freePirateMaxSpeed;
            }

            // calculate attack radius
            this.attackRadius = Utils.Pow(p.AttackRadius, 0.5);
        }