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;
            }
Ejemplo n.º 3
0
 void ITraitCollection.RemoveTrait(ITrait value)
 {
     if (value == null)
     {
         return;
     }
     RemoveTrait(value.Id);
 }
Ejemplo n.º 4
0
        public static void SetAttackStrength(IStatsCollection statsCollection, int quantity)
        {
            ITrait trait = statsCollection.GetStat(attackStrengthTraitId);

            if (trait != null)
            {
                trait.Quantity = quantity;
            }
        }
Ejemplo n.º 5
0
        public static void SetSize(IStatsCollection statsCollection, int quantity)
        {
            ITrait trait = statsCollection.GetStat(sizeTraitId);

            if (trait != null)
            {
                trait.Quantity = quantity;
            }
        }
Ejemplo n.º 6
0
        public static int GetDefenseStrength(IStatsCollection statsCollection)
        {
            ITrait trait = statsCollection.GetStat(defenseStrengthTraitId);

            if (trait == null)
            {
                return(defaultDefenseStrength);
            }
            return(Mathf.Clamp(trait.Quantity, minDefenseStrength, maxDefenseStrength));
        }
Ejemplo n.º 7
0
        public static int GetMoveRadius(IStatsCollection statsCollection)
        {
            ITrait trait = statsCollection.GetStat(moveRadiusTraitId);

            if (trait == null)
            {
                return(0);
            }
            return(trait.Quantity);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 10
0
        public static int GetSize(IStatsCollection statsCollection)
        {
            ITrait trait = statsCollection.GetStat(sizeTraitId);

            if (trait == null)
            {
                return(0);
            }
            return(trait.Quantity);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 13
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
        }
Ejemplo n.º 14
0
        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
            });
        }
Ejemplo n.º 15
0
        /// <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);
        }
Ejemplo n.º 16
0
 void InitData()
 {
     if (data == null)
     {
         if (trait == null)
         {
             data = new NullTrait();
         }
         else
         {
             data = trait;
         }
     }
 }
Ejemplo n.º 17
0
        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);
            }
Ejemplo n.º 19
0
 void ITraitCollection.RemoveTrait(ITrait trait) => Traits.RemoveTrait(trait);
Ejemplo n.º 20
0
 void ITraitCollection.AddTrait(ITrait trait) => Traits.AddTrait(trait);
Ejemplo n.º 21
0
 public static void Swim(this ITrait <CanSwim> trait)
 {
     Console.WriteLine("Swim");
 }
Ejemplo n.º 22
0
 void ITraitCollection.AddTrait(ITrait trait) => Advertisement.AddTrait(trait);
Ejemplo n.º 23
0
 private bool AddTrait(CharacterObject character, ITrait traitSet)
 {
     return(true);
 }
Ejemplo n.º 24
0
 public static bool isMultiplayer(ITrait <MultiPlayer> game)
 {
     return(true);
 }
            public bool Matches(ITrait trait)
            {
                Trait other = (Trait)trait;

                return(other.Name == Name);
            }
Ejemplo n.º 26
0
 public static void Walk(this ITrait <CanWalk> trait)
 {
     Console.WriteLine("Walk");
 }
Ejemplo n.º 27
0
 public void AddTrait(ITrait t)
 {
     traits.Add(t);
 }
Ejemplo n.º 28
0
 private void ApplySetData(ITrait <T> aTrait, T aT)
 {
     _data = aT;
 }
Ejemplo n.º 29
0
 public static int GetNumber(this ITrait trait, int i)
 {
     return(i + 1);
 }
Ejemplo n.º 30
0
 void ITraitCollection.RemoveTrait(ITrait trait) => Advertisement.RemoveTrait(trait);