コード例 #1
0
        public static void SetupRadarCamera()
        {
            if (radarRT && radarTex2D && radarCam && radarShader)
            {
                return;
            }

            //setup shader first
            if (!radarShader)
            {
                radarShader = BDAShaderLoader.LoadManifestShader("BahaTurret.UnlitBlack.shader");
            }

            //then setup textures
            radarRT    = new RenderTexture(radarResolution, radarResolution, 16);
            radarTex2D = new Texture2D(radarResolution, radarResolution, TextureFormat.ARGB32, false);

            //set up camera
            radarCam                 = (new GameObject("RadarCamera")).AddComponent <Camera>();
            radarCam.enabled         = false;
            radarCam.clearFlags      = CameraClearFlags.SolidColor;
            radarCam.backgroundColor = Color.white;
            radarCam.SetReplacementShader(radarShader, string.Empty);
            radarCam.cullingMask   = 1 << 0;
            radarCam.targetTexture = radarRT;
            //radarCam.nearClipPlane = 75;
            //radarCam.farClipPlane = 40000;
        }
コード例 #2
0
 void Awake()
 {
     if (!grayscaleMaterial)
     {
         grayscaleMaterial = new Material(BDAShaderLoader.LoadManifestShader("BahaTurret.GrayscaleEffectShader.shader"));
         grayscaleMaterial.SetTexture("_RampTex", textureRamp);
         grayscaleMaterial.SetFloat("_RampOffset", rampOffset);
     }
 }
コード例 #3
0
        void OnEnable()
        {
            startPosition    = transform.position;
            collisionEnabled = false;

            maxDistance = Mathf.Clamp(BDArmorySettings.PHYSICS_RANGE, 2500, BDArmorySettings.MAX_BULLET_RANGE);
            if (!wasInitiated)
            {
                //projectileColor.a = projectileColor.a/2;
                //startColor.a = startColor.a/2;
            }

            projectileColor.a = Mathf.Clamp(projectileColor.a, 0.25f, 1f);
            startColor.a      = Mathf.Clamp(startColor.a, 0.25f, 1f);
            currentColor      = projectileColor;
            if (fadeColor)
            {
                currentColor = startColor;
            }

            prevPosition = gameObject.transform.position;

            sourceOriginalV = sourceVessel.rb_velocity;

            if (!lightFlash)
            {
                lightFlash           = gameObject.AddComponent <Light>();
                light.type           = LightType.Point;
                lightFlash.range     = 8;
                lightFlash.intensity = 1;
            }
            lightFlash.color   = lightColor;
            lightFlash.enabled = true;


            //tracer setup
            if (!bulletTrail)
            {
                bulletTrail = gameObject.AddComponent <LineRenderer>();
            }
            if (!wasInitiated)
            {
                bulletTrail.SetVertexCount(2);
            }
            bulletTrail.SetPosition(0, transform.position);
            bulletTrail.SetPosition(1, transform.position);

            //float width = tracerStartWidth * Vector3.Distance(transform.position, FlightCamera.fetch.mainCamera.transform.position)/50;
            //bulletTrail.SetWidth(width, width);

            if (!shaderInitialized)
            {
                shaderInitialized = true;
                bulletShader      = BDAShaderLoader.LoadManifestShader("BahaTurret.BulletShader.shader");
            }

            if (!wasInitiated)
            {
                //bulletTrail.material = new Material(Shader.Find("KSP/Particles/Alpha Blended"));
                bulletTrail.material = new Material(bulletShader);

                randomWidthScale = UnityEngine.Random.Range(0.5f, 1f);
                gameObject.layer = 15;
            }

            bulletTrail.material.mainTexture = GameDatabase.Instance.GetTexture(bulletTexturePath, false);
            bulletTrail.material.SetColor("_TintColor", currentColor);
            bulletTrail.material.SetFloat("_Lum", tracerLuminance);

            tracerStartWidth *= 2f;
            tracerEndWidth   *= 2f;

            hasBounced = false;



            wasInitiated = true;

            StartCoroutine(FrameDelayedRoutine());
        }