Ejemplo n.º 1
0
    public bool Read(out string value)
    {
        if (_offset + 1 > _len)
        {
            ViDebuger.Warning("Read Fail string");
            value   = string.Empty;
            _offset = _len;
            return(false);
        }
        Int32 len = ViBitConverter.ToUInt8(_buffer, _offset);

        _offset += 1;
        if (len == 255)
        {
            if (_offset + 2 > _len)
            {
                ViDebuger.Warning("Read Fail string");
                value   = string.Empty;
                _offset = _len;
                return(false);
            }
            len      = ViBitConverter.ToUInt16(_buffer, _offset);
            _offset += 2;
        }
        value = ViBitConverter.ToString(_buffer, _offset, len);
        _Print("string", value);
        _offset += len;
        return(true);
    }
Ejemplo n.º 2
0
    public void OnUpdate(Index slot, UInt8 channel, ViIStream IS, ViEntity entity)
    {
        ViDebuger.AssertError(slot < _updateSlots.Count);
        ViReceiveDataNode data = _updateSlots[slot];

        ViDebuger.AssertError(data);
        if (OnIndexPropertyUpdate != null)
        {
            Index idx = 0;
            if (_slotToIndex.TryGetValue(slot, out idx))
            {
                ViReceiveDataInt32 dataInt32 = data as ViReceiveDataInt32;
                Int32 oldValue = dataInt32.Value;
                data.OnUpdate(channel, IS, entity);
                OnIndexPropertyUpdate(idx, dataInt32, oldValue);
            }
            else
            {
                data.OnUpdate(channel, IS, entity);
            }
        }
        else
        {
            data.OnUpdate(channel, IS, entity);
        }
    }
Ejemplo n.º 3
0
 public static void Append <TReceiveKey, TProteKey, TReceiveData, TProtoData>(this ViOStream OS, ViReceiveDataDictionary <TReceiveKey, TProteKey, TReceiveData, TProtoData> value)
     where TReceiveKey : ViReceiveDataKeyInterface, new()
     where TReceiveData : ViReceiveDataNode, new()
 {
     ViDebuger.Error("ViReceiveDataDictionarySerialize未实现代码");
     //value.Update();
 }
Ejemplo n.º 4
0
    public void PushAfter(ViRefNode2 <T> before, ViRefList2 <T> list)
    {
        if (list.Size == 0)
        {
            return;
        }
        if (before.IsAttach(list))
        {
            return;
        }
        if (before.IsAttach() == false)
        {
            return;
        }
        ViDebuger.AssertError(before._list);
        ViRefList2 <T> receiveList = before._list;
        ViRefNode2 <T> iter        = list._root._next;

        while (iter != list._root)
        {
            iter._list = receiveList;
            iter       = iter._next;
        }
        ViDebuger.AssertError(receiveList != list);
        ViRefNode2 <T> first = list._root._next;
        ViRefNode2 <T> back  = list._root._pre;
        ViRefNode2 <T> next  = before._next;

        _Link(before, first);
        _Link(back, next);
        receiveList._cnt += list.Size;
        list._Init();
    }
Ejemplo n.º 5
0
    public void Active(TAvatar avatar, ViAvatarDurationVisualInterface <TAvatar> kEffect)
    {
        if (m_kPriorityList.IsEmpty())
        {
            m_kPriorityList.PushBack(kEffect._priorityNode);
            kEffect.OnActive(avatar);
            _OnUpdated(avatar, null);
        }
        else
        {
            ViDoubleLinkNode2 <ViAvatarDurationVisualInterface <TAvatar> > iter = m_kPriorityList.GetHead();
            ViAvatarDurationVisualInterface <TAvatar> pkOldTop = iter.Data as ViAvatarDurationVisualInterface <TAvatar>;
            ViDebuger.AssertError(pkOldTop);
            while (!m_kPriorityList.IsEnd(iter))
            {
                ViAvatarDurationVisualInterface <TAvatar> pkEffect = iter.Data as ViAvatarDurationVisualInterface <TAvatar>;
                ViDebuger.AssertError(pkEffect);
                if (kEffect.Weight > pkEffect.Weight)
                {
                    break;
                }
                ViDoubleLink2 <ViAvatarDurationVisualInterface <TAvatar> > .Next(ref iter);
            }
            ViDoubleLink2 <ViAvatarDurationVisualInterface <TAvatar> > .PushBefore(iter, kEffect._priorityNode);

            if (kEffect._priorityNode == m_kPriorityList.GetHead())
            {
                pkOldTop.OnDeactive(avatar);
                kEffect.OnActive(avatar);
                _OnUpdated(avatar, pkOldTop);
            }
        }
    }
