public bool ProductionCompleted()
        {
            var result = false;

            //localiser le camp le plus proche pour envoyer l'unit
            //incrementer ce camp
            var cf = new ComponentFilter(0);
            var x  = GetParent().X;
            var y  = GetParent().Y;
            var cm = GetParent().GetLevel().GetComponentManager();
            var c  = cm.GetClosestComponent(x, y, cf);

            while (c != null)
            {
                Data d = null;
                if (m_vUnits.Count > 0)
                {
                    d = m_vUnits[0].Data;
                }
                if (!((UnitStorageComponent)c).CanAddUnit((CombatItemData)d))
                {
                    //Storage camp is full
                    cf.AddIgnoreObject(c.GetParent());
                    c = cm.GetClosestComponent(x, y, cf);
                }
                else
                {
                    break;
                }
            }

            if (c != null)
            {
                var cd = (CombatItemData)m_vUnits[0].Data;
                ((UnitStorageComponent)c).AddUnit(cd);
                StartProducingNextUnit();
                result = true;
            }
            else
            {
                m_vIsWaitingForSpace = true;
            }
            return(result);
        }
Esempio n. 2
0
        public bool ProductionCompleted()
        {
            var result = false;
            var cf     = new ComponentFilter(0);
            var x      = GetParent().X;
            var y      = GetParent().Y;
            var cm     = GetParent().Avatar.GetComponentManager();
            var c      = cm.GetClosestComponent(x, y, cf);

            while (c != null)
            {
                Data d = null;
                if (m_vUnits.Count > 0)
                {
                    d = m_vUnits[0].Data;
                }
                if (!((UnitStorageComponent)c).CanAddUnit((CombatItemData)d))
                {
                    cf.AddIgnoreObject(c.GetParent());
                    c = cm.GetClosestComponent(x, y, cf);
                }
                else
                {
                    break;
                }
            }

            if (c != null)
            {
                var cd = (CombatItemData)m_vUnits[0].Data;
                ((UnitStorageComponent)c).AddUnit(cd);
                StartProducingNextUnit();
                result = true;
            }
            else
            {
                m_vIsWaitingForSpace = true;
            }
            return(result);
        }
        public bool ProductionCompleted()
        {
            bool result = false;
            //localiser le camp le plus proche pour envoyer l'unit
            //incrementer ce camp
            ComponentFilter cf = new ComponentFilter(0);
            int x = GetParent().X;
            int y = GetParent().Y;
            ComponentManager cm = GetParent().GetLevel().GetComponentManager();
            Component c = cm.GetClosestComponent(x, y, cf);

            while (c != null)
            {
                Data d = null;
                if (m_vUnits.Count > 0)
                    d = m_vUnits[0].Data;
                if (!((UnitStorageComponent)c).CanAddUnit((CombatItemData)d))
                {
                    //Storage camp is full
                    cf.AddIgnoreObject(c.GetParent());
                    c = cm.GetClosestComponent(x, y, cf);
                }
                else
                    break;
            }

            if(c != null)
            {
                var cd = (CombatItemData)m_vUnits[0].Data;
                ((UnitStorageComponent)c).AddUnit(cd);
                StartProducingNextUnit();             
                result = true;
            }
            else
            {
                m_vIsWaitingForSpace = true;
            }
            return result;
        }