void processor_SC_NOTI_USE_SKILL(GAME.SC_NOTI_USE_SKILL read)
    {
        var key       = read.Key;
        var skill_key = read.SkillKey;
        var skill_id  = read.SkillId;
        var rot       = new Quaternion(read.RotX, read.RotY, read.RotZ, read.RotW);
        var pos       = new Vector3(read.PosX, read.PosY, read.PosZ);
        var forward   = new Vector3(read.ForwardX, read.ForwardY, read.ForwardZ);
        var distance  = read.Distance;
        var speed     = read.Speed;

        // 먼저 본인인지 구별
        if (key_ == read.Key)
        {
            Debug.Log("본인 스킬\n");
            GameObject top = GameObject.Find("Top");
            if (top)
            {
                var script = top.GetComponent <Direct_Tank_Topfire>();
                script.Fire(rot, pos, forward, distance, speed);

                var state = script.state;

                pos.y = script.GetBulletStartY();
                var bullet = Instantiate(state.bullet, pos, rot);
                bullet.transform.localScale = new Vector3(bullet.transform.localScale.x * state.bulletSize, bullet.transform.localScale.y * state.bulletSize, bullet.transform.localScale.z * state.bulletSize);
                bullet.GetComponent <DirectBullet>().SetProperty(speed, distance);

                var bullet_info = new BulletInfo();
                bullet_info.bullet = bullet;

                HandleAddBullet(skill_key, bullet_info);
            }
            //var top = player.Find("Top");
            return;
        }

        var enemy_info = enemies[key];

        if (enemy_info != null)
        {
            var e = enemy_info.obj;
            Debug.Log("enemy 존재");
            var top = e.transform.Find("tank_enemy_02_top").gameObject;
            if (top != null)
            {
                top.transform.rotation = rot;

                var script = GameObject.Find("Top").GetComponent <Direct_Tank_Topfire>();
                script.Fire(rot, pos, forward, distance, speed);

                var state = script.state;

                pos.y = top.transform.position.y;

                var bullet = Instantiate(Resources.Load("Prefabs/FireBall")) as GameObject;

                bullet.transform.position = pos;
                bullet.transform.rotation = rot;

                bullet.transform.localScale = new Vector3(bullet.transform.localScale.x * state.bulletSize, bullet.transform.localScale.y * state.bulletSize, bullet.transform.localScale.z * state.bulletSize);
                bullet.GetComponent <DirectBullet>().SetProperty(speed, distance);

                var bullet_info = new BulletInfo();
                bullet_info.bullet = bullet;

                HandleAddBullet(skill_key, bullet_info);
            }
        }


        Debug.Log("패킷받음");
    }
예제 #2
0
    // 패킷 처리
    public void process_packet()
    {
        while (network_module_.recv_stream_queue.Count > 0)
        {
            var packet_stream = network_module_.recv_stream_queue.Dequeue();

            // 패킷 스트림에서 대가리 2바이트 짤라서 opcode 가져와야함
            byte[] packet_buffer = packet_stream.ToArray();

            Int16 _opcode         = BitConverter.ToInt16(packet_buffer, 0);
            var   protobuf_stream = new MemoryStream();
            var   protobuf_size   = packet_stream.Length - sizeof(Int16);
            protobuf_stream.Write(packet_buffer, sizeof(Int16), (int)protobuf_size);

            byte[] proto_buffer = protobuf_stream.ToArray();


            try
            {
                if ((network.opcode)_opcode == network.opcode.SC_LOG_IN)
                {
                    LOBBY.SC_LOG_IN read = LOBBY.SC_LOG_IN.Parser.ParseFrom(proto_buffer);
                    if (processor_SC_LOG_IN != null)
                    {
                        processor_SC_LOG_IN(read);
                    }
                }
                else if ((network.opcode)_opcode == network.opcode.SC_SET_NICKNAME)
                {
                    LOBBY.SC_SET_NICKNAME read = LOBBY.SC_SET_NICKNAME.Parser.ParseFrom(proto_buffer);
                    if (processor_SC_SET_NICKNAME != null)
                    {
                        processor_SC_SET_NICKNAME(read);
                    }
                }
                // GAME
                else if ((network.opcode)_opcode == network.opcode.SC_ENTER_FIELD)
                {
                    GAME.SC_ENTER_FIELD read = GAME.SC_ENTER_FIELD.Parser.ParseFrom(proto_buffer);
                    if (processor_SC_ENTER_FIELD != null)
                    {
                        processor_SC_ENTER_FIELD(read);
                    }
                }
                else if ((network.opcode)_opcode == network.opcode.SC_NOTI_ENTER_FIELD)
                {
                    GAME.SC_NOTI_ENTER_FIELD read = GAME.SC_NOTI_ENTER_FIELD.Parser.ParseFrom(proto_buffer);
                    if (processor_SC_NOTI_ENTER_FIELD != null)
                    {
                        processor_SC_NOTI_ENTER_FIELD(read);
                    }
                }
                else if ((network.opcode)_opcode == network.opcode.SC_NOTI_MOVE_OBJECT)
                {
                    GAME.SC_NOTI_MOVE_OBJECT read = GAME.SC_NOTI_MOVE_OBJECT.Parser.ParseFrom(proto_buffer);
                    if (processor_SC_NOTI_MOVE_OBJECT != null)
                    {
                        processor_SC_NOTI_MOVE_OBJECT(read);
                    }
                }
                else if ((network.opcode)_opcode == network.opcode.SC_NOTI_LEAVE_FIELD)
                {
                    GAME.SC_NOTI_LEAVE_FIELD read = GAME.SC_NOTI_LEAVE_FIELD.Parser.ParseFrom(proto_buffer);
                    if (processor_SC_NOTI_LEAVE_FIELD != null)
                    {
                        processor_SC_NOTI_LEAVE_FIELD(read);
                    }
                }
                else if ((network.opcode)_opcode == network.opcode.SC_PING)
                {
                    GAME.CS_PING send = new GAME.CS_PING();
                    send.Timestamp = instance_.getServerTimestamp();
                    instance_.send_protobuf(network.opcode.CS_PING, send);
                    //GAME.SC_PING read = GAME.SC_PING.Parser.ParseFrom(proto_buffer);
                    //ping_time = getServerTimestamp() - protobuf_session.send_time;
                    //Debug.Log("ping time: " + ping_time);
                }
                else if ((network.opcode)_opcode == network.opcode.SC_NOTI_USE_SKILL)
                {
                    GAME.SC_NOTI_USE_SKILL read = GAME.SC_NOTI_USE_SKILL.Parser.ParseFrom(proto_buffer);
                    if (processor_SC_NOTI_USE_SKILL != null)
                    {
                        processor_SC_NOTI_USE_SKILL(read);
                    }
                }
                else if ((network.opcode)_opcode == network.opcode.SC_NOTI_DESTROY_SKILL)
                {
                    GAME.SC_NOTI_DESTROY_SKILL read = GAME.SC_NOTI_DESTROY_SKILL.Parser.ParseFrom(proto_buffer);
                    if (processor_SC_NOTI_DESTROY_SKILL != null)
                    {
                        processor_SC_NOTI_DESTROY_SKILL(read);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.Log(e);
                Debug.Log("protobuf 읽다가 에러");
            }
        }
    }