/// <summary>
    /// Constructor to create derived attributes from a character.
    /// </summary>
    /// <param name="character">Character object for base attributes.</param>
    /// <param name="level">Level of the character.</param>
    public DerivedAttributes(Character character, int level)
    {
        this.character = character;
        this.level     = level;

        if (character.CharacterType == CharacterType.Hero)
        {
            bonusAttributes = character.BonusAttributes + GameManager.InventoryManager.AttributeModifiers;
        }
        else
        {
            bonusAttributes = character.BonusAttributes;
        }

        if (character.CharacterType == CharacterType.Ally)
        {
            var ally = character as Ally;
            levelUpgrades = ally.LevelUpgrades;
        }
        else
        {
            levelUpgrades = new LevelUpgrades();
        }

        CalculateDerivedAttributes();
    }
Esempio n. 2
0
 public void RemoveAttributes(List <GameAttribute> attributes)
 {
     foreach (GameAttribute ga in attributes)
     {
         BaseAttributes.Remove(ga);
     }
 }
Esempio n. 3
0
    public void CreateEntity(Vector3Int location, ShipDesign design)
    {
        var loc = StarSystem.TileToWorld(location);
        var obj = Instantiate(Entity, loc, Entity.transform.rotation);
        var atr = obj.GetComponent <Attributes>();

        atr.Id         = BaseAttributes.GetId();
        atr.StarSystem = StarSystem;
        atr.Empire     = this;
        atr.Location   = location;
        var br = obj.GetComponent <EntityBrain>();

        br.StarSystem        = StarSystem;
        br.Movement          = obj.GetComponent <EntityMovement>();
        br.Movement.Location = location;
        var ti = obj.GetComponent <TickControlScript>();

        ti.StarSystem         = StarSystem;
        atr.TickControlScript = ti;

        EntityManager.Entities.Add(atr);
        Ships.Add(br);
        obj.name = $"{Id}:{design.Name}:{atr.Id}";

        atr.Initialize(design);

        OnBuildShip?.Invoke(location, atr);
    }
Esempio n. 4
0
    //Loads data based on teh path name and the type of data object to be loaded
    //Overload this method if any other type of data should be loaded
    public static BaseAttributes DataLoader(string _fileName)
    {
        DataBuilder(_fileName);
        BaseAttributes Data = JsonUtility.FromJson <BaseAttributes>(jsonString);

        return(Data);
    }
Esempio n. 5
0
 public Creature(Creature other)
     : base(other)
 {
     BaseAttributes            = other.BaseAttributes.Clone();
     ModifiedAttributes        = BaseAttributes.Clone();
     _usedAttacksOfOpportunity = 0;
 }
Esempio n. 6
0
        public override void ReadAttributesXML(XmlNode xmlNode)
        {
            bool readBase     = false;
            bool readModified = false;

            try
            {
                foreach (XmlNode childNode in xmlNode.ChildNodes)
                {
                    if (childNode.Name == "BaseAttributes")
                    {
                        BaseAttributes.ReadXML(childNode.ChildNodes[0]);
                        readBase = true;
                    }
                    else if (childNode.Name == "ModifiedAttributes")
                    {
                        ModifiedAttributes.ReadXML(childNode.ChildNodes[0]);
                        readModified = true;
                    }
                }
            }
            catch (XmlException e)
            {
                MessageBox.Show(e.ToString());
            }

            if (readBase && !readModified)
            {
                ModifiedAttributes = new CreatureAttributes(BaseAttributes);
            }
        }
