private void Update()
 {
     if (Mouse.current.leftButton.isPressed)
     {
         ClientSend.PlayerShoot(new Vector3(movementX, 0.0f, movementY));
         //ClientSend.PlayerShoot(camTransform.forward);
     }
 }
Ejemplo n.º 2
0
 private void Update()
 {
     //we do this in its own update with keyGetDown to get every time a player presses the key
     if (Input.GetKeyDown(KeyCode.Mouse0))
     {
         ClientSend.PlayerShoot(camTransform.forward);
     }
 }
 public void WaitJump()
 {
     ClientSend.AddEffects(1);
     tekst.SetActive(true);
     inventory.instance.Remove(Item);
     TextCounterJump.instance.Start();
     TextCounterJump.instance.Update();
     Invoke("Jumpy", seconds);
 }
 public void WaitSpeed()
 {
     ClientSend.AddEffects(3);
     tekst2.SetActive(true);
     inventory.instance.Remove(Item);
     TextCounterSpeed.instance.Start();
     TextCounterSpeed.instance.Update();
     Invoke("Speedy", seconds);
 }
 public void WaitInvisible()
 {
     ClientSend.SetInvis(true);
     tekst3.SetActive(true);
     inventory.instance.Remove(Item);
     TextCounterInvisible.instance.Start();
     TextCounterInvisible.instance.Update();
     Invoke("Invy", seconds);
 }
Ejemplo n.º 6
0
    private void Update()
    {
        manager.cursor = mainCam.ScreenToWorldPoint(Input.mousePosition); //updates mouse position

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            ClientSend.PlayerShoot();
        }
    }
Ejemplo n.º 7
0
    IEnumerator Wait()
    {
        ClientSend.GetRooms();
        UIManager.instance.SetPlayersInRoom(new string[0]);
        ClientSend.GetPlayersInRoom();
        yield return(new WaitForSeconds(3f));

        check = true;
    }
Ejemplo n.º 8
0
 private void SendMovement(Vector3 position)
 {
     using (Packet packet = new Packet((int)ClientPackets.pirateMovement))
     {
         packet.Write(Client.instance.id);
         packet.Write(position);
         ClientSend.SendUDPData(packet);
     }
 }
 void HitAnimal(GameObject animal)
 {
     int damage = 25;
     ClientSend.Hit("animal", animal.GetComponent<AnimalManager>().id, damage);
     if (animal.GetComponent<AnimalManager>().health <= damage)
     {
         ClientSend.AddItem("meat", 2);
     }
 }
 void HitRock(GameObject rock)
 {
     int damage = 25;
     ClientSend.Hit("rock", rock.GetComponent<Rock>().id, damage);
     if (rock.GetComponent<Rock>().hp <= damage)
     {
         ClientSend.AddItem("rock", 2);
     }
 }
Ejemplo n.º 11
0
    private void SendAudioToServer()
    {
        AudioSource audioSource = GetComponent <AudioSource>();

        float[] samples = new float[audioSource.clip.samples * audioSource.clip.channels];
        audioSource.clip.GetData(samples, 0);

        ClientSend.PlayerAudio(samples);
    }
Ejemplo n.º 12
0
    public static void Welcome(Packet packet)
    {
        string msg  = packet.ReadString();
        int    myid = packet.ReadInt();

        Debug.Log("Welcome Message received " + msg);
        Client.Instance.myId = myid;
        ClientSend.WelcomeReceived();
    }
Ejemplo n.º 13
0
 private static void SendMessage(string buttonName)
 {
     if (Client.Instance.isConnected)
     {
         Log(_chatInput.GetText());
         ClientSend.Chat(Client.Instance.myId, _chatInput.GetText());
     }
     MultiplayerClient.Instance.herochat.text = _chatInput.GetText();
 }
Ejemplo n.º 14
0
 private void SendInputToServer()
 {
     bool[] _inputs = new bool[]
     {
         Input.GetKey(KeyCode.Mouse0)
     };
     print(EventSystem.current.currentSelectedGameObject.name);
     ClientSend.PlayerMovement(_inputs);
 }
Ejemplo n.º 15
0
    public static void Welcome(Packet _packet)
    {
        string _msg  = _packet.ReadString();
        int    _myId = _packet.ReadInt();

        Debug.Log($"Message from server: {_msg}");
        Client.instance.myId = _myId;
        ClientSend.WelcomeReceived();
    }
Ejemplo n.º 16
0
    public static void Welcome(Packet _packet)
    {
        string _msg  = _packet.ReadString();
        int    _myId = _packet.ReadInt();

        Console.WriteLine($"Message from server: {_msg}");
        Client.myId = _myId;
        ClientSend.WelcomeReceived();
    }
Ejemplo n.º 17
0
 public void OnMouseDown()
 {
     clicksRecorded++;
     ClientSend.BoxClicked(id);
     if (clicksRecorded >= clickCapacity)
     {
         gameObject.SetActive(false);
     }
 }
