상속: MonoBehaviour
예제 #1
0
    // 处理子弹同步
    public void RecvShooting(GameMessage message)
    {
        ShootInfo shootInfo = ProtoTransfer.Deserialize <ShootInfo>(message.data);
        //解析协议
        string id = shootInfo.id;

        Vector3 pos;
        Vector3 rot;

        pos.x = shootInfo.posX;
        pos.y = shootInfo.posY;
        pos.z = shootInfo.posZ;

        rot.x = shootInfo.rotateX;
        rot.y = shootInfo.rotateY;
        rot.z = shootInfo.rotateZ;

        //处理
        if (!unitDic.ContainsKey(id))
        {
            Debug.Log("RecvShooting bt == null");
            return;
        }
        BattleUnit bu = unitDic[id];

        if (id == GameMgr._instance.id)
        {
            return;
        }
        bu.player.weapon.NetShoot(pos, rot);
    }
예제 #2
0
 public void Init(ShootInfo _info, int index)
 {
     info     = _info;
     ownIndex = index;
     DoAnimation();
     //
     isDestroy = false;
 }
 public DamageInfo(ShootInfo info, Projectile projectile)
 {
     dmg          = info.dmg;;
     hitDir       = projectile.transform.forward;
     hitPoint     = projectile.transform.position;
     hitForce     = info.hitForce;
     sender       = info.sender;
     canDismember = true;
 }
예제 #4
0
    //public void ShowMyName(string name)
    //{
    //    GameObject obj = PoolManager.instance.GetPoolObjByType(PreLoadType.PeopleInfo, GameRunUI.instance.transName);
    //    obj.transform.position = Vector3.zero;
    //    PeopleInfo info = obj.GetComponent<PeopleInfo>();
    //    info.Init(this, name);
    //}

    public void ShowBullet(ShootInfo info)
    {
        GameObject obj = null;

        obj = PoolManager.instance.GetPoolObjByType(PreLoadType.Bullet, shootMuzzle);
        //obj.transform.localEulerAngles = Vector3.zero;
        obj.transform.parent = GameManager.instance.transBullet;
        //
        MagicFireball b = obj.GetComponent <MagicFireball>();

        b.Init(info, myIndex);
    }
예제 #5
0
    public void SendShootInfo(Vector3 shootlocatin)
    {
        var shootInfo = new ShootInfo {
            self_name  = UsernameText.text.ToString(),
            enemy_name = EnemyName,
            type       = "shoot",
            location   = shootlocatin,
            unix_time  = 0,
        };

        Debug.LogError(shootInfo);
        ws.Send(JsonConvert.SerializeObject(shootInfo));
    }
예제 #6
0
        ShootInfo GetShootInfo(ISFSObject info)
        {
            int[] shootSeats = info.GetIntArray("daqiang");

            ShootInfo shoot = new ShootInfo
            {
                Seat       = info.GetInt("seat"),
                ShootTargs = shootSeats,
                ShootCount = shootSeats.Length
            };

            return(shoot);
        }
예제 #7
0
        ShootInfo GetShootInfo(ISFSObject info)
        {
            int[]     shootSeats = info.GetIntArray("daqiang");
            int[]     beShoot    = info.GetIntArray("bedaqiang");
            int       shootCount = beShoot == null ? 0 : beShoot.Length;
            ShootInfo shoot      = new ShootInfo
            {
                Seat         = info.GetInt("seat"),
                ShootTargs   = shootSeats,
                BeShootCount = shootCount,
                ShootCount   = shootSeats.Length
            };

            return(shoot);
        }
예제 #8
0
        public void SendShootData()
        {
            if (ClientName != Client.ReceiverGameData.TurnPlayerName || Client.ReceiverGameData.Shoots.Count == 3)
            {
                return;
            }
            var shootInfo = new ShootInfo
            {
                MousePoint = { X = GMouse.Position.X, Y = GMouse.Position.Y },
                ShootScore = Darts.GetIntersectedSegmentScore()
            };

            Client.ReceiverGameData.Shoots.Add(shootInfo);
            Client.SendGameMessage();
        }
