public void Set(IInvItem newItem, Vector3 position)
 {
     view.Scope.EnableScopeCalculation();
     transform.position = position;
     item = newItem;
     set  = true;
     view.SendReliable("Set", RpcTarget.NonControllers, newItem, position);
 }
Exemple #2
0
 void Die()
 {
     AiManager.AiDied(this);
     Invoke("Despawn", 30);
     view.SendReliable("Die", RpcTarget.NonControllers);
     gameObject.SetActive(false);
 }
 private bool CanSend()
 {
     if (Time.time - lastInput < MininumBetweenInput)
     {
         return(false);
     }
     if (Time.time - lastInput > FloodProtectionReset)
     {
         floodInput = 0;
     }
     lastInput = Time.time;
     floodInput++;
     if (floodInput <= FloodInputTrip)
     {
         return(!FloodMuted);
     }
     lastFloodTrip = Time.time;
     view.SendReliable("ReceiveFloodMuted", RpcTarget.Controllers, FloodMuteDuration);
     return(!FloodMuted);
 }
 void Jump()
 {
     if (jumping || !grounded)
     {
         return;
     }
     netView.SendReliable("StartJump", RpcTarget.Server);
     currJumpVel = JumpVel;
     jumping     = true;
     grounded    = false;
     currFallVel = 0;
 }
Exemple #5
0
 public void Chase()
 {
     if (target != null)
     {
         SetState("chase");
         view.SendReliable("StateInput", RpcTarget.Server, "chase");
     }
     else
     {
         Debug.Log("No target");
     }
 }
Exemple #6
0
    void Update()
    {
        Hotkeys();
        if (Input.GetMouseButtonDown(0))
        {
            if (!UIManager.instance.InDeadZone(Input.mousePosition))
            {
                RaycastHit hit;
                if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 1000f))
                {
                    if (aoePoint != null)
                    {
                        string[] targets = aoePoint.GetTargets("Enemy");
                        view.SendReliable("CastInput", RpcTarget.Server, castSkillIndex, targets);

                        Destroy(aoePoint.gameObject);
                        aoePoint       = null;
                        castSkillIndex = -1;
                    }
                    else if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Terrain"))
                    {
                        Move(hit.point);
                    }
                    else if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Selectable"))
                    {
                        Select(hit.collider.gameObject);
                    }
                }
            }
        }

        if (aoePoint != null)
        {
            RaycastHit aoeHit;
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out aoeHit, 1000f))
            {
                aoePoint.transform.position = aoeHit.point;
            }
        }
    }
Exemple #7
0
        private void RegisterHit(Transform hitTarget)
        {
            NetView hitView = hitTarget.GetComponent <NetView>();

            if (hitView == null)
            {
                return;
            }
            if (!view.AmServer)
            {
                view.SendReliable("ReceiveHit", RpcTarget.Server, hitView.Id);
            }
        }
Exemple #8
0
 void TryPickup()
 {
     PickupProxy[] pickups = FindObjectsOfType <PickupProxy>();
     foreach (var pickup in pickups)
     {
         if (Vector3.Distance(pickup.transform.position, transform.position) > 30)
         {
             continue;
         }
         view.SendReliable("PickupItem", RpcTarget.Server, pickup.GetViewId());
         break;
     }
 }
        private void SendInput()
        {
            if (bufferPos > 0 && CanTalk())
            {
                var newArr = new char[bufferPos];
                Array.Copy(buffer, 0, newArr, 0, bufferPos);
                switch (mode)
                {
                case Mode.Whisper:
                    view.SendReliable("ReceiveWhisperInput", RpcTarget.Server, whisperTarget, newArr);
                    break;

                case Mode.Say:
                    view.SendReliable("ReceiveSayInput", RpcTarget.Server, newArr);
                    break;

                case Mode.Local:
                    view.SendReliable("ReceiveLocalInput", RpcTarget.Server, newArr);
                    break;
                }
            }
            ChangeMode(Mode.Closed);
        }
Exemple #10
0
    void Update()
    {
        if (Input.GetMouseButton(0))
        {
            if (testing)
            {
                character.Fire();
            }
            else
            {
                view.SendReliable("AttackInput", RpcTarget.Server);
            }
        }

        if (Input.GetMouseButton(1))
        {
            limbsCam.Aim();
        }
        if (Input.GetMouseButtonUp(1))
        {
            limbsCam.Reset();
        }
    }
        private void ReceiveWhisperInput(string targetName, char[] input)
        {
            if (!CanSend() || !InputValid(input))
            {
                return;
            }
            if (!InputValidator.LowercaseOnly(targetName))
            {
                return;
            }
            if (player.PlayerName == targetName)
            {
                return;
            }
            if (!PlayerCreator.Players.ContainsKey(targetName))
            {
                view.SendReliable("ReceiveWhisperFailed", RpcTarget.Controllers);
                return;
            }
            NetView playerView = PlayerCreator.Players[targetName].View;

            playerView.SendReliable("ReceiveWhisperMessage", RpcTarget.Controllers, player.PlayerName, input);
            view.SendReliable("ReceiveDeliveredWhisper", RpcTarget.Controllers, targetName, input);
        }
Exemple #12
0
 private void MoveInput(Vector3 moveTo)
 {
     character.Move(moveTo);
     view.SendReliable("Move", RpcTarget.NonControllers, moveTo);
 }