Exemplo n.º 1
0
        public bool NetEnd(Node node, int tag)
        {
            Point  ptNet        = new Point();
            Point  ptTNet       = new Point();
            Point  ptFish       = new Point();
            Size   szFish       = new Size();
            Point  ptDifference = new Point();
            Rect   rcScreen     = new Rect(0, 0, 1280, 738);
            double sint;
            double cost;


            CGameScene       pGameScene       = (CGameScene)parent();
            CNetObjectExtend pNetObjectExtend = (CNetObjectExtend)node.node_extend();

            if (pNetObjectExtend.wChairID == pGameScene.GetMeChairID())
            {
                CMD_C_Cast_Net CastNet = new CMD_C_Cast_Net();
                CastNet.wChairID = pNetObjectExtend.wChairID;
                CastNet.cbCount  = 0;

                ptNet = node.position();

                foreach (Node j in pGameScene.m_layFishObject.childs())
                {
                    if (CastNet.cbCount >= FishDefine.MAX_FISH_IN_NET)
                    {
                        break;
                    }

                    CFishObjectExtend pFishObjectExtend = (CFishObjectExtend)j.node_extend();

                    if (pFishObjectExtend.wID == FishDefine.INVALID_WORD)
                    {
                        continue;
                    }

                    ptFish = j.position();
                    szFish = pFishObjectExtend.GetFishObjectSize();

                    cost      = Math.Cos(j.rotation());
                    sint      = Math.Sin(j.rotation());
                    ptTNet.x_ = (ptNet.x_ - ptFish.x_) * cost + (ptNet.y_ - ptFish.y_) * sint;
                    ptTNet.y_ = -(ptNet.x_ - ptFish.x_) * sint + (ptNet.y_ - ptFish.y_) * cost;

                    if (CFishObjectExtend.ComputeCollision(szFish.width_, szFish.height_, pNetObjectExtend.GetNetRadius(), ptTNet.x_, ptTNet.y_))
                    {
                        CastNet.FishNetObjects[CastNet.cbCount].wID      = pFishObjectExtend.wID;
                        CastNet.FishNetObjects[CastNet.cbCount].wRoundID = pFishObjectExtend.wRoundID;
                        CastNet.FishNetObjects[CastNet.cbCount].wType    = (int)pFishObjectExtend.FishType;
                        CastNet.FishNetObjects[CastNet.cbCount].dwTime   = pNetObjectExtend.dwMulRate; //时间没用上,占时存放倍数

                        CastNet.cbCount++;
                    }
                }

                CClientKernel pClientKernel = pGameScene.GetClientKernel();

                if ((pClientKernel != null) && (pNetObjectExtend.dwMulRate <= 1000))
                {
                    pClientKernel.SendSocketData(FishDefine.SUB_C_CAST_NET, CastNet);
                }
            }

            remove_child(node);

            return(true);
        }
Exemplo n.º 2
0
        //C++ TO C# CONVERTER TODO TASK: The implementation of the following method could not be found:
        //	CBulletLayer();
        //C++ TO C# CONVERTER TODO TASK: The implementation of the following method could not be found:
        //	public void Dispose();

        public override void update(double dt)
        {
            base.update(dt);

            CGameScene pGameScene = (CGameScene)parent();



            Point  ptBullet  = new Point();
            Point  ptTBullet = new Point();
            Point  ptFish    = new Point();
            Size   szFish    = new Size();
            double sint;
            double cost;
            Rect   rcScreen = new Rect(0, 0, 1280, 738);

            foreach (Node i in childs_)
            {
                CBulletObjectExtend pBulletObjectExtend = (CBulletObjectExtend)i.node_extend();

                UserInfo pUserData = null;
                if (pGameScene.GetClientKernel() != null)
                {
                    pUserData = pGameScene.GetClientKernel().GetUserInfo(pBulletObjectExtend.wChairID);
                }

                ptBullet = i.position();
                if (!rcScreen.pt_in_rect(ptBullet))
                {
                    if (pUserData != null)
                    {
                        if ((pBulletObjectExtend.nBackCount < 1000) && (GetBulletCount() < 51))
                        {
                            if ((pBulletObjectExtend.wChairID < GameDefine.GAME_PLAYER) && (pBulletObjectExtend.wChairID >= 0))
                            {
                                tagBulletBack tBulletBack = new tagBulletBack();

                                tBulletBack.ptStart = ptBullet;

                                if (tBulletBack.ptStart.x_ < 0)
                                {
                                    tBulletBack.ptStart.x_ = 0;
                                }
                                else if (tBulletBack.ptStart.x_ > 1280)
                                {
                                    tBulletBack.ptStart.x_ = 1280;
                                }

                                if (tBulletBack.ptStart.y_ < 0)
                                {
                                    tBulletBack.ptStart.y_ = 0;
                                }
                                else if (tBulletBack.ptStart.y_ > 738)
                                {
                                    tBulletBack.ptStart.y_ = 738;
                                }

                                tBulletBack.wChair     = pBulletObjectExtend.wChairID;
                                tBulletBack.nBackCount = pBulletObjectExtend.nBackCount + 1;
                                tBulletBack.fRotation  = pBulletObjectExtend.fRotation;
                                tBulletBack.dwMulRate  = pBulletObjectExtend.dwMulRate;
                                tBulletBack.wType      = (int)pBulletObjectExtend.CannonType;

                                m_BulletBackList.Add(tBulletBack);
                            }
                        }
                    }

                    m_NodeDelete.Add(i);

                    continue;
                }

                foreach (Node j in pGameScene.m_layFishObject.childs())
                {
                    CFishObjectExtend pFishObjectExtend = (CFishObjectExtend)j.node_extend();
                    if (pFishObjectExtend.wID == FishDefine.INVALID_WORD)
                    {
                        continue;
                    }

                    ptFish = j.position();
                    szFish = pFishObjectExtend.GetFishObjectSize();

                    cost         = Math.Cos(j.rotation());
                    sint         = Math.Sin(j.rotation());
                    ptTBullet.x_ = (ptBullet.x_ - ptFish.x_) * cost + (ptBullet.y_ - ptFish.y_) * sint;
                    ptTBullet.y_ = -(ptBullet.x_ - ptFish.x_) * sint + (ptBullet.y_ - ptFish.y_) * cost;

                    if (CFishObjectExtend.ComputeCollision(szFish.width_, szFish.height_, 10, ptTBullet.x_, ptTBullet.y_))
                    {
                        pGameScene.m_layNetObject.NetFire(ptBullet, pBulletObjectExtend.wChairID, pBulletObjectExtend.CannonType, pBulletObjectExtend.dwMulRate);
                        m_NodeDelete.Add((i));
                        break;
                    }
                }
            }

            List <Node> .Enumerator k = m_NodeDelete.GetEnumerator();
            while (k.MoveNext())
            {
                remove_child((k.Current));
                //delete(k.Current).node_extend();
                //delete(k.Current);
            }

            m_NodeDelete.Clear();

            if (m_BulletBackList.Count() > 0)
            {
                List <tagBulletBack> .Enumerator it;
                foreach (tagBulletBack its in m_BulletBackList)
                {
                    double fRotation = (its.ptStart.x_ >= 1280) ? -its.fRotation : (its.ptStart.y_ <= 0) ? -its.fRotation + Math.PI : (its.ptStart.y_ >= 738) ? -its.fRotation + Math.PI : -its.fRotation;
                    BulletFireBack(its.ptStart, fRotation, its.wChair, (FishDefine.enCannonType)its.wType, its.nBackCount, its.dwMulRate);
                }
            }

            m_BulletBackList.Clear();
        }