예제 #9
0
        /// <summary>
        /// 同步子弹
        /// </summary>
        /// <param name="player"></param>
        /// <param name="protocolBase"></param>
        public void MsgShooting(Session session, GameMessage message)
        {
            Player player = session.player;

            //获取房间
            if (player.tempData.status != PlayerTempData.Status.Fight)
            {
                return;
            }
            ShootInfo shootInfo = ProtoTransfer.Deserialize <ShootInfo>(message.data);

            shootInfo.id = player.id;
            message.data = ProtoTransfer.Serialize(shootInfo);
            player.tempData.room.BroadcastTcp(message);
        }
예제 #10
0
    public override void CreateTrail(ShootInfo shootInfo)
    {
        Vector3 start = weaponFirepos.GetWeaponFirePos();
        Vector3 end   = shootInfo.end;

        start = NagaUtils.GetPointAlongDirection(start, end - start, Random.value * startposRandomness);

        TrailRenderer trail = GenericObjectPooler.RequestObject(trailRenderer).gameObject.GetComponent <TrailRenderer>();

        trail.gameObject.transform.position = start;
        trail.gameObject.SetActive(true);

        trail.Clear();

        Timing.RunCoroutine(_TweenTrail(trail, end));
    }
예제 #11
0
    // 发送子弹同步信息
    public void SendShootInfo(Vector3 pos, Vector3 rot)
    {
        GameMessage message = new GameMessage();

        message.type = System.BitConverter.GetBytes((int)Protocol.Shooting);
        ShootInfo shootInfo = new ShootInfo();

        shootInfo.posX = pos.x;
        shootInfo.posY = pos.y;
        shootInfo.posZ = pos.z;

        shootInfo.rotateX = rot.x;
        shootInfo.rotateY = rot.y;
        shootInfo.rotateZ = rot.z;

        message.data = ProtoTransfer.Serialize(shootInfo);
        NetMgr.GetInstance().tcpSock.Send(message);
    }
예제 #12
0
    public void UIShot()
    {
        int index = DataController.instance.MyLocateIndex;

        if (DataController.instance.ActorList[index].CurState == RoomActorState.Dead)
        {
            return;
        }
        //旋转
        ShootInfo info = new ShootInfo();

        info.userIndex  = index;
        info.bulletType = 0;
        info.position   = DataController.BackNetLimetByType(GameManager.instance.GetControl(index).cameraParent.position);
        info.direction  = DataController.BackNetLimetByType(GameManager.instance.GetControl(index).cameraParent.eulerAngles);
        //
        GetControl(index).ShowBullet(info);
        //发送
        SendNetInfo(info);
    }
예제 #13
0
        private void Mainlist_OnConnect(Shoot obj)
        {
            //NEW VERSION -- ONLY OPEN ROLES SCREEN, WITHOUT CONNECTING...

            //Intent i = new Intent(this, typeof(Roles));
            //i.PutExtra("id", obj.id);
            //StartActivityForResult(i, 0);

            ShootInfo info = ShootInfo.NewInstance(obj.id);

            ShootInfo.ClearDels();
            ShootInfo.OnConnect += (s) =>
            {
                Bundle conData = new Bundle();
                conData.PutString("connectto", s.id);
                Intent intent = new Intent();
                intent.PutExtras(conData);
                SetResult(Result.Ok, intent);
                Finish();
            };
            info.Show(SupportFragmentManager, "fragment_edit_name");
        }
예제 #14
0
파일: ITrail.cs 프로젝트: nagahole/scope
 public abstract void CreateTrail(ShootInfo shootInfo);
