예제 #1
0
        public void NetDataManager(NetData data)
        {
            switch ((NetStatus)data.ReadByte())
            {
            case NetStatus.GetStatus:
                NetData n = Manager.CreateNetData(NetID, (byte)NetStatus.SetStatus);
                n.Write(Heart);
                n.Write((byte)status);
                n.Write(index);
                NetServer.Send(n);
                break;

            case NetStatus.SetStatus:
                heart  = data.ReadInt();
                status = (RoleStatus)data.ReadByte();
                SetTarget(data.ReadInt(), data.RemoteIP);
                switch (status)
                {
                case RoleStatus.Death:
                    PlayDeath(data.RemoteIP);
                    break;

                case RoleStatus.Vectory:
                    PlayVictory(data.RemoteIP);
                    break;
                }
                break;

            case NetStatus.SetTarget:
                SetTarget(data.ReadInt(), data.RemoteIP);
                break;

            case NetStatus.Idle:
                PlayIdle(data.RemoteIP);
                break;

            case NetStatus.Attacking:
                PlayAttack(data.ReadInt(), data.RemoteIP);
                break;

            case NetStatus.Moving:
                break;

            case NetStatus.Hurt:
                Corsair.AttackInfo a = new Corsair.AttackInfo();
                a.Position = data.ReadVector3();
                a.Rotation = data.ReadQuaternion();
                a.Value    = data.ReadInt();
                base.Hurt(a);
                break;

            case NetStatus.Death:
                PlayDeath(data.RemoteIP);
                break;

            case NetStatus.Victory:
                PlayVictory(data.RemoteIP);
                break;
            }
        }
예제 #2
0
        public void NetDataManager(NetData data)
        {
            switch ((NetStatus)data.ReadByte())
            {
            case NetStatus.GetStatus:
                NetData ngs = Manager.CreateNetData(NetID, (byte)NetStatus.SetStatus);
                ngs.Write(heart);
                ngs.Write((byte)Status);
                NetServer.SendTo(ngs, data.RemoteIP);
                break;

            case NetStatus.SetStatus:
                heart  = data.ReadInt();
                Status = (ShipStatus)data.ReadInt();
                break;

            case NetStatus.ShipStatus:
                Status = (ShipStatus)data.ReadByte();
                break;

            case NetStatus.Avatar:
                transform.position = data.ReadVector3();
                transform.rotation = data.ReadQuaternion();
                break;

            case NetStatus.Death:
                Death(data.RemoteIP);
                break;
            }
        }
예제 #3
0
        public void NetDataManager(NetData data)
        {
            switch ((NetStatus)data.ReadByte())
            {
            case NetStatus.Select:
                Select(data.ReadInt(), data.RemoteIP);
                break;

            case NetStatus.LookAt:
                LookAt(data.ReadVector3(), data.RemoteIP);
                break;

            case NetStatus.LaunchTo:
                LaunchTo(data.ReadVector3(), data.RemoteIP);
                break;
            }
        }
예제 #4
0
        public void NetDataManager(NetData data)
        {
            if (!isMain)
            {
                switch ((NetStatus)data.ReadByte())
                {
                case NetStatus.GetStatus:
                    NetData ngs = Manager.CreateNetData(NetID, (byte)NetStatus.SetStatus);
                    ngs.Write(Heart);
                    ngs.Write((byte)status);
                    NetServer.SendTo(ngs, data.RemoteIP);
                    break;

                case NetStatus.SetStatus:
                    heart  = data.ReadInt();
                    status = (PlayerStatus)data.ReadByte();
                    break;

                case NetStatus.Avatar:
                    head.transform.position = data.ReadVector3();
                    head.transform.rotation = data.ReadQuaternion();

                    left.transform.position = data.ReadVector3();
                    left.transform.rotation = data.ReadQuaternion();

                    right.transform.position = data.ReadVector3();
                    right.transform.rotation = data.ReadQuaternion();
                    break;

                case NetStatus.Death:
                    Death(data.RemoteIP);
                    break;

                case NetStatus.Hurt:
                    AttackInfo a = new AttackInfo();
                    a.Position = data.ReadVector3();
                    a.Rotation = data.ReadQuaternion();
                    a.Value    = data.ReadInt();
                    Hurt(a, data.RemoteIP);
                    break;
                }
            }
        }