Ejemplo n.º 6
0
 public void Deactive(TAvatar avatar, ViAvatarDurationVisualInterface <TAvatar> kEffect)
 {
     if (kEffect._priorityNode.IsAttach() == false)
     {
         return;
     }
     if (m_kPriorityList.IsEmpty())
     {
         return;
     }
     if (kEffect._priorityNode == m_kPriorityList.GetHead())
     {
         kEffect._priorityNode.Detach();
         kEffect.OnDeactive(avatar);
         if (!m_kPriorityList.IsEmpty())
         {
             ViAvatarDurationVisualInterface <TAvatar> pNewTop = m_kPriorityList.GetHead().Data as ViAvatarDurationVisualInterface <TAvatar>;
             ViDebuger.AssertError(pNewTop);
             pNewTop.OnActive(avatar);
         }
         _OnUpdated(avatar, kEffect);
     }
     else
     {
         kEffect._priorityNode.Detach();
     }
 }
Ejemplo n.º 7
0
    TEntity GetNearst(Queue <TEntity> objs, ViVector3 center)
    {
        TEntity pkNearst = null;
        float   fMinDist = 100.0f;

        ViDebuger.AssertError(_deleIsInRange);
        ViDebuger.AssertError(_deleIsStateMatch);
        foreach (TEntity obj in objs)
        {
            ViDebuger.AssertError(obj);
            if (_Has(obj))
            {
                continue;
            }
            if (!_deleIsInRange(obj, center))
            {
                continue;
            }
            if (!_deleIsStateMatch(obj))
            {
                continue;
            }

            float fDist = obj.GetDistance(center);
            if (fMinDist > fDist)
            {
                fMinDist = fDist;
                pkNearst = obj;
            }
        }
        return(pkNearst);
    }
Ejemplo n.º 8
0
 public void Exec(UInt32 eventID, ViTupleInterface tuple)
 {
     ViDebuger.AssertError(_delegate);
     _asynDele = _delegate;
     _eventID  = eventID;
     _AttachAsyn();
 }
Ejemplo n.º 9
0
    //
    public void Print(ViTupleInterface tuple)
    {
        if (_type < ViDebuger.LogLevel)
        {
            return;
        }
        StringBuilder logStr = new StringBuilder(1024, 1024);
        UInt32        idx    = 0;

        for (; idx < (UInt32)Description.Length; ++idx)
        {
            logStr.Append(Description[idx]);
            Object value = tuple.Value(idx);
            if (value != null)
            {
                logStr.Append("(");
                logStr.Append(tuple.Value(idx));
                logStr.Append(")");
            }
            else
            {
                //Console.Write("(参数不足)");
            }
        }
        for (; idx < tuple.Size; ++idx)
        {
            Object value = tuple.Value(idx);
            ViDebuger.AssertError(value);
            logStr.Append("(");
            logStr.Append(tuple.Value(idx));
            logStr.Append(")");
        }
        logStr.AppendLine();
        Print(logStr.ToString(), tuple);
    }
Ejemplo n.º 10
0
    public void PushBefore(ViRefNode1 <T> after, ViRefList1 <T> list)
    {
        if (list.Size == 0)
        {
            return;
        }
        if (after.IsAttach(list))
        {
            return;
        }
        if (after.IsAttach() == false)
        {
            return;
        }
        ViDebuger.AssertError(after._list);
        ViRefList1 <T> receiveList = after._list;
        ViRefNode1 <T> iter        = list._root._next;

        while (iter != list._root)
        {
            iter._list = receiveList;
            iter       = iter._next;
        }
        ViDebuger.AssertError(receiveList != list);
        ViRefNode1 <T> first = list._root._next;
        ViRefNode1 <T> back  = list._root._pre;
        ViRefNode1 <T> pre   = after._pre;

        _Link(pre, first);
        _Link(back, after);
        receiveList._cnt += list.Size;
        list._Init();
    }
