예제 #1
0
        public virtual void AddUnit(FormationType formationType, ushort type, ushort count)
        {
            if (count <= 0)
            {
                return;
            }

            IFormation formation;

            if (!Data.TryGetValue(formationType, out formation))
            {
                formation = new Formation(formationType);
                Data.Add(formationType, formation);
            }

            formation.Add(type, count);
        }
예제 #2
0
        public bool AddFormation(FormationType type)
        {
            lock (objLock)
            {
                CheckUpdateMode();
                if (Data.ContainsKey(type))
                {
                    return(false);
                }
                var formation = new Formation(type);
                formation.OnUnitUpdated += FormationOnUnitUpdated;
                Data.Add(type, formation);

                FireUnitUpdated();
            }

            return(true);
        }
예제 #3
0
        public void Add(ISimpleStub stub)
        {
            lock (objLock)
            {
                CheckUpdateMode();

                foreach (IFormation stubFormation in stub)
                {
                    IFormation targetFormation;
                    if (!Data.TryGetValue(stubFormation.Type, out targetFormation))
                    {
                        targetFormation = new Formation(stubFormation.Type);
                        targetFormation.OnUnitUpdated += FormationOnUnitUpdated;
                        Data.Add(stubFormation.Type, targetFormation);
                    }

                    targetFormation.Add(stubFormation);
                }

                FireUnitUpdated();
            }
        }