Esempio n. 7
0
    public void CreateColony(Vector3Int location, GameObject source = null)
    {
        if (EntityManager.Entities.OfType <ColonyAttributes>().FirstOrDefault(x => x.Location == location) != null)
        {
            return;
        }


        var loc = StarSystem.TileToWorld(location);
        var obj = Instantiate(Colony, loc, Colony.transform.rotation);
        var atr = obj.GetComponent <ColonyAttributes>();

        atr.Id         = BaseAttributes.GetId();
        atr.StarSystem = StarSystem;
        atr.Empire     = this;
        atr.Location   = location;
        var c = obj.GetComponent <ColonyControl>();

        c.StarSystem = StarSystem;
        c.Location   = location;
        c.Empire     = this;

        EntityManager.Entities.Add(atr);
        Colonies.Add(c);

        obj.name = $"{Id}:ColonyPlanet:{atr.Id}";
        OnColonize?.Invoke(location, atr);

        if (source != null)
        {
            Destroy(source);
        }
    }
 public Character(int level, BaseAttributes attributes)
 {
     Level          = level;
     BaseAttributes = attributes;
     Equipments     = new List <Equipment>();
     Buffs          = new List <Buff>();
 }
    public CharacterStats Stats;//Combination of Stats from: base stats + items + abilities and modifiers

    void Start()
    {
        //Load base stats based on the stat file selected
        baseStats    = JsonStatLoader.DataLoader(StatsFile);
        currentLevel = 1;

        Stats.reloadCharacterStats(); //calculate CharacterStats for the first time
    }
 public void SetupCharacter(Character target)
 {
     target.GameName        = Name;
     target.BaseAttributes  = BaseAttributes.Select(b => new Caracteristic(b)).ToList();
     target.SpendablePoints = SpendablePoints.Select(sp => new Caracteristic(sp)).ToList();
     target.Skills          = Skills.Select(s => new Caracteristic(s)).ToList();
     target.Stats           = Stats.Select(s => new Caracteristic(s)).ToList();
 }
Esempio n. 11
0
 /// <summary>
 /// Class that defines a simple monster that has no AI
 /// </summary>
 /// <param name="id">the ID of the monster</param>
 /// <param name="currentLevel">current level the monster is in</param>
 public Monster(string id, Level currentLevel) : base(0, id)
 {
     this.currentLevel = currentLevel;
     playersHit        = new List <Character>();
     attributes        = new BaseAttributes();
     baseattributes    = new BaseAttributes();
     hitCounter        = 0;
     idAnimation       = "idle";
 }
Esempio n. 12
0
        public override void WriteAttributesXML(XmlWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("BaseAttributes");
            BaseAttributes.WriteXML(xmlWriter);
            xmlWriter.WriteEndElement();

            xmlWriter.WriteStartElement("ModifiedAttributes");
            ModifiedAttributes.WriteXML(xmlWriter);
            xmlWriter.WriteEndElement();
        }
Esempio n. 13
0
    public void Subtract(BaseAttributes toSub)
    {
        if (toSub == null)
        {
            return;
        }

        foreach (AttributesEnum ae in toSub.DictKeys)
        {
            this[ae] -= toSub[ae];
        }
    }
Esempio n. 14
0
    public void Add(BaseAttributes toAdd)
    {
        if (toAdd == null)
        {
            return;
        }

        foreach (AttributesEnum ae in toAdd.DictKeys)
        {
            this[ae] += toAdd[ae];
        }
    }
Esempio n. 15
0
 //初始化属性
 protected void InitAttributes()
 {
     //base
     Attributes = BaseAttributes.Clone();
     InitEquipAttributes();
     HP        = Attributes.HP;
     MP        = Attributes.MP;
     Stamina   = Attributes.Stamina;
     Strength  = Attributes.Strength;
     Dexterity = Attributes.Dexterity;
     Mental    = Attributes.Mental;
     Steady    = Data.Steady;
 }