Ejemplo n.º 11
0
 //-------------------------------------------------------------------------
 void _NewStep(ViAstarStep step)
 {
     for (Int32 idx = 0; idx < step.RoundSteps.Count; ++idx)
     {
         ViAstarRoundStep roundStep = step.RoundSteps[idx];
         ViDebuger.AssertError(roundStep.node);
         ViAstarStep childStep = roundStep.node;
         if (childStep.IsClose)
         {
             continue;
         }
         float newG = roundStep.cost + step.G;
         if (childStep.IsOpen)
         {
             if (childStep.G > newG)
             {
                 childStep.G      = newG;
                 childStep.Key    = childStep.G + childStep.H;
                 childStep.Parent = step;
             }
         }
         else
         {
             childStep.G      = newG;
             childStep.H      = ViAstarStep.Distance(childStep, _destStep);
             childStep.Key    = childStep.G + childStep.H;
             childStep.Parent = step;
             _AddToOpen(childStep);
         }
     }
 }
Ejemplo n.º 12
0
#pragma warning disable 0219
    public static void Test()
    {
        ViAngle angle0 = new ViAngle(ViMathDefine.PI * 0.5f);
        ViAngle angle1 = new ViAngle(-ViMathDefine.PI);

        float fDiff          = ViAngle.Diff(angle0, angle1);          //-pi/ 2
        float fSameSignAngle = ViAngle.SameSignAngle(angle0, angle1); //- 1.5pi
        bool  bIsIn          = angle1.IsBetween(angle1, angle0);      //true

        ViAngle angle2 = new ViAngle(8.0f);
        ViAngle angle3 = new ViAngle(12.0f);

        float fDiff1          = ViAngle.Diff(angle2, angle3);
        float fSameSignAngle1 = ViAngle.SameSignAngle(angle2, angle3);
        bool  bIsIn1          = angle1.IsBetween(angle2, angle3);

        ViAngle angle4 = new ViAngle(3.0f);
        ViAngle angle5 = new ViAngle(-3.0f);
        ViAngle angle6 = new ViAngle(-3.1f);
        ViAngle angle7 = new ViAngle(1.0f);
        bool    bIsIn2 = angle6.IsBetween(angle4, angle5);

        ViDebuger.AssertError(bIsIn2 == true);
        bool bIsIn3 = angle6.IsBetween(angle5, angle4);

        ViDebuger.AssertError(bIsIn3 == false);
        bool bIsIn4 = angle7.IsBetween(angle4, angle5);

        ViDebuger.AssertError(bIsIn4 == false);
        bool bIsIn5 = angle7.IsBetween(angle5, angle4);

        ViDebuger.AssertError(bIsIn5 == true);
    }
Ejemplo n.º 13
0
 public override void OnPressed()
 {
     ViDebuger.AssertWarning(_state == State.NONE);
     _state = State.PRESSED;
     ViTimerInstance.SetTime(_allowMoveStartNode, IgnoreMovingStateTime, this.OnAllowMoveStartTime);
     ViTimerInstance.SetTime(_pressedEndNode, EnterMovingStateTime, this.OnMoveTime);
 }
Ejemplo n.º 14
0
 //
 public void Init(ViTime64 startTime, UInt32 rollSize, UInt32 span)
 {
     ViDebuger.AssertError(rollSize != 0);
     _timeListArray.Resize(rollSize);
     _span    = span;
     _timeInf = startTime;
     _timeSup = startTime + span * rollSize;
 }
Ejemplo n.º 15
0
    internal override void _AsynExec()
    {
        ViDebuger.AssertError(_asynDele);
        Callback dele = _asynDele;

        _asynDele = null;
        dele(_eventID);
    }
Ejemplo n.º 16
0
 public void _SetValue(int offset, byte[] value, int cnt)
 {
     ViDebuger.AssertError(offset + cnt < _offset && cnt <= value.Length);
     for (int i = 0; i < cnt; i++)
     {
         _buffer[offset + i] = value[i];
     }
 }
Ejemplo n.º 17
0
    static void _PushBefore(ViRefNode1 <T> after, ViRefNode1 <T> node)
    {
        ViRefNode1 <T> pre = after._pre;

        ViDebuger.AssertError(pre);
        _Link(pre, node);
        _Link(node, after);
    }
Ejemplo n.º 18
0
 public void Exec(UInt32 eventID, T0 param0)
 {
     ViDebuger.AssertError(_delegate);
     _asynDele = _delegate;
     _eventID  = eventID;
     _param0   = param0;
     _AttachAsyn();
 }
