public ITrait GetTraitByName(string name) { ITrait t = null; m_allTraits.TryGetValue(name, out t); return(t); }
private void Adjustment(ITrait thisTrait, ITrait thatTrait, ref int adjustment) { var key = new KeyValuePair <int, int>(thisTrait.GetHashCode(), thatTrait.GetHashCode()); int adj = 0; m_tableTraitRelationshipAdjustment.TryGetValue(key, out adj); adjustment += adj; }
void ITraitCollection.RemoveTrait(ITrait value) { if (value == null) { return; } RemoveTrait(value.Id); }
public static void SetAttackStrength(IStatsCollection statsCollection, int quantity) { ITrait trait = statsCollection.GetStat(attackStrengthTraitId); if (trait != null) { trait.Quantity = quantity; } }
public static void SetSize(IStatsCollection statsCollection, int quantity) { ITrait trait = statsCollection.GetStat(sizeTraitId); if (trait != null) { trait.Quantity = quantity; } }
public static int GetDefenseStrength(IStatsCollection statsCollection) { ITrait trait = statsCollection.GetStat(defenseStrengthTraitId); if (trait == null) { return(defaultDefenseStrength); } return(Mathf.Clamp(trait.Quantity, minDefenseStrength, maxDefenseStrength)); }
public static int GetMoveRadius(IStatsCollection statsCollection) { ITrait trait = statsCollection.GetStat(moveRadiusTraitId); if (trait == null) { return(0); } return(trait.Quantity); }
static float GetSpeed(IStatsCollection statsCollection) { ITrait trait = statsCollection.GetStat(speedTraitId); if (trait == null) { return(defaultSpeed); } return(Mathf.Clamp(trait.Quantity * 1.0f, minSpeed, maxSpeed)); }
protected void AddTraits(CharacterInformation characterInformation, ITrait trait) { foreach (ITrait characterTrait in characterInformation.Traits) { if (trait.Title == characterTrait.Title) return; } characterInformation.Traits.Add(trait); }
public static int GetSize(IStatsCollection statsCollection) { ITrait trait = statsCollection.GetStat(sizeTraitId); if (trait == null) { return(0); } return(trait.Quantity); }
void RemoveTrait(string id) { ITrait trait = GetTrait(id); bool hasTrait = trait != null; if (hasTrait) { Collection.Remove(trait); } }
private bool RunSimpleTestSingleMajorHero() { TraitManager traitManager = CreateTraitManager(); ITrait fire = traitManager.GetTraitByName("fire"); ITrait water = traitManager.GetTraitByName("water"); ITrait earth = traitManager.GetTraitByName("earth"); ITrait air = traitManager.GetTraitByName("air"); MonsterMatcher matcher = new MonsterMatcher(2, new Random(1), traitManager); IEntityManager entityMgr = (IEntityManager)matcher; entityMgr.Add(new EntityTemplate(new EntityFaction(EntityFaction.FactionKind.Hero), new EntityRating(1, new List <ITrait>() { }))); entityMgr.Add(new EntityTemplate(new EntityFaction(EntityFaction.FactionKind.Monster), new EntityRating(1, new List <ITrait>() { water, fire }))); entityMgr.Add(new EntityTemplate(new EntityFaction(EntityFaction.FactionKind.Monster), new EntityRating(2, new List <ITrait>() { air }))); entityMgr.Add(new EntityTemplate(new EntityFaction(EntityFaction.FactionKind.Monster), new EntityRating(3, new List <ITrait>() { water }))); entityMgr.Add(new EntityTemplate(new EntityFaction(EntityFaction.FactionKind.Monster), new EntityRating(4, new List <ITrait>() { fire }))); entityMgr.Add(new EntityTemplate(new EntityFaction(EntityFaction.FactionKind.Monster), new EntityRating(5, new List <ITrait>() { earth, fire }))); entityMgr.Add(new EntityTemplate(new EntityFaction(EntityFaction.FactionKind.Monster), new EntityRating(6, new List <ITrait>() { water, water }))); entityMgr.Add(new EntityTemplate(new EntityFaction(EntityFaction.FactionKind.Monster), new EntityRating(7, new List <ITrait>() { air, fire }))); var hero = new EntityTemplate(new EntityFaction(EntityFaction.FactionKind.Hero), new EntityRating(10, new List <ITrait>() { water })); IEnemyGroupMaker maker = (IEnemyGroupMaker)matcher; var group = maker.MakeEnemyGroup(hero); return(group.Count > 0); }
public void Bind(object manager, LinkData data) { this.data = data; this.data.container = this; this.trait = GetTrait(data.node); this.trait.Bind(this); this.data.node.transform.SetParent(content.transform, false); // @todo wait add more animtion effect when switch window }
public IEnumerable <FrameworkElement> CreatePrintView(ITrait trait) { var grid = CreateGrid(string.IsNullOrWhiteSpace(trait.Description) ? 2 : 3); var name = CreateObjectName(trait.Name + " (" + trait.Ring.ToString() + ")"); Grid.SetRow(name, 0); grid.Children.Add(name); string skills = string.Join(", ", trait.SkillGroups.Select(s => s.ToString())); string spheres = string.Join(", ", trait.Spheres.Select(s => s.ToString())); var types = new TextBlock { TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 3, 0, 0) }; types.Inlines.Add(new Run("Types: ") { FontWeight = FontWeights.Bold }); types.Inlines.Add(skills); if (!string.IsNullOrEmpty(skills) && !string.IsNullOrEmpty(spheres)) { types.Inlines.Add("; "); } types.Inlines.Add(new Run(spheres) { FontStyle = FontStyles.Italic }); Grid.SetRow(types, 1); grid.Children.Add(types); if (!string.IsNullOrWhiteSpace(trait.Description)) { var description = new TextBlock { Text = trait.Description.Trim(), TextWrapping = TextWrapping.Wrap, TextAlignment = TextAlignment.Justify, Margin = new Thickness(0, 4, 0, 0) }; Grid.SetRow(description, 2); grid.Children.Add(description); } DoMeasure(grid); return(new List <FrameworkElement> { grid }); }
/// <summary> /// Creates a clone of the agent at a bigger size and destroys the original. /// </summary> void IMoltable.Molt() { ITrait sizeTrait = (Agent as IStatsCollection).GetStat(TraitsUtil.sizeTraitId); int size = sizeTrait != null ? sizeTrait.Quantity : 0; // If the size is less than one, then simply destroy the agent without molting. if (size < 1) { GameObject.Destroy(AgentGameObject); return; } int newSize = (int)(size * moltPercentage); newSize = Mathf.Max(newSize, size + 1); sizeTrait.Quantity = newSize; Vector3 scale = AgentTransform.localScale; scale *= moltPercentage; Vector3 position = Agent.Position; int health = TraitsUtil.GetHealth(Agent) + 1; Agent.RemoveFromMap(); GameObject instance = spawnable.Spawn(position, scale); IAgent instanceAgent = instance.GetComponentInChildren <IAgent>(); if (instanceAgent != null) { instanceAgent.Data = Agent.Data.Copy(); instanceAgent.DisplayName = Agent.DisplayName; instanceAgent.Description = ""; instanceAgent.GroupId = Agent.GroupId; TraitsUtil.SetHealth(instanceAgent, health); } Tweener tweener = instance.GetComponentInChildren <Tweener>(); if (tweener != null) { tweener.TweenOnStart = TweenerMethod.None; } GameObject.Destroy(AgentGameObject); }
void InitData() { if (data == null) { if (trait == null) { data = new NullTrait(); } else { data = trait; } } }
void ITraitCollection.AddTrait(ITrait value) { if (value == null) { return; } ITrait trait = GetTrait(value.Id); bool hasTrait = trait != null; if (hasTrait == false) { Collection.Add(trait); } }
public void RegisterTraitRelation(ITrait thisTrait, ITrait thatTrait, int effect) { if (!m_allTraits.ContainsKey(thisTrait.ToString())) { m_allTraits.Add(thisTrait.ToString(), thisTrait); } if (!m_allTraits.ContainsKey(thatTrait.ToString())) { m_allTraits.Add(thatTrait.ToString(), thatTrait); } var key = new KeyValuePair <int, int>(thisTrait.GetHashCode(), thatTrait.GetHashCode()); m_tableTraitRelationshipAdjustment.Add(key, effect); }
void ITraitCollection.RemoveTrait(ITrait trait) => Traits.RemoveTrait(trait);
void ITraitCollection.AddTrait(ITrait trait) => Traits.AddTrait(trait);
public static void Swim(this ITrait <CanSwim> trait) { Console.WriteLine("Swim"); }
void ITraitCollection.AddTrait(ITrait trait) => Advertisement.AddTrait(trait);
private bool AddTrait(CharacterObject character, ITrait traitSet) { return(true); }
public static bool isMultiplayer(ITrait <MultiPlayer> game) { return(true); }
public bool Matches(ITrait trait) { Trait other = (Trait)trait; return(other.Name == Name); }
public static void Walk(this ITrait <CanWalk> trait) { Console.WriteLine("Walk"); }
public void AddTrait(ITrait t) { traits.Add(t); }
private void ApplySetData(ITrait <T> aTrait, T aT) { _data = aT; }
public static int GetNumber(this ITrait trait, int i) { return(i + 1); }
void ITraitCollection.RemoveTrait(ITrait trait) => Advertisement.RemoveTrait(trait);