Esempio n. 16
0
        /// <summary>
        /// Copies this entity's properties to another entity.
        /// </summary>
        /// <param name="entityAnimate">The entity to copy to.</param>
        /// <remarks>Doesn't copy IDs or cache type.</remarks>
        public virtual void CopyTo(EntityAnimate entityAnimate)
        {
            if (entityAnimate == null)
            {
                return;
            }

            base.CopyTo(entityAnimate);

            BaseMaxPools.CopyTo(entityAnimate.BaseMaxPools);
            BaseAttributes.CopyTo(entityAnimate.BaseAttributes);
            BaseQualities.CopyTo(entityAnimate.BaseQualities);
            Currency.CopyTo(entityAnimate.Currency);
        }
Esempio n. 17
0
        public int GetAttributeStartingMin(AttributeCode attribute)
        {
            if (!BaseAttributes.ContainsKey(attribute))
            {
                throw new ArgumentOutOfRangeException("Tried to get nonexistent attribute.");
            }

            if (IsMainAttribute(attribute))
            {
                return(1);
            }

            return(0);
        }
Esempio n. 18
0
        public int GetAttributeMax(AttributeCode attribute)
        {
            if (!BaseAttributes.ContainsKey(attribute))
            {
                throw new ArgumentOutOfRangeException("Tried to get nonexistent attribute.");
            }

            if (IsMainAttribute(attribute))
            {
                return(3 + (Level - 1) - ((Level - 1) / 3));
            }

            return(RuleTables.GetStartingMaxAttribute(Exceptionality) + (Level - 1) - (Level - 1) / 2);
        }
        public BaseAttrEditor()
        {
            InitializeComponent();
            selectedObject = new BaseAttributes();
            selectedObject.SetCurrentBase(this);
            this.DataContext = selectedObject;
            _propertyGrid.Update();

            for (int j = 0; j < Constants.City[HeatSourceLayoutApp.globalProperty.ProvinceId].Count; ++j)
            {
                viewCities.Add(j, Constants.City[HeatSourceLayoutApp.globalProperty.ProvinceId][j]);
            }
            //第一次初始化,更新【北京】的供暖天数等值
            //获取数据库中的CityID,如果不存在,返回一个默认值1
            ArrayList cityListInDB = DataConfig.getCustomConfig("城市列表");

            String[] cityList = (String[])cityListInDB.ToArray(typeof(String));
            String   cityName = Constants.City[0][0];
            int      i;

            for (i = 0; i < cityList.Length; i++)
            {
                String testCityName0 = cityList[i];
                String testCityName1 = cityList[i] + "市";
                String testCityName2 = cityList[i] + "州";
                String testCityName3 = cityList[i] + "地区";
                String testCityName4 = cityList[i] + "盟";

                if ((testCityName0 == cityName) || (testCityName1 == cityName) || (testCityName2 == cityName) || (testCityName3 == cityName) || (testCityName4 == cityName))
                {
                    HeatSourceLayoutApp.globalProperty.CityId = i;
                    break;
                }
            }
            if (i == cityList.Length)
            {
                HeatSourceLayoutApp.globalProperty.CityId = 0;
            }
            HeatSourceLayoutApp.globalProperty.HeatingDays = (int)double.Parse(DataConfig.getDailyTemperatureLessthanFive(HeatSourceLayoutApp.globalProperty.CityId));
            HeatSourceLayoutApp.globalProperty.OutDoorTemp = double.Parse(DataConfig.getHeatingOutsideTemperature(HeatSourceLayoutApp.globalProperty.CityId));
            try
            {
                HeatSourceLayoutApp.globalProperty.OutAverageTemp = double.Parse(DataConfig.getDailyTemperatureLessthanFiveAverageTemperature(HeatSourceLayoutApp.globalProperty.CityId));
            }
            catch (Exception e)
            {
                e.ToString();
            }
        }
Esempio n. 20
0
    void GatherRefs()
    {
        effects = GetComponent <Effects>();

        startingAtts  = GetComponent <StartingAttributes>();
        purchasedAtts = GetComponent <PurchasedAttributes>();
        baseAtts      = GetComponent <BaseAttributes>();
        actualAtts    = GetComponent <ActualAttributes>();

        baseStats           = GetComponent <BaseStats>();
        purchasedStats      = GetComponent <PurchasedStats>();
        startingStats       = GetComponent <StartingStats>();
        startingActualStats = GetComponent <StartingActualStats>();
        actualStats         = GetComponent <ActualStats>();
    }
