public Blob CreateBlob(ICommand command)
        {
            string name = command.Parameters[0];
            int health = int.Parse(command.Parameters[1]);
            int attackDamage = int.Parse(command.Parameters[2]);
            BehaviorType behaviorType;
            if (command.Parameters[3] == "Inflated")
            {
                behaviorType = BehaviorType.Inflated;
            }
            else
            {
                behaviorType = BehaviorType.Aggresive;
            }
            AttackType attackType;
            if (command.Parameters[4] == "PutridFart")
            {
                attackType = AttackType.PutridFart;
            }
            else
            {
                attackType = AttackType.Blobplode;
            }

            var blob = new Blob(name, health, attackDamage, behaviorType, attackType);

            return blob;
        }
Esempio n. 2
0
        public override void Execute(params string[] commandParams)
        {
            var blobName = commandParams[0];
            var blobHealth = int.Parse(commandParams[1]);
            var blobDamage = int.Parse(commandParams[2]);
            var behaviorType = commandParams[3];
            IBehavior blobBehavior = this.Engine.BehaviorFactory.CreateBehavior(behaviorType);
            var attackType = commandParams[4];
            IAttack blobAttack = this.Engine.AttackFactory.CreateAttack(attackType);

            var blob = new Blob(blobName, blobHealth, blobDamage, blobBehavior, blobAttack);

            this.Engine.AddBlob(blob);
        }
        public void AddBlob(Blob blob)
        {
            if (blob == null)
            {
                throw new ArgumentNullException(nameof(blob));
            }

            if (!this.Blobs.Contains(blob))
            {
                this.Blobs.Add(blob);
            }
            else
            {
                throw new ArgumentException($"The blob with name {blob.Name} already exists");
            }
        }
Esempio n. 4
0
        public void AttackBlob(Blob blob)
        {
            int initialHealth = this.Health;
            int initialEnemyHealth = blob.Health;

            if (blob.Health <= initialEnemyHealth / 2)
            {
                if (triggerCounter != 0)
                {
                    throw new Exception("A behavior can only be triggered once");
                }
                TriggerBehavior();
                triggerCounter++;
            }
            if (this.AttackType == AttackType.Blobplode)
            {
                this.Health %= 2;
                blob.Health -= 2 * this.AttackDamage;
            }
            else
            {
                blob.Health -= this.AttackDamage;
            }
        }
Esempio n. 5
0
        public IBlob CreateBlob(string name, int health, int damage, IBehavior behavior, IAttack attack)
        {
            var blob = new Blob(name, health, damage, behavior, attack);

            return blob;
        }