/// <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(); }
public void RemoveAttributes(List <GameAttribute> attributes) { foreach (GameAttribute ga in attributes) { BaseAttributes.Remove(ga); } }
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); }
//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); }
public Creature(Creature other) : base(other) { BaseAttributes = other.BaseAttributes.Clone(); ModifiedAttributes = BaseAttributes.Clone(); _usedAttacksOfOpportunity = 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); } }
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(); }
/// <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"; }
public override void WriteAttributesXML(XmlWriter xmlWriter) { xmlWriter.WriteStartElement("BaseAttributes"); BaseAttributes.WriteXML(xmlWriter); xmlWriter.WriteEndElement(); xmlWriter.WriteStartElement("ModifiedAttributes"); ModifiedAttributes.WriteXML(xmlWriter); xmlWriter.WriteEndElement(); }
public void Subtract(BaseAttributes toSub) { if (toSub == null) { return; } foreach (AttributesEnum ae in toSub.DictKeys) { this[ae] -= toSub[ae]; } }
public void Add(BaseAttributes toAdd) { if (toAdd == null) { return; } foreach (AttributesEnum ae in toAdd.DictKeys) { this[ae] += toAdd[ae]; } }
//初始化属性 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; }
/// <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); }
public int GetAttributeStartingMin(AttributeCode attribute) { if (!BaseAttributes.ContainsKey(attribute)) { throw new ArgumentOutOfRangeException("Tried to get nonexistent attribute."); } if (IsMainAttribute(attribute)) { return(1); } return(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(); } }
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>(); }
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); }
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); }
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(); } }
/// <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); }
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 + ")"); }
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); }
// 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; } }
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); } } }
//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. }
public BaseEquipment() { Name = ""; Attributes = new BaseAttributes(); SlotType = ESlotType.Head; }
public extern static ReactElement Base(BaseAttributes properties, params ReactElementOrText[] children);