Ejemplo n.º 19
0
    //+--------------------------------------------------------------------------------------------------------------
    static void _PushAfter(ViRefNode1 <T> before, ViRefNode1 <T> node)
    {
        ViRefNode1 <T> next = before._next;

        ViDebuger.AssertError(next);
        _Link(before, node);
        _Link(node, next);
    }
Ejemplo n.º 20
0
    public override bool InArea(ViVector3 pos, float range)
    {
        ViDebuger.AssertWarning(_dirLeftAngle <= _dirRightAngle);
        float deltaX = pos.x - _center.x;
        float deltaY = pos.y - _center.y;
        float dir    = ViMath2D.GetAngle(deltaX, deltaY);

        return((ViMath2D.Length2(_center.x, _center.y, pos.x, pos.y) < (_radius2 + range * range)) && (_dirLeftAngle <= dir && dir < _dirRightAngle));
    }
Ejemplo n.º 21
0
    internal override void _OnExec()
    {
        base.Detach();
        ViDebuger.AssertError(_delegate);
        Callback tempDele = _delegate;

        _delegate = null;
        tempDele();
    }
Ejemplo n.º 22
0
 public static void Update()
 {
     while (_callbackList.IsNotEmpty())
     {
         ViFramEndCallback0 callback = _callbackList.GetHead() as ViFramEndCallback0;
         ViDebuger.AssertError(callback);
         callback._OnExec();
     }
 }
Ejemplo n.º 23
0
 public static UInt8 ToUInt8(byte[] value, int offset)
 {
     ViDebuger.AssertError(value);
     if (offset < 0 || offset + 1 > value.Length)
     {
         return((UInt8)0);
     }
     return((UInt8)value[offset + 0]);
 }
Ejemplo n.º 24
0
 //
 public void AddEntity(ViEntityID ID, ViEntity entity)
 {
     ViDebuger.AssertError(entity);
     ViDebuger.AssertError(!_entityList.ContainsKey(ID));
     _entityList[ID] = entity;
     entity.PreStart();
     entity.Start();
     entity.AftStart();
 }
Ejemplo n.º 25
0
 public void SetDir(float dir)
 {
     _dirLeftAngle  = _leftAngle + dir;
     _dirRightAngle = _rightAngle + dir;
     if (_dirLeftAngle > _dirRightAngle)
     {
         _dirRightAngle += ViMathDefine.PI_X2;
     }
     ViDebuger.AssertWarning(_leftAngle <= _rightAngle);
 }
Ejemplo n.º 26
0
    internal override void _AsynExec()
    {
        ViDebuger.AssertError(_asynDele);
        Callback dele   = _asynDele;
        T0       param0 = _param0;

        _asynDele = null;
        _param0   = default(T0);
        dele(_eventID, param0);
    }
Ejemplo n.º 27
0
    void _Fresh(TAvatar avatar, ViAvatarDurationVisualInterface <TAvatar> kEffect)
    {
        ViDebuger.AssertError(_deleGetEffectController);
        ViAvatarDurationVisualController <TAvatar> pkController = _deleGetEffectController(avatar, kEffect.Type);

        if (pkController != null)
        {
            pkController.Fresh(avatar, kEffect);
        }
    }
Ejemplo n.º 28
0
 //+----------------------------------------------------------------------------------------------------------------
 static public void Update(float deltaTime)
 {
     _tickList.BeginIterator();
     while (!_tickList.IsEnd())
     {
         ViTickNode tickNode = _tickList.CurrentNode as ViTickNode;
         ViDebuger.AssertError(tickNode);
         _tickList.Next();
         tickNode._delegate(deltaTime);
     }
 }
Ejemplo n.º 29
0
 public static void Update(ViGameUnit entity, ViRefList2 <ViStateConditionCallback> list)
 {
     list.BeginIterator();
     while (!list.IsEnd())
     {
         ViStateConditionCallback obj = list.CurrentNode.Data;
         list.Next();
         ViDebuger.AssertError(obj);
         obj._Update(entity);
     }
 }
Ejemplo n.º 30
0
 public void Invoke(UInt32 eventId, T0 param0)
 {
     _eventList.BeginIterator();
     while (!_eventList.IsEnd())
     {
         ViCallbackInterface <T0> callback = _eventList.CurrentNode.Data;
         ViDebuger.AssertError(callback);
         _eventList.Next();
         callback.Exec(eventId, param0);
     }
 }