예제 #1
0
 public void AddBaseValue(BaseObject baseValue)
 {
     if (BaseValues.ContainsKey(baseValue.Key))
     {
         throw new MeException($"Duplicate base value {baseValue.Name}.");
     }
     BaseValues.Add(baseValue.Key, baseValue);
 }
예제 #2
0
    public int ReadJsonCivValues(TextAsset ai, int line, int value)
    {
        string jsoni = ai.text;

        BaseValues destinyInJson = JsonUtility.FromJson <BaseValues>(jsoni);
        int        ergebniss     = destinyInJson.base1[line].GW[value];

        return(ergebniss);
    }
예제 #3
0
 public EnemyGeneric(BaseValues patk, BaseValues matk, BaseValues armor, BaseValues magarmor, CreateEntity th)
 {
     thePlayer           = th;
     jobName             = "Enemies";
     physicalWeaponValue = patk;
     magicalWeaponValue  = matk;
     armorValue          = armor;
     magArmorValue       = magarmor;
 }
        public PermanentStatBuilder Reset()
        {
            BaseValues.Clear();

            foreach (var type in Enum.GetValues <PermanentStatType>())
            {
                IndividualValues[type] = 0;
                EffortValues[type]     = 0;
            }

            return(this);
        }
예제 #5
0
 public Paladin(PlayerData thePlayer)
 {
     JobSkills           = CreateSkills();
     jobName             = "Paladin";
     this.thePlayer      = thePlayer;
     physicalWeaponValue = new BaseValues(9999, 50, 0, 0);
     magicalWeaponValue  = new BaseValues(9999, 25, 0, 0);
     armorValue          = new BaseValues(9999, 75, 0, 0);
     magArmorValue       = new BaseValues(9999, 35, 0, 0);
     AdjustStats();
     jobDescription = "Defensive warrior with a fairly potent self heal. Can stun enemies and become immune to damage, but trades raw attack power in exchange for sustainability.";
 }
예제 #6
0
 public DarkKnight(PlayerData thePlayer)
 {
     JobSkills           = CreateSkills();
     jobName             = "Dark Knight";
     this.thePlayer      = thePlayer;
     physicalWeaponValue = new BaseValues(9999, 100, 0, 0);
     magicalWeaponValue  = new BaseValues(9999, 50, 0, 0);
     armorValue          = new BaseValues(9999, 25, 0, 0);
     magArmorValue       = new BaseValues(9999, 25, 0, 0);
     AdjustStats();
     jobDescription = "In-between defensive and glass cannon. Uses necromantic powers to recover health, increase defenses and poison enemies. Powerful physical attacks.";
 }
예제 #7
0
    private void CreateStageButtons()
    {
        List <Stage>  stages = _master.GetStages();
        GameObject    newStageItem;
        float         buttonHeight        = 0f;
        float         buttonSpacing       = _stageContainer.GetComponent <VerticalLayoutGroup>().spacing;
        float         containerViewHeight = _stageView.GetComponent <RectTransform>().sizeDelta.y;
        bool          scrollNeeded        = false;
        RectTransform containerRect       = _stageContainer.GetComponent <RectTransform>();
        Vector2       containerSize       = containerRect.sizeDelta;

        _stageContainer.GetComponent <RectTransform>().sizeDelta = new Vector2(0, containerViewHeight);

        ClearStagesButtons();

        for (int i = 0; i < stages.Count; i++)
        {
            if (!stages[i].Islocked)
            {
                if (buttonHeight == 0f)
                {
                    buttonHeight = _baseStageButton.GetComponent <RectTransform>().sizeDelta.y;
                }

                newStageItem      = Instantiate(_baseStageButton, _stageContainer.transform, false);
                newStageItem.name = "s" + i;

                newStageItem.GetComponent <StageMenuItem>()
                .SetStageNameLabel(stages[i].Label, false)
                .SetStars(BaseValues.GetStars(stages[i].HighestPickUps, stages[i].TotalPickUps))
                .SetStageIndex(i);

                containerSize.y = (buttonHeight + buttonSpacing) * (i + 1);

                if (containerSize.y > containerViewHeight)
                {
                    containerRect.sizeDelta = containerSize;
                    scrollNeeded            = true;
                }
            }
        }

        if (!scrollNeeded)
        {
            _stageView.GetComponent <ScrollRect>().vertical = false;
        }
        else
        {
            _scrollbar.value = 0;
        }
    }
예제 #8
0
        public void Test_HiddenMembers()
        {
            DerivedValues values = new DerivedValues {
                X = "hello", Y = 42
            };
            BaseValues bValues = values;

            bValues.X = 42;

            string expected = $"{values.X} {values.Y}";
            string actual   = StringTemplate.Format("{X} {Y}", values);

            Assert.Equal(expected, actual);
        }
