Esempio n. 1
0
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Application.Quit();
            }

            GCli.Receive();

            frameSpan += Time.deltaTime;
            if (frameSpan >= 0.1f)
            {
                frameSpan = 0;

                PushData push = Players.GetPushData();
                if (push != null)
                {
                    GCli.Send(MessageType.Push, GCli.Serialize <PushData>(push), NetDeliveryMethod.UnreliableSequenced);
                }
            }

            /*if(firstFrame)
             * {
             *  firstFrame = false;
             *  InitData init = GetDummyInitData();
             *  GameObject.Find("Canvas").GetComponent<UIScript>().SetInitData(init.bmps);
             * }*/
        }
Esempio n. 2
0
        void SendDrawData(Dictionary <int, List <int> > rewrites)
        {
            DrawData draw = new DrawData();

            foreach (KeyValuePair <int, List <int> > item in rewrites)
            {
                foreach (int y in item.Value)
                {
                    if (surface == 0)
                    {
                        draw.pixels.Add(new PixelData()
                        {
                            isbot = true, x = item.Key, y = y, color = pixels[item.Key, y]
                        });
                    }
                    else
                    {
                        draw.pixels.Add(new PixelData()
                        {
                            isbot = false, x = item.Key, y = y, color = pixels[item.Key, y]
                        });
                    }
                }
            }

            GCli.Send(MessageType.Draw, GCli.Serialize <DrawData>(draw), Lidgren.Network.NetDeliveryMethod.Unreliable);
        }
Esempio n. 3
0
        void SendFire(bool hit, int parts, int userid)
        {
            FireData data = new FireData {
                hit = hit, parts = parts, userid = userid
            };

            GCli.Send(MessageType.SendFire, GCli.Serialize <FireData>(data), NetDeliveryMethod.ReliableOrdered);
        }
Esempio n. 4
0
        void Construct()
        {
            if (weaponTimer <= 0 && !haveGun)
            {
                if (Input.GetButtonDown("Fire1"))
                {
                    RaycastHit hit;

                    if (Physics.Raycast(fpsCamera.position, fpsCamera.forward, out hit, distance))
                    {
                        Vector3 hitPoint = hit.point + hit.normal * 0.1f;
                        int     x        = (int)hitPoint.x;
                        int     y        = (int)hitPoint.y;
                        int     z        = (int)hitPoint.z;

                        Collider[] cols = Physics.OverlapBox(new Vector3(x + 0.5f, y + 0.5f, z + 0.5f), new Vector3(0.49f, 0.49f, 0.49f));
                        if (cols.Length == 0)
                        {
                            if (Env.IsInsideWorld(x, y, z) && !Env.IsCorePos(x, y, z))
                            {
                                BlockData block = new BlockData {
                                    x = x, y = y, z = z, blocktype = init.faction == 0 ? 2 : 3
                                };
                                GCli.Send(MessageType.SetBlock, GCli.Serialize <BlockData>(block), NetDeliveryMethod.ReliableOrdered);
                                //World.SetBlock(x, y, z, init.faction == 0 ? 2 : 3);
                            }
                        }
                    }
                }
                else if (Input.GetButtonDown("Fire2"))
                {
                    RaycastHit hit;

                    if (Physics.Raycast(fpsCamera.position, fpsCamera.forward, out hit, distance))
                    {
                        Vector3 hitPoint = hit.point - hit.normal * 0.1f;
                        int     x        = (int)hitPoint.x;
                        int     y        = (int)hitPoint.y;
                        int     z        = (int)hitPoint.z;

                        if (Env.IsInsideWorld(x, y, z) && !Env.IsCorePos(x, y, z))
                        {
                            BlockData block = new BlockData {
                                x = x, y = y, z = z, blocktype = 0
                            };
                            GCli.Send(MessageType.SetBlock, GCli.Serialize <BlockData>(block), NetDeliveryMethod.ReliableOrdered);
                            //World.SetBlock(x, y, z, 0);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Application.Quit();
            }

            GCli.Receive();

            frameSpan += Time.deltaTime;
            if (frameSpan >= 0.1f)
            {
                frameSpan = 0;

                if (Players.GetPlayer() != null)
                {
                    PushData push = Players.GetPushData();
                    if (push != null)
                    {
                        GCli.Send(MessageType.Push, GCli.Serialize <PushData>(push), NetDeliveryMethod.UnreliableSequenced);
                    }
                }
            }
        }