예제 #5
0
        public void NetDataManager(NetData data)
        {
            switch ((NetStatus)data.ReadByte())
            {
            case NetStatus.Create:
                string     n = data.ReadString();
                Vector3    p = data.ReadVector3();
                Quaternion r = data.ReadQuaternion();
                Manager.CreateGameObject(prefabId, p, r);
                break;

            case NetStatus.Remain:
                Remain(data.ReadFloat());
                break;

            case NetStatus.End:
                End();
                break;
            }
        }
예제 #6
0
        public void NetManager(NetData data)
        {
            switch ((NetStatus)data.ReadByte())
            {
            case NetStatus.GetStatus:
                NetData ngs = Manager.CreateNetData(NetID, (byte)NetStatus.SetStatus);
                ngs.Write(heart);
                NetServer.Send(ngs);
                break;

            case NetStatus.SetStatus:
                heart = data.ReadInt();
                if (heart > 0)
                {
                    LifeEvent.Invoke(heart / (float)max);
                }
                else
                {
                    base.Death();
                    Ramparts.Remove(this);
                }
                break;

            case NetStatus.Hurt:
                AttackInfo a = new AttackInfo();
                a.Position = data.ReadVector3();
                a.Rotation = data.ReadQuaternion();
                a.Value    = data.ReadInt();
                base.Hurt(a);
                LifeEvent.Invoke(heart / (float)max);
                break;

            case NetStatus.Death:
                base.Death();
                Ramparts.Remove(this);
                break;
            }
        }
예제 #7
0
        private static void NetManager(NetData data)
        {
            switch ((NetStatus)data.ReadByte())
            {
            case NetStatus.GetLevel:
                NetData ngl = Manager.CreateNetData(NetID, (byte)NetStatus.SetLevel);
                ngl.Write(Level);
                NetServer.SendTo(ngl, data.RemoteIP);
                break;

            case NetStatus.SetLevel:
                int level = data.ReadInt();
                if (Level != level)
                {
                    LoadLevel(level);
                }
                break;

            case NetStatus.ResetLevel:
                LoadLevel(data.ReadInt());
                break;

            case NetStatus.GetPlayerIndex:
                NetData ngp = Manager.CreateNetData(NetID, (byte)NetStatus.SetPlayerIndex);
                ngp.Write(1);
                NetServer.SendTo(ngp, data.RemoteIP);
                break;

            case NetStatus.SetPlayerIndex:
                SetPlayerIndex(data.ReadInt());
                break;

            case NetStatus.GetGameStatus:
                NetData ngg = Manager.CreateNetData(NetID, (byte)NetStatus.SetGameStatus);
                ngg.Write((byte)GameStatus);
                NetServer.SendTo(ngg, data.RemoteIP);
                break;

            case NetStatus.SetGameStatus:
                SetGameStatus((GameStatus)data.ReadByte());
                break;

            case NetStatus.CreateGameObject:
                int        id = data.ReadInt();
                string     na = data.ReadString();
                Vector3    po = data.ReadVector3();
                Quaternion ro = data.ReadQuaternion();
                Instantiate(Prefabs[id], po, ro).name = na;
                break;

            case NetStatus.GetGameObjects:
                for (int i = 0; i < GameObjects.Count; i++)
                {
                    NetData    ng = Manager.CreateNetData(NetID, (byte)NetStatus.CreateGameObject);
                    GameObject g  = GameObjects[i];
                    ng.Write(int.Parse(g.name.Substring(0, g.name.IndexOf('_'))));
                    ng.Write(g.name);
                    ng.Write(g.transform.position);
                    ng.Write(g.transform.rotation);
                    NetServer.SendTo(ng, data.RemoteIP);
                }
                break;
            }
        }