Exemplo n.º 1
0
    /// <summary>
    /// 炮弹兵请求寻路
    /// </summary>
    public static void DoRunRoadRequest(int DataID, tga.SoldierRunRoadRequest Info)
    {
        if (Info == null)
        {
            return;
        }
        UpdataLifeInfo(DataID, Info.info);
        BSsyncDTask task = new BSsyncDTask();

        task.cmd           = new BscCmd(DataID, BSCEventType.BSC_RunRoad);
        task.RemainingTime = Random.Range(0.01f, 0.1f);
        tga.SoldierRunRoadResponse sresponse = new tga.SoldierRunRoadResponse();
        sresponse.end   = Info.end;
        sresponse.start = Info.start;
        for (int i = 0; i < Info.roadlist.Count; i++)
        {
            sresponse.roadlist.Add(Info.roadlist[i]);
        }
        sresponse.time              = Info.time;
        sresponse.time.servertime   = Time.time;
        sresponse.time.Responsetime = sresponse.time.servertime + task.RemainingTime;
        task.Info = sresponse;
        m_lTask.Add(task);
    }
Exemplo n.º 2
0
    public void ServerPathInit(tga.SoldierRunRoadResponse info)
    {
        if (!Life.ServerMode)
        {
            return;
        }
        float delatime  = Time.time - info.time.Requesttime;
        float timecount = 0f;
        int   i         = 0;

        Path.ClearPath();
        bool flag = false;

#if UNITY_EDITOR_LOG
        FileLog.write(m_parent.SceneID, "ServerPathInit  " + Time.time, true);
#endif
        for (; i < info.roadlist.Count; i++)
        {
            if (!flag)
            {
                timecount += info.roadlist[i].deltaTime * 0.001f;
                if (delatime < timecount)
                {
                    flag = true;
                    Path.Path.Add(new PathData(info.roadlist[i]));
                    //Path.SetIndex(i+1);
                    //Role r = m_parent as Role;
                    //if (r.CurrentAction is GridActionCmdStand)
                    {
                        //Path.Path.Add(new PathData(info.roadlist[i]));
                        //r.CurrentAction.SetDone();
                        //Path.Path[0].deltaTime = timecount - delatime;
                    }
                }
            }
            else
            {
                Path.Path.Add(new PathData(info.roadlist[i]));
            }
        }
        if (!m_parent.islocal)
        {
            //判断首个节点是否为楼梯
            PathData Road = Path.GetPathData(PathAccess.Cur);
            if (Road != null && Road.state == RoleState.STAIR)
            {
                m_Reject      = true;
                m_DoUpatePath = false;
            }

            //获取路线上的下一个攻击位,包含当前路径点
            ErrorInfo Error             = new ErrorInfo();
            PathData  NextAttackStation = Path.GetNextAttackPosCurInPath(ref Error);
            if (NextAttackStation != null)
            {
                m_AttackStation  = NextAttackStation.Road.GridPos;
                m_NAttackStation = NextAttackStation.Road.GridPos;
            }

            Role r = m_parent as Role;
            if (r.CurrentAction is GridActionCmdStand)
            {
                Reject = false;
            }
            if (!Path.CheckHavePath())
            {
                return;
            }
        }
        //map
    }