Exemple #1
0
        public bool StoreAura(AuraData aura)
        {
            if (auras.ContainsKey(aura.AuraId))
            {
                this.auras[aura.AuraId] = aura;
            }
            else
            {
                this.auras.Add(aura.AuraId, aura);
            }

            this.itemDb.Store(aura);

            return(true);
        }
Exemple #2
0
    public static List <AuraData> LoadAllAuras()
    {
        List <AuraData> auraList = new List <AuraData>();

        foreach (string filename in Directory.EnumerateFiles(JSON_AURAS_ROOT))
        {
            // Watch out for Unity-generated .meta files
            if (filename.Contains(".meta"))
            {
                continue;
            }
            string   json = File.ReadAllText(filename);
            AuraData aura = new AuraData(JsonUtility.FromJson <AuraDataJsonWrapper>(json));
            auraList.Add(aura);
        }

        return(auraList);
    }
Exemple #3
0
        /// <summary>
        /// Loads aura info for display
        /// </summary>
        private void LoadAura(AuraData aura)
        {
            this.labelAuraId.Text = aura.AuraId.ToString();
            this.comboBoxAuraType.SelectedIndex = (int)aura.AuraType;
            this.textBoxAuraName.Text           = aura.Name;
            this.textBoxAuraLevel.Text          = aura.Level.ToString();

            if (checkBoxExpirable.Checked = aura.Duration.HasValue)
            {
                this.textBoxAuraDuration.Text = aura.Duration.Value.ToString();
            }

            var buff = aura as BuffData;

            if (buff != null)
            {
                this.groupBoxBuff.Visible               = true;
                this.comboBoxBuffType.SelectedIndex     = (int)buff.BuffType;
                this.comboBoxBuffTypeVal1.SelectedIndex = buff.Vital.HasValue ? (int)buff.Vital.Value : (int)buff.Attribute.Value;
                this.radioButtonBeneficial.Checked      = buff.Beneficial;
                this.textBoxFrequency.Text              = buff.Frequency.HasValue ? buff.Frequency.Value.ToString() : "0";
                this.textBoxAmount.Text = buff.Amount.ToString();
            }
        }
Exemple #4
0
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            short auraId = short.Parse(this.labelAuraId.Text);

            if (this.dataHandler.Auras.ContainsKey(auraId))
            {
                MessageBox.Show("Auraid already exists in the database", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            AuraData aura;
            var      type = (byte)this.comboBoxAuraType.SelectedIndex;

            switch (type)
            {
            case (byte)AuraType.Buff:
                aura = new BuffData();
                break;

            default:
                aura = new AuraData();
                break;
            }

            aura.Id       = AuraData.GenerateId(auraId);
            aura.AuraId   = auraId;
            aura.AuraType = type;

            if (this.StoreAura(aura))
            {
                var node = this.treeViewAuras.Nodes[(int)aura.AuraType].Nodes.Add(aura.AuraId.ToString(), string.Format("{0} - Lvl {1}", aura.Name, aura.Level));

                this.logger.LogFormat("New Aura Created. Id = {0} Name = {1}", auraId, aura.Name);
                this.ResetFields();
            }
        }
Exemple #5
0
 /// <summary>
 /// Adds an aura to this combatant's list of currently active auras.
 /// </summary>
 /// <param name="aura">The Aura object being added to this combatant's aura list.</param>
 /// <param name="caster">The CombatantController object applying the aura.</param>
 public void AddAura(AuraData aura, CombatantController caster)
 {
     Debug.Log("Adding aura " + aura.name + " to combatant " + Name + "[" + BattleID + "]");
     ActiveAuraCasterPairs.Add(new KeyValuePair <CombatantController, AuraData>(caster, aura));
 }
Exemple #6
0
        /// <summary>
        /// Saves info to the aura
        /// </summary>
        private bool StoreAura(AuraData aura)
        {
            aura.Name     = this.textBoxAuraName.Text;
            aura.Level    = byte.Parse(this.textBoxAuraLevel.Text);
            aura.FamilyId = short.Parse(this.textBoxAuraFamilyId.Text);
            aura.Duration = this.checkBoxExpirable.Checked ? short.Parse(this.textBoxAuraDuration.Text) : (short?)null;

            if (aura.Level < 1)
            {
                logger.Error("Level must be greater than 0");
                return(false);
            }

            if (aura.FamilyId < 1)
            {
                logger.Error("FamilyId must be greater than 0");
                return(false);
            }

            if (aura.Duration.HasValue && aura.Duration.Value < 1)
            {
                logger.Error("Duration must be greater than 0");
                return(false);
            }

            switch (aura.AuraType)
            {
            case (byte)AuraType.Buff:
            {
                var buff = aura as BuffData;
                buff.BuffType   = (byte)this.comboBoxBuffType.SelectedIndex;
                buff.Beneficial = this.radioButtonBeneficial.Checked;
                buff.Amount     = int.Parse(this.textBoxAmount.Text);

                switch (buff.BuffType)
                {
                case (byte)BuffType.AttributeFixed:
                {
                    buff.Attribute = (byte)this.comboBoxBuffTypeVal1.SelectedIndex;
                }
                break;

                case (byte)BuffType.VitalOvertime:
                {
                    buff.Vital     = (byte)this.comboBoxBuffTypeVal1.SelectedIndex;
                    buff.Frequency = short.Parse(this.textBoxFrequency.Text);

                    if (buff.Frequency < 1)
                    {
                        logger.Error("Frequency must be greater than 0");
                        return(false);
                    }
                }
                break;
                }
            }
            break;

            default:
            {
                logger.Error(string.Format("Aura type {0} is not handled", aura.AuraType));
            }
            break;
            }

            return(this.dataHandler.StoreAura(aura));
        }