예제 #9
0
    public int ReadJsonBaseValues(TextAsset ai, int from, int line, int value)
    {
        string jsoni = ai.text;

        if (from == 4)
        {
            Destinys destinyInJson = JsonUtility.FromJson <Destinys>(jsoni);
            int      ergebniss     = destinyInJson.destinies1[line].GW[value];
            return(ergebniss);
        }
        else
        {
            BaseValues destinyInJson = JsonUtility.FromJson <BaseValues>(jsoni);
            int        ergebniss     = destinyInJson.base1[line].GW[value];
            return(ergebniss);
        }
    }
예제 #10
0
 public Bear(ulong playerid)
 {
     hp            = new BaseValues(800, 0, 800, 0);
     mp            = new BaseValues(25, 0, 25, 0);
     patk          = new BaseValues(9999, 50, 150);
     matk          = new BaseValues(9999, 1, 0);
     pdef          = new BaseValues(9999, 250, 200);
     mdef          = new BaseValues(9999, 2, 0);
     agi           = new BaseValues(9999, 15, 150);
     aiName        = "Bear";
     aiExpValue    = 25;
     aiJobExpValue = 1;
     _allData      = new RPGSaveData()
     {
         weaponLevel      = 1,
         magicWeaponLevel = 1,
         armorLevel       = 3,
         magArmorLevel    = 1,
         _level           = 2
     };
     CurrentJob = new EnemyGeneric(patk, matk, pdef, mdef, this);
 }
예제 #11
0
파일: Wolf.cs 프로젝트: cprogrammer9/Nepbot
 public Wolf(ulong playerid)
 {
     hp            = new BaseValues(150, 0, 150, 0);
     mp            = new BaseValues(25, 0, 25, 0);
     patk          = new BaseValues(9999, 10, 5);
     matk          = new BaseValues(9999, 1, 1);
     pdef          = new BaseValues(9999, 10, 5);
     mdef          = new BaseValues(9999, 1, 1);
     agi           = new BaseValues(9999, 150, 25);
     aiName        = "Wolf";
     aiExpValue    = 10;
     aiJobExpValue = 1;
     _allData      = new RPGSaveData()
     {
         weaponLevel      = 2,
         magicWeaponLevel = 1,
         armorLevel       = 2,
         magArmorLevel    = 1,
         _level           = 1
     };
     CurrentJob = new EnemyGeneric(patk, matk, pdef, mdef, this);
 }
예제 #12
0
 public bool HasBaseValue(string key)
 {
     return(BaseValues.ContainsKey(key));
 }
