public EntityTemplate(int tmpID, string tmpName, int tmpminLevel, Weapon tmpWeapon)
     : base(tmpID,tmpName)
 {
     this.minLevel = tmpminLevel;
     this.equipedWeapon = tmpWeapon;
     this.baseHP = 10 * tmpminLevel;
     this.speed = 1;
 }
 public EntityTemplate(int tmpID, string tmpName, int tmpminLevel, Weapon tmpWeapon, int tmpBaseHP, int tmpSpeed)
     : base(tmpID, tmpName)
 {
     this.minLevel = tmpminLevel;
     this.equipedWeapon = tmpWeapon;
     this.baseHP = tmpBaseHP;
     this.speed = tmpSpeed;
 }
 public ItemWrapper(string tmpType)
 {
     this._WeaponPotionEncrypter = new EncrypterDecrypter();
     this._WeaponPotionEncrypter.setKey(this._key);
     if (tmpType == "Weapon")
     {
         this.bLogger = new BasicLogger(this._WLog);
         this._ActivePath = this._WPath;
         string encryptedWeapons = this._WeaponPotionEncrypter.decryptFile(this._WPath);
         if (encryptedWeapons.Length > 0)
         {
             int TotalItems = ParseItems.parseIntFrom(encryptedWeapons, 4);
             encryptedWeapons = encryptedWeapons.Substring(4);
             int i = 0;
             while (i < TotalItems)
             {
                 int lengthOfWeapon = ParseItems.parseIntFrom(encryptedWeapons, 3);
                 encryptedWeapons = encryptedWeapons.Substring(3);
                 this.bLogger.Log("Attempting to decrypt: " + encryptedWeapons.Substring(0, lengthOfWeapon), debug);
                 Weapon newWeapon = new Weapon(encryptedWeapons.Substring(0, lengthOfWeapon));
                 encryptedWeapons = encryptedWeapons.Substring(lengthOfWeapon);
                 this._listOfItems.Add(newWeapon);
                 this._usedIDs.Add(newWeapon.itemID);
                 i++;
             }
         }
     }
     else if (tmpType == "Potion")
     {
         this.bLogger = new BasicLogger(this._PLog);
         this._ActivePath = this._PPath;
         string encryptedPotions = this._WeaponPotionEncrypter.decryptFile(this._PPath);
         if (encryptedPotions.Length > 0)
         {
             int TotalItems = ParseItems.parseIntFrom(encryptedPotions, 4);
             encryptedPotions = encryptedPotions.Substring(4);
             int i = 0;
             while (i < TotalItems)
             {
                 int lengthOfPotion = ParseItems.parseIntFrom(encryptedPotions, 3);
                 encryptedPotions = encryptedPotions.Substring(3);
                 Potion newPotion = new Potion(encryptedPotions.Substring(0, lengthOfPotion));
                 encryptedPotions = encryptedPotions.Substring(lengthOfPotion);
                 this._listOfItems.Add(newPotion);
                 this._usedIDs.Add(newPotion.itemID);
                 i++;
             }
         }
     }
     else
     {
         this.bLogger = new BasicLogger(this._ActivePath);
         bLogger.Log("ItemWrapper:ItemWrapper(Type): - Critical Error - Invalid ItemType");
         MessageBox.Show("Critical Error, please see crit.err");
         Environment.FailFast("Invalid Type");
     }
 }
 public Entity(int tmpID, string tmpName, int tmpLevel, Weapon tmpWeapon, int tmpHP, int tmpSpeed)
     : base(tmpID, tmpName)
 {
     this.level = tmpLevel;
     this.equipedWeapon = tmpWeapon;
     this.maxHP = tmpHP;
     this.speed = tmpSpeed;
     this.currentDamage = 0;
     speed = tmpSpeed;
     Thread.Sleep(1);
 }
        public Entity(string EString, List<Weapon> currentWeapons)
            : base(EString)
        {
            EString = EString.Substring(29 + this.name.Length);

            int WepID = ParseItems.parseIntFrom(EString, 4);

            foreach (Weapon tmpWep in currentWeapons)
            {
                if (tmpWep.ItemID == WepID)
                {
                    this.equipedWeapon = tmpWep;
                }
            }
        }
        private void btnSelect_Click(object sender, EventArgs e)
        {
            if (this.dgvWeapons.SelectedCells.Count > 0)
            {
                int tmpID = Int32.Parse(this.dgvWeapons.SelectedRows[0].Cells[0].Value.ToString());
                foreach (Weapon tmpWep in this._listOfWeapons)
                {
                    if (tmpWep.ItemID == tmpID)
                    {
                        this.selectedWep = tmpWep;
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                }

            }
        }
        private void btnAddEdit_Click(object sender, EventArgs e)
        {
            if (this.rWeapon.Checked)
            {
                int newID;
                if (this.selectedItemID > -1)
                {
                    newID = this.selectedItemID;
                }
                else if (this.cIDOverride.Checked)
                {
                    newID = (int)this.nIDForce.Value;

                }else{
                    newID = this._weaponWrapper.getNextID();
                }

                Weapon newWep = new Weapon(newID, this.txtName.Text, (int)this.nValue.Value, (int)this.nEffect.Value, (int)this.nAttackRollBonus.Value);
                this._weaponWrapper.AddItem(newWep);
            }
            else
            {
                int newID;
                if (this.selectedItemID > -1)
                {
                    newID = this.selectedItemID;
                }
                else if (this.cIDOverride.Checked)
                {
                    newID = (int)this.nIDForce.Value;
                }
                else
                {
                    newID = this._potionWrapper.getNextID();
                }

                Potion newPotion = new Potion(newID, this.txtName.Text, (int)this.nValue.Value, (int)this.nEffect.Value);
                this._potionWrapper.AddItem(newPotion);
            }

            this.populateDataGrid();
            this.changesSaved = false;
        }
        public Entity generateAnEntity(int tmpId, string tmpName, List<Weapon> tmpWeapons)
        {
            //Figure out which stat has priority
            List<int> sortedStats = baseStats.ToList();
            sortedStats.Sort();
            List<int> indexes = new List<int>();
            foreach (int tmpPriorityValue in sortedStats)
            {
                bool found = false;
                int i = 0;
                while (!found)
                {
                    if (baseStats[i] == tmpPriorityValue && !indexes.Contains(i))
                    {
                        indexes.Add(i);
                        found = true;
                    }
                    i++;
                }
            }

            //Spend all points earned by this level
            int points = 2 * this.minLevel;
            int[] gStats = new int[5]{this.minLevel,1,1,1,1};
            int j = 1;
            while (points > 0)
            {
                int spending = RandomInt.r.Next(0, 1);
                if (spending == 1)
                {
                    gStats[indexes[j]] += 1;
                    points -= 1;
                    j = 1;
                }
                else if (j == 4)
                {
                    j = 1;
                }
                else
                {
                    j++;
                }

            }

            //Select a random weapon from weapons this template uses
            int selectedID = RandomInt.r.Next(0, weaponIDs.Count);
            Weapon selectedWep = new Weapon(0, "Unarmed", 0, 0, true, new List<int>(), new List<int>());
            foreach(Weapon tmpWep in tmpWeapons)
            {
                if(tmpWep.ItemID == weaponIDs[selectedID]){
                    selectedWep = tmpWep;
                }
            }

            //Create the Entity
            Entity tmpEnt = new Entity(tmpId, tmpName, gStats, selectedWep);

            return tmpEnt;
        }
 //#####Combat Methods
 public void equipWeapon(Weapon tmpNewWep)
 {
     this.equipedWeapon = tmpNewWep;
 }
Beispiel #10
0
 public void unequipWeapon()
 {
     this.equipedWeapon = new Weapon(-001, "Unarmed", 0, 1, 20);
 }
 //Constructors
 public Entity(int tmpID, string tmpName, int[] tmpStats, Weapon tmpWeapon)
     : base(tmpID, tmpName, tmpStats)
 {
     this.equipedWeapon = tmpWeapon;
 }
 /// <summary>
 /// Unequips and returns the previously equiped weapon
 /// "Equips" unarmed weapon with ID of -001
 /// </summary>
 /// <returns></returns>
 public Weapon unequipWeapon()
 {
     Weapon tmpOld = this.equipedWeapon;
     this.equipedWeapon = new Weapon(-001, "Unarmed", 0, 1, false,new List<int>(), new List<int>());
     return tmpOld;
 }
Beispiel #13
0
 public override Item Clone(int tmpID)
 {
     Weapon tmpNewWep = new Weapon(tmpID, ItemName, value, power, magiPower, canBuy, magicalEffects, classesCanUse);
     return tmpNewWep;
 }
        private void updateCmbInfo()
        {
            if (cmbCurrent.SelectedValue != null)
            {
                if (((int)cmbCurrent.SelectedValue) == -1)
                {
                    selectedWeapon = (Weapon)newWeapon.Clone(-1);
                }
                else
                {
                    selectedWeapon = (Weapon)weaponWrapper.getItem((int)cmbCurrent.SelectedValue);
                }

                updateSelectedItemsInfo();
            }
        }
 private void saveChanges()
 {
     if (cmbCurrent.SelectedIndex > 0)
     {
         selectedWeapon.ItemName = txtName.Text;
         if (selectedWeapon.ItemName != string.Empty)
         {
             if (selectedWeapon.ItemID == -1)
             {
                 selectedWeapon.ItemID = weaponWrapper.NextID();
             }
             selectedWeapon = new Weapon(selectedWeapon.ItemID, selectedWeapon.ItemName, (int)nudValue.Value, (int)nudPower.Value, (int)nudMagiPower.Value, cAvailInShops.Checked, effectsBox1.getList(), getListOfClasses());
             weaponWrapper.AddItem(selectedWeapon);
             loadPreExsistingWeapons();
             cmbCurrent.SelectedIndex = 0;
             updateCmbInfo();
             configureGui();
         }
         else
         {
             MessageBox.Show("Please Enter a Spell Name");
         }
     }
 }