Пример #1
0
 /// <summary>
 /// search for a parameter
 /// </summary>
 /// <param name="name">the name of this parameter</param>
 /// <returns>found parameter</returns>
 private IValueWrapper getParameter(string name)
 {
     if (Parameter.ContainsKey(name))
     {
         return(Parameter[name]);
     }
     return(BasePrototype?.getParameter(name));
 }
Пример #2
0
 public MainConfig()
 {
     PlayerUnit  = new UnitPrototype();
     EnemyUnit   = new UnitPrototype();
     EnemyBase   = new BasePrototype();
     PlayerBase  = new BasePrototype();
     NeutralBase = new BasePrototype();
     PlayerTower = new TowerPrototype();
     EnemyTower  = new TowerPrototype();
 }
Пример #3
0
 /// <summary>
 /// Search a single animation of this or base elements by its name
 /// </summary>
 /// <param name="name">the name of the animation</param>
 /// <returns>The Animation or null if not found</returns>
 public Physic.AnimationGroup GetAnimation(string name)
 {
     foreach (var ag in Animations)
     {
         if (ag.Name == name)
         {
             return(ag);
         }
     }
     return(BasePrototype?.GetAnimation(name));
 }
Пример #4
0
        /// <summary>
        /// flatten this prototype
        /// </summary>
        /// <param name="flat">target of informations</param>
        /// <param name="helper">information that helps this flattening</param>
        private void Flatten(FlatPrototype flat, PrototypeFlattenerHelper helper)
        {
            if (BasePrototype != null)
            {
                BasePrototype.Flatten(flat, helper);
            }
            flat.Container.AddRange(Container.ConvertAll((p) =>
            {
                var h = new PrototypeFlattenerHelper();
                var f = p.Flatten(h);
                helper.Import(h);
                return(f);
            }));
            foreach (var p in flat.Parameter.ToArray())
            {
                if (Parameter.ContainsKey(p.Key))
                {
                    var par     = p.Value;
                    var current = Parameter[p.Key];
                    var newPar  = current.Clone();
                    helper.Conversion[par]     = newPar;
                    helper.Conversion[current] = newPar;
                    flat.Parameter[p.Key]      = newPar;
                }
            }
            foreach (var p in Parameter)
            {
                if (!flat.Parameter.ContainsKey(p.Key))
                {
                    var par = p.Value.Clone();
                    helper.Conversion[p.Value] = par;
                    flat.Parameter[p.Key]      = par;
                }
            }
            foreach (var a in Animations)
            {
                var anim = a.Clone();
                helper.Animations[a] = anim;
                flat.Animations.Add(anim);
            }
            MoveTargets(helper, flat);


            if (RenderName != null)
            {
                flat.RenderName = RenderName;
            }
        }
Пример #5
0
        /// <summary>
        /// Find a single Element in its container or its base prototype containers by
        /// its given name
        /// </summary>
        /// <param name="name">the name of the object</param>
        /// <returns>The found object or null if not found</returns>
        public PrototypeBase GetElement(string name)
        {
            if (Name == name)
            {
                return(this);
            }
            PrototypeBase result;

            foreach (var pb in Container)
            {
                if ((result = pb.GetElement(name)) != null)
                {
                    return(result);
                }
            }
            return(BasePrototype?.GetElement(name));
        }
Пример #6
0
        /// <summary>
        /// Search a single Parameter in this or base elements by its name
        /// </summary>
        /// <param name="name">the name of the parameter</param>
        /// <returns>The Parameter or null if not found</returns>
        public IValueWrapper GetParameter(string name)
        {
            var par = GetOwnParameter(name);

            if (par != null)
            {
                return(par);
            }
            par = BasePrototype?.getParameter(name);
            if (par != null)
            {
                return(Parameter[name] = par.Clone());
            }
            else
            {
                return(par);
            }
        }
Пример #7
0
        private void CreateFromPrototype()
        {
            BasePrototype proto = SaveDataManager.instance.GetBasePrototype(side);

            if (proto != null)
            {
                maxHP        = proto.maxHP;
                currentHP    = maxHP;
                spawnRate    = proto.SpawnRate;
                ProduceRate  = proto.ProduceUnitRate;
                MaxCountUnit = proto.MaxUnit;

                attack.damage       = proto.Damage;
                attack.damageRate   = proto.DamageRate;
                attack.attackRadius = proto.AttackRadius;
                CurrentCountUnit    = proto.StartCountUnit;
            }
            UpdateHP();
        }