Ejemplo n.º 1
0
    public void AddResourceToHanger(int hangarID, int type, int qte)
    {
        Hangar h = _container._hangars[hangarID];

        ResourceStack stack = null;

        foreach (int id in h.StacksIDs)
        {
            ResourceStack tmp = _container._resourceStacks[id];
            if (tmp.Type == type)
            {
                stack = tmp;
                break;
            }
        }
        if (null == stack)
        {
            stack        = new ResourceStack(_container._resourceStackIDs++);
            stack.Qte    = 0;
            stack.Type   = type;
            stack.Loaded = true;
            _container._resourceStacks.Add(stack.ID, stack);
            h.StacksIDs.Add(stack.ID);
        }

        stack.Qte += qte;

        ServerUpdate update = new ServerUpdate();

        update.stacks.Add(stack);
        update.hangars.Add(h);
        _manager.SendServerUpdate(update);
    }
    public void UpdateOneFrame()
    {
        int frame = _manager.Frame;

        List <Fleet> copy = new List <Fleet>(_container._fleets.Values);


        foreach (Fleet f in copy)
        {
            _currentUpdate = new ServerUpdate();

            if (!_nextChange.ContainsKey(f.ID) || _nextChange[f.ID] <= _container._currentFrame)
            {
                if (!_nextChange.ContainsKey(f.ID))
                {
                    _nextChange.Add(f.ID, 0);
                }
                _nextChange[f.ID] = UpdateFlee(f);
            }
            _manager.SendServerUpdate(_currentUpdate);
            _currentUpdate = null;
        }
    }