예제 #15
0
    public void Hit()
    {
        float   min             = 999999;
        Vector3 shooterPosition = new Vector3(0f, 11.25f, 0f);

        int    mode       = ModeDecision();
        float  angle      = 0;
        float  force      = 0;
        string targetName = "";

        if (mode == 0)
        {
            foreach (Transform child in m.redChess.transform)
            {
                Chess chess = child.gameObject.GetComponent <Chess>();
                if (Distance(child.position, new Vector3(0f, 11.25f, 9.457f)) <= min && chess.region == 5)
                {
                    ShootInfo info = BombChess(child);
                    if (info.able)
                    {
                        min             = Distance(child.position, new Vector3(0f, 11.25f, 9.457f));
                        shooterPosition = info.position;
                        angle           = info.angle;
                        force           = info.force;
                        targetName      = child.gameObject.name;
                    }
                }
            }
        }
        else if (mode == 1)
        {
            foreach (Transform child in m.redChess.transform)
            {
                Chess chess = child.gameObject.GetComponent <Chess>();
                if (chess.region >= 1 && chess.region <= 2 && chess.type != 1)
                {
                    ShootInfo info = EasyChess(child);
                    if (info.able)
                    {
                        shooterPosition = info.position;
                        angle           = info.angle;
                        force           = info.force;
                        targetName      = child.gameObject.name;
                    }
                }
            }
            foreach (Transform child in m.redChess.transform)
            {
                Chess chess = child.gameObject.GetComponent <Chess>();
                if (chess.region >= 3 && chess.region <= 4 && chess.type != 1)
                {
                    ShootInfo info = EasyChess(child);
                    if (info.able)
                    {
                        shooterPosition = info.position;
                        angle           = info.angle;
                        force           = info.force;
                        targetName      = child.gameObject.name;
                    }
                }
            }
            foreach (Transform child in m.redChess.transform)
            {
                Chess chess = child.gameObject.GetComponent <Chess>();
                if (chess.type == 1)
                {
                    ShootInfo info = SmallReturnChess(child);
                    if (info.able)
                    {
                        shooterPosition = info.position;
                        angle           = info.angle;
                        force           = info.force;
                        targetName      = child.gameObject.name;
                    }
                }
            }
        }
        else if (mode == 2)
        {
            foreach (Transform child in m.redChess.transform)
            {
                Chess chess = child.gameObject.GetComponent <Chess>();
                if (chess.region == 8)
                {
                    ShootInfo info = ReturnChess(child);
                    if (info.able)
                    {
                        shooterPosition = info.position;
                        angle           = info.angle;
                        force           = info.force;
                        targetName      = child.gameObject.name;
                    }
                }
            }
            foreach (Transform child in m.redChess.transform)
            {
                Chess chess = child.gameObject.GetComponent <Chess>();
                if (chess.region == 6 || chess.region == 7)
                {
                    ShootInfo info = CornerChess(child);
                    if (info.able)
                    {
                        shooterPosition = info.position;
                        angle           = info.angle;
                        force           = info.force;
                        targetName      = child.gameObject.name;
                    }
                }
            }
        }
        if (force == 0)
        {
            ShootInfo info = RandomChess();
            shooterPosition = info.position;
            angle           = info.angle;
            force           = info.force;
        }
        Debug.Log(targetName);
        StartCoroutine(AIShoot(shooterPosition, angle, force));
    }
