Пример #1
0
        protected virtual void BuildLiquidMaterialsAndRegister()
        {
            if (color != Color.clear)
            {
                Material  mat = new Material(BaseObjects.originMaterial["Depth Water Ball"]);
                Texture2D tex = new Texture2D(1, 1);
                tex.SetPixel(0, 0, color);

                mat.SetTexture("_ColorRamp", tex);

                materials = mat.Group();

                GameObject inFX = EffectObjects.fxWaterAcquire.CreatePrefabCopy();
                inFX.name = inFX.name.Replace("(Clone)", "." + mainObject.Name);
                ParticleSystem part = inFX.GetComponent <ParticleSystem>();
                if (part != null)
                {
                    ParticleSystem.MainModule main = part.main;
                    main.startColor = color;
                }

                ParticleSystemRenderer render = inFX.FindChild("Water Glops").GetComponent <ParticleSystemRenderer>();
                if (render != null)
                {
                    render.sharedMaterials = materials;
                }

                foreach (ParticleSystem childPart in inFX.GetComponentsInChildren <ParticleSystem>())
                {
                    ParticleSystem.MainModule main = childPart.main;
                    main.startColor = color;
                }



                GameObject vacFailFX = EffectObjects.fxWaterVacFail.CreatePrefabCopy();
                vacFailFX.name = vacFailFX.name.Replace("(Clone)", "." + mainObject.Name);
                part           = vacFailFX.GetComponent <ParticleSystem>();
                if (part != null)
                {
                    ParticleSystem.MainModule main = part.main;
                    main.startColor = color;
                }

                foreach (ParticleSystem childPart in vacFailFX.GetComponentsInChildren <ParticleSystem>())
                {
                    ParticleSystem.MainModule main = childPart.main;
                    main.startColor = color;
                }

                destroyFX      = EffectObjects.fxWaterSplat.CreatePrefabCopy();
                destroyFX.name = destroyFX.name.Replace("(Clone)", "." + mainObject.Name);
                part           = destroyFX.GetComponent <ParticleSystem>();
                if (part != null)
                {
                    ParticleSystem.MainModule main = part.main;
                    main.startColor = color;
                }

                render = destroyFX.FindChild("Water Glops").GetComponent <ParticleSystemRenderer>();
                if (render != null)
                {
                    render.sharedMaterials = materials;
                }

                foreach (ParticleSystem childPart in destroyFX.GetComponentsInChildren <ParticleSystem>())
                {
                    ParticleSystem.MainModule main = childPart.main;
                    main.startColor = color;
                }

                LookupRegistry.RegisterLiquid(new LiquidDefinition()
                {
                    id        = ID,
                    inFX      = inFX,
                    vacFailFX = vacFailFX
                });
            }
            else
            {
                LookupRegistry.RegisterLiquid(new LiquidDefinition()
                {
                    id   = ID,
                    inFX = EffectObjects.fxWaterAcquire,

                    vacFailFX = EffectObjects.fxWaterVacFail
                });
            }
        }
