예제 #1
0
 private void TargetSendShaderValue(NetworkConnection conn, ShaderValue[] shaderValues)
 {
     foreach (ShaderValue shaderValue in shaderValues)
     {
         GameScreenDrawer.SetShaderValue(shaderValue);
     }
 }
예제 #2
0
    private void HunterController()
    {
        if (!IsHunter)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.L))
        {
            Vector3 euler = new Vector3(0f, Random.Range(0f, 360f), 0f);
            SetVelocity(transform.position, Quaternion.Euler(euler) * Vector3.forward * -12f, euler, .8f);
            RpcPlayAnimation("Flying");
            GameScreenDrawer.SetShaderValue(new ShaderValue {
                ShaderType = GameScreenDrawer.ShaderType.ColorGrading_Filter,
                ColorValue = Color.red,
                TimeFull   = .8f,
                TimeIn     = 0f,
                TimeOut    = .4f
            });
            GameScreenDrawer.SetShaderValue(new ShaderValue {
                ShaderType = GameScreenDrawer.ShaderType.DepthOfField_Distance,
                FloatValue = .1f,
                TimeFull   = .8f,
                TimeIn     = 0f,
                TimeOut    = .4f
            });
            GameScreenDrawer.SetShaderValue(new ShaderValue {
                ShaderType = GameScreenDrawer.ShaderType.ChromaticAberration_Intensity,
                FloatValue = 1f,
                TimeFull   = .8f,
                TimeIn     = 0f,
                TimeOut    = .4f
            });
        }

        if (NetworkTime.time >= LastAction + Cooldown)
        {
            RaycastHit[] hits    = Physics.SphereCastAll(transform.position, Distance, Vector3.up, Distance / 2f);
            Transform    nearest = PhysicsUtils.GetNearestPlayerHit(hits.Where(hit => {
                Player p;
                return((p = hit.transform.GetComponent <Player>()) != null && !p.IsHunter);
            }).ToArray(), transform);
            if (nearest != null)
            {
                RaycastHit[] hits1 = Physics.RaycastAll(transform.position + new Vector3(0f, 1f, 0f),
                                                        (nearest.position + new Vector3(0f, 1f, 0f)) -
                                                        (transform.position + new Vector3(0f, 1f, 0f)),
                                                        Distance);
                Transform nearest1 = PhysicsUtils.GetNearestHit(hits1, transform);
                if (nearest1 == nearest)
                {
                    _lineRenderer.positionCount = 2;
                    _lineRenderer.startColor    = new Color32(255, 155, 155, 255);
                    _lineRenderer.endColor      = new Color32(255, 155, 155, 255);
                    _lineRenderer.startWidth    = .25f;
                    _lineRenderer.endWidth      = .25f;
                    _lineRenderer.SetPositions(new[] {
                        transform.position + new Vector3(0f, 1f, 0f),
                        nearest.position + new Vector3(0f, 1f, 0f)
                    });

                    if (Input.GetKeyDown(KeyCode.Q) && !IsFlying)
                    {
                        CmdKill(nearest.gameObject);
                    }
                }
                else
                {
                    _lineRenderer.positionCount = 0;
                }
            }
            else
            {
                _lineRenderer.positionCount = 0;
            }
        }
        else
        {
            _lineRenderer.positionCount = 0;
        }

        // Check other player vision
        Collider[] victimColliders = Physics.OverlapSphere(transform.position, GameManager.Instance.HunterVision - 1f, 1 << 9);
        foreach (Collider victimCollider in victimColliders)
        {
            Player p = victimCollider.GetComponent <Player>();
            if (p == null)
            {
                continue;
            }
            LineRenderer line = p.GetComponent <LineRenderer>();

            bool inDistance = Vector3.Distance(transform.position, victimCollider.transform.position) <= p.Vision - 1f;
            line.startWidth    = .01f;
            line.endWidth      = .01f;
            line.startColor    = inDistance ? Color.magenta : Color.green;
            line.endColor      = inDistance ? Color.magenta : Color.green;
            line.positionCount = 2;
            line.SetPositions(new[] { transform.position + new Vector3(0f, 1f, 0f), victimCollider.transform.position + new Vector3(0f, 1f, 0f) });
        }
    }