Esempio n. 21
0
        public ItemTemplate AddBaseAttribute(StatisticsTypes type, double Value, double perLevelChange)
        {
            var statFactory = new StatisticsFactory();

            if (BaseAttributes == null)
            {
                BaseAttributes = new List <Statistics>();
            }

            if (!BaseAttributes.ContainsType(type))
            {
                BaseAttributes.Add(statFactory.CreateStatFlat(Value, perLevelChange, type));
            }

            return(this);
        }
Esempio n. 22
0
    public static Dictionary <AttributesEnum, float> CloneDict(BaseAttributes attsToClone)
    {
        Dictionary <AttributesEnum, float> dict = new Dictionary <AttributesEnum, float>();

        if (attsToClone == null)
        {
            return(dict);
        }

        foreach (AttributesEnum se in attsToClone.DictKeys)
        {
            dict.Add(se, attsToClone[se]);
        }

        return(dict);
    }
Esempio n. 23
0
        public static GeneticAttributes GetGeneticAttributes(BaseAttributes attributes, SerializableChromosome chromosome)
        {
            var effectiveAttributes = new GeneticAttributes
            {
                MaximumHealth           = CalculateMaximumHealth(attributes.Health, chromosome),
                EffectiveSpeed          = CalculateSpeed(attributes.Speed, chromosome),
                EffectivePiercingResist = CalculateResistance(attributes.PiercingResist, 0, chromosome),
                EffectiveBombardResist  = CalculateResistance(attributes.BombardResist, 1, chromosome),
                EffectiveChemicalResist = CalculateResistance(attributes.ChemicalResist, 2, chromosome),
                EffectiveFireResist     = CalculateResistance(attributes.FireResist, 3, chromosome),
                EffectiveFrostResist    = CalculateResistance(attributes.FrostResist, 4, chromosome),
                EffectiveElectricResist = CalculateResistance(attributes.ElectricResist, 5, chromosome),
                IsFlying = attributes.IsFlying,
            };

            return(effectiveAttributes);
        }
        public BaseAttrEditor()
        {
            InitializeComponent();
            selectedObject = new BaseAttributes();
            selectedObject.SetCurrentBase(this);
            this.DataContext = selectedObject;
            _propertyGrid.Update();

            for (int j = 0; j < Constants.City[HeatSourceLayoutApp.globalProperty.ProvinceId].Count; ++j)
            {
                viewCities.Add(j, Constants.City[HeatSourceLayoutApp.globalProperty.ProvinceId][j]);
            }
            //第一次初始化,更新【北京】的供暖天数等值
            //获取数据库中的CityID,如果不存在,返回一个默认值1
            ArrayList cityListInDB = DataConfig.getCustomConfig("城市列表");
            String[] cityList = (String[])cityListInDB.ToArray(typeof(String));
            String cityName = Constants.City[0][0];
            int i;
            for (i = 0; i < cityList.Length; i++)
            {
                String testCityName0 = cityList[i];
                String testCityName1 = cityList[i] + "市";
                String testCityName2 = cityList[i] + "州";
                String testCityName3 = cityList[i] + "地区";
                String testCityName4 = cityList[i] + "盟";

                if ((testCityName0 == cityName) || (testCityName1 == cityName) || (testCityName2 == cityName) || (testCityName3 == cityName) || (testCityName4 == cityName))
                {
                    HeatSourceLayoutApp.globalProperty.CityId = i;
                    break;
                }
            }
            if (i == cityList.Length)
                HeatSourceLayoutApp.globalProperty.CityId = 0;
            HeatSourceLayoutApp.globalProperty.HeatingDays = (int)double.Parse(DataConfig.getDailyTemperatureLessthanFive(HeatSourceLayoutApp.globalProperty.CityId));
            HeatSourceLayoutApp.globalProperty.OutDoorTemp = double.Parse(DataConfig.getHeatingOutsideTemperature(HeatSourceLayoutApp.globalProperty.CityId));
            try
            {
                HeatSourceLayoutApp.globalProperty.OutAverageTemp = double.Parse(DataConfig.getDailyTemperatureLessthanFiveAverageTemperature(HeatSourceLayoutApp.globalProperty.CityId));
            }
            catch (Exception e)
            {
                e.ToString();
            }
        }