예제 #13
0
            /*!
             * \brief   Parse readed csv key-value pairs to real data types.
             *          Iterates through all properties with getter and setter and tries to set with value.
             *
             * \param   values      The csv values.
             * \param   nameDict    Dictionary to translate names. 'property name' => 'csv-field name'.
             * \param   pdb         The plant database to parse type "Plant".
             * \param   sdb         The soil database to parse type "Soil".
             * \param   cdb         The climate database to parse type "Climate".
             * \param   cultureInfo Information to parse data in different localized formats
             */

            protected void parseData(IDictionary <String, String> values, IDictionary <String, String> nameDict = null, PlantDb pdb = null, SoilDb sdb = null, ClimateDb cdb = null, RainPatternDb rpdb = null, CultureInfo cultureInfo = null)
            {
                IEnumerable <PropertyInfo> piList = this.GetType().GetRuntimeProperties();

                IList <String> propertyNames = new List <String>();

                foreach (PropertyInfo pi in piList)
                {
                    propertyNames.Add(pi.Name);
                }

                IDictionary <String, IDictionary <String, String> > subObjects = new Dictionary <String, IDictionary <String, String> >();

                foreach (String key in values.Keys)
                {
                    // Skip known properties
                    if (propertyNames.Contains(key))
                    {
                        continue;
                    }

                    if (key.Contains("."))
                    {
                        String[] parts = key.Split(".".ToCharArray(), 2);

                        String subObjectName     = parts[0];
                        String subObjectProperty = parts[1];

                        // FIXME: Raise error for empty parts
                        if (
                            String.IsNullOrWhiteSpace(subObjectName) ||
                            String.IsNullOrWhiteSpace(subObjectProperty) ||
                            subObjectName.Equals("_iterator") ||
                            !propertyNames.Contains(subObjectName)
                            )
                        {
                            continue;
                        }

                        if (!subObjects.ContainsKey(subObjectName))
                        {
                            subObjects.Add(subObjectName, new Dictionary <String, String>());
                        }
                        subObjects[subObjectName].Add(subObjectProperty, values[key]);
                    }
                }
                foreach (String subObjName in subObjects.Keys)
                {
                    PropertyInfo pi = this.GetType().GetRuntimeProperty(subObjName);

                    if (pi.PropertyType.IsArray)
                    {
                        Type       arrayType     = pi.PropertyType.GetElementType();
                        List <int> indexes       = subObjects[subObjName].Keys.Select(Int32.Parse).ToList();
                        Array      arrayInstance = Array.CreateInstance(arrayType, indexes.Max() + 1);

                        foreach (int index in indexes)
                        {
                            if (String.IsNullOrEmpty(subObjects[subObjName][index.ToString()]))
                            {
                                continue;
                            }

                            if (arrayType == typeof(String))
                            {
                                arrayInstance.SetValue(subObjects[subObjName][index.ToString()], index);
                            }
                            else if (arrayType == typeof(Double))
                            {
                                arrayInstance.SetValue(Double.Parse(subObjects[subObjName][index.ToString()], cultureInfo != null ? cultureInfo : CultureInfo.InvariantCulture), index);
                            }
                            else if (arrayType == typeof(int) || arrayType == typeof(Int16) || arrayType == typeof(Int32) || arrayType == typeof(Int64))
                            {
                                arrayInstance.SetValue(int.Parse(subObjects[subObjName][index.ToString()], cultureInfo != null ? cultureInfo : CultureInfo.InvariantCulture), index);
                            }
                        }

                        pi.SetValue(this, arrayInstance, null);
                    }
                    else
                    {
                        BaseValues instance = Activator.CreateInstance(pi.PropertyType) as BaseValues;
                        // FIXME: Raise error on wrong object type
                        if (instance == null)
                        {
                            continue;
                        }

                        instance.parseData(subObjects[subObjName], nameDict, pdb, sdb, cdb, rpdb, cultureInfo);
                        pi.SetValue(this, instance, null);
                    }
                }

                //use this for .net 4.0
                //foreach (PropertyInfo pi in this.GetType().GetProperties())
                //use this for .net 4.5
                foreach (PropertyInfo pi in piList)
                {
                    //if (pi.GetGetMethod() == null || pi.GetSetMethod() == null) continue;

                    String name = nameDict != null && nameDict.ContainsKey(pi.Name) ? nameDict[pi.Name] : pi.Name;
                    if (!values.ContainsKey(name))
                    {
                        continue;
                    }

                    propertyNames.Add(name);

                    String value = values[name];
                    if (String.IsNullOrWhiteSpace(value) || value.StartsWith("#NV"))
                    {
                        continue;
                    }

                    Type type = Nullable.GetUnderlyingType(pi.PropertyType);
                    if (type == null)
                    {
                        type = pi.PropertyType;
                    }

                    if (type == typeof(String))
                    {
                        pi.SetValue(this, value, null);
                    }
                    else if (type == typeof(Double))
                    {
                        pi.SetValue(this, Double.Parse(value, cultureInfo != null ? cultureInfo : CultureInfo.InvariantCulture), null);
                    }
                    //use this for .net 4.0
                    //else if (type.IsEnum)
                    //use this for .net 4.5
                    else if (type.GetTypeInfo().IsEnum)
                    {
                        try
                        {
                            pi.SetValue(this, System.Enum.Parse(type, value), null);
                        }
                        catch
                        {
                            pi.SetValue(this, null, null);
                        }
                    }
                    else if (type == typeof(Plant))
                    {
                        if (pdb == null)
                        {
                            continue;
                        }
                        pi.SetValue(this, pdb.getPlant(value), null);
                    }
                    else if (type == typeof(Soil))
                    {
                        if (sdb == null)
                        {
                            continue;
                        }
                        pi.SetValue(this, sdb.getSoil(value), null);
                    }
                    else if (type == typeof(Climate))
                    {
                        if (cdb == null)
                        {
                            continue;
                        }
                        pi.SetValue(this, cdb.getClimate(value), null);
                    }
                    else if (type == typeof(RainPattern))
                    {
                        if (rpdb == null)
                        {
                            continue;
                        }
                        pi.SetValue(this, rpdb.getRainPattern(value), null);
                    }
                    else if (type == typeof(IrrigationType))
                    {
                        foreach (FieldInfo fi in typeof(IrrigationTypes).GetRuntimeFields())
                        {
                            if (fi.Name == value)
                            {
                                IrrigationType tmpIt = new IrrigationType();
                                tmpIt = (IrrigationType)fi.GetValue(tmpIt);
                                pi.SetValue(this, tmpIt, null);
                                break;
                            }
                        }
                    }
                    else /* if (type.isValueType)*/
                    {
                        pi.SetValue(this, Convert.ChangeType(value, type), null);
                    }
                }
            }