Пример #2
0
    void Update()
    {
        if (Input.GetKeyDown(ReloadKey))
        {
            WeaponCodeScr.AnimComp.CrossFade("Reload");
            if (!AudioComponent.isPlaying)
            {
                AudioComponent.PlayOneShot(ReloadSound);
            }
            AmmoSize -= (CollarSize - Collar);
            Collar    = CollarSize;
            if (FlashlightLaserScr != null)
            {
                FlashlightLaserScr.LaserMove = true;
            }
        }
        if ((Input.GetKeyDown(OnBelt)) && (!Input.GetMouseButton(1)))
        {
            if (Safty == true)
            {
                Safty = false;
                AudioComponent.PlayOneShot(BeltOffSound);
            }
            else
            {
                Safty = true;
                AudioComponent.PlayOneShot(BeltOnSound);
            }
        }
        Belt();
        if (((Input.GetKey(CharacterScr.ForwardKey)) || (Input.GetKey(CharacterScr.BackwardKey)) || (Input.GetKey(CharacterScr.RightKey)) || (Input.GetKey(CharacterScr.LeftKey))) && (!WeaponCodeScr.AnimComp.IsPlaying("Reload")) && (!Input.GetMouseButton(0)))
        {
            WeaponCodeScr.AnimComp.CrossFade("Move");
            if (FlashlightLaserScr != null)
            {
                FlashlightLaserScr.LaserMove = true;
            }
        }
        else if ((!WeaponCodeScr.AnimComp.IsPlaying("Reload")) && (!WeaponCodeScr.AnimComp.IsPlaying("Sprint")))
        {
            WeaponCodeScr.AnimComp.CrossFade("Idle");
            if (Safty == false)
            {
                if (FlashlightLaserScr != null)
                {
                    FlashlightLaserScr.LaserMove = false;
                }
            }
        }
        if ((Input.GetKey(CharacterScr.ForwardKey)) && (Input.GetKey(CharacterScr.SprintLieKey)) && (!Input.GetKey(CharacterScr.SeatKey)) && (CharacterScr.Seat == false) && (!WeaponCodeScr.AnimComp.IsPlaying("Reload")) && (!Input.GetMouseButton(0)))
        {
            WeaponCodeScr.AnimComp.CrossFade("Sprint");
            if (FlashlightLaserScr != null)
            {
                FlashlightLaserScr.LaserMove = true;
            }
        }
        else if ((!WeaponCodeScr.AnimComp.IsPlaying("Reload")) && (!WeaponCodeScr.AnimComp.IsPlaying("Move")))
        {
            WeaponCodeScr.AnimComp.CrossFade("Idle");
            if (Safty == false)
            {
                if (FlashlightLaserScr != null)
                {
                    FlashlightLaserScr.LaserMove = false;
                }
            }
        }
        if (Input.GetMouseButtonDown(1))
        {
            WeaponCodeScr.AnimComp ["Idle"].speed = WeaponCodeScr.AnimComp ["Idle"].speed / 5;
        }
        if (Input.GetMouseButtonUp(1))
        {
            WeaponCodeScr.AnimComp ["Idle"].speed = WeaponCodeScr.AnimComp ["Idle"].speed * 5;
        }
        if (!Input.GetMouseButton(1))
        {
            if (Safty == false)
            {
                GunMove();
            }
            if (MainBone.transform.localPosition == StartPosition)
            {
                MainBone.transform.localPosition = StartPosition;
            }
        }
        else if ((!WeaponCodeScr.AnimComp.IsPlaying("Reload")) && (!Input.GetKeyDown(ReloadKey)) && (!Input.GetKey(CharacterScr.SprintLieKey)) && (!WeaponCodeScr.AnimComp.IsPlaying("Sprint")))
        {
            WeaponCodeScr.AnimComp.Play("Idle", PlayMode.StopAll);
            WeaponCodeScr.AnimComp.Stop("Shoot");
            WeaponCodeScr.AnimComp.Stop("Move");
            Safty = false;
            if (ScopeScr != null)
            {
                Vector3 NewPosition = new Vector3(WeaponCodeScr.AimNoScope.x, -Vector3.Distance(MainBone.transform.position, ScopeScr.AimBone.transform.position), WeaponCodeScr.AimNoScope.z);
                if (MainBone.transform.localPosition != NewPosition)
                {
                    MainBone.transform.localPosition = Vector3.Lerp(MainBone.transform.localPosition, NewPosition, Time.deltaTime * GunMoveX);
                }
                else
                {
                    MainBone.transform.localPosition = new Vector3(WeaponCodeScr.AimNoScope.x, -Vector3.Distance(MainBone.transform.position, ScopeScr.AimBone.transform.position), WeaponCodeScr.AimNoScope.z);
                }
            }
            else
            {
                if (MainBone.transform.localPosition != WeaponCodeScr.AimNoScope)
                {
                    MainBone.transform.localPosition = Vector3.Lerp(MainBone.transform.localPosition, WeaponCodeScr.AimNoScope, Time.deltaTime * GunMoveX);
                }
                else
                {
                    MainBone.transform.localPosition = WeaponCodeScr.AimNoScope;
                }
            }
            if (MainBone.transform.localRotation != Quaternion.Euler(StartRotation))
            {
                MainBone.transform.localRotation = Quaternion.Lerp(MainBone.transform.localRotation, Quaternion.Euler(StartRotation), Time.deltaTime * GunMoveX);
            }
            else
            {
                MainBone.transform.localRotation = Quaternion.Euler(StartRotation);
            }
        }
        if ((Input.GetKeyDown(SwitchKey)) && (!Input.GetMouseButton(0)))
        {
            AudioComponent.PlayOneShot(SwitchSound);
            if (UsingMod < (ModsOfShooting))
            {
                UsingMod++;
                WeaponCodeScr.AnimComp["Shoot"].speed = WeaponCodeScr.AnimComp["Shoot"].length / (ShootTime / 1.5f);
            }
            else
            {
                UsingMod = 1;
                WeaponCodeScr.AnimComp["Shoot"].speed = OriginSpeed;
            }
        }
        ParticleSystem.MainModule TParticleMain = SmokeParticle.GetComponent <ParticleSystem> ().main;
        if (Input.GetMouseButton(0))
        {
            Safty = false;
            switch (UsingMod)
            {
            case 2: {
                MouseTimer += Time.deltaTime;
                TParticleMain.startColor = new Color(30f, 30f, 30f, SmokeFactor * MouseTimer);
                TimeDelay = ShootTime;
                if (FirstShoot == false)
                {
                    Timer      = TimeDelay;
                    FirstShoot = true;
                }
                Timer += Time.deltaTime;
                if (Timer >= TimeDelay)
                {
                    Shoot();
                    Timer = 0;
                }
                else
                {
                    ShootParticle.GetComponent <MuzzleFlash> ().MuzzleFlashParticle.Stop();
                    ShootParticle.SetActive(false);
                }
                break;
            }

            case 1: {
                TParticleMain.startColor = new Color(30f, 30f, 30f, SmokeFactor);
                if (ShootBool == false)
                {
                    Shoot();
                    if (Collar > 0)
                    {
                        SmokeParticle.transform.position = ShootParticle.transform.position;
                        SmokeParticle.SetActive(true);
                        SmokeParticle.GetComponent <ParticleSystem> ().Play();
                    }
                    ShootBool = true;
                }
                else
                {
                    ShootParticle.GetComponent <MuzzleFlash> ().MuzzleFlashParticle.Stop();
                    ShootParticle.SetActive(false);
                }
                break;
            }

            case 3: {
                TParticleMain.startColor = new Color(30f, 30f, 30f, SmokeFactor * ShootTime * 3);
                if (i < 3)
                {
                    TimeDelay = ShootTime;
                    if (i < 1)
                    {
                        Timer = TimeDelay;
                    }
                    else
                    {
                        Timer += Time.deltaTime;
                    }
                    if (Timer >= TimeDelay)
                    {
                        Shoot();
                        Timer = 0;
                        i++;
                    }
                    if ((i == 2) && (Collar > 0))
                    {
                        SmokeParticle.transform.position = ShootParticle.transform.position;
                        SmokeParticle.SetActive(true);
                        SmokeParticle.GetComponent <ParticleSystem> ().Play();
                    }
                }
                else
                {
                    ShootParticle.GetComponent <MuzzleFlash> ().MuzzleFlashParticle.Stop();
                    ShootParticle.SetActive(false);
                }
                break;
            }
            }
            if (Collar == 0)
            {
                ShootBool = false;
                ShootParticle.SetActive(false);
                if (UsingMod == 1)
                {
                    FirstShoot = false;
                }
            }
        }
        else
        {
            i         = 0;
            Timer     = 0;
            TimeDelay = 0;
            ShootBool = false;
            ShootParticle.SetActive(false);
            if ((Input.GetMouseButtonUp(0)) && (Collar > 0) && (UsingMod == 1))
            {
                FirstShoot = false;
                SmokeParticle.transform.position = ShootParticle.transform.position;
                SmokeParticle.SetActive(true);
                SmokeParticle.GetComponent <ParticleSystem> ().Play();
            }
            if (SmokeParticle.GetComponent <ParticleSystem>().isStopped)
            {
                SmokeParticle.SetActive(false);
            }
        }
    }
Пример #3
0
 private void ChangeStartLifetimeAndDurationOfPs(ParticleSystem ps, float castingSpeed)
 {
     ParticleSystem.MainModule temp = ps.main;
     temp.startLifetime = castingSpeed / 2;
     temp.duration      = castingSpeed / 2;
 }
Пример #4
0
 public void ChangeColor(e_stats _key)
 {
     ParticleSystem.MainModule main = explosion.main;
     main.startColor = GameplayManager.Instance.Data.GetColor(_key);
 }
Пример #5
0
        protected bool Initialize()
        {
            // initialize members
            if (_transform == null)
            {
                _transform = transform;
            }
            if (pSystem == null)
            {
                pSystem = GetComponent <ParticleSystem>();

                if (pSystem == null)
                {
                    return(false);
                }

#if UNITY_5_5_OR_NEWER
                mainModule = pSystem.main;
                if (pSystem.main.maxParticles > 14000)
                {
                    mainModule.maxParticles = 14000;
                }
#else
                if (pSystem.maxParticles > 14000)
                {
                    pSystem.maxParticles = 14000;
                }
#endif

                pRenderer = pSystem.GetComponent <ParticleSystemRenderer>();
                if (pRenderer != null)
                {
                    pRenderer.enabled = false;
                }

                //Shader foundShader = Shader.Find("UI Extensions/Particles/Additive");
                Shader   foundShader = Shader.Find("UI/Default");
                Material pMaterial   = new Material(foundShader);

                if (material == null)
                {
                    material = pMaterial;
                }

                currentMaterial = material;
                if (currentMaterial && currentMaterial.HasProperty("_MainTex"))
                {
                    currentTexture = currentMaterial.mainTexture;
                    if (currentTexture == null)
                    {
                        currentTexture = Texture2D.whiteTexture;
                    }
                }
                material = currentMaterial;
                // automatically set scaling
#if UNITY_5_5_OR_NEWER
                mainModule.scalingMode = ParticleSystemScalingMode.Hierarchy;
#else
                pSystem.scalingMode = ParticleSystemScalingMode.Hierarchy;
#endif

                particles = null;
            }
#if UNITY_5_5_OR_NEWER
            if (particles == null)
            {
                particles = new ParticleSystem.Particle[pSystem.main.maxParticles];
            }
#else
            if (particles == null)
            {
                particles = new ParticleSystem.Particle[pSystem.maxParticles];
            }
#endif

            imageUV = new Vector4(0, 0, 1, 1);

            // prepare texture sheet animation
            textureSheetAnimation          = pSystem.textureSheetAnimation;
            textureSheetAnimationFrames    = 0;
            textureSheetAnimationFrameSize = Vector2.zero;
            if (textureSheetAnimation.enabled)
            {
                textureSheetAnimationFrames    = textureSheetAnimation.numTilesX * textureSheetAnimation.numTilesY;
                textureSheetAnimationFrameSize = new Vector2(1f / textureSheetAnimation.numTilesX, 1f / textureSheetAnimation.numTilesY);
            }

            return(true);
        }
