コード例 #1
0
ファイル: SceneBulletMgr.cs プロジェクト: profiles/Fish
    public void SendCheckPos()
    {
        if (++SendInterval < 60 * 6)
        {
            return;
        }
        SendInterval = 0;

        NetCmdCheckBulletPos pp = new NetCmdCheckBulletPos();

        pp.SetCmdType(NetCmdType.CMD_CHECK_BULLET_POS);
        List <CheckBulletPos> pl = new List <CheckBulletPos>();

        for (int i = 0; i < m_PlayerBullets.Length; ++i)
        {
            PlayerBullets pb = m_PlayerBullets[i];
            foreach (Bullet bullet in pb.BulletList.Values)
            {
                CheckBulletPos bb = new CheckBulletPos();
                bb.Pos = new NetCmdVector3(bullet.Position.x, bullet.Position.y, bullet.Position.z);
                bb.ID  = bullet.ServerID;
                pl.Add(bb);
            }
        }
        pp.Count   = (ushort)pl.Count;
        pp.Bullets = pl.ToArray();
        SceneRuntime.Send <NetCmdCheckBulletPos>(pp);
    }
コード例 #2
0
    public void CheckFishPos()
    {
        if (m_FishNum == 0 || ++SendInterval < 120)
        {
            return;
        }
        SendInterval = 0;

        List <CheckFishPos> list = new List <CheckFishPos>();

        foreach (Fish fish in m_FishList.Values)
        {
            if (fish.Delay)
            {
                continue;
            }
            CheckFishPos ncf = new CheckFishPos();
            ncf.FishID = fish.FishID;
            ncf.Time   = fish.Time;
            ncf.Pos    = Utility.ToNetCmdVec3(fish.Position);
            ncf.Rot    = Utility.ToNetCmdVec4(fish.Rotation);
            ncf.Speed  = fish.Speed;
            list.Add(ncf);

            if (list.Count > 50)
            {
                NetCmdCheckFishPos cmd = new NetCmdCheckFishPos();
                cmd.Fish    = list.ToArray();
                cmd.FishNum = (ushort)cmd.Fish.Length;
                cmd.SetCmdType(NetCmdType.CMD_CHECK_FISH_POS);
                SceneRuntime.Send <NetCmdCheckFishPos>(cmd);
                list.Clear();
            }
        }
        {
            NetCmdCheckFishPos cmd = new NetCmdCheckFishPos();
            cmd.Fish    = list.ToArray();
            cmd.FishNum = (ushort)cmd.Fish.Length;
            cmd.SetCmdType(NetCmdType.CMD_CHECK_FISH_POS);
            SceneRuntime.Send <NetCmdCheckFishPos>(cmd);
        }
    }