public bool HoldPill(Pill.Effect effect)
    {
        if (PickupCooldown == 0)
        {
            PickupCooldown = 10;

            if (isHoldingPill())
            {
                Vector3 temppos = gameObject.transform.position;
                temppos.y += 2;

                Pill newPill = (Instantiate(PillPrefab, temppos, Quaternion.identity) as GameObject).GetComponent<Pill>();
                newPill.PillEffect = PillEffect;
            }

            PillEffect = effect;

            levelMenu.SetHUDPill(effect);

            return true;
        }
        else
        {
            return false;
        }
    }
        protected new void AddItem(string[] inputParams)
        {
            string characterId = inputParams[1];
            Character character = characterList.Find(x => x.Id == characterId);

            string itemClass = inputParams[2];
            string itemId = inputParams[3];

            Item item;
            switch (itemClass)
            {
                case "axe":
                    item = new Axe(itemId);
                    break;
                case "shield":
                    item = new Shield(itemId);
                    break;
                case "pill":
                    item = new Pill(itemId);
                    break;
                case "injection":
                default:
                    item = new Injection(itemId);
                    break;
            }

            character.AddToInventory(item);
        }
        protected override void AddItem(string[] inputParams)
        {
            Item currentItem;
            switch (inputParams[2])
            {
                case "axe":
                    currentItem = new Axe(inputParams[3]);
                    break;
                case "shield":
                    currentItem = new Shield(inputParams[3]);
                    break;
                case "pill":
                    currentItem = new Pill(inputParams[3]);
                    this.timeoutItems.Add((Bonus)currentItem);
                    break;
                case "injection":
                    currentItem = new Injection(inputParams[3]);
                    this.timeoutItems.Add((Bonus)currentItem);
                    break;
                default:
                    throw new InvalidOperationException();
                    break;
            }

            Character currentCharacter = this.characterList.First(x => x.Id == inputParams[1]);
            currentCharacter.AddToInventory(currentItem);
        }
Exemple #4
0
        protected void AddItem(string[] inputParams)
        {
            Character target = this.characterList.FirstOrDefault(x => x.Id == inputParams[1]);

            if (target == null)
            {
                throw new InvalidOperationException("Character does not exists!");
            }

            string itemClass = inputParams[2].ToLower();
            string itemID = inputParams[3];
            switch (itemClass)
            {
                case "axe":
                    Item currentAxe = new Axe(itemID, target);
                    break;
                case "shield":
                    Item currenShield = new Shield(itemID, target);
                    break;
                case "pill":
                    Bonus currentPill = new Pill(itemID, target);
                    this.timeoutItems.AddLast(currentPill);
                    break;
                case "injection":
                    Bonus currentInjection = new Injection(itemID, target);
                    this.timeoutItems.AddLast(currentInjection);
                    break;
                default:
                    {
                        throw new InvalidOperationException("Invalid input!");
                    }
            }
        }
        protected override void AddItem(string[] inputParams)
        {
            string character = inputParams[1];
            string itemClass = inputParams[2];
            string itemId = inputParams[3];

            Item item;
            switch (itemClass)
            {
                case "axe":
                    Item axe = new Axe(itemId);
                    characterList.Find(x => x.Id == character).AddToInventory(axe);
                    break;
                case "injection":
                    Item injection = new Injection(itemId);
                    characterList.Find(x => x.Id == character).AddToInventory(injection);
                    break;
                case "pill":
                    Item pill = new Pill(itemId);
                    characterList.Find(x => x.Id == character).AddToInventory(pill);
                    break;
                case "shield":
                    Item shield = new Shield(itemId);
                    characterList.Find(x => x.Id == character).AddToInventory(shield);
                    break;
                default:
                    throw new ArgumentException("Item missing", "No such an item exist.");
            }
        }
        protected new void AddItem(string[] inputParams)
        {
            Character characterToAcceptIthem = GetCharacterById(inputParams[1]);
            string itemId = inputParams[3];
            Item itemToAdd;

            switch (inputParams[2].Trim())
            {
                case "axe":
                    itemToAdd = new Axe(itemId);
                    characterToAcceptIthem.AddToInventory(itemToAdd);
                    break;
                case "pill":
                    itemToAdd = new Pill(itemId);
                    characterToAcceptIthem.AddToInventory(itemToAdd);
                    break;
                case "shield":
                    itemToAdd = new Shield(itemId);
                    characterToAcceptIthem.AddToInventory(itemToAdd);
                    break;
                case "injection":
                    itemToAdd = new Injection(itemId);
                    characterToAcceptIthem.AddToInventory(itemToAdd);
                    break;
            }
        }