Пример #6
0
        private void Start()
        {
            AudioSource source = gameObject.AddComponent <AudioSource>();

            source.clip        = Res.ResourceLoader.instance.LoadedAudio[1000];
            source.volume      = 16;
            source.rolloffMode = AudioRolloffMode.Linear;
            source.maxDistance = 100;
            source.Play();
            if (particleMaterial == null)
            {
                particleMaterial = Core.CreateMaterial(new BuildingData()
                {
                    MainTexture = Res.ResourceLoader.instance.LoadedTextures[22],
                    Metalic     = 0.2f,
                    Smoothness  = 0.6f,
                    renderMode  = BuildingData.RenderMode.Cutout
                });
            }
            Destroy(gameObject, duration);
            if (!FromEnemy && !GameSetup.IsMpClient)
            {
                CoughtEnemies = new List <Transform>();
            }
            if (GameSetup.IsMpClient)
            {
                if (col != null)
                {
                    Destroy(col);
                }
            }
            else
            {
                col           = gameObject.AddComponent <SphereCollider>();
                col.radius    = radius;
                col.isTrigger = true;
            }
            scale      = 0;
            particleGO = new GameObject("BlackHoleParticles");
            particleGO.transform.position = transform.position;
            particleGO.transform.SetParent(transform);
            sys = particleGO.AddComponent <ParticleSystem>();
            ParticleSystem.ShapeModule shape = sys.shape;
            shape.shapeType = ParticleSystemShapeType.SphereShell;
            shape.radius    = radius * 2;
            //shape.radiusMode = ParticleSystemShapeMultiModeValue.Random;
            //shape.length = 0;
            ParticleSystem.MainModule main = sys.main;
            main.startSpeed    = -radius * 4;
            main.startLifetime = 0.5f;
            main.loop          = true;
            main.prewarm       = false;
            main.startSize     = 0.4f;
            main.maxParticles  = 500;

            ParticleSystem.EmissionModule emission = sys.emission;
            emission.enabled      = true;
            emission.rateOverTime = 500;
            Renderer rend = sys.GetComponent <Renderer>();

            rend.material = particleMaterial;

            WindZone wz = gameObject.AddComponent <WindZone>();

            wz.radius   = radius * 2;
            wz.mode     = WindZoneMode.Spherical;
            wz.windMain = 40;

            StartCoroutine(HitEverySecond());
        }
Пример #7
0
            static void BuildWallSegment(Vector3 position1, Vector3 position2, string effectName, string spellId, float lifeTime, float enlargeTime, float secondsDelayStart, float shrinkTime, float rotation, float distanceBetweenWallEffectsFeet, ref float availableWallLength, ref float gapSoFar, ref float totalWallBuiltSoFarFeet)
            {
                if (availableWallLength <= 0)
                {
                    return;
                }

                Vector3 delta = position2 - position1;
                float   totalDistanceThisSegmentTiles = Math.Abs(delta.magnitude);
                Vector3 normalizedDelta = delta.normalized;

                float distanceToNextEffectTiles = 0;

                float   distanceBetweenWallEffectsTiles = Convert.FeetToTiles(distanceBetweenWallEffectsFeet);
                Vector3 targetPointToLookAt             = position1 + delta * distanceBetweenWallEffectsTiles * 2;

                if (gapSoFar > 0)
                {
                    distanceToNextEffectTiles += distanceBetweenWallEffectsTiles;
                }
                else
                {
                    availableWallLength       -= distanceBetweenWallEffectsFeet / 2;
                    distanceToNextEffectTiles += distanceBetweenWallEffectsTiles / 2;
                }

                Log.Debug($"BuildWallSegment: availableWallLength: {availableWallLength}");
                while (availableWallLength > 0)
                {
                    Vector3 yOffset  = new Vector3(0, RandomRange(-0.01f, 0.01f), 0);
                    Vector3 position = position1 + normalizedDelta * (distanceToNextEffectTiles - gapSoFar) + yOffset;
                    Log.Debug($"position: {position}");
                    const float feetPerSecond = 60f;

                    Action <GameObject> rotateAndVary = (gameObject) => {
                        ParticleSystem[] particleSystems = gameObject.GetComponentsInChildren <ParticleSystem>(true);
                        foreach (ParticleSystem particleSystem in particleSystems)
                        {
                            ParticleSystem.MainModule main = particleSystem.main;
                            main.simulationSpeed *= RandomRange(0.9f, 1.1f);
                            //particleSystem.randomSeed = (uint)UnityEngine.Random.value * 100000;
                        }
                        if (rotation == 0 || rotation == -1)
                        {
                            // rotate effect to line-up between the two ruler points:
                            Vector3 saveEulerAngles = gameObject.transform.localEulerAngles;
                            float   degreesOffset   = 0;
                            if (rotation == -1)
                            {
                                degreesOffset = RandomRange(0, 360);
                            }
                            gameObject.transform.LookAt(targetPointToLookAt);
                            gameObject.transform.localEulerAngles = new Vector3(saveEulerAngles.x, gameObject.transform.localEulerAngles.y + degreesOffset, saveEulerAngles.z);
                        }
                    };

                    PlayEffectAtPosition(effectName, spellId, position, lifeTime, enlargeTime, secondsDelayStart + totalWallBuiltSoFarFeet / feetPerSecond, shrinkTime, 0, false, rotateAndVary);
                    totalWallBuiltSoFarFeet += distanceBetweenWallEffectsFeet;


                    distanceToNextEffectTiles += distanceBetweenWallEffectsTiles;
                    if (distanceToNextEffectTiles - gapSoFar > totalDistanceThisSegmentTiles)
                    {
                        gapSoFar = Math.Abs((position2 - position).magnitude);
                        Log.Debug($"gapSoFar: {gapSoFar}");
                        break;
                    }
                    availableWallLength -= distanceBetweenWallEffectsFeet;
                    Log.Debug($"availableWallLength: {availableWallLength}");
                }

                availableWallLength -= distanceBetweenWallEffectsFeet;
            }