Esempio n. 25
0
    /// <summary>
    /// Adds two BaseAttributes together and returns a new one.
    /// </summary>
    /// <param name="attributesA">BaseAttributes to add to.</param>
    /// <param name="attributesB">BaseAttributes to add from.</param>
    /// <returns>BaseAttributes containing the sum of attributesA and attributesB.</returns>
    public static BaseAttributes operator +(BaseAttributes attributesA, BaseAttributes attributesB)
    {
        var attributes = new BaseAttributes();

        attributes.AttackDamage       = attributesA.AttackDamage + attributesB.AttackDamage;
        attributes.AbilityDamage      = attributesA.AbilityDamage + attributesB.AbilityDamage;
        attributes.Defense            = attributesA.Defense + attributesB.Defense;
        attributes.Health             = attributesA.Health + attributesB.Health;
        attributes.HealthRegeneration = attributesA.HealthRegeneration + attributesB.HealthRegeneration;
        attributes.Energy             = attributesA.Energy + attributesB.Energy;
        attributes.EnergyRegeneration = attributesA.EnergyRegeneration + attributesB.EnergyRegeneration;
        attributes.AttackSpeed        = attributesA.AttackSpeed + attributesB.AttackSpeed;
        attributes.CriticalHitChance  = attributesA.CriticalHitChance + attributesB.CriticalHitChance;
        attributes.CriticalHitDamage  = attributesA.CriticalHitDamage + attributesB.CriticalHitDamage;
        attributes.CooldownReduction  = attributesA.CooldownReduction + attributesB.CooldownReduction;
        attributes.LifeDrain          = attributesA.LifeDrain + attributesB.LifeDrain;
        attributes.MovementSpeed      = attributesA.MovementSpeed + attributesB.MovementSpeed;

        return(attributes);
    }
Esempio n. 26
0
        public string GetAttributeNote(AttributeCode attribute)
        {
            int baseValue = 0, raceValue = 0, improvementsValue = 0;

            if (BaseAttributes.ContainsKey(attribute))
            {
                baseValue = BaseAttributes[attribute];
            }
            else if (DerivedAttributes.ContainsKey(attribute))
            {
                baseValue = DerivedAttributes[attribute];
            }
            else
            {
                throw new ArgumentOutOfRangeException("Tried to get nonexistent attribute.");
            }

            raceValue = Race.GetAttribute(attribute, Female && ApplyGender);

            return("Rasa(" + raceValue + ") + Úrovně(" + baseValue + ") + Ostatní(" + improvementsValue + ")");
        }
Esempio n. 27
0
        public int GetAttribute(AttributeCode attribute)
        {
            int baseValue = 0, raceValue, improvementsValue = 0;

            if (BaseAttributes.ContainsKey(attribute))
            {
                baseValue = BaseAttributes[attribute];
            }
            else if (DerivedAttributes.ContainsKey(attribute))
            {
                baseValue = DerivedAttributes[attribute];
            }
            else
            {
                throw new ArgumentOutOfRangeException("Tried to get nonexistent attribute.");
            }

            raceValue = Race.GetAttribute(attribute, Female && ApplyGender);

            return(baseValue + raceValue + improvementsValue);
        }