Ejemplo n.º 18
0
    public void OnTriggerStay(Collider other)
    {
        if (getKeyDownF)
        {
            getKeyDownF = false;
            //문열기
            if (other.CompareTag("Door"))
            {
                if (other.gameObject.transform.rotation.y == 0f)
                {
                    other.gameObject.transform.RotateAround(other.gameObject.transform.GetChild(0).position, Vector3.up, -90f);
                }
                else
                {
                    other.gameObject.transform.RotateAround(other.gameObject.transform.GetChild(0).position, Vector3.up, 90f);
                }
            }
            //은폐
            if (isInHideZone)
            {
                ClientSend.Hide(other.gameObject);
            }
            //아이템획득
            if (other.CompareTag("Item"))
            {
                if (other.GetComponent <ItemSpawner>().hasItem)
                {
                    switch (other.GetComponent <ItemSpawner>().itemType)
                    {
                    case ItemType.GUN:
                    case ItemType.DRONE:
                        if (this.GetComponent <PlayerManager>().playerItem.item_number1 == null)
                        {
                            ClientSend.PlayerGetItem(other.gameObject);
                        }
                        else
                        {
                            Debug.Log($"해당 아이템은 1개만 획득할 수 있습니다");
                        }
                        break;

                    default:
                        ClientSend.PlayerGetItem(other.gameObject);
                        break;
                    }
                }
                else
                {
                    Debug.Log($"주위에 아무것도 없습니다");
                }
            }
            else
            {
                Debug.Log($"주위에 아무것도 없습니다");
            }
        }
    }
Ejemplo n.º 19
0
 private void ChangeTeam()
 {
     using (Packet packet = new Packet((int)ClientPackets.changeTeam))
     {
         packet.Write(Client.instance.id);
         packet.Write(team.id);
         ClientSend.SendTCPData(packet);
     }
 }
Ejemplo n.º 20
0
    IEnumerator AnswerDelay()
    {
        yield return(new WaitForSeconds(3));

        ClientSend.ColorRequest();
        waktu = 10;
        //ss.playerAnswer = false;
        Debug.Log("Second");
    }
Ejemplo n.º 21
0
    /// <summary>
    /// 连接到服务端后收到Welcome消息
    /// </summary>
    /// <param name="_packet">Packet包含:消息字串,ID</param>
    public static void Welcome(Packet _packet)
    {
        string _msg  = _packet.ReadString();
        int    _myId = _packet.ReadInt();

        Console.WriteLine($"Message from server: {_msg}");
        Client.instance.myId = _myId;
        ClientSend.WelcomeReceived();
        Client.instance.udp.Connect(((IPEndPoint)Client.instance.tcp.socket.Client.LocalEndPoint).Port);
    }
Ejemplo n.º 22
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Mouse1) && localPlayerController.IsAlive() && readyToThrow)
     {
         readyToThrow = false;
         ClientSend.PlayerThrowItem(camTransform.forward);
         //audioManager.Throw(); FIX THIS
         StartCoroutine(ThrowCooldown());
     }
 }
Ejemplo n.º 23
0
    protected override void Awake()
    {
        base.Awake();

        CanMove        = true;
        currentStamina = MaxStamina;

        ClientSend.PlayerMovementStats(RunSpeed, SprintSpeed);
        PlatformLayer = LayerMask.NameToLayer(PlatformLayerName);
    }
Ejemplo n.º 24
0
    public void TakeDamage(int damage, int bulletOwnerID)
    {
        if (CurrentHealth - damage <= 0)
        {
            Die(bulletOwnerID);
        }

        PlayerManager.TookDamage(damage, CurrentHealth - damage);
        ClientSend.TookDamage(damage, CurrentHealth);
    }
Ejemplo n.º 25
0
    public void SendBuilding(SendBuildingSignal signal)
    {
        Debug.Log("Send buildoing to server: " + signal.Building.Name);
        JsonSerializerSettings settings = new JsonSerializerSettings {
            TypeNameHandling = TypeNameHandling.All, ReferenceLoopHandling = ReferenceLoopHandling.Ignore
        };
        string json = JsonConvert.SerializeObject(signal.Building, settings);

        ClientSend.SendJsonPackage(json);
    }
Ejemplo n.º 26
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            string username = Username.Text;
            string password = Password.Password;

            ClientSend.SendLoginData(username, password);
            //var glWindow = new GLwindow();
            //glWindow.Show();
            //this.Close();
        }
Ejemplo n.º 27
0
 private void ShootBullet()
 {
     if (!CanShoot)
     {
         return;
     }
     PlayerManager.CallOnBulletShotEvent(FirePointTransform.position, FirePointTransform.rotation);
     //base.ShootBullet(FirePointTransform.position, FirePointTransform.rotation);
     ClientSend.ShotBullet(FirePointTransform.position, FirePointTransform.rotation);
 }
Ejemplo n.º 28
0
    /// <summary>Takes a shot in semi-automatic mode.</summary>
    /// <param name="_shootDirection">The vector that the shot will travel.</param>

    public void SemiShot(Vector3 _shootDirection)
    {
        ClientSend.PlayerShoot(_shootDirection);
        isNextShotReady = false;

        if (!preparingNextShot)
        {
            StartCoroutine(PrepareNextShot());
        }
    }
Ejemplo n.º 29
0
 private void SendInputToServer()
 {
     bool[] _inputs = new bool[] {
         Input.GetKey(KeyCode.Z),
         Input.GetKey(KeyCode.S),
         Input.GetKey(KeyCode.Q),
         Input.GetKey(KeyCode.D)
     };
     ClientSend.PlayerMovement(_inputs);
 }
Ejemplo n.º 30
0
 void OnTriggerStay2D(Collider2D aaa)
 {
     if (gameObject.tag == "LocalPlayer")
     {
         if (aaa.gameObject.tag == "Water" && Input.GetKeyDown(KeyCode.Space))
         {
             ClientSend.CharacterStatus((int)CharacterStats.Water);
         }
     }
 }