Пример #8
0
        static bool InteractionHighlight_Update_Pre(InteractionHighlight __instance)
        {
            #region quit
            if (!_highlightsToggle ||
                !__instance.m_renderer.TryAs(out ParticleSystemRenderer renderer) ||
                !renderer.GetComponent <ParticleSystem>().TryAssign(out var particleSystem))
            {
                return(true);
            }
            #endregion

            if (Time.renderedFrameCount % HIGHLIGHT_UPDATE_DURATION != 0 || renderer.enabled == __instance.ShouldShowHighlight())
            {
                return(false);
            }

            // Cache
            ParticleSystem.MainModule main = particleSystem.main;
            float intensity = _highlightsIntensity / 100f;
            Color newColor  = Color.white;

            // Choose color
            if (_highlightsColored)
            {
                newColor = HIGHLIGHT_COLOR_INTERACTION;
                if (__instance.TryAs(out ItemHighlight itemHighlight))
                {
                    newColor = HIGHLIGHT_COLOR_OTHER_ITEM;
                    if (itemHighlight.Item.TryAssign(out var item))
                    {
                        if (item is Equipment)
                        {
                            newColor = HIGHLIGHT_COLOR_EQUIP;
                        }
                        else if (item is ItemContainer)
                        {
                            newColor = HIGHLIGHT_COLOR_INTERACTION;
                        }
                        else if (item.IsIngestible())
                        {
                            newColor = HIGHLIGHT_COLOR_INGESTIBLE;
                        }
                    }
                }
            }

            // Apply intensity
            if (intensity <= 1)
            {
                newColor.a       *= intensity;
                main.maxParticles = intensity.MapFrom01(1, HIGHLIGHT_MAX_PARTICLES).Round();
                particleSystem.transform.localScale = Vector3.one;
            }
            else
            {
                intensity        -= 1;
                main.maxParticles = intensity.MapFrom01(1, 4).Mul(HIGHLIGHT_MAX_PARTICLES).Round();
                particleSystem.transform.localScale = intensity.MapFrom01(1, 1.5f).ToVector3();
            }

            // Apply color
            main.startColor = newColor;

            // Apply distance
            if (particleSystem.GetComponent <DisableParticlesWhenFar>().TryAssign(out var disableParticlesWhenFar))
            {
                disableParticlesWhenFar.m_sqrDist = _highlightsDistance.Value.Pow(2);
            }

            // Finalize
            renderer.enabled = !renderer.enabled;
            return(false);
        }