Esempio n. 28
0
    // Use this for initialization
    void Start()
    {
        UsualSpriteRenderer = GetComponent <SpriteRenderer>();
        BaseAttributes      = GetComponent <BaseAttributes>();
        UsualTexture        = UsualSpriteRenderer.sprite;
        EmpireTexture       = BaseAttributes.Empire.EmpireBanner;
        var go = Instantiate(EmptyPrefab, transform);

        go.transform.parent = transform;
        EmpireSpriteRenders = go.AddComponent <SpriteRenderer>();
        if (EmpireTexture != null)
        {
            EmpireSpriteRenders.sortingOrder = UsualSpriteRenderer.sortingOrder - 1;
            EmpireSpriteRenders.sprite       = EmpireTexture;

            EmpireSpriteRenders.enabled = true;
        }
        else
        {
            EmpireSpriteRenders.sprite = UsualTexture;
        }
    }
Esempio n. 29
0
 public void Update(List <CaracteristicViewModel> Caracs)
 {
     foreach (var item in Caracs)
     {
         if (BaseAttributes.Any(b => b.Name.ToLower() == item.Name.ToLower()))
         {
             BaseAttributes.FirstOrDefault(b => b.Name.ToLower() == item.Name.ToLower()).Setvalue(item.Score);
         }
         else if (Skills.Any(s => s.Name.ToLower() == item.Name.ToLower()))
         {
             Skills.FirstOrDefault(s => s.Name.ToLower() == item.Name.ToLower()).Setvalue(item.Score);
         }
         else if (Stats.Any(s => s.Name.ToLower() == item.Name.ToLower()))
         {
             Stats.FirstOrDefault(s => s.Name.ToLower() == item.Name.ToLower()).Setvalue(item.Score);
         }
         else if (SpendablePoints.Any(s => s.Name.ToLower() == item.Name.ToLower()))
         {
             SpendablePoints.FirstOrDefault(s => s.Name.ToLower() == item.Name.ToLower()).Setvalue(item.Score);
         }
     }
 }
Esempio n. 30
0
 //Constructor: sets up the controls given to the constructor for each player (xbox or keyboard)
 protected Character(int playerNumber, int controlsNumber, Level currentLevel, string id = "") : base(0, id)
 {
     attributes     = new BaseAttributes();
     baseattributes = new BaseAttributes();
     // load paths into the characterSFX dictionary
     characterSFX = new Dictionary <string, string>
     {
         { "ice_slide", "Assets/SFX/ice_slide" },
         { "ability_not_ready", "Assets/SFX/ability_not_ready" },
         { "switch_wrong", "Assets/SFX/switch_wrong" }
     };
     // make a new healthbar
     healthbar = new Healthbar(this);
     // initialize all the timers
     deathTimer = new Timer(10)
     {
         IsPaused = false
     };
     stepSoundTimer = new Timer(0.5F)
     {
         IsExpired = true
     };
     reviveTimer = new Timer(3);
     hitTimer    = new Timer(0.5f)
     {
         IsExpired = true
     };
     // Define speeds on ice and land
     this.iceSpeed      = new Vector2(0, 0);
     this.movementSpeed = new Vector2(4, 4);
     // Make a new AI
     AI = new BaseAI(this, 200F, currentLevel, false, 700, 1);
     this.playerNumber = playerNumber;
     controllerNumber  = playerNumber;
     ControlsInitializer(controlsNumber);
     // Generates controls for the keyboard if the character is not controlled by xbox, keyboard is only used for 2 players so as a safeguard player 3 and 4 will become AI if this is called them.
 }
Esempio n. 31
0
 public BaseEquipment()
 {
     Name       = "";
     Attributes = new BaseAttributes();
     SlotType   = ESlotType.Head;
 }
Esempio n. 32
0
 public extern static ReactElement Base(BaseAttributes properties, params ReactElementOrText[] children);