Exemple #7
0
 protected new void AddItem(string[] inputParams)
 {
     var character = GetCharacterById(inputParams[1]);
     Item item;
     switch (inputParams[2].ToLower())
     {
         case "axe":
             item = new Axe(inputParams[3]);
             character.AddToInventory(item);
             break;
         case "shield":
             item = new Shield(inputParams[3]);
             character.AddToInventory(item);
             break;
         case "pill":
             item = new Pill(inputParams[3]);
             character.AddToInventory(item);
             break;
         case "injection":
             item = new Injection(inputParams[3]);
             character.AddToInventory(item);
             break;
         default:
             break;
     }
 }
        protected new void AddItem(string[] inputParams)
        {
            // add character itemClass itemId
            string hero = inputParams[1];
            string itemClass = inputParams[2];
            string itemID = inputParams[3];
            Character temp = GetCharacterById(hero);

            switch (itemClass.ToLower())
            {
                case "axe":
                    Axe axe = new Axe(itemID);
                    temp.AddToInventory(axe);
                    break;
                case "shield":
                    Shield shield = new Shield(itemID);
                    temp.AddToInventory(shield);
                    break;
                case "injection":
                    Injection inj = new Injection(itemID);
                    temp.AddToInventory(inj);
                    break;
                case "pill":
                    Pill pill = new Pill(itemID);
                    temp.AddToInventory(pill);
                    break;
                default:
                    break;
            }
        }
        private Item CreateBonus(string[] inputParams)
        {
            Bonus bonus = null;
            switch (inputParams[2])
            {
                case "pill":
                    bonus = new Pill(inputParams[3]);
                    break;
                case "injection":
                    bonus = new Injection(inputParams[3]);
                    break;
                default:
                    throw new InvalidOperationException("Invalid Item or Bonus");
            }

            this.timeoutItems.Add(bonus);
            return (Item)bonus;
        }
        protected void AddItem(string[] inputParams)
        {
            string id = inputParams[3];
            Item item = null;

            switch (inputParams[2])
            {
                case "axe":
                    item = new Axe(id);
                    break;
                case "shield":
                    item = new Shield(id);
                    break;
                case "injection":
                    item = new Injection(id);
                    break;
                case "pill":
                    item = new Pill(id);
                    break;
            }

            this.GetCharacterById(inputParams[1]).AddToInventory(item);
        }
        private new void AddItem(string[] inputParams)
        {
            Item item;
            switch (inputParams[2].ToLower())
            {
                case "axe":
                    item = new Axe(inputParams[3]);
                    break;
                case "shield":
                    item = new Shield(inputParams[3]);
                    break;
                case "injection":
                    item = new Injection(inputParams[3]);
                    break;
                case "pill":
                    item = new Pill(inputParams[3]);
                    break;
                default:
                    throw new ApplicationException("No such kind of item.");
            }

            var character = this.characterList.First(c => c.Id == inputParams[1]);
            character.AddToInventory(item);
        }
         protected void AddItem(string[] inputParams)
         {
             string characterId;
             string itemId;
             string itemClass;

             Characters character;
             Item item;

             characterId = inputParams[1];
             character = characterList.Find(x => x.ID == characterId);

             itemClass = inputParams[2];
             itemId = inputParams[3];

             switch (itemClass)
             {
                 case "axe":
                     item = new Axe(itemId);
                     break;
                 case "shield":
                     item = new Shield(itemId);
                     break;
                 case "pill":
                     item = new Pill(itemId);
                     break;
                 case "injection":
                     item = new Injection(itemId);
                     break;
                 default:
                     break;
             }
         }
 private void AddItem(string[] inputParams)
 {
     Character characterToAcceptIitem = this.GetCharacterById(inputParams[1]);
     Item itemToAdd;
     switch (inputParams[2].ToLower())
     {
         case "axe":
             itemToAdd = new Axe(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         case "shield":
             itemToAdd = new Shield(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         case "pill":
             itemToAdd = new Pill(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         case "injection":
             itemToAdd = new Injection(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         default:
             break;
     }
 }
Exemple #14
0
        private new void AddItem(string[] inputParams)
        {
            Item item;
            switch (inputParams[2].ToLower())
            {
                case "axe":
                    item = new Axe(inputParams[3]);
                    break;
                case "shield":
                    item = new Shield(inputParams[3]);
                    break;
                case "injection":
                    item = new Injection(inputParams[3]);
                    break;
                case "pill":
                    item = new Pill(inputParams[3]);
                    break;
                default:
                    throw new ApplicationException("No such kind of item.");
            }

            string targetCharecterId = inputParams[1];

            var character = this.characterList.Where(ch => ch.IsAlive)
                .FirstOrDefault(c => c.Id == targetCharecterId);

            if (character == null)
                throw new ArgumentException("No character with id " + targetCharecterId);

            character.AddToInventory(item);
        }
 public void SetHUDPill(Pill.Effect effect)
 {
     if (effect != Pill.Effect.Nothing)
     {
         currentPill.material = Pill.getMaterial(effect);
         currentPill.color = Color.white;
     }
     else
     {
         currentPill.material = defaultPillMaterial;
         currentPill.color = defaultPillColor;
     }
 }