Пример #9
0
 private void Start()
 {
     this.ps = (ParticleSystem)((Component)this).GetComponent <ParticleSystem>();
     ParticleSystem.MainModule main = this.ps.get_main();
     this.particles = new ParticleSystem.Particle[((ParticleSystem.MainModule) ref main).get_maxParticles()];
Пример #10
0
        protected override void DoLevel()
        {
            ColorDriver colorDriver = (sharedDriver != null) ? (ColorDriver)sharedDriver : this;

            int      i        = 0;
            Material material = null;
            float    v        = 0.0f;

            if (!ps && !vertexColor)
            {
                i        = Mathf.Min(colorDriver.materialIndex, materials.Length - 1);
                material = materials[i];
            }

            float level = LevelScalar();

            Color mainColor    = Color.white;
            Color restingColor = Color.black;

            if (colorDriver.stationaryToggle && !vertexColor)
            {
                if (colorDriver.colorMode == ColorMode.Frequency)
                {
                    v = base.level.linearizedFrequency;
                }
                else
                {
                    v = base.level.normalizedLevel;
                }

                if (level >= base.level.normalizedLevel)
                {
                    mainColor = Color.Lerp(colorDriver.restingColor.Evaluate(v), colorDriver.mainColor.Evaluate(v), level);
                }
                else
                {
                    mainColor = colorDriver.restingColor.Evaluate(v);
                }
            }
            else
            {
                switch (colorDriver.colorMode)
                {
                case ColorMode.Magnitude:
                    mainColor    = colorDriver.mainColor.Evaluate(level);
                    restingColor = colorDriver.restingColor.Evaluate(level);

                    break;

                case ColorMode.Frequency:
                    v = base.level.linearizedFrequency;

                    if (vertexColor)
                    {
                        mainColor    = colorDriver.mainColor.Evaluate(v);
                        restingColor = colorDriver.restingColor.Evaluate(v);
                    }
                    else
                    {
                        mainColor = Color.Lerp(colorDriver.restingColor.Evaluate(v), colorDriver.mainColor.Evaluate(v), level);
                    }

                    break;
                }
            }

            if (ps)
            {
                ParticleSystem.MainModule module = ps.main;
                module.startColor = mainColor;
            }
            else if (material)
            {
                material.SetColor(colorID, mainColor);
            }
            else if (vertexColor)
            {
                vertexColor.mainColor    = mainColor;
                vertexColor.restingColor = restingColor;
            }
        }
Пример #11
0
    // Update is called once per frame
    void Update()
    {
        float currentTime = Time.time - startTime;

        if (transform.childCount > 0)
        {
            LineRenderer lineRenderer = transform.GetChild(0).gameObject.GetComponent <LineRenderer>();
            lineRenderer.SetPosition(0, transform.position);

            length = maxLength;

            if (currentTime < maxLength / speed)
            {
                length = speed * currentTime;
            }

            endPos.transform.localPosition = new Vector3(0, 0, 0);
            endPos.transform.Translate(direction.normalized * length, Space.Self);

            RaycastHit hit;

            if (Physics.Raycast(transform.position, transform.forward, out hit, length))
            {
                if (!hit.collider.isTrigger)
                {
                    lineRenderer.SetPosition(1, hit.point);

                    hitEffect.SetActive(true);
                    hitEffect.transform.position = hit.point;
                    hitEffect.transform.rotation = Quaternion.LookRotation(hit.normal);
                }
                else
                {
                    lineRenderer.SetPosition(1, endPos.transform.position);

                    hitEffect.SetActive(false);
                }
            }

            else
            {
                lineRenderer.SetPosition(1, endPos.transform.position);

                hitEffect.SetActive(false);
            }

            GameObject glow = transform.GetChild(1).gameObject;
            glow.transform.localRotation = Quaternion.LookRotation(direction);

            lineRenderer.startWidth = Mathf.Clamp(0.5f * WidthOverTime.Evaluate(currentTime / duration) - 0.2f, 0.0f, 1.0f);
            lineRenderer.endWidth   = Mathf.Clamp(0.5f * WidthOverTime.Evaluate(currentTime / duration) - 0.2f, 0.0f, 1.0f);

            ParticleSystem.MainModule _haloMain = _halo.main;
            _haloMain.startSize = Random.Range(1.25f, 1.5f) * WidthOverTime.Evaluate(currentTime / duration);

            ParticleSystem.MainModule _hitGlowMain = _hitGlow.main;
            _hitGlowMain.startSize = Random.Range(0.15f, 0.25f) * WidthOverTime.Evaluate(currentTime / duration);

            ParticleSystem.EmissionModule _hitSparkEmission = _hitSpark.emission;
            _hitSparkEmission.rateOverTime = 25 * WidthOverTime.Evaluate(currentTime / duration);
        }
    }
Пример #12
0
 private void Awake()
 {
     pMain           = GetComponent <ParticleSystem>().main;
     pSystem         = GetComponent <ParticleSystem>();
     collisionEvents = new List <ParticleCollisionEvent>();
 }
Пример #13
0
    protected override void update()
    {
        bool canReclaim = true;

        if (fadeOut)
        {
            for (int i = 0; i < particles.Length; i++)
            {
                ParticleSystem.MainModule main = particles[i].main;
                Color color = main.startColor.color;
                color.a -= Time.deltaTime / 2f;
                if (color.a > 0)
                {
                    canReclaim = false;
                }
                main.startColor = color;
            }

            if (canReclaim)
            {
                GameObject.Destroy(gameObject);
            }
            return;
        }


        float nowTime = Time.timeSinceLevelLoad;

        if (time > 0)
        {
            float reallyLifeTime = time;
            if (nowTime - startTime < reallyLifeTime)
            {
                canReclaim = false;
            }
        }
        else
        {
            if (particles.Length == 0)
            {
                return;
            }
            for (int i = 0; i < particles.Length; i++)
            {
                ParticleSystem            particle = particles[i];
                ParticleSystem.MainModule main     = particles[i].main;
                if (main.loop == false && main.duration + 3f < nowTime - startTime && !particle.isStopped)
                {
                    particle.Stop();
                }

                if (particle.isStopped == false)
                {
                    canReclaim = false;
                }
            }
        }

        if (canReclaim)
        {
            stop();
        }
    }
Пример #14
0
 void Awake()
 {
     activationGlowModule = activationGlow.main;
 }
Пример #15
0
 public void changeSpeed(int particle, float newSpeed)
 {
     //.simulationSpeed = newSpeed;
     ParticleSystem.MainModule mainParticleSystem = particlePoolManager.singleton.getSpecificParticle(particle).GetComponent <ParticleSystem>().main;
     mainParticleSystem.simulationSpeed = newSpeed;
 }
    public void UpdateLaserBeamLevel()
    {
        if (HasLaserBeamWS)
        {
            // Update Laser Firing SoundFX
            if (LaserBeamFiringSFX != null)
            {
                LaserBeamFiringSFX.clip = LaserFireSoundFXs[laserBeamLevelNum];
            }

            // Set the Outer Laser Beam Materials
            LaserBeamWSScript.OuterLaserLineRender.material = OuterLaserBeamMaterials[laserBeamLevelNum];

            // Set the Inner Laser Beam Materials
            LaserBeamWSScript.InnerLaserLineRender.material = InnerLaserBeamMaterials[laserBeamLevelNum];

            // Set Laser Beam Grow Speed
            float growSpeed = 0.75f + (0.25f * laserBeamLevelNum);
            LaserBeamWSScript.LaserGrowSpeed = growSpeed;

            // Set Inner and Outer Tile Amounts
            float innerTileAmount = 1 + laserBeamLevelNum;
            LaserBeamWSScript.innerLaserTileAmount = innerTileAmount;
            float outerTileAmount = 1 + laserBeamLevelNum;
            LaserBeamWSScript.outerLaserTileAmount = outerTileAmount;
            LaserBeamWSScript.UpdateLaserBeamTiling();

            // Update Laser Beam Recharge Speed by Level Number
            LaserBeamWSScript.LaserRechargeTime = 1.0f - (0.025f * laserBeamLevelNum);

            // Update Laser Beam Color Based on Level Number
            LaserBeamWSScript.LaserBeamColor = LaserBeamLevelColors[laserBeamLevelNum];
            if (LaserBeamWSScript.TurretColorRender != null)
            {
                LaserBeamWSScript.TurretColorRender.material.color = LaserBeamLevelColors[laserBeamLevelNum];
            }

            // Update Firing and Hit Particle Size Based On Level
            float firingParticleSize = 1.25f + (0.1f * laserBeamLevelNum);
            LaserBeamWSScript.FiringParticleSize = firingParticleSize;
            float hitParticleSize = 2.0f + LBTargetHitSizes[laserBeamLevelNum];
            LaserBeamWSScript.HitParticleSize = hitParticleSize;

            // Update Level Color Indicators
            LaserBeamWSScript.UpdateLevelIndicators(laserBeamLevelNum, LaserBeamLevelColors[laserBeamLevelNum]);

            // Update Firing Particle Materials Based on Laser Beam Level
            LaserBeamWSScript.LaserFireCenterEmitter.GetComponent <Renderer>().material = LBStartPartMaterials[laserBeamLevelNum];
            ParticleSystem.MainModule mainModule = LaserBeamWSScript.LaserFireCenterEmitter.main;
            mainModule.startSpeed = 1 + (0.25f * laserBeamLevelNum);

            // Update Laser Hit Particle Materials Based on Laser Beam Level
            LaserBeamWSScript.TargetHitEmitter.GetComponent <Renderer>().material = LBTargetHitMaterials[laserBeamLevelNum];
            ParticleSystem.MainModule hitEmitterModule = LaserBeamWSScript.TargetHitEmitter.main;
            hitEmitterModule.startSize = 2 + (0.5f * laserBeamLevelNum);

            // Update Beam Width Based on Laser Level Num
            float outerWidth = 0.65f;            // + (0.025f * laserBeamLevelNum);
            float innerWidth = 0.5f + (0.05f * laserBeamLevelNum);
            LaserBeamWSScript.OuterLaserStartWidth = outerWidth;
            LaserBeamWSScript.OuterLaserEndWidth   = outerWidth;
            LaserBeamWSScript.InnerLaserStartWidth = innerWidth;
            LaserBeamWSScript.InnerLaserEndWidth   = innerWidth;

            // Update Beam Damage Based on Laser Level Num
            float laserBeamDamage         = 5 + (5 * laserBeamLevelNum);
            float laserBeamDamageOverTime = 2 + (2 * laserBeamLevelNum);
            LaserBeamWSScript.LaserDamage          = laserBeamDamage;
            LaserBeamWSScript.LaserDamagePerSecond = laserBeamDamageOverTime;

            if (CurrentLaserBeamLevel == LaserBeamLevelTypes.Level1)
            {
                // Change Laser Beam Graphics


                // Change Laser Beam Stats
                LaserBeamWSScript.LaserDamage = 10;
            }
        }
    }
        public static void EnforceRealtimeParticleSystemLimits(Dictionary <ParticleSystem, int> particleSystems, bool includeDisabled = false, bool stopSystems = true)
        {
            float          totalEmission = 0;
            ParticleSystem ps            = null;
            int            max           = 0;
            int            em_penalty    = 1;

            ParticleSystem.EmissionModule em;
            float emission = 0;

            ParticleSystem.Burst[] bursts;

            foreach (KeyValuePair <ParticleSystem, int> kp in particleSystems)
            {
                if (kp.Key == null)
                {
                    continue;
                }

                if (!kp.Key.isPlaying && !includeDisabled)
                {
                    continue;
                }

                ps         = kp.Key;
                max        = kp.Value;
                em_penalty = 1;
                if (ps.collision.enabled)
                {
                    // particle force is always restricted (not dependent on ps_limiter_enabled)
                    var restrictedCollision = ps.collision;
                    restrictedCollision.colliderForce = ps_max_particle_force;

                    if (ps_limiter_enabled)
                    {
                        switch (ps.collision.quality)
                        {
                        case ParticleSystemCollisionQuality.High:
                            max         = max / ps_collision_penalty_high;
                            em_penalty += 3;
                            break;

                        case ParticleSystemCollisionQuality.Medium:
                            max         = max / ps_collision_penalty_med;
                            em_penalty += 2;
                            break;

                        case ParticleSystemCollisionQuality.Low:
                            max         = max / ps_collision_penalty_low;
                            em_penalty += 2;
                            break;
                        }
                    }
                }
                if (ps_limiter_enabled && ps.trails.enabled)
                {
                    max         = max / ps_trails_penalty;
                    em_penalty += 3;
                }
                if (ps_limiter_enabled && ps.emission.enabled)
                {
                    em        = ps.emission;
                    emission  = 0;
                    emission += GetCurveMax(em.rateOverTime);
                    emission += GetCurveMax(em.rateOverDistance);

                    bursts = new ParticleSystem.Burst[em.burstCount];
                    em.GetBursts(bursts);
                    for (int i = 0; i < bursts.Length; i++)
                    {
                        float adjMax = bursts[i].repeatInterval > 1 ? bursts[i].maxCount : bursts[i].maxCount * bursts[i].repeatInterval;
                        if (adjMax > ps_max_emission)
                        {
                            bursts[i].maxCount = (short)Mathf.Clamp(adjMax, 0, ps_max_emission);
                        }
                    }
                    em.SetBursts(bursts);

                    emission      *= em_penalty;
                    totalEmission += emission;
                    if ((emission > ps_max_emission || totalEmission > ps_max_total_emission) && stopSystems)
                    {
                        kp.Key.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
                        // Debug.LogWarning("Particle system named " + kp.Key.gameObject.name + " breached particle emission limits, it has been stopped");
                    }
                }
                if (ps_limiter_enabled && ps.main.maxParticles > Mathf.Clamp(max, 1, kp.Value))
                {
                    ParticleSystem.MainModule psm = ps.main;
                    psm.maxParticles = Mathf.Clamp(psm.maxParticles, 1, max);
                    if (stopSystems)
                    {
                        kp.Key.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
                    }
                    Debug.LogWarning("Particle system named " + kp.Key.gameObject.name + " breached particle limits, it has been limited");
                }
            }
        }
Пример #18
0
    void OnTriggerEnter(Collider col)
    {
        /* CHECKS FOR HIT VALIDIDTY */
        if (hasHit && dieOnHit)
        {
            return;                     // We only want to hit one object... for some reason it collides multiple times before destroying itself
        }
        if (col.isTrigger)
        {
            return;                // Only want our own trigger effects
        }
        PlayerStats ps;

        if (!sourcePlayer)
        {
            return;                // Shouldn't collide with anything that isn't a source player
        }
        if ((ps = col.GetComponentInParent <PlayerStats>()))
        {
            if (ps.gameObject == sourcePlayer.gameObject)
            {
                return;
            }
            if (!hitSameTeam && ps.teamIndex == sourcePlayer.GetComponent <PlayerStats>().teamIndex&& ps.teamIndex != -1)
            {
                return;                                                                                                           // dont hit players on same team
            }
        }
        /* ACTIONS TO TAKE POST-HIT */

        hasHit = true;
        Rigidbody myRigid = this.GetComponent <Rigidbody> ();

        if (col.GetComponentInParent <IHittable>() != null)
        {
            //Debug.DrawLine(transform.position, new Vector3((transform.position.x - col.transform.position.x) * -5 + col.transform.position.x, transform.position.y, (transform.position.z - col.transform.position.z) * -5 + col.transform.position.z), Color.blue, 10f);
            //Debug.DrawLine(new Vector3(transform.position.x, transform.position.y, transform.position.z), new Vector3(transform.position.x, transform.position.y, transform.position.z) - myRigid.velocity, Color.red, 10f);
            HitManager.HitClientside(HitManager.HitVerificationMethod.projectile, new HitArguments(((Component)col.gameObject.GetComponentInParent <IHittable>()).gameObject, sourcePlayer.GetComponentInParent <PlayerStats>().gameObject)
                                     .withDamage(damage)
                                     .withDamageType(damageType)
                                     .withEffect(effect)
                                     .withEffectDuration(effectDuration)
                                     .withSourcePosition(new Vector3((transform.position.x - col.transform.position.x) * -5 + col.transform.position.x, (transform.position.z - col.transform.position.z) * -5 + col.transform.position.z))
                                     .withHitSameTeam(hitSameTeam));
        }

        if (dieOnHit)
        {
            if (explodeParticles)
            {
                trailParticles.Stop();
                ParticleSystem.MainModule m = trailParticles.main;
                m.loop = false;
                trailParticles.transform.parent = null;
                GameObject spawn = GameObject.Instantiate(explodeParticles, transform.position, Quaternion.identity);
                Explosion  e;
                if ((e = spawn.GetComponent <Explosion>()))
                {
                    e.sourcePlayer = sourcePlayer;
                }
            }
            Destroy(this.gameObject);
        }
    }
 void Start()
 {
     particleSystem           = GetComponent <ParticleSystem>();
     particleSystemMainModule = particleSystem.main;
 }
Пример #20
0
 private void LaserBeamSmoothEmission()
 {
     if ((laserTimer >= 0.5f) & (laserTimer <= 1))
     {
         ParticleSystem.MainModule m = particlelauncher.main;
         m.maxParticles = 300;
     }
     else if ((laserTimer >= 1) & (laserTimer <= 1.5f))
     {
         ParticleSystem.MainModule m = particlelauncher.main;
         m.maxParticles = 400;
     }
     else if ((laserTimer >= 2) & (laserTimer <= 2.5f))
     {
         ParticleSystem.MainModule m = particlelauncher.main;
         m.maxParticles = 550;
     }
     else if ((laserTimer >= 3) & (laserTimer <= 3.5f))
     {
         ParticleSystem.MainModule m = particlelauncher.main;
         m.maxParticles = 600;
     }
     else if ((laserTimer >= 4) & (laserTimer <= 4.5f))
     {
         ParticleSystem.MainModule m = particlelauncher.main;
         m.maxParticles = 575;
     }
     else if ((laserTimer >= 9) & (laserTimer <= 10))
     {
         ParticleSystem.MainModule m = particlelauncher.main;
         m.maxParticles = 550;
     }
     else if ((laserTimer >= 11) & (laserTimer <= 12))
     {
         ParticleSystem.MainModule m = particlelauncher.main;
         m.maxParticles = 525;
     }
     else if ((laserTimer >= 13) & (laserTimer <= 14))
     {
         ParticleSystem.MainModule m = particlelauncher.main;
         m.maxParticles = 500;
     }
     else if ((laserTimer >= 15) & (laserTimer <= 16))
     {
         ParticleSystem.MainModule m = particlelauncher.main;
         m.maxParticles = 475;
     }
     else if ((laserTimer >= 17) & (laserTimer <= 18))
     {
         ParticleSystem.MainModule m = particlelauncher.main;
         m.maxParticles = 455;
     }
     else if ((laserTimer >= 19) & (laserTimer <= 20))
     {
         ParticleSystem.MainModule m = particlelauncher.main;
         m.maxParticles = 425;
     }
     else if ((laserTimer >= 21) & (laserTimer <= 22))
     {
         ParticleSystem.MainModule m = particlelauncher.main;
         m.maxParticles = 400;
     }
 }
Пример #21
0
    //-------------------------------------------------------------------
    private void ParticleColor()
    {
        switch (colorNumber)
        {
        case 0:
            if (!colorChangeFlag[0])
            {
                colorR += 0.01f;
                if (colorR > 0.5f)
                {
                    colorR             = 1f;
                    colorChangeFlag[0] = true;
                    colorNumber        = 1;
                }
            }
            else if (colorChangeFlag[0])
            {
                colorR -= 0.01f;
                if (colorR < 0)
                {
                    colorR             = 0f;
                    colorChangeFlag[0] = false;
                    colorNumber        = 2;
                }
            }
            break;

        case 1:
            if (!colorChangeFlag[1])
            {
                colorG += 0.01f;
                if (colorG > 0.5f)
                {
                    colorG             = 1f;
                    colorChangeFlag[1] = true;
                    colorNumber        = 0;
                }
            }
            else if (colorChangeFlag[1])
            {
                colorG -= 0.01f;
                if (colorG < 0)
                {
                    colorG             = 0f;
                    colorChangeFlag[1] = false;
                    colorNumber        = 2;
                }
            }
            break;

        case 2:
            if (!colorChangeFlag[2])
            {
                colorB += 0.01f;
                if (colorB > 0.5f)
                {
                    colorB             = 1f;
                    colorChangeFlag[2] = true;
                    colorNumber        = 0;
                }
            }
            else if (colorChangeFlag[2])
            {
                colorB -= 0.01f;
                if (colorB < 0)
                {
                    colorB             = 0f;
                    colorChangeFlag[2] = false;
                    colorNumber        = 1;
                }
            }
            break;
        }

        GradientColorKey[] gradientColorKeyMin;
        gradientColorKeyMin          = new GradientColorKey[3];
        gradientColorKeyMin[0].color = Color.red;
        gradientColorKeyMin[0].time  = colorR;
        gradientColorKeyMin[1].color = Color.blue;
        gradientColorKeyMin[1].time  = colorG;
        gradientColorKeyMin[2].color = Color.green;
        gradientColorKeyMin[2].time  = colorB;

        GradientAlphaKey[] gradientAlphaKeyMin;
        gradientAlphaKeyMin          = new GradientAlphaKey[3];
        gradientAlphaKeyMin[0].alpha = colorR;
        gradientAlphaKeyMin[0].time  = colorR;
        gradientAlphaKeyMin[1].alpha = colorG;
        gradientAlphaKeyMin[1].time  = colorG;
        gradientAlphaKeyMin[2].alpha = colorB;
        gradientAlphaKeyMin[2].time  = colorB;

        GradientColorKey[] gradientColorKeyMax;
        gradientColorKeyMax          = new GradientColorKey[3];
        gradientColorKeyMax[0].color = Color.red;
        gradientColorKeyMax[0].time  = colorR;
        gradientColorKeyMax[1].color = Color.blue;
        gradientColorKeyMax[1].time  = colorG;
        gradientColorKeyMax[2].color = Color.green;
        gradientColorKeyMax[2].time  = colorB;

        GradientAlphaKey[] gradientAlphaKeyMax;
        gradientAlphaKeyMax          = new GradientAlphaKey[3];
        gradientAlphaKeyMax[0].alpha = 1.0f;
        gradientAlphaKeyMax[0].time  = colorR;
        gradientAlphaKeyMax[1].alpha = 0.5f;
        gradientAlphaKeyMax[1].time  = colorG;
        gradientAlphaKeyMax[2].alpha = 1f;
        gradientAlphaKeyMax[2].time  = colorB;

        Gradient gradientMin = new Gradient();

        gradientMin.SetKeys(gradientColorKeyMin, gradientAlphaKeyMin);

        //Gradient gradientMax = new Gradient();
        //gradientMax.SetKeys(gradientColorKeyMax, gradientAlphaKeyMax);

        ParticleSystem.MinMaxGradient color = new ParticleSystem.MinMaxGradient();
        color.mode        = ParticleSystemGradientMode.TwoGradients;
        color.gradientMin = gradientMin;
        //color.gradientMax = gradientMax;

        ParticleSystem.MainModule main = particleSystem.main;
        main.startColor = color;

        //var main = particleSystem.main;
        //size++;
        //GradientColorKey[] colorkey = new GradientColorKey[2];
        //GradientAlphaKey[] alphakey = new GradientAlphaKey[2];

        //main.startColor.gradient.SetKeys(colorkey, alphakey);

        /*
         * main.startColor = new Color(colorR, colorB ,colorG);
         */
    }
Пример #22
0
 public void SetColor(Color32 playerColor)
 {
     GetComponent <TrailRenderer>().startColor = playerColor;
     ParticleSystem.MainModule particleSystem = GetComponentInChildren <ParticleSystem>().main;
     particleSystem.startColor = GetComponent <TrailRenderer>().startColor;
 }
Пример #23
0
    // Specific methods may have to be re written in cas of new import
    public IEnumerator SpecificSceneAction(int sceneIndex)
    {
        switch (sceneIndex)
        {
        case 27:
            m_CameraFollow.target = transform.parent;
            break;

        case 26:
            m_DialogueManager.ShutOffContinueButton();
            yield return(new WaitForSeconds(3f));

            m_AudioManager.PlaySound("Fire");
            m_CameraShake.Shake(0.02f, 1.25f);
            yield return(new WaitForSeconds(1.17f));

            yield return(new WaitForSeconds(0.2f));

            m_AudioManager.StopSound("Fire");
            yield return(new WaitForSeconds(0.38f));

            m_AudioManager.PlaySound("DragonFire");
            yield return(new WaitForSeconds(1.35f));

            m_AudioManager.StopSound("DragonFire");
            m_AudioManager.PlaySound("DragonDie");
            yield return(new WaitForSeconds(0.07f));

            m_CameraShake.Shake(0.5f, 0.2f);
            m_AudioManager.PlaySound("WoodImpact");
            yield return(new WaitForSeconds(m_CurrentDialogue.scenes[1].sceneClip.length - 6.17f));

            Destroy(m_FirstDragon);
            Destroy(m_SecondDragon);
            m_DialogueManager.DisplayNextSentence();
            m_DialogueManager.ShutOnContinueButton();
            break;

        case 11:
            if (m_CoinCounter != null)
            {
                m_CoinCounter.SetActive(true);
            }
            m_AudioManager.PlaySound("Coin");
            break;

        case 4:
            m_DialogueManager.ShutOffContinueButton();
            yield return(new WaitForSeconds(1f));

            GameObject burnprefab;

            m_PlayerMov.RollPlayer(true);

            burnprefab = Instantiate(m_BurnEffectPrefab, m_Player.transform);
            ParticleSystem.MainModule main = m_BurnEffectPrefab.GetComponent <ParticleSystem>().main;
            main.loop     = true;
            main.duration = 3f;
            burnprefab.GetComponent <ParticleSystem>().Play();
            m_AudioManager.PlaySound("Fire");

            yield return(new WaitForSeconds(3f));


            m_PlayerMov.RollPlayer(false);
            m_AudioManager.StopSound("Fire");
            Destroy(burnprefab);

            yield return(new WaitForSeconds(1f));

            m_DialogueManager.ShutOnContinueButton();
            break;


        case 3:
            m_DialogueManager.ShutOffContinueButton();
            yield return(new WaitForSeconds(0.52f));

            m_SausageTrigger.enabled = true;
            m_SausageImage.enabled   = true;
            yield return(new WaitForSeconds(0.5f));

            m_PlayerMov.IsMovementAllowed = true;
            PlayerSpit playerspit = FindObjectOfType <PlayerSpit>();
            if (playerspit != null)
            {
                playerspit.IsSpittingAllowed = true;
            }
            m_ArrowRed.SetActive(true);


            break;

        case 2:

            m_DialogueManager.ShutOffContinueButton();
            m_ArrowRed.SetActive(false);
            m_PlayerMov.IsMovementAllowed = false;
            PlayerSpit playerspit2 = FindObjectOfType <PlayerSpit>();
            if (playerspit2 != null)
            {
                playerspit2.IsSpittingAllowed = false;
            }
            yield return(new WaitForSeconds(1.5f));

            m_SausageTrigger.enabled = false;
            m_SausageImage.enabled   = false;
            m_DialogueManager.ShutOnContinueButton();
            yield return(new WaitForSeconds(2f));

            Destroy(m_SausageObject);

            break;

        case 1:

            yield return(new WaitForSeconds(0.25f));

            m_AudioManager.PlaySound("WoodImpact");
            yield return(new WaitForSeconds(0.75f));

            m_AudioManager.PlaySound("WoodImpact");
            yield return(new WaitForSeconds(0.5f));

            m_AudioManager.PlaySound("WoodImpact");
            break;

        default:
            break;
        }


        yield return(null);
    }
Пример #24
0
        public static GameObject Create()
        {
            AnimationCurve sizecurve = new AnimationCurve(new Keyframe[] { new Keyframe(0, 0, 5.129462f, 5.129462f), new Keyframe(0.2449522f, 1, 0, 0), new Keyframe(1, 0, -1.242162f, -1.242162f), });

            if (mat1 == null)
            {
                mat1 = new Material(Shader.Find("Particles/Multiply"));
                mat2 = new Material(Shader.Find("Particles/Additive"));

                mat1.color = Color.white;
                mat2.color = Color.white;

                mat1.mainTexture = Res.ResourceLoader.GetTexture(111);
                mat2.mainTexture = Res.ResourceLoader.GetTexture(111);

                mat1.renderQueue = 3050;
                mat2.renderQueue = 3000;
            }

            GameObject go = new GameObject("__BlackFlames__");

            ParticleSystem ps = go.AddComponent <ParticleSystem>();

            ParticleSystem.MainModule                 main     = ps.main;
            ParticleSystem.EmissionModule             emission = ps.emission;
            ParticleSystem.ShapeModule                shape    = ps.shape;
            ParticleSystem.RotationOverLifetimeModule rot      = ps.rotationOverLifetime;
            ParticleSystem.SizeOverLifetimeModule     size     = ps.sizeOverLifetime;
            ParticleSystemRenderer rend = ps.GetComponent <ParticleSystemRenderer>();

            main.startSize     = 0.4f;
            main.startSpeed    = -6f;
            main.startLifetime = 0.75f;
            main.startColor    = new Color(0, 0, 1, 0.623f);
            main.startRotation = new ParticleSystem.MinMaxCurve(0, 90);

            emission.rateOverTime = 100;

            shape.shapeType = ParticleSystemShapeType.Cone;
            shape.angle     = 0;
            shape.radius    = 0.25f;

            rot.enabled = true;
            rot.z       = 180;

            size.enabled = true;
            size.size    = new ParticleSystem.MinMaxCurve(1, sizecurve);

            rend.renderMode      = ParticleSystemRenderMode.Stretch;
            rend.lengthScale     = 2;
            rend.normalDirection = 1;
            rend.material        = mat1;

            GameObject             go2   = GameObject.Instantiate(go, go.transform);
            ParticleSystem         ps2   = go.GetComponent <ParticleSystem>();
            ParticleSystemRenderer rend2 = go.GetComponent <ParticleSystemRenderer>();

            ParticleSystem.MainModule main2 = ps2.main;
            main2.startColor    = new Color(0, 0.15f, 1, 0.623f);
            main2.startLifetime = 1;
            main2.startSpeed    = -4;

            rend2.material = mat2;

            var light = go2.AddComponent <Light>();

            light.shadowStrength = 1;
            light.shadows        = LightShadows.Hard;
            light.type           = LightType.Point;
            light.range          = 20;
            light.color          = new Color(0.6f, 0.3f, 1f);
            light.intensity      = 0.6f;

            return(go);
        }
Пример #25
0
 public static void SetParticleSystemColor(ParticleSystem ps, Color _color)
 {
     ParticleSystem.MainModule m = ps.main;
     m.startColor = _color;
 }
Пример #26
0
 private void Awake()
 {
     _particleSystemMainModule = GetComponent <ParticleSystem>().main;
 }
Пример #27
0
 private void ChangeStartLifetimeOfPs(ParticleSystem ps, float castingSpeed)
 {
     ParticleSystem.MainModule temp = ps.main;
     temp.startLifetime = castingSpeed;
 }
 private void Start()
 {
     psMain = particleSystem.main;
     tallRotationRadians = tallRotation * Mathf.Deg2Rad;
     wideRotationRadians = wideRotation * Mathf.Deg2Rad;
 }
 private void Awake()
 {
     particleSystem = GetComponent <ParticleSystem>();
     mainModule     = particleSystem.main;
 }
Пример #30
0
        private void OnTriggerEnter(Collider other)
        {
            // Collect all the colliders in a sphere from the shell's current position to a radius of the explosion radius.
            Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius, m_TankMask);

            // Go through all the colliders...
            for (int i = 0; i < colliders.Length; i++)
            {
                // ... and find their rigidbody.
                Rigidbody targetRigidbody = colliders[i].GetComponent <Rigidbody>();

                // If they don't have a rigidbody, go on to the next collider.
                if (!targetRigidbody)
                {
                    continue;
                }

                // Add an explosion force.
                targetRigidbody.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius);

                // Find the TankHealth script associated with the rigidbody.
                TankHealth targetHealth = targetRigidbody.GetComponent <TankHealth>();

                // If there is no TankHealth script attached to the gameobject, go on to the next collider.
                if (!targetHealth)
                {
                    continue;
                }

                // Calculate the amount of damage the target should take based on it's distance from the shell.
                float damage = CalculateDamage(targetRigidbody.position);

                var targetPhotonView = targetRigidbody.GetComponent <PhotonView>();

                if (targetPhotonView != null && targetPhotonView.IsMine)
                {
                    // Deal this damage to the tank.
                    targetHealth.TakeDamage(damage);
                }
                else
                {
                    Debug.Log("CalculateDamage " + damage);
                }
            }

            // Unparent the particles from the shell.
            m_ExplosionParticles.transform.parent = null;

            // Play the particle system.
            m_ExplosionParticles.Play();

            // Play the explosion sound effect.
            m_ExplosionAudio.Play();

            // Once the particles have finished, destroy the gameobject they are on.
            ParticleSystem.MainModule mainModule = m_ExplosionParticles.main;
            Destroy(m_ExplosionParticles.gameObject, mainModule.duration);

            // Destroy the shell.
            Destroy(gameObject);
        }