예제 #16
0
    /// <summary>
    /// 解析所有帧操作指令并在本客户端复现
    /// </summary>
    /// <param name="xieyi"></param>
    private void SelectFrameInfo(MessageXieYi xieyi)
    {
        byte[]          tempMessageContent = xieyi.MessageContent;
        string          messageInfo        = "";
        CharacterCommon member             = null;
        BuffInfo        buffInfo           = null;

        switch ((MessageConvention)xieyi.XieYiFirstFlag)
        {
        case MessageConvention.moveDirection:
            ActorMoveDirection moveDir = SerializeHelper.Deserialize <ActorMoveDirection>(tempMessageContent);
            member = GameManager.instance.memberGroup[moveDir.userIndex];
            //用上次移动操作到这次操作的时间,算出当前位置,并移动到该点
            //member.transform.DOMove(SerializeHelper.BackVector(moveDir.position), DataController.FrameFixedTime);
            //member.SetPosition(SerializeHelper.BackVector(moveDir.position));
            member.SetNetDirection(moveDir);
            break;

        case MessageConvention.rotateDirection:
            ActorRotateDirection rotateDir = SerializeHelper.Deserialize <ActorRotateDirection>(tempMessageContent);
            //判断用户
            //Debug.LogError("玩家接收方向移动:" + messageInfo);
            member = GameManager.instance.memberGroup[rotateDir.userIndex];
            member.SetNetDirection(rotateDir);
            break;

        case MessageConvention.jump:
            ActorJump netJump = SerializeHelper.Deserialize <ActorJump>(tempMessageContent);
            member = GameManager.instance.memberGroup[netJump.userIndex];
            member.SetJump();
            break;

        case MessageConvention.shootBullet:
            ShootInfo shootInfo = SerializeHelper.Deserialize <ShootInfo>(tempMessageContent);
            member = GameManager.instance.memberGroup[shootInfo.userIndex];
            if (shootInfo.userIndex != DataController.instance.MyLocateIndex)    //自身在收到服务器消息之前已旋转
            {
                member.ShowBullet(shootInfo);
            }
            break;

        case MessageConvention.bulletInfo:
            BulletInfo bulletInfo = SerializeHelper.Deserialize <BulletInfo>(tempMessageContent);
            switch (bulletInfo.shootTag)
            {
            case ShootTag.Box:
                BoxManager.instance.SetBulletInfo(bulletInfo);
                break;

            case ShootTag.Character:
                UpdateMemberShoot(xieyi);
                break;

            case ShootTag.Wall:
                Debug.Log("射中Wall:" + bulletInfo.shootInfo);
                break;

            case ShootTag.Buff:
                Debug.LogError("Buff不算是子弹");
                break;
            }

            break;

        case MessageConvention.createBuff:
            buffInfo = SerializeHelper.Deserialize <BuffInfo>(tempMessageContent);
            GameObject obj = PoolManager.instance.GetPoolObjByType(PreLoadType.Buff, GameManager.instance.transBuff);
            obj.transform.position = BoxManager.instance.GetBoxInfoByIndex(buffInfo.boxIndex).transform.position;
            MagicBuff buff = obj.GetComponent <MagicBuff>();
            buff.Init(buffInfo);
            break;

        case MessageConvention.getBuff:
            buffInfo = SerializeHelper.Deserialize <BuffInfo>(tempMessageContent);
            BoxManager.instance.SetBuffData(buffInfo);
            break;
        }
    }
예제 #17
0
 public void Shoot(ShootInfo info)
 {
     currentDirection = info.ShootDirection;
     shootDuration    = info.ShootDuration;
 }
예제 #18
0
    public byte[] SelectMessage(byte[] data, EndPoint endPoint)
    {
        string strPoint = endPoint.ToString();

        byte[]       newBuffer = null;
        MessageXieYi xieyi     = MessageXieYi.FromBytes(data);

        if (xieyi == null)
        {
            return(newBuffer);
        }

        byte[]             tempMessageContent = xieyi.MessageContent;
        ActorMoveDirection moveDirection      = null;
        SingleRoom         room  = null;
        UDPLogin           login = null;

        //该处RoomList没有加锁
        if (ServerDataManager.instance.allRoom.RoomList.ContainsKey(allUDPs[strPoint].roomID))
        {
            room = ServerDataManager.instance.allRoom.RoomList[allUDPs[strPoint].roomID];
        }

        switch ((MessageConvention)xieyi.XieYiFirstFlag)
        {
        case MessageConvention.setUDP:
            login       = SerializeHelper.Deserialize <UDPLogin>(tempMessageContent);
            login.login = strPoint;
            allUDPs[strPoint].roomID = login.roomID;
            allUDPs[strPoint].unique = login.unique;
            Log4Debug("UDP login 房间号:" + login.roomID);
            newBuffer = SerializeHelper.Serialize <UDPLogin>(login);
            break;

        case MessageConvention.moveDirection:
            moveDirection = SerializeHelper.Deserialize <ActorMoveDirection>(tempMessageContent);
            if (room.ActorList[moveDirection.userIndex].CurState != RoomActorState.Dead)
            {
                //Log4Debug("将历史帧:" + moveDirection.frameIndex + "保存到" + (moveDirection.frameIndex + room.RoomInfo.frameInterval) + "/" + room.RoomInfo.FrameIndex);
                room.SetRecondFrame(xieyi.ToBytes());
                //Log4Debug("站位:" + moveDirection.userIndex + " 更新了方向:" + "["
                //    + moveDirection.direction.x + ","
                //    + moveDirection.direction.y + ","
                //    + moveDirection.direction.z + "]"
                //    + "/速度:" + moveDirection.speed);
            }
            else
            {
                Log4Debug("死亡用户不更新移动。");
            }
            break;

        case MessageConvention.rotateDirection:
            ActorRotateDirection netRotation = SerializeHelper.Deserialize <ActorRotateDirection>(tempMessageContent);
            if (room.ActorList[netRotation.userIndex].CurState != RoomActorState.Dead)
            {
                room.SetRecondFrame(xieyi.ToBytes());
                //Log4Debug("站位:" + netRotation.userIndex + " 更新了旋转:" + netRotation.rotateY);
            }
            else
            {
                Log4Debug("死亡用户不更新旋转。");
            }
            break;

        case MessageConvention.jump:
            ActorJump netJump = SerializeHelper.Deserialize <ActorJump>(tempMessageContent);
            if (room.ActorList[netJump.userIndex].CurState != RoomActorState.Dead)
            {
                room.SetRecondFrame(xieyi.ToBytes());
            }
            else
            {
                Log4Debug("死亡用户不更新跳跃。");
            }
            break;

        case MessageConvention.shootBullet:
            ShootInfo shootInfo = SerializeHelper.Deserialize <ShootInfo>(tempMessageContent);
            if (room.ActorList[shootInfo.userIndex].CurState != RoomActorState.Dead)
            {
                room.SetRecondFrame(xieyi.ToBytes());
                //Log4Debug("站位:" + netRotation.userIndex + " 更新了旋转:" + netRotation.rotateY);
            }
            else
            {
                Log4Debug("死亡用户不更新射击。");
            }
            break;

        case MessageConvention.bulletInfo:
            //
            BulletInfo bulletInfo = SerializeHelper.Deserialize <BulletInfo>(xieyi.MessageContent);
            room.UpdateBulletInfo(bulletInfo);    //更新
            //room.SetRecondFrame(xieyi.ToBytes());
            break;

        default:
            Log4Debug("检查协议->" + (MessageConvention)xieyi.XieYiFirstFlag);
            break;
        }

        byte[] sendBuffer = null;
        if (newBuffer != null)//用户需要服务器返回值给自己的话
        {
            xieyi      = new MessageXieYi(xieyi.XieYiFirstFlag, xieyi.XieYiSecondFlag, newBuffer);
            sendBuffer = xieyi.ToBytes();
        }
        return(sendBuffer);
    }
예제 #19
0
 public void SendNetInfo(ShootInfo shootInfo)
 {
     byte[] sendData = SerializeHelper.Serialize <ShootInfo>(shootInfo);
     //SocketManager.instance.SendSave((byte)MessageConvention.shootBullet, message, false);
     UDPManager.instance.SendSave((byte)MessageConvention.shootBullet, sendData);
 }