Пример #1
0
        public static void Create(Vector3 pos, float rootDuration)
        {
            if (ChainInstance == null)
            {
                ChainInstance = new GameObject();
                ChainInstance.AddComponent <RootSpell>();
                ParticleSystem            ps   = ChainInstance.AddComponent <ParticleSystem>();
                ParticleSystem.MainModule main = ps.main;
                main.startLifetime   = 30;
                main.startSpeed      = 0;
                main.startSize       = 2.5f;
                main.scalingMode     = ParticleSystemScalingMode.Hierarchy;
                main.startRotationX  = 90;
                main.startRotationY  = 90;
                main.startRotationZ  = new ParticleSystem.MinMaxCurve(0, 90);
                main.simulationSpace = ParticleSystemSimulationSpace.World;

                ParticleSystem.EmissionModule e = ps.emission;
                e.rateOverDistance = 4;
                e.rateOverTime     = 0;

                ParticleSystem.ShapeModule s = ps.shape;
                s.shapeType        = ParticleSystemShapeType.SingleSidedEdge;
                s.alignToDirection = true;


                s.radius = 0.0001f;
                s.length = 0.0001f;

                ParticleSystem.ExternalForcesModule ef = ps.externalForces;
                ef.enabled    = true;
                ef.multiplier = 2;

                ParticleSystemRenderer r = ps.GetComponent <ParticleSystemRenderer>();
                r.material = new Material(Shader.Find("Particles/Additive"))
                {
                    color = new Color(0.2431373f, 0.2051491f, 0, 0.10f)
                };
                r.renderMode        = ParticleSystemRenderMode.Mesh;
                r.mesh              = Res.ResourceLoader.instance.LoadedMeshes[69];
                r.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
                r.alignment         = ParticleSystemRenderSpace.World;
                ChainInstance.SetActive(false);

                RepulsionEffectInstance = new GameObject();
                WindZone wz = RepulsionEffectInstance.AddComponent <WindZone>();
                wz.windMain       = -10;
                wz.windTurbulence = 5;
                wz.mode           = WindZoneMode.Spherical;
                wz.radius         = 15;
                RepulsionEffectInstance.SetActive(false);
            }
            ChainInstance.SetActive(true);
            for (int i = 0; i < ChainCount; i++)
            {
                Vector3 rand = new Vector3(Random.value * 2 - 1, Random.value, Random.value * 2 - 1);
                rand *= 10;
                rand += pos;

                GameObject go = Instantiate(ChainInstance, rand, Quaternion.LookRotation(pos - rand));
                go.transform.LookAt(pos);
                RootSpell spell = go.GetComponent <RootSpell>();
                spell.targetPos = pos;
                spell.Duration  = rootDuration;
            }
            ChainInstance.SetActive(false);
        }
Пример #2
0
    void OnMouseDrag()
    {
        // 飛ばす前の左右移動プログラム
        if (touchcount <= 10)
        {
            touchcount = 10;

            Vector3 objectPointInScreen
                = Camera.main.WorldToScreenPoint(this.transform.position);

            Vector3 mousePointInScreen = new Vector3(
                Input.mousePosition.x,
                Input.mousePosition.y,
                objectPointInScreen.z
                );

            Vector3 mousePointInWorld = Camera.main.ScreenToWorldPoint(mousePointInScreen);
            // Y・Z軸へは動かない
            mousePointInWorld.y = this.transform.position.y;
            mousePointInWorld.z = this.transform.position.z;

            this.transform.position = mousePointInWorld;
            // 左右の範囲
            this.transform.position = (new Vector3(
                                           Mathf.Clamp(Soap.transform.position.x, -3.5f, 3.5f),
                                           Mathf.Clamp(Soap.transform.position.y, 0.06f, 0.06f),
                                           Mathf.Clamp(Soap.transform.position.z, -0.01f, 0.01f)
                                           //Soap.transform.position.z
                                           )
                                       );
            //--- エフェクト関連加筆
            // エフェクト
            var bubble = Instantiate <GameObject>(bubbleSlideObj, gameObject.transform);
            bubble.transform.localScale = Vector3.one;
            // パーティクルシステムを有効にする
            bubble.GetComponent <ParticleSystem>().Play();
            ratetime += 10;
            ParticleSystem.EmissionModule em = bubble.GetComponent <ParticleSystem>().emission;
            em.rateOverTime = new ParticleSystem.MinMaxCurve(ratetime);
            //--- エフェクト関連加筆終了
        }
        else if (touchcount == 20)
        {
            BubbleCors = 10;

            Vector3 objectPointInScreen
                = Camera.main.WorldToScreenPoint(this.transform.position);

            Vector3 mousePointInScreen = new Vector3(
                Input.mousePosition.x,
                Input.mousePosition.y,
                objectPointInScreen.z
                );

            if (Input.GetMouseButtonDown(0))
            {
                this.touchPos = Input.mousePosition;
            }
            else
            {
                Vector3 sabun = Input.mousePosition - this.touchPos;

                if (sabun.x > 10) // 右にスワイプ
                {
                    if (RightSwipe == 0)
                    {
                        transform.rotation = Quaternion.Euler(0, transform.localRotation.y + 0.5f, 0);
                        Rigidbody rb  = Soap.GetComponent <Rigidbody>();
                        Vector3   vec = rb.velocity;
                        // 三角関数の計算式 cosX - sinY, sinX + cosZ
                        float next_x = vec.x * Mathf.Cos(Mathf.Deg2Rad * -1) - vec.z * (Mathf.Sin(Mathf.Deg2Rad * -1));
                        float next_z = vec.x * Mathf.Sin(Mathf.Deg2Rad * -1) + vec.z * (Mathf.Cos(Mathf.Deg2Rad * -1));
                        rb.velocity = new Vector3(next_x, rb.velocity.y, next_z);

                        RightSwipe = 1;
                        LeftSwipe  = 0;
                    }
                    else if (RightSwipe == 1 && LeftSwipe == 0 && RightSwipe != 15)
                    {
                        transform.rotation = Quaternion.Euler(0, transform.localRotation.y + 1f, 0);
                        Rigidbody rb  = Soap.GetComponent <Rigidbody>();
                        Vector3   vec = rb.velocity;
                        // 三角関数の計算式 cosX - sinY, sinX + cosZ
                        float next_x = vec.x * Mathf.Cos(Mathf.Deg2Rad * -2) - vec.z * (Mathf.Sin(Mathf.Deg2Rad * -2));
                        float next_z = vec.x * Mathf.Sin(Mathf.Deg2Rad * -2) + vec.z * (Mathf.Cos(Mathf.Deg2Rad * -2));
                        rb.velocity = new Vector3(next_x, rb.velocity.y, next_z);

                        RightSwipe = 3;
                    }
                    else if (RightSwipe == 3 && LeftSwipe == 0 && RightSwipe != 15)
                    {
                        transform.rotation = Quaternion.Euler(0, transform.localRotation.y + 2f, 0);
                        Rigidbody rb  = Soap.GetComponent <Rigidbody>();
                        Vector3   vec = rb.velocity;
                        // 三角関数の計算式 cosX - sinY, sinX + cosZ
                        float next_x = vec.x * Mathf.Cos(Mathf.Deg2Rad * -4) - vec.z * (Mathf.Sin(Mathf.Deg2Rad * -4));
                        float next_z = vec.x * Mathf.Sin(Mathf.Deg2Rad * -4) + vec.z * (Mathf.Cos(Mathf.Deg2Rad * -4));
                        rb.velocity = new Vector3(next_x, rb.velocity.y, next_z);

                        RightSwipe = 7;
                    }
                    else if (RightSwipe == 7 && LeftSwipe == 0 && RightSwipe != 15)
                    {
                        transform.rotation = Quaternion.Euler(0, transform.localRotation.y + 4f, 0);
                        Rigidbody rb  = Soap.GetComponent <Rigidbody>();
                        Vector3   vec = rb.velocity;
                        // 三角関数の計算式 cosX - sinY, sinX + cosZ
                        float next_x = vec.x * Mathf.Cos(Mathf.Deg2Rad * -8) - vec.z * (Mathf.Sin(Mathf.Deg2Rad * -8));
                        float next_z = vec.x * Mathf.Sin(Mathf.Deg2Rad * -8) + vec.z * (Mathf.Cos(Mathf.Deg2Rad * -8));
                        rb.velocity = new Vector3(next_x, rb.velocity.y, next_z);

                        RightSwipe = 15;
                    }
                    else if (RightSwipe == 15 && LeftSwipe == 0)
                    {
                    }
                }
                else if (sabun.x < -10) // 左にスワイプ
                {
                    if (LeftSwipe == 0)
                    {
                        transform.rotation = Quaternion.Euler(0, transform.localRotation.y - 0.5f, 0);
                        Rigidbody rb  = Soap.GetComponent <Rigidbody>();
                        Vector3   vec = rb.velocity;
                        // 三角関数の計算式 cosX - sinY, sinX + cosZ
                        float next_x = vec.x * Mathf.Cos(Mathf.Deg2Rad * 1) - vec.z * (Mathf.Sin(Mathf.Deg2Rad * 1));
                        float next_z = vec.x * Mathf.Sin(Mathf.Deg2Rad * 1) + vec.z * (Mathf.Cos(Mathf.Deg2Rad * 1));
                        rb.velocity = new Vector3(next_x, rb.velocity.y, next_z);

                        LeftSwipe  = 1;
                        RightSwipe = 0;
                    }
                    else if (LeftSwipe == 1 && RightSwipe == 0 && LeftSwipe != 15)
                    {
                        transform.rotation = Quaternion.Euler(0, transform.localRotation.y - 1f, 0);
                        Rigidbody rb  = Soap.GetComponent <Rigidbody>();
                        Vector3   vec = rb.velocity;
                        // 三角関数の計算式 cosX - sinY, sinX + cosZ
                        float next_x = vec.x * Mathf.Cos(Mathf.Deg2Rad * 2) - vec.z * (Mathf.Sin(Mathf.Deg2Rad * 2));
                        float next_z = vec.x * Mathf.Sin(Mathf.Deg2Rad * 2) + vec.z * (Mathf.Cos(Mathf.Deg2Rad * 2));
                        rb.velocity = new Vector3(next_x, rb.velocity.y, next_z);

                        LeftSwipe = 3;
                    }
                    else if (LeftSwipe == 3 && RightSwipe == 0 && LeftSwipe != 15)
                    {
                        transform.rotation = Quaternion.Euler(0, transform.localRotation.y - 2f, 0);
                        Rigidbody rb  = Soap.GetComponent <Rigidbody>();
                        Vector3   vec = rb.velocity;
                        // 三角関数の計算式 cosX - sinY, sinX + cosZ
                        float next_x = vec.x * Mathf.Cos(Mathf.Deg2Rad * 4) - vec.z * (Mathf.Sin(Mathf.Deg2Rad * 4));
                        float next_z = vec.x * Mathf.Sin(Mathf.Deg2Rad * 4) + vec.z * (Mathf.Cos(Mathf.Deg2Rad * 4));
                        rb.velocity = new Vector3(next_x, rb.velocity.y, next_z);

                        LeftSwipe = 7;
                    }
                    else if (LeftSwipe == 7 && RightSwipe == 0 && LeftSwipe != 15)
                    {
                        transform.rotation = Quaternion.Euler(0, transform.localRotation.y - 4f, 0);
                        Rigidbody rb  = Soap.GetComponent <Rigidbody>();
                        Vector3   vec = rb.velocity;
                        // 三角関数の計算式 cosX - sinY, sinX + cosZ
                        float next_x = vec.x * Mathf.Cos(Mathf.Deg2Rad * 8) - vec.z * (Mathf.Sin(Mathf.Deg2Rad * 8));
                        float next_z = vec.x * Mathf.Sin(Mathf.Deg2Rad * 8) + vec.z * (Mathf.Cos(Mathf.Deg2Rad * 8));
                        rb.velocity = new Vector3(next_x, rb.velocity.y, next_z);

                        LeftSwipe = 15;
                    }
                    else if (LeftSwipe == 15 && RightSwipe == 0)
                    {
                    }
                }

                this.touchPos = Input.mousePosition;
            }

            Vector3 mousePointInWorld = Camera.main.ScreenToWorldPoint(mousePointInScreen);
            // Y・Z軸へは動かない

            mousePointInWorld.x = this.transform.position.x;
            mousePointInWorld.y = this.transform.position.y;
            mousePointInWorld.z = this.transform.position.z;

            this.transform.position = mousePointInWorld;
            // 左右の範囲
            this.transform.position = (new Vector3(
                                           Soap.transform.position.x,
                                           Mathf.Clamp(Soap.transform.position.y, 0.06f, 0.06f),
                                           Soap.transform.position.z)
                                       );
        }
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        if (GetComponent <Rigidbody>().velocity.magnitude > currentMaxSpeed)
        {
            Vector3 v = GetComponent <Rigidbody>().velocity.normalized *currentMaxSpeed;

            GetComponent <Rigidbody>().velocity = new Vector3(v.x, GetComponent <Rigidbody>().velocity.y, v.z);
        }

        // Control particle emission based on velocity
        var em   = particles.GetComponent <ParticleSystem>().emission;
        var rate = new ParticleSystem.MinMaxCurve();

        rate.constantMax = GetComponent <Rigidbody>().velocity.magnitude * 2.0f;
        em.rate          = rate;

        rb.angularVelocity = Vector3.zero;

        ControlUpdate();
        PowerUpdate();

        GrabTimer    -= Time.deltaTime;
        HoldTimer    -= Time.deltaTime;
        StunTimer    -= Time.deltaTime;
        iTimer       -= Time.deltaTime;
        AbilityTimer -= Time.deltaTime;
        DashTimer    -= Time.deltaTime;

        if (currentMaxSpeed > maxSpeed)
        {
            IceBrake.GetComponent <Renderer>().enabled = false;
            currentMaxSpeed -= maxSpeedDecay * Time.deltaTime;
            if (currentMaxSpeed < maxSpeed)
            {
                currentMaxSpeed = maxSpeed;
            }
        }
        else
        {
            if (movementState != State.Braking)
            {
                //audio.PlayOneShot (Brake, 1.0f); need help so it doesn't play every frame
                currentMaxSpeed = maxSpeed;
                IceBrake.GetComponent <Renderer>().enabled = false;
            }
            else
            {
                IceBrake.GetComponent <Renderer>().enabled = true;
                Color c = IceBrake.GetComponent <Renderer>().material.color;
                IceBrake.GetComponent <Renderer>().material.SetColor("_Color", new Color(c.r, c.g, c.b, 1.0f - currentMaxSpeed / maxSpeed));

                currentMaxSpeed -= brakeSpeed * Time.deltaTime;
                if (currentMaxSpeed < 0)
                {
                    currentMaxSpeed = 0;
                }
            }
        }


        //cdtext.text = Mathf.Ceil(AbilityTimer).ToString();

        if (AbilityTimer <= 0)
        {
            cdtext.enabled = false;
            ParticleSystem.EmissionModule tempEm = cooldownParticles.GetComponent <ParticleSystem>().emission;
            tempEm.enabled = false;
            cooldownParticles.GetComponent <ParticleSystemCooldownParticle>().CooldownExplosion();
        }

        if (DashTimer <= 0)
        {
            //dashCDImage.enabled = false;
            if (dashCDParticles.GetComponent <ParticleSystem>().isPlaying)
            {
                dashCDParticles.GetComponent <ParticleSystem>().Stop();
            }
        }
        //else
        //{
        //    dashCDImage.enabled = true;
        //}

        if (GrabTimer <= 0)
        {
            if (grabBox.GetComponent <GrabBox>().isactive)
            {
                grabBox.GetComponent <GrabBox>().isactive = false;
            }
        }

        if (movementState == State.Dash && DashTimer <= dashCooldown)
        {
            ChangeMovementState(State.GroundedMovement);
            currentMaxSpeed = maxSpeed;
        }

        if ((movementState == State.NoMovement || movementState == State.Countdown) && StunTimer <= 0)
        {
            ChangeMovementState(State.GroundedMovement);

            if (environmentDamage < tempedamage)
            {
                environmentDamage = tempedamage;
            }
        }
        if (beingHeld && HoldTimer <= 0)
        {
            holder.Chuck();
        }


        if (Skill == SkillID.None)
        {
            Kill();
        }

        CooldownUpdate();
    }
        void LateUpdate()
        {
        #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                _editorTimeDelta   = EditorApplication.timeSinceStartup - _editorTimetracker;
                _editorTimetracker = EditorApplication.timeSinceStartup;

                ParticleSystem.EmissionModule em = _particle_system.emission;
                em.enabled = false;
            }
        #endif

            if (transform.childCount <= 1)
            {
                return;
            }

            // emision
            if (_emissionRateTracker <= 0.0f)
            {
                _emissionRateTracker += 1.0f / emissionRate;

                RenewOneDeadParticle();
            }
            _emissionRateTracker -= (Application.isPlaying ? Time.deltaTime : (float)_editorTimeDelta);

            // age them
            foreach (PathParticleTracker tracker in _particle_trackerArray)
            {
                if (tracker.particle.remainingLifetime > 0.0f)
                {
                    tracker.particle.remainingLifetime = Mathf.Max(tracker.particle.remainingLifetime - (Application.isPlaying ? Time.deltaTime : (float)_editorTimeDelta), 0.0f);
                }
            }


            float      normLifetime = 0.0f;
            Path_Point Rpoint;

            // move them
            foreach (PathParticleTracker tracker in _particle_trackerArray)
            {
                if (tracker.particle.remainingLifetime > 0.0f)
                {
                    normLifetime = tracker.particle.remainingLifetime / tracker.particle.startLifetime;
                    normLifetime = 1.0f - normLifetime;

                    Rpoint = _path_comp.GetPathPoint(normLifetime * _path_comp.TotalDistance);

                    // rotate around Rpoint.direction

                    Rpoint.point += (pathWidth * tracker.distance) * Math_Functions.Rotate_Vector(Rpoint.up, Rpoint.forward, tracker.rotation);

                    tracker.particle.position = Rpoint.point;
                    tracker.particle.velocity = Rpoint.forward;
                }
            }

            _particle_count = 0;

            // set the given array
            foreach (PathParticleTracker tracker in _particle_trackerArray)
            {
                if (tracker.particle.remainingLifetime > 0.0f)         // it's alive
                {
                    _particle_array[_particle_count] = tracker.particle;
                    _particle_count++;
                }
            }

            _particle_system.SetParticles(_particle_array, _particle_count);
        }
Пример #5
0
    void Update()
    {
        // Acceleration

        speedTarget = Mathf.SmoothStep(speedTarget, speed, Time.deltaTime * 12f); speed = 0f;

        if (Input.GetKey(accelerate))
        {
            ControlAccelerate();
        }
        if (Input.GetKey(brake))
        {
            ControlBrake();
        }

        // Steering

        rotateTarget = Mathf.Lerp(rotateTarget, rotate, Time.deltaTime * 4f); rotate = 0f;

        if (Input.GetKey(steerLeft))
        {
            ControlSteer(-1);
        }
        if (Input.GetKey(steerRight))
        {
            ControlSteer(1);
        }

        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(new Vector3(0, transform.eulerAngles.y + rotateTarget, 0)), Time.deltaTime * 2.0f);

        // Jump

        if (Input.GetKeyDown(jump))
        {
            ControlJump();
        }

        // Wheel and body tilt

        if (wheelFrontLeft != null)
        {
            wheelFrontLeft.localRotation = Quaternion.Euler(0, rotateTarget / 2, 0);
        }
        if (wheelFrontRight != null)
        {
            wheelFrontRight.localRotation = Quaternion.Euler(0, rotateTarget / 2, 0);
        }

        body.localRotation = Quaternion.Slerp(body.localRotation, Quaternion.Euler(new Vector3(speedTarget / 4, 0, rotateTarget / 6)), Time.deltaTime * 4.0f);

        // Vehicle tilt

        float tilt = 0.0f; if (motorcycleTilt)

        {
            tilt = -rotateTarget / 1.5f;
        }

        // Well, this stops the wheels going crazy so i guess i'll just comment it out.

        /*container.localPosition = containerBase + new Vector3(0, Mathf.Abs(tilt) / 2000, 0);
         * container.localRotation = Quaternion.Slerp(container.localRotation, Quaternion.Euler(0, rotateTarget / 8, tilt), Time.deltaTime * 10.0f);*/

        // Effects

        if (!motorcycleTilt)
        {
            smoke.transform.localPosition = new Vector3(-rotateTarget / 100, smoke.transform.localPosition.y, smoke.transform.localPosition.z);
        }

        ParticleSystem.EmissionModule smokeEmission = smoke.emission;
        smokeEmission.enabled = onGround && sphere.velocity.magnitude > (acceleration / 4) && (Vector3.Angle(sphere.velocity, vehicleModel.forward) > 30.0f || alwaysSmoke);

        if (trailLeft != null)
        {
            trailLeft.emitting = smoke.emission.enabled;
        }
        if (trailRight != null)
        {
            trailRight.emitting = smoke.emission.enabled;
        }

        // Stops vehicle from floating around when standing still

        if (speed == 0 && sphere.velocity.magnitude < 4f)
        {
            sphere.velocity = Vector3.Lerp(sphere.velocity, Vector3.zero, Time.deltaTime * 2.0f);
        }
    }
Пример #6
0
 // Use this for initialization
 void Start()
 {
     GetComponent <ParticleSystem>().Play();
     ParticleSystem.EmissionModule em = GetComponent <ParticleSystem>().emission;
     em.enabled = true;
 }
Пример #7
0
    /// <summary>
    /// Prepare a particle system and its renderer for effectively showing point cloud data.
    /// </summary>
    /// <param name="ps">The particle system to configure.</param>
    /// <param name="renderer">The particle system's renderer component.</param>
    /// <param name="max_particles">The maximum number of particles the particle system is to handle.</param>
    protected void InitializeParticleSystem(ParticleSystem ps, ParticleSystemRenderer renderer, int max_particles)
    {
        ParticleSystem.MainModule main = ps.main;

        // The point cloud is unanimated, so we don't need looping or play-on-awake.
        main.loop        = false;
        main.playOnAwake = false;

        main.maxParticles = max_particles;
        main.startColor   = new ParticleSystem.MinMaxGradient(new Color(1.0f, 1.0f, 1.0f, 0.0f));

        renderer.sortMode = ParticleSystemSortMode.Distance;

        // Performance optimizing options.
        renderer.shadowCastingMode   = UnityEngine.Rendering.ShadowCastingMode.Off;
        renderer.receiveShadows      = false;
        renderer.enableGPUInstancing = true;

        Material particleMaterial = new Material(Shader.Find(shader));

        renderer.material = particleMaterial;
        PrepareMaterial(particleMaterial);
        particleMaterial.SetColor("_Color", new Color(1.0f, 1.0f, 1.0f, 1.0f));
        particleMaterial.SetColor("_EmissionColor", new Color(0.8f, 0.8f, 0.8f, 1.0f));

        SetRenderMethod(ParticleSystemRenderMode.Billboard);

        // Disable all unneeded components of the particle system.

        ParticleSystem.EmissionModule em = ps.emission;
        em.enabled = false;
        ParticleSystem.ShapeModule sh = ps.shape;
        sh.enabled = false;
        ParticleSystem.VelocityOverLifetimeModule vol = ps.velocityOverLifetime;
        vol.enabled = false;
        ParticleSystem.LimitVelocityOverLifetimeModule lvol = ps.limitVelocityOverLifetime;
        lvol.enabled = false;
        ParticleSystem.InheritVelocityModule ivm = ps.inheritVelocity;
        ivm.enabled = false;
        ParticleSystem.ForceOverLifetimeModule fol = ps.forceOverLifetime;
        fol.enabled = false;
        ParticleSystem.ColorOverLifetimeModule col = ps.colorOverLifetime;
        col.enabled = false;
        ParticleSystem.ColorBySpeedModule cbs = ps.colorBySpeed;
        cbs.enabled = false;
        ParticleSystem.SizeOverLifetimeModule sol = ps.sizeOverLifetime;
        sol.enabled = false;
        ParticleSystem.SizeBySpeedModule sbs = ps.sizeBySpeed;
        sbs.enabled = false;
        ParticleSystem.RotationOverLifetimeModule rol = ps.rotationOverLifetime;
        rol.enabled = false;
        ParticleSystem.RotationBySpeedModule rbs = ps.rotationBySpeed;
        rbs.enabled = false;
        ParticleSystem.ExternalForcesModule extf = ps.externalForces;
        extf.enabled = false;
        ParticleSystem.NoiseModule noise = ps.noise;
        noise.enabled = false;
        ParticleSystem.CollisionModule collision = ps.collision;
        collision.enabled = false;
        ParticleSystem.TriggerModule triggers = ps.trigger;
        triggers.enabled = false;
        ParticleSystem.SubEmittersModule subem = ps.subEmitters;
        subem.enabled = false;
        ParticleSystem.TextureSheetAnimationModule tsa = ps.textureSheetAnimation;
        tsa.enabled = false;
        ParticleSystem.LightsModule lights = ps.lights;
        lights.enabled = false;
        ParticleSystem.CustomDataModule cd = ps.customData;
        cd.enabled = false;
    }
Пример #8
0
 public void OnPlayerDashChargeInterrupted(Player player)
 {
     Debug.Log("Event on player dash charge interrupted");
     ParticleSystem.EmissionModule em = player.GetDashChargeSystem().emission;
     em.enabled = false;
 }
Пример #9
0
 void Start()
 {
     particleEmission = GetComponentInChildren <ParticleSystem>().emission;
 }
Пример #10
0
 private void CheckForRainChange()
 {
     //if (lastRainIntensityValue != RainIntensity)
     //{
     lastRainIntensityValue = RainIntensity;
     if (RainIntensity <= 0.01f)
     {
         if (audioSourceRainCurrent != null)
         {
             audioSourceRainCurrent.Stop();
             audioSourceRainCurrent = null;
         }
         if (RainFallParticleSystem != null)
         {
             ParticleSystem.EmissionModule e = RainFallParticleSystem.emission;
             e.enabled = false;
             RainFallParticleSystem.Stop();
         }
         if (RainMistParticleSystem != null)
         {
             ParticleSystem.EmissionModule e = RainMistParticleSystem.emission;
             e.enabled = false;
             RainMistParticleSystem.Stop();
         }
     }
     else
     {
         LoopingAudioSource newSource;
         if (RainIntensity >= 0.67f)
         {
             newSource = audioSourceRainHeavy;
         }
         else if (RainIntensity >= 0.33f)
         {
             newSource = audioSourceRainMedium;
         }
         else
         {
             newSource = audioSourceRainLight;
         }
         if (audioSourceRainCurrent != newSource)
         {
             if (audioSourceRainCurrent != null)
             {
                 audioSourceRainCurrent.Stop();
             }
             audioSourceRainCurrent = newSource;
             audioSourceRainCurrent.Play(1.0f);
         }
         if (RainFallParticleSystem != null)
         {
             ParticleSystem.EmissionModule e = RainFallParticleSystem.emission;
             e.enabled = RainFallParticleSystem.GetComponent <Renderer>().enabled = true;
             if (!RainFallParticleSystem.isPlaying)
             {
                 RainFallParticleSystem.Play();
             }
             ParticleSystem.MinMaxCurve rate = e.rateOverTime;
             rate.mode        = ParticleSystemCurveMode.Constant;
             rate.constantMin = rate.constantMax = RainFallEmissionRate();
             e.rateOverTime   = rate;
         }
         if (RainMistParticleSystem != null)
         {
             ParticleSystem.EmissionModule e = RainMistParticleSystem.emission;
             e.enabled = RainMistParticleSystem.GetComponent <Renderer>().enabled = true;
             if (!RainMistParticleSystem.isPlaying)
             {
                 RainMistParticleSystem.Play();
             }
             float emissionRate;
             if (RainIntensity < RainMistThreshold)
             {
                 emissionRate = 0.0f;
             }
             else
             {
                 // must have RainMistThreshold or higher rain intensity to start seeing mist
                 emissionRate = MistEmissionRate();
             }
             ParticleSystem.MinMaxCurve rate = e.rateOverTime;
             rate.mode        = ParticleSystemCurveMode.Constant;
             rate.constantMin = rate.constantMax = emissionRate;
             e.rateOverTime   = rate;
         }
     }
     //}
 }
Пример #11
0
 public void OnPlayerDashChargeStart(Player player)
 {
     Debug.Log("Event on player dash charge start");
     ParticleSystem.EmissionModule em = player.GetDashChargeSystem().emission;
     em.enabled = true;
 }
Пример #12
0
    // Start is called before the first frame update

    void Awake()
    {
        //get and check if the boss Object has the required component attached
        if (GetComponent <Animator>())
        {
            anim = GetComponent <Animator>();
        }
        else
        {
            Debug.LogError("Boss1 AI needs a aniamtor");
        }
        //if(GameObject.FindWithTag("Player")) target = GameObject.FindWithTag("Player"); else Debug.LogError("The player needs to have tag 'Player' for the boss to target");
        if (GetComponent <NavMeshAgent>())
        {
            agent = GetComponent <NavMeshAgent>();
        }
        else
        {
            Debug.Log("The boss needs a navmeshagent component dude ");
        }
        if (GetComponent <Rigidbody>())
        {
            rb = GetComponent <Rigidbody>();
        }
        else
        {
            Debug.Log("The boss needs a rigidbody component");
        }
        if (GetComponent <BoxCollider>())
        {
            boxColl = GetComponent <BoxCollider>();
        }
        else
        {
            Debug.Log("The boss needs a boxCollider for tree detection ");
        }

        foreach (BoxCollider bs in GetComponentsInChildren <BoxCollider>())
        {
            if (bs.gameObject.name == "BossLHhitbox")
            {
                lhitbox = bs;
                break;
            }
        }

        if (lhitbox == null)
        {
            Debug.Log("There is on left hand hitbox for the boss");
        }
        tailEmission = tailPs.emission;
        tailMain     = tailPs.main;
        tailShape    = tailPs.shape;

        emissionRate = new ParticleSystem.MinMaxCurve(10.0f);

        //ParticleSystem[] ps = GetComponentsInChildren<ParticleSystem>();
        //foreach (ParticleSystem tpS in ps)
        //{
        //    if(tpS.gameObject.name == "TailElectricity")
        //    {
        //        tailPs = tpS;
        //    }
        //    break;
        //}



        if (tailPs == null)
        {
            Debug.Log("Cant find TailElectricity");
        }
        player = GameObject.FindWithTag("Player");
        //if (player.GetComponent<ThirdPersonController>()) playerControl = player.GetComponent<ThirdPersonController>(); else Debug.Log("Cant find the 3rd person controller ");
        //the default status of the boss is follow , assuming the boss found the player as the boss fight begins
        bossState = Status.Follow;
    }
Пример #13
0
 void unsetSnow()
 {
     GetComponent <ParticleSystem>().Play();
     ParticleSystem.EmissionModule em = GetComponent <ParticleSystem>().emission;
     em.enabled = false;
 }
Пример #14
0
    public override void SetAnimation()
    {
        if (Mathf.Abs(velocity.x) > .05f && collisions.onGround)
        {
            animator.SetBool("isRunning", true);
        }
        else
        {
            animator.SetBool("isRunning", false);
        }
        if (!collisions.onGround && !collisions.onWall || collisions.passingTroughPlatform)
        {
            animator.SetBool("isJumping", true);
        }
        else
        {
            animator.SetBool("isJumping", false);
        }
        if (collisions.onGround && !collisions.passingTroughPlatform)
        {
            animator.SetBool("onGround", true);
        }
        else
        {
            animator.SetBool("onGround", false);
        }

        /* if(collisions.onGround || !collisions.onWall){
         *  animator.SetBool("isWallSliding",false);
         * }
         * else if((collisions.onLeftWall ^ collisions.onRightWall) && !collisions.passingTroughPlatform){
         *  animator.SetBool("isWallSliding",true);
         * } */
        if (knockBacked)
        {
            animator.SetBool("Knockbacked", true);
        }
        else
        {
            animator.SetBool("Knockbacked", false);
        }
        if (holdingBroom)
        {
            animator.SetBool("holdingBroom", true);
        }
        else
        {
            animator.SetBool("holdingBroom", false);
        }
        ParticleSystem.EmissionModule PSsmoke = feetSmoke.GetComponent <ParticleSystem>().emission;
        if (collisions.onGround && !collisions.passingTroughPlatform)
        {
            if (!PSsmoke.enabled)
            {
                PSsmoke.enabled = true;
            }
        }
        else
        {
            PSsmoke.enabled = false;
        }
    }
Пример #15
0
    void Frictions()
    {
        WheelHit GroundHit;

        wheelCollider.GetGroundHit(out GroundHit);
        bool contacted = false;

        for (int i = 0; i < physicsFrictions.Length; i++)
        {
            if (GroundHit.point != Vector3.zero && GroundHit.collider.sharedMaterial == physicsFrictions[i].groundMaterial)
            {
                contacted = true;

                forwardFrictionCurve.stiffness  = physicsFrictions[i].forwardStiffness;
                sidewaysFrictionCurve.stiffness = (physicsFrictions[i].sidewaysStiffness * tractionHelpedSidewaysStiffness);

                if (RCC_Settings.Instance.behaviorType == RCC_Settings.BehaviorType.Drift)
                {
                    Drift(Mathf.Abs(GroundHit.forwardSlip));
                }

                wheelCollider.forwardFriction  = forwardFrictionCurve;
                wheelCollider.sidewaysFriction = sidewaysFrictionCurve;

                wheelCollider.wheelDampingRate = physicsFrictions[i].damp;

                emission  = allWheelParticles[i].emission;
                audioClip = physicsFrictions[i].groundSound;

                if (wheelSlipAmountSideways > physicsFrictions[i].slip || wheelSlipAmountForward > physicsFrictions[i].slip * 2f)
                {
                    emission.enabled = true;
                }
                else
                {
                    emission.enabled = false;
                }
            }
        }

        if (!contacted && physicsMaterials.useTerrainSplatMapForGroundFrictions)
        {
            for (int k = 0; k < physicsMaterials.terrainSplatMapIndex.Length; k++)
            {
                if (GroundHit.point != Vector3.zero && GroundHit.collider.sharedMaterial == physicsMaterials.terrainPhysicMaterial)
                {
                    if (TerrainSurface.GetTextureMix(transform.position) != null && TerrainSurface.GetTextureMix(transform.position)[k] > .5f)
                    {
                        contacted = true;

                        forwardFrictionCurve.stiffness  = physicsFrictions[physicsMaterials.terrainSplatMapIndex[k]].forwardStiffness;
                        sidewaysFrictionCurve.stiffness = (physicsFrictions[physicsMaterials.terrainSplatMapIndex[k]].sidewaysStiffness * tractionHelpedSidewaysStiffness);

                        if (RCC_Settings.Instance.behaviorType == RCC_Settings.BehaviorType.Drift)
                        {
                            Drift(Mathf.Abs(GroundHit.forwardSlip));
                        }

                        wheelCollider.forwardFriction  = forwardFrictionCurve;
                        wheelCollider.sidewaysFriction = sidewaysFrictionCurve;

                        wheelCollider.wheelDampingRate = physicsFrictions[physicsMaterials.terrainSplatMapIndex[k]].damp;

                        emission  = allWheelParticles[physicsMaterials.terrainSplatMapIndex[k]].emission;
                        audioClip = physicsFrictions[physicsMaterials.terrainSplatMapIndex[k]].groundSound;

                        if (wheelSlipAmountSideways > physicsFrictions[physicsMaterials.terrainSplatMapIndex[k]].slip || wheelSlipAmountForward > physicsFrictions[physicsMaterials.terrainSplatMapIndex[k]].slip * 2f)
                        {
                            emission.enabled = true;
                        }
                        else
                        {
                            emission.enabled = false;
                        }
                    }
                }
            }
        }

        if (!contacted)
        {
            forwardFrictionCurve.stiffness  = orgForwardStiffness;
            sidewaysFrictionCurve.stiffness = orgSidewaysStiffness * tractionHelpedSidewaysStiffness;

            if (RCC_Settings.Instance.behaviorType == RCC_Settings.BehaviorType.Drift)
            {
                Drift(Mathf.Abs(GroundHit.forwardSlip));
            }

            wheelCollider.forwardFriction  = forwardFrictionCurve;
            wheelCollider.sidewaysFriction = sidewaysFrictionCurve;

            wheelCollider.wheelDampingRate = physicsFrictions[0].damp;

            emission  = allWheelParticles[0].emission;
            audioClip = physicsFrictions[0].groundSound;

            if (wheelSlipAmountSideways > physicsFrictions[0].slip || wheelSlipAmountForward > physicsFrictions[0].slip * 2f)
            {
                emission.enabled = true;
            }
            else
            {
                emission.enabled = false;
            }
        }

        for (int i = 0; i < allWheelParticles.Count; i++)
        {
            if (wheelSlipAmountSideways > startSlipValue || wheelSlipAmountForward > startSlipValue * 2f)
            {
            }
            else
            {
                emission         = allWheelParticles[i].emission;
                emission.enabled = false;
            }
        }
    }
Пример #16
0
 /// <summary>
 /// 设置中雨
 /// </summary>
 public void SetSnow()
 {
     ParticleSystem.EmissionModule emissionModule = psSnow.emission;
     emissionModule.rateOverTime = Random.Range(200, 300);
 }
Пример #17
0
    void Start()
    {
        carController     = GetComponentInParent <RCC_CarControllerV3>();
        carRigid          = carController.GetComponent <Rigidbody>();
        wheelCollider     = GetComponent <WheelCollider>();
        allWheelColliders = carController.allWheelColliders.ToList();
        allWheelColliders.Remove(this);

        if (FindObjectOfType(typeof(RCC_Skidmarks)))
        {
            skidmarks = FindObjectOfType(typeof(RCC_Skidmarks)) as RCC_Skidmarks;
        }
        else
        {
            Debug.Log("No skidmarks object found. Creating new one...");
            skidmarks = (RCC_Skidmarks)Instantiate(RCC_Settings.Instance.skidmarksManager, Vector3.zero, Quaternion.identity);
        }

        wheelCollider.mass    = carRigid.mass / 20f;
        forwardFrictionCurve  = wheelCollider.forwardFriction;
        sidewaysFrictionCurve = wheelCollider.sidewaysFriction;
        camber = this == carController.FrontLeftWheelCollider || this == carController.FrontRightWheelCollider ? carController.frontCamber : carController.rearCamber;

        switch (RCC_Settings.Instance.behaviorType)
        {
        case RCC_Settings.BehaviorType.SemiArcade:
            forwardFrictionCurve                = SetFrictionCurves(forwardFrictionCurve, .2f, 1f, 1f, 1f);
            sidewaysFrictionCurve               = SetFrictionCurves(sidewaysFrictionCurve, .25f, 1f, 1f, 1f);
            forwardFrictionCurve.stiffness      = 1f;
            sidewaysFrictionCurve.stiffness     = 1f;
            wheelCollider.forceAppPointDistance = Mathf.Clamp(wheelCollider.forceAppPointDistance, .35f, 1f);
            break;

        case RCC_Settings.BehaviorType.Drift:
            forwardFrictionCurve  = SetFrictionCurves(forwardFrictionCurve, .25f, 1f, .8f, .75f);
            sidewaysFrictionCurve = SetFrictionCurves(sidewaysFrictionCurve, .35f, 1f, .5f, .75f);
            wheelCollider.forceAppPointDistance = Mathf.Clamp(wheelCollider.forceAppPointDistance, .1f, 1f);
            if (carController._wheelTypeChoise == RCC_CarControllerV3.WheelType.FWD)
            {
                Debug.LogError("Current behavior mode is ''Drift'', but your vehicle named " + carController.name + " was FWD. You have to use RWD, AWD, or BIASED to rear wheels. Setting it to *RWD* now. ");
                carController._wheelTypeChoise = RCC_CarControllerV3.WheelType.RWD;
            }
            break;

        case RCC_Settings.BehaviorType.Fun:
            forwardFrictionCurve  = SetFrictionCurves(forwardFrictionCurve, .2f, 2f, 2f, 2f);
            sidewaysFrictionCurve = SetFrictionCurves(sidewaysFrictionCurve, .25f, 2f, 2f, 2f);
            wheelCollider.forceAppPointDistance = Mathf.Clamp(wheelCollider.forceAppPointDistance, .75f, 2f);
            break;

        case RCC_Settings.BehaviorType.Racing:
            forwardFrictionCurve  = SetFrictionCurves(forwardFrictionCurve, .2f, 1f, .8f, .75f);
            sidewaysFrictionCurve = SetFrictionCurves(sidewaysFrictionCurve, .3f, 1f, .25f, .75f);
            wheelCollider.forceAppPointDistance = Mathf.Clamp(wheelCollider.forceAppPointDistance, .25f, 1f);
            break;

        case RCC_Settings.BehaviorType.Simulator:
            forwardFrictionCurve  = SetFrictionCurves(forwardFrictionCurve, .2f, 1f, .8f, .75f);
            sidewaysFrictionCurve = SetFrictionCurves(sidewaysFrictionCurve, .25f, 1f, .5f, .75f);
            wheelCollider.forceAppPointDistance = Mathf.Clamp(wheelCollider.forceAppPointDistance, .1f, 1f);
            break;
        }

        orgForwardStiffness            = forwardFrictionCurve.stiffness;
        orgSidewaysStiffness           = sidewaysFrictionCurve.stiffness;
        wheelCollider.forwardFriction  = forwardFrictionCurve;
        wheelCollider.sidewaysFriction = sidewaysFrictionCurve;

        if (RCC_Settings.Instance.useSharedAudioSources)
        {
            if (!carController.transform.Find("All Audio Sources/Skid Sound AudioSource"))
            {
                audioSource = RCC_CreateAudioSource.NewAudioSource(carController.gameObject, "Skid Sound AudioSource", 5, 50, 0, audioClip, true, true, false);
            }
            else
            {
                audioSource = carController.transform.Find("All Audio Sources/Skid Sound AudioSource").GetComponent <AudioSource>();
            }
        }
        else
        {
            audioSource = RCC_CreateAudioSource.NewAudioSource(carController.gameObject, "Skid Sound AudioSource", 5, 50, 0, audioClip, true, true, false);
            audioSource.transform.position = transform.position;
        }

        for (int i = 0; i < RCC_GroundMaterials.Instance.frictions.Length; i++)
        {
            GameObject ps = (GameObject)Instantiate(RCC_GroundMaterials.Instance.frictions[i].groundParticles, transform.position, transform.rotation) as GameObject;
            emission         = ps.GetComponent <ParticleSystem>().emission;
            emission.enabled = false;
            ps.transform.SetParent(transform, false);
            ps.transform.localPosition = Vector3.zero;
            ps.transform.localRotation = Quaternion.identity;
            allWheelParticles.Add(ps.GetComponent <ParticleSystem>());
        }
    }
Пример #18
0
    // start from unity3d
    public void Start()
    {
        // Turns of PS based on controller type
        switch (m_eCurrState)
        {
        case E_BRANCH_STATE.E_BRANCH_STATE_PROTEK_TRACKER:
        case E_BRANCH_STATE.E_BRANCH_STATE_GFORCE_TRACKER:
        {
            psCol = psEffectsArray[0];
            ps    = psEffectsArray[1];
            if (m_eCurrState == E_BRANCH_STATE.E_BRANCH_STATE_GFORCE_TRACKER)
            {
                isTrackerOnBranch = true;
            }
            else
            {
                isTrackerOnBranch = false;
            }
            //isFreezeRot = false;
            break;
        }

        case E_BRANCH_STATE.E_BRANCH_STATE_PROTEK_VIVE:
        case E_BRANCH_STATE.E_BRANCH_STATE_GFORCE_VIVE:
        {
            psCol             = psEffectsArray[2];
            ps                = psEffectsArray[3];
            isTrackerOnBranch = false;
            //isFreezeRot = false;
            break;
        }

        case E_BRANCH_STATE.E_BRANCH_STATE_COUNT:
            break;

        default:
            break;
        }
        switch (m_eCurrState)
        {
        case E_BRANCH_STATE.E_BRANCH_STATE_PROTEK_TRACKER:
        case E_BRANCH_STATE.E_BRANCH_STATE_PROTEK_VIVE:
            isProtek = true;
            break;

        case E_BRANCH_STATE.E_BRANCH_STATE_GFORCE_TRACKER:
        case E_BRANCH_STATE.E_BRANCH_STATE_GFORCE_VIVE:
            isProtek = false;
            break;

        case E_BRANCH_STATE.E_BRANCH_STATE_COUNT:
            break;

        default:
            break;
        }

        // Water
        //ps = psEffectCurr;//.GetComponent<ParticleSystem>();
        _shapeModule    = ps.shape;
        _emissionModule = ps.emission;
        Angle           = _shapeModule.angle; //TODO: ??
        // Water Collision ps
        //psCol = psSteamEffectCurr;
        _shapeModuleCol    = psCol.shape;
        _emissionModuleCol = psCol.emission;
        Angle = _shapeModuleCol.angle; //TODO: ??

        prevFlowRateComb  = -1;
        prevfogStream     = -1;
        flowSelectSNormal = 0;
        fogStreamSNormal  = 0;
        init();
        if (_branchAnim == null)
        {
            _branchAnim = _branchesAnim[(int)m_eCurrState];
        }
        //turn off all other Branches that are not being used
        for (int i = 0; i < _branchesAnim.Length; i++)
        {
            if (i != (int)m_eCurrState)
            {
                _branchesAnim[i].gameObject.SetActive(false);
            }
        }
        this.StartCoroutine(this.PerformChanges());
        isXboxController = _branchAnim.GetIsXboxControllerUsed();
    }
 private void EnemyShoots(bool IsFriendlyActive)
 {
     ParticleSystem.EmissionModule eModule = projectileParticleEnemy.emission;
     eModule.enabled = IsFriendlyActive;
 }
Пример #20
0
    override public void Update()
    {
        ParticleSystemRenderer ren = GetComponentInChildren <ParticleSystemRenderer>();

        ren.material.color = ren.trailMaterial.color = gameSettings.GetComponent <GameSettings>().playerColors[playerNumber];


        if (GetComponent <PhotonView>().ownerId == PhotonNetwork.player.ID)
        {
            //THIS IS THE OWNER


            //update speeds
            float tempSpeed = MOVEMENT_SPEED;
            float tempMax   = MAX_SPEED;
            if (myPowerUp != powerUp.NONE)
            {
                timer += Time.deltaTime;
            }

            if (timer > 5)
            {
                timer     = 0;
                myPowerUp = powerUp.NONE;
            }

            if (myPowerUp == powerUp.SPEED)
            {
                tempSpeed += 1;
                tempMax   += 1;
            }



            //MOVEMENT
            int verticalMovement   = 0;
            int horizontalMovement = 0;

#if UNITY_STANDALONE
            if (Input.GetKey(thisMovement[MOVE_UP]))
            {
                verticalMovement += 1;
            }

            if (Input.GetKey(thisMovement[MOVE_DOWN]))
            {
                verticalMovement -= 1;
            }

            if (Input.GetKey(thisMovement[MOVE_RIGHT]))
            {
                horizontalMovement += 1;
            }

            if (Input.GetKey(thisMovement[MOVE_LEFT]))
            {
                horizontalMovement -= 1;
            }
#endif

            //Controls for Android devices
#if UNITY_ANDROID
            Touch touch = Input.GetTouch(0);

            if (!touch.Equals(null))
            {
                horizontalMovement = (int)(touch.deltaPosition.x);
                verticalMovement   = (int)(touch.deltaPosition.y);
            }
#endif

            xVel += horizontalMovement * tempSpeed * Time.deltaTime;
            yVel += verticalMovement * tempSpeed * Time.deltaTime;

            if (horizontalMovement == 0)
            {
                xVel -= Time.deltaTime * MOVEMENT_FRICTION * Mathf.Sign(xVel);
            }
            if (verticalMovement == 0)
            {
                yVel -= Time.deltaTime * MOVEMENT_FRICTION * Mathf.Sign(yVel);
            }

            if (Mathf.Abs(xVel) > tempMax)
            {
                xVel = tempMax * Mathf.Sign(xVel);
            }

            if (Mathf.Abs(xVel) < 0.2f && horizontalMovement == 0)
            {
                xVel = 0;
            }

            if (Mathf.Abs(yVel) > tempMax)
            {
                yVel = tempMax * Mathf.Sign(yVel);
            }

            if (Mathf.Abs(yVel) < 0.2f && verticalMovement == 0)
            {
                yVel = 0;
            }



            Vector3 move = (Vector3.up * yVel) + (Vector3.right * xVel);
            //move.Normalize();



            gameObject.transform.Translate(move);
        }
        else
        {
            //THIS IS ANOTHER PLAYER
        }

        //BOTH

        if (myPowerUp == powerUp.WIND)
        {
            GetComponent <SphereCollider>().radius = PLAYER_WIND_RADIUS;
            ParticleSystem ps = GetComponentInChildren <ParticleSystem>();

            ParticleSystem.ShapeModule shape = ps.shape;
            shape.radius = PLAYER_PARTICLE_WIND_RADIUS;

            ParticleSystem.EmissionModule emit = ps.emission;
            emit.rateOverTime = PLAYER_EMIT_WIND;
        }
        else
        {
            GetComponent <SphereCollider>().radius = PLAYER_RADIUS;
            ParticleSystem ps = GetComponentInChildren <ParticleSystem>();

            ParticleSystem.ShapeModule shape = ps.shape;
            shape.radius = PLAYER_PARTICLE_WIND_RADIUS;

            ParticleSystem.EmissionModule emit = ps.emission;
            emit.rateOverTime = PLAYER_EMIT;
        }
    }
 void Start()
 {
     em = bulletParticleSystem.emission;
 }
Пример #22
0
 private void ToggleTorch()
 {
     ParticleSystem.EmissionModule emission = TorchFire.emission;
     emission.enabled = !emission.enabled;
 }
Пример #23
0
 // Use this for initialization
 void Start()
 {
     emissionModule = GetComponentInChildren <ParticleSystem>().emission;
 }
Пример #24
0
    // Update is called once per frame
    void Update()
    {
        controller = new Controller();
        frame      = controller.Frame();
        hands      = frame.Hands;

        //Debug.Log(hands.Count);
        // rain -> pinecone play
        if (rain.isPlaying)
        {
            //StopCoroutine(rainRoutine);
            //Debug.Log("rain");
            if (delayTime == 150)
            {
                //Debug.Log("ani");
                pineconeAni["ani_0"].speed = 1;
                pineconeAni["ani_0"].time  = 0;
                pineconeAni.Play("ani_0");
                stopTime = -1;
            }
            else if (delayTime > 150 && !pineconeAni.isPlaying && stopTime == -1)
            {
                stopTime = delayTime;
            }
            else if (delayTime > 400 && !pineconeAni.isPlaying && (delayTime - stopTime) > 10 && stopTime != -1)
            {
                ParticleSystem.EmissionModule m_rain = rain.emission;
                m_rain.enabled = false;
                rain.Stop();
                rain.Clear();
                spreadPinecone = false;
                StopCoroutine(rainRoutine);
                //Debug.Log("rain stop");
            }
            delayTime++;
        }

        // sun -> pinecone reverse play
        if (sun.isPlaying)
        {
            //StopCoroutine(sunRoutine);
            //Debug.Log("sun");
            if (delayTime == 150)
            {
                //Debug.Log("reverse ani");
                pineconeAni["ani_0"].speed = -1;
                pineconeAni["ani_0"].time  = pineconeAni["ani_0"].length;
                pineconeAni.Play("ani_0");
                stopTime = -1;
            }
            else if (delayTime > 150 && !pineconeAni.isPlaying && stopTime == -1)
            {
                stopTime = delayTime;
            }
            else if (delayTime > 300 && !pineconeAni.isPlaying && (delayTime - stopTime) > 10 && stopTime != -1)
            {
                ParticleSystem.EmissionModule m_sun = sun.emission;
                m_sun.enabled = false;
                sun.Stop();
                sun.Clear();
                spreadPinecone = true;
                StopCoroutine(sunRoutine);
                //Debug.Log("sun stop");
            }
            delayTime++;
        }

        if (!rain.isPlaying && !sun.isPlaying)
        {
            delayTime = 0;
        }
    }
Пример #25
0
    // Update is called once per frame
    void Update()
    {
        /*//mobile input stuff
         * float smooth = 1, sensV = 1, sensH = 1;
         * CurAc = Vector3.Lerp(curAc, Input.acceleration-zeroAc, Time.deltaTime/smooth);
         * GetAxisV = Mathf.Clamp(curAc.y * sensV, -1, 1);
         * GetAxisH = Mathf.Clamp(curAc.x * sensH, -1, 1);*/

        float previousAngle = transform.rotation.eulerAngles.z;

        myVelocity = gameObject.GetComponent <Rigidbody2D>().velocity;       //Gets our current velocity, used for sound, and speed checks
        float currentSpeed = myVelocity.magnitude;

        //Analog Rotating stuff
        if (directionShootingJoystick.Vertical() < 0)           //Checks if the shoot analog/keys has negative vertial direction. If so, a negative rotation is applied (ask Ben if needed).
        {
            transform.rotation = Quaternion.RotateTowards(
                transform.rotation, Quaternion.AngleAxis(
                    -Vector2.Angle(Vector2.right, new Vector2(directionShootingJoystick.Horizontal(), directionShootingJoystick.Vertical())) - 90f,
                    Vector3.forward),
                rotationSpeed * (Time.deltaTime * 60) /* (1.3f - Mathf.Clamp( (myVelocity.magnitude  / maxSpeedMagnitude), 0.3f, 1f))*/);
        }
        else if (directionShootingJoystick.Vertical() != 0 || directionShootingJoystick.Horizontal() != 0)             //Checks if the shoot analog/keys is in use in any other direction
        {
            transform.rotation = Quaternion.RotateTowards(
                transform.rotation, Quaternion.AngleAxis(
                    Vector2.Angle(Vector2.right, new Vector2(directionShootingJoystick.Horizontal(), directionShootingJoystick.Vertical())) - 90f,
                    Vector3.forward),
                rotationSpeed * (Time.deltaTime * 60) /* (1.3f - Mathf.Clamp( (myVelocity.magnitude  / maxSpeedMagnitude), 0.3f, 1f))*/);
        }
        else if (movementJoystick.Vertical() < 0)              //Checks if the move analog/keys has negative vertial direction. If so, a negative rotation is applied (ask Ben if needed).
        {
            transform.rotation = Quaternion.RotateTowards(
                transform.rotation, Quaternion.AngleAxis(
                    -Vector2.Angle(Vector2.right, new Vector2(movementJoystick.Horizontal(), movementJoystick.Vertical())) - 90f,
                    Vector3.forward),
                rotationSpeed * (Time.deltaTime * 60) /* (1.3f - Mathf.Clamp( (myVelocity.magnitude  / maxSpeedMagnitude), 0.3f, 1f))*/);
        }
        else if (movementJoystick.Vertical() != 0 || movementJoystick.Horizontal() != 0)              //Checks if the move analog/keys is in use in any other direction
        {
            transform.rotation = Quaternion.RotateTowards(
                transform.rotation, Quaternion.AngleAxis(
                    Vector2.Angle(Vector2.right, new Vector2(movementJoystick.Horizontal(), movementJoystick.Vertical())) - 90f,
                    Vector3.forward),
                rotationSpeed * (Time.deltaTime * 60) /* (1.3f - Mathf.Clamp( (myVelocity.magnitude  / maxSpeedMagnitude), 0.3f, 1f))*/);
        }

        //Should ship also start shooting?
        if (directionShootingJoystick.Vertical() != 0 || directionShootingJoystick.Horizontal() != 0)
        {
            gameObject.GetComponent <Shoot> ().startShooting();
        }

        /*//This is purely a control for PC/Mac. It checks keyboard input at the same time so it only works to shoot as you move, but doesn't work on mobile touch screens
         * else if (Input.GetMouseButton (0) && (Input.GetKey (KeyCode.W) || Input.GetKey (KeyCode.A) || Input.GetKey (KeyCode.S) || Input.GetKey (KeyCode.D))) {//Mouse control for pc/mac where mouse is used to aim and shoot
         *
         *      gameObject.GetComponent<Shoot> ().startShooting ();
         *
         *      Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint (Input.mousePosition);
         *      Vector2 mouseRelativePos = new Vector2 (mouseWorldPos.x - transform.position.x, mouseWorldPos.y - transform.position.y);
         *
         *      if (mouseRelativePos.y > 0) {
         *              transform.rotation = Quaternion.RotateTowards (
         *                      transform.rotation, Quaternion.AngleAxis (
         *                      Vector2.Angle (Vector2.right, new Vector2 (mouseRelativePos.x, mouseRelativePos.y)) - 90f,
         *                      Vector3.forward),
         *                      rotationSpeed * (Time.deltaTime * 60) /* (1.3f - Mathf.Clamp( (myVelocity.magnitude  / maxSpeedMagnitude), 0.3f, 1f))*//*);
         *      } else {
         *              transform.rotation = Quaternion.RotateTowards (
         *                      transform.rotation, Quaternion.AngleAxis (
         *                      -Vector2.Angle (Vector2.right, new Vector2 (mouseRelativePos.x, mouseRelativePos.y)) - 90f,
         *                      Vector3.forward),
         *                      rotationSpeed * (Time.deltaTime * 60) /* (1.3f - Mathf.Clamp( (myVelocity.magnitude  / maxSpeedMagnitude), 0.3f, 1f))*//*);
         *      }
         * }*/else
        {
            gameObject.GetComponent <Shoot> ().stopShooting();            //As the shoot analog wasn't in use, don't shoot
        }



        //Zero all the thrusters
        theParticleSystem                       = rightThruster.GetComponent <ParticleSystem> ().emission;
        theParticleSystemsRateCurve             = theParticleSystem.rate;
        theParticleSystemsRateCurve.constantMax = 0;
        theParticleSystem.rate                  = theParticleSystemsRateCurve;

        theParticleSystem                       = leftThruster.GetComponent <ParticleSystem> ().emission;
        theParticleSystemsRateCurve             = theParticleSystem.rate;
        theParticleSystemsRateCurve.constantMax = 0;
        theParticleSystem.rate                  = theParticleSystemsRateCurve;

        //Increase particles to front thrusts
        theParticleSystem                       = rightFrontThrust.GetComponent <ParticleSystem>().emission;
        theParticleSystemsRateCurve             = theParticleSystem.rate;
        theParticleSystemsRateCurve.constantMax = 0;
        theParticleSystem.rate                  = theParticleSystemsRateCurve;

        theParticleSystem                       = leftFrontThrust.GetComponent <ParticleSystem>().emission;
        theParticleSystemsRateCurve             = theParticleSystem.rate;
        theParticleSystemsRateCurve.constantMax = 0;
        theParticleSystem.rate                  = theParticleSystemsRateCurve;
        //All thrusters are now zeroed

        float newAngle = transform.rotation.eulerAngles.z;

        float rotationAmount = newAngle - previousAngle;

        if (rotationAmount > 0)
        {
            //Increase particles to rear thrusts
            theParticleSystem                       = rightThruster.GetComponent <ParticleSystem> ().emission;
            theParticleSystemsRateCurve             = theParticleSystem.rate;
            theParticleSystemsRateCurve.constantMax = 100;
            theParticleSystem.rate                  = theParticleSystemsRateCurve;

            theParticleSystem                       = leftFrontThrust.GetComponent <ParticleSystem>().emission;
            theParticleSystemsRateCurve             = theParticleSystem.rate;
            theParticleSystemsRateCurve.constantMax = 100;
            theParticleSystem.rate                  = theParticleSystemsRateCurve;
        }
        else if (rotationAmount < 0)
        {
            theParticleSystem                       = leftThruster.GetComponent <ParticleSystem> ().emission;
            theParticleSystemsRateCurve             = theParticleSystem.rate;
            theParticleSystemsRateCurve.constantMax = 100;
            theParticleSystem.rate                  = theParticleSystemsRateCurve;

            //Increase particles to front thrusts
            theParticleSystem                       = rightFrontThrust.GetComponent <ParticleSystem>().emission;
            theParticleSystemsRateCurve             = theParticleSystem.rate;
            theParticleSystemsRateCurve.constantMax = 100;
            theParticleSystem.rate                  = theParticleSystemsRateCurve;
        }


        //Movement and sound
        Vector2 moveAngleInput = new Vector2(movementJoystick.Horizontal(), movementJoystick.Vertical());
        //Vector2 myVelocity = gameObject.GetComponent<Rigidbody2D>().velocity;//Gets our current velocity, used for sound, and speed checks


        float thrustMagnitude = moveAngleInput.magnitude;        //This is just for sound

        //float percentOfThrustFromRear = (180 - Mathf.Abs(Vector2.Angle (Vector2.right, new Vector2 (transform.up.x,transform.up.y)) - Vector2.Angle (Vector2.right, new Vector2 (movementJoystick.Horizontal (), movementJoystick.Vertical ())))) / 180;
        thrusterSound.pitch  = thrusterIdlePitch + myVelocity.magnitude / 30 + (thrustMagnitude / 3);        //Increase pitch a bit more for faster sound
        thrusterSound.volume = thrusterIdleVolume + myVelocity.magnitude / 100 + (thrustMagnitude / 3);

        //This works good as well
        //velocityToAdd += moveAngleInput * (((180 - angleDifference) / 360) + 0.5f);



        //angle of analog from nose
        angleDifference = (Vector2.Angle(moveAngleInput, new Vector2(transform.up.x, transform.up.y)));

        if (angleDifference < 90)
        {
            //Increases speed limit when going forward
            speedLimitToUse = Mathf.Clamp(strafeAndReverseSpeedLimit + ((forwardSpeedLimit - strafeAndReverseSpeedLimit) * (1 - angleDifference / 90)), currentSpeed, forwardSpeedLimit);

            //Add velocity for forward movement, using accerlation curve
            velocityToAdd += (moveAngleInput * (1 - angleDifference / 90) * forwardAccel * Time.deltaTime) * (1.5f - Mathf.Clamp((currentSpeed / forwardSpeedLimit - 4), 0.5f, 1f));
        }
        else
        {
            speedLimitToUse = Mathf.Clamp(strafeAndReverseSpeedLimit, currentSpeed, forwardSpeedLimit);
        }

        speedLimitToUse *= (1 - percentageFrostSlow);

        //Debug.Log (currentSpeed);

        //Inrcase velocity in move direction accordingly

        //Limit magnitude based on newly calculated top speed


        /*
         * //Try to apply some amount forward velocity
         * angleDifference = ( Vector2.Angle (moveAngleInput, new Vector2 (transform.up.x, transform.up.y)));
         * if (angleDifference < 90) {
         *
         *      //velocity to add is here
         *      velocityToCheck = moveAngleInput * (1 - angleDifference / 90) * forwardAccel * Time.deltaTime;
         *      velocityToCheck *= 1.5f - Mathf.Clamp( (myVelocity.magnitude  / maxSpeedMagnitude - 4), 0.5f, 1f);//Better working one
         *
         *      //float currentSpeed = myVelocity.y * -transform.up.y + myVelocity.x * -transform.up.x;
         *      float newSpeed = (myVelocity.y + velocityToCheck.y) * transform.up.y + (myVelocity.x + velocityToCheck.x) * transform.up.x;
         *
         *      //Don't add it if it puts you over the speed limit
         *      if (newSpeed < forwardSpeedLimit * (1 - angleDifference / 90)) {
         *              velocityToAdd += velocityToCheck;
         *      }
         * }
         */

        //Increase particles to rear thrusts
        theParticleSystem                        = rightThruster.GetComponent <ParticleSystem>().emission;
        theParticleSystemsRateCurve              = theParticleSystem.rate;
        theParticleSystemsRateCurve.constantMax += ((1 - angleDifference / 90) * 300);
        theParticleSystem.rate                   = theParticleSystemsRateCurve;

        theParticleSystem                        = leftThruster.GetComponent <ParticleSystem>().emission;
        theParticleSystemsRateCurve              = theParticleSystem.rate;
        theParticleSystemsRateCurve.constantMax += ((1 - angleDifference / 90) * 300);
        theParticleSystem.rate                   = theParticleSystemsRateCurve;

        /*
         * //Try to apply some amount of backward velocity
         * angleDifference = ( Vector2.Angle (moveAngleInput, new Vector2 (-transform.up.x, -transform.up.y)));
         * if (angleDifference < 90) {
         *
         *      velocityToCheck = /*-transform.up*//* moveAngleInput * (1 - angleDifference / 90) * backwardAccel * Time.deltaTime;
         *
         *      //float currentSpeed = myVelocity.y * -transform.up.y + myVelocity.x * -transform.up.x;
         *      float newSpeed = (myVelocity.y + velocityToCheck.y) * -transform.up.y + (myVelocity.x + velocityToCheck.x) * -transform.up.x;
         *
         *      //Don't add it if it puts you over the speed limit
         *      if (newSpeed < backwardSpeedLimit * (1 - angleDifference / 90)) {
         *              velocityToAdd += velocityToCheck;
         *      }
         * }*/

        angleDifference = (Vector2.Angle(moveAngleInput, new Vector2(-transform.up.x, -transform.up.y)));
        if (angleDifference < 90)
        {
            velocityToAdd += moveAngleInput * (1 - angleDifference / 90) * backwardAccel * Time.deltaTime;
        }

        //Increase particles to front thrusts
        theParticleSystem                        = rightFrontThrust.GetComponent <ParticleSystem>().emission;
        theParticleSystemsRateCurve              = theParticleSystem.rate;
        theParticleSystemsRateCurve.constantMax += ((1 - angleDifference / 90) * 50) + 0;
        theParticleSystem.rate                   = theParticleSystemsRateCurve;

        theParticleSystem                        = leftFrontThrust.GetComponent <ParticleSystem>().emission;
        theParticleSystemsRateCurve              = theParticleSystem.rate;
        theParticleSystemsRateCurve.constantMax += ((1 - angleDifference / 90) * 50) + 0;
        theParticleSystem.rate                   = theParticleSystemsRateCurve;


        /*
         * //Try to apply some amount of rightward velocity
         * angleDifference = ( Vector2.Angle (moveAngleInput, new Vector2 (transform.right.x, transform.right.y)));
         * if (angleDifference < 90) {
         *
         *      velocityToCheck = moveAngleInput * (1 - angleDifference / 90) * strafeAccel * Time.deltaTime;
         *
         *      //float currentSpeed = myVelocity.y * transform.right.y + myVelocity.x * transform.right.x;
         *      float newSpeed = (myVelocity.y + velocityToCheck.y) * transform.right.y + (myVelocity.x + velocityToCheck.x) * transform.right.x;
         *
         *      //Don't add it if it puts you over the speed limit
         *      if (newSpeed < strafeSpeedLimit * (1 - angleDifference / 90)) {
         *              velocityToAdd += velocityToCheck;
         *      }
         * }*/

        angleDifference = (Vector2.Angle(moveAngleInput, new Vector2(transform.right.x, transform.right.y)));
        if (angleDifference < 90)
        {
            velocityToAdd += moveAngleInput * (1 - angleDifference / 90) * strafeAccel * Time.deltaTime;
        }

        theParticleSystem                        = leftFrontThrust.GetComponent <ParticleSystem>().emission;
        theParticleSystemsRateCurve              = theParticleSystem.rate;
        theParticleSystemsRateCurve.constantMax += ((1 - angleDifference / 90) * 50) + 0;
        theParticleSystem.rate                   = theParticleSystemsRateCurve;

        /*
         * //Try to apply some amount of leftward velocity
         * angleDifference = ( Vector2.Angle (moveAngleInput, new Vector2 (-transform.right.x, -transform.right.y)));
         * if (angleDifference < 90) {
         *
         *      velocityToCheck = moveAngleInput * (1 - angleDifference / 90) * strafeAccel * Time.deltaTime;
         *
         *      //float currentSpeed = myVelocity.y * -transform.right.y + myVelocity.x * -transform.right.x;
         *      float newSpeed = (myVelocity.y + velocityToCheck.y) * -transform.right.y + (myVelocity.x + velocityToCheck.x) * -transform.right.x;
         *      //Debug.Log (newSpeed);
         *      //Don't add it if it puts you over the speed limit
         *      if (newSpeed < strafeSpeedLimit * (1 - angleDifference / 90)) {
         *              velocityToAdd += velocityToCheck;
         *      }
         * }*/

        angleDifference = (Vector2.Angle(moveAngleInput, new Vector2(-transform.right.x, -transform.right.y)));
        if (angleDifference < 90)
        {
            velocityToAdd += moveAngleInput * (1 - angleDifference / 90) * strafeAccel * Time.deltaTime;
        }

        //Increase particles to front right thrusts
        theParticleSystem                        = rightFrontThrust.GetComponent <ParticleSystem>().emission;
        theParticleSystemsRateCurve              = theParticleSystem.rate;
        theParticleSystemsRateCurve.constantMax += ((1 - angleDifference / 90) * 50) + 0;
        theParticleSystem.rate                   = theParticleSystemsRateCurve;


        //IMPROVE
        //Ship accelerates slower at speed, similar to a plane
        //Debug.Log(1.0f - (myVelocity.magnitude / maxSpeedMagnitude));

        //velocityToAdd *= 1.5f - Mathf.Clamp( (myVelocity.magnitude  / maxSpeedMagnitude - 4), 0.5f, 1f);//Old one
        //velocityToAdd *= 1.5f - Mathf.Clamp( (myVelocity.magnitude  / maxSpeedMagnitude - 4), 0.5f, 1f);//Better working one

        //velocityToAdd *= 2f - Mathf.Clamp( (myVelocity.magnitude  / maxSpeedMagnitude) * 1.5f, 1f, 1.5f);//Other decent alternative

        //Slow acceleration
        velocityToAdd *= (1 - percentageFrostSlow);

        gameObject.GetComponent <Rigidbody2D> ().velocity += velocityToAdd;       //Add the velocity
        //Debug.Log (gameObject.GetComponent<Rigidbody2D> ().velocity.magnitude);

        velocityToAdd = Vector2.zero;        //Reset the velocity to add value, ready for the next update

        //If the ship's velocity is above the max speed, it is reduced to the max speed instead.
        if (gameObject.GetComponent <Rigidbody2D> ().velocity.magnitude > /*maxSpeedMagnitude*/ speedLimitToUse)
        {
            gameObject.GetComponent <Rigidbody2D> ().velocity = gameObject.GetComponent <Rigidbody2D> ().velocity.normalized *speedLimitToUse;
        }

        //Debug.Log (gameObject.GetComponent<Rigidbody2D> ().velocity.magnitude);

        //UNSURE

        /*if (gameObject.GetComponent<Rigidbody2D> ().velocity.magnitude < 10f && moveAngleInput.magnitude < 0.5f) {
         *      gameObject.GetComponent<Rigidbody2D> ().drag = originalDrag + (1 - (gameObject.GetComponent<Rigidbody2D> ().velocity.magnitude / 10)) * 1.2f;
         *      //gameObject.GetComponent<Rigidbody2D> ().drag = originalDrag + 1;
         * } else
         *      gameObject.GetComponent<Rigidbody2D> ().drag = originalDrag;
         */


        /*//stuff for recharging boost
         * remainingBoostRechargeDelay -= Time.deltaTime;
         * if (remainingBoostRechargeDelay <= 0) {
         *      remainingBoostDuration += (maxBoostDuration / fullBoostRechargeTime) * Time.deltaTime;
         *      if (remainingBoostDuration > maxBoostDuration)
         *              remainingBoostDuration = maxBoostDuration;
         * }*/
    }
Пример #26
0
 void Start()
 {
     ps  = GetComponent <ParticleSystem>();
     em  = ps.emission;
     col = ps.colorOverLifetime;
 }
Пример #27
0
 public static void ActiveEmit(this ParticleSystem particleSystem, bool isOpen)
 {
     ParticleSystem.EmissionModule em = particleSystem.emission;
     em.enabled = isOpen;
 }
Пример #28
0
 // Use this for initialization
 void Start()
 {
     markerEmission = markerParticles.emission;
     monsterList    = reader.LoadCSV();
     GameStart();
 }
Пример #29
0
 // Token: 0x0600019D RID: 413 RVA: 0x0001C934 File Offset: 0x0001AD34
 private void Update()
 {
     if (this.Phase == 1)
     {
         this.Darkness.color = new Color(this.Darkness.color.r, this.Darkness.color.g, this.Darkness.color.b, Mathf.MoveTowards(this.Darkness.color.a, 1f, Time.deltaTime));
         this.Panel.alpha    = Mathf.MoveTowards(this.Panel.alpha, 0f, Time.deltaTime);
         this.Jukebox.Volume = Mathf.MoveTowards(this.Jukebox.Volume, 0f, Time.deltaTime);
         if (this.Darkness.color.a == 1f)
         {
             this.Timer += Time.deltaTime;
             if (this.Timer > 1f)
             {
                 this.BloomEffect.bloomIntensity      = 1f;
                 this.BloomEffect.bloomThreshhold     = 0f;
                 this.BloomEffect.bloomBlurIterations = 1;
                 this.Suitor = this.StudentManager.Students[13];
                 this.Rival  = this.StudentManager.Students[7];
                 this.Rival.transform.position    = this.RivalSpot.position;
                 this.Rival.transform.eulerAngles = this.RivalSpot.eulerAngles;
                 this.Suitor.Cosmetic.MyRenderer.materials[this.Suitor.Cosmetic.FaceID].SetFloat("_BlendAmount", 1f);
                 this.Suitor.transform.eulerAngles = this.StudentManager.SuitorConfessionSpot.eulerAngles;
                 this.Suitor.transform.position    = this.StudentManager.SuitorConfessionSpot.position;
                 this.Suitor.Character.GetComponent <Animation>().Play(this.Suitor.IdleAnim);
                 var emission = this.MythBlossoms.emission;
                 emission.rateOverTime = 100f;
                 this.HeartBeatCamera.SetActive(false);
                 this.ConfessionBG.SetActive(true);
                 base.GetComponent <AudioSource>().Play();
                 this.MainCamera.position    = this.CameraDestinations[1].position;
                 this.MainCamera.eulerAngles = this.CameraDestinations[1].eulerAngles;
                 this.Timer = 0f;
                 this.Phase++;
             }
         }
     }
     else if (this.Phase == 2)
     {
         this.Darkness.color = new Color(this.Darkness.color.r, this.Darkness.color.g, this.Darkness.color.b, Mathf.MoveTowards(this.Darkness.color.a, 0f, Time.deltaTime));
         if (this.Darkness.color.a == 0f)
         {
             if (!this.ShowLabel)
             {
                 this.Label.color = new Color(this.Label.color.r, this.Label.color.g, this.Label.color.b, Mathf.MoveTowards(this.Label.color.a, 0f, Time.deltaTime));
                 if (this.Label.color.a == 0f)
                 {
                     if (this.TextPhase < 5)
                     {
                         this.MainCamera.position    = this.CameraDestinations[this.TextPhase].position;
                         this.MainCamera.eulerAngles = this.CameraDestinations[this.TextPhase].eulerAngles;
                         if (this.TextPhase == 4 && !this.Kissing)
                         {
                             ParticleSystem.EmissionModule emission = this.Suitor.Hearts.emission;
                             emission.enabled      = true;
                             emission.rateOverTime = 10f;
                             this.Suitor.Hearts.Play();
                             ParticleSystem.EmissionModule emission2 = this.Rival.Hearts.emission;
                             emission2.enabled      = true;
                             emission2.rateOverTime = 10f;
                             this.Rival.Hearts.Play();
                             this.Suitor.Character.transform.localScale = new Vector3(1f, 1f, 1f);
                             this.Suitor.Character.GetComponent <Animation>().Play("kiss_00");
                             this.Suitor.transform.position = this.KissSpot.position;
                             this.Rival.Character.GetComponent <Animation>()[this.Rival.ShyAnim].weight = 0f;
                             this.Rival.Character.GetComponent <Animation>().Play("f02_kiss_00");
                             this.Kissing = true;
                         }
                         this.Label.text = this.Text[this.TextPhase];
                         this.ShowLabel  = true;
                     }
                     else
                     {
                         this.Phase++;
                     }
                 }
             }
             else
             {
                 this.Label.color = new Color(this.Label.color.r, this.Label.color.g, this.Label.color.b, Mathf.MoveTowards(this.Label.color.a, 1f, Time.deltaTime));
                 if (this.Label.color.a == 1f)
                 {
                     if (!this.PromptBar.Show)
                     {
                         this.PromptBar.ClearButtons();
                         this.PromptBar.Label[0].text = "Continue";
                         this.PromptBar.UpdateButtons();
                         this.PromptBar.Show = true;
                     }
                     if (Input.GetButtonDown("A"))
                     {
                         this.TextPhase++;
                         this.ShowLabel = false;
                     }
                 }
             }
         }
     }
     else if (this.Phase == 3)
     {
         this.Darkness.color = new Color(this.Darkness.color.r, this.Darkness.color.g, this.Darkness.color.b, Mathf.MoveTowards(this.Darkness.color.a, 1f, Time.deltaTime));
         if (this.Darkness.color.a == 1f)
         {
             this.Timer += Time.deltaTime;
             if (this.Timer > 1f)
             {
                 DatingGlobals.SuitorProgress = 2;
                 this.Suitor.Character.transform.localScale = new Vector3(0.94f, 0.94f, 0.94f);
                 this.PromptBar.ClearButtons();
                 this.PromptBar.UpdateButtons();
                 this.PromptBar.Show = false;
                 this.ConfessionBG.SetActive(false);
                 this.Yandere.FixCamera();
                 this.Phase++;
             }
         }
     }
     else
     {
         this.Darkness.color = new Color(this.Darkness.color.r, this.Darkness.color.g, this.Darkness.color.b, Mathf.MoveTowards(this.Darkness.color.a, 0f, Time.deltaTime));
         this.Panel.alpha    = Mathf.MoveTowards(this.Panel.alpha, 1f, Time.deltaTime);
         if (this.Darkness.color.a == 0f)
         {
             this.Yandere.RPGCamera.enabled = true;
             this.Yandere.CanMove           = true;
             this.HeartBeatCamera.SetActive(true);
             var emission = MythBlossoms.emission;
             emission.rateOverTime = 20f;
             this.Clock.StopTime   = false;
             base.enabled          = false;
             this.Suitor.CoupleID  = 7;
             this.Rival.CoupleID   = 13;
         }
     }
     if (this.Kissing)
     {
         Animation component = this.Suitor.Character.GetComponent <Animation>();
         if (component["kiss_00"].time >= component["kiss_00"].length)
         {
             component.CrossFade(this.Suitor.IdleAnim);
             this.Rival.Character.GetComponent <Animation>().CrossFade(this.Rival.IdleAnim);
             this.Kissing = false;
         }
     }
 }
Пример #30
0
    void Update()
    {
        rollDodgeTimer += Time.deltaTime;
        universalTimer += Time.deltaTime;
        meleeTimer     += Time.deltaTime;
        //rangedTimer += Time.deltaTime;

        if (!isControllerEnabled)
        {
            return;
        }

        #region Movement

        wasGroundedLastFrame = isGrounded;

        Vector2 downDirection = new Vector2(0, -1);

        /*Check if grounded
         * RaycastHit2D groundRay = Physics2D.Raycast(transform.position, downDirection, 10, groundMask);
         *
         * float groundDistance = Vector2.Distance(transform.position + bottomOffset, groundRay.point);
         *
         * if (groundDistance < groundDetectDistance)
         * {
         *  if (!(jumpCount == 1 && lastJumpCount == 0))
         *  {
         *      isGrounded = true;
         *
         *      jumpCount = 0;
         *  }
         * }
         * else
         * {
         *  isGrounded = false;
         * }
         */

        RaycastHit2D groundRay = Physics2D.Raycast(transform.position + horizontalOffset, downDirection, 10, groundMask);

        float groundDistance = Vector2.Distance(transform.position + horizontalOffset + bottomOffset, groundRay.point);

        if (groundDistance < groundDetectDistance)
        {
            if (!(jumpCount == 1 && lastJumpCount == 0))
            {
                isGrounded = true;

                jumpCount = 0;
            }
        }
        else
        {
            isGrounded = false;
        }

        if (!groundRay)
        {
            groundRay = Physics2D.Raycast(transform.position - horizontalOffset, downDirection, 10, groundMask);

            groundDistance = Vector2.Distance(transform.position - horizontalOffset + bottomOffset, groundRay.point);

            if (groundDistance < groundDetectDistance)
            {
                if (!(jumpCount == 1 && lastJumpCount == 0))
                {
                    isGrounded = true;

                    jumpCount = 0;
                }
            }
            else
            {
                isGrounded = false;
            }
        }

        /*Check if can climb down
         * groundRay = Physics2D.Raycast(transform.position, downDirection, 10, climbMask);
         *
         * groundDistance = Vector2.Distance(transform.position + bottomOffset, groundRay.point);
         *
         * if (groundDistance < groundDetectDistance && canClimbDown)
         * {
         *  if (!(jumpCount == 1 && lastJumpCount == 0))
         *  {
         *      isGrounded = true;
         *
         *      jumpCount = 0;
         *  }
         * }
         */

        groundRay = Physics2D.Raycast(transform.position + horizontalOffset, downDirection, 10, climbMask);

        groundDistance = Vector2.Distance(transform.position + horizontalOffset + bottomOffset, groundRay.point);

        if (groundDistance < groundDetectDistance && canJump && !canClimbUp)
        {
            if (!(jumpCount == 1 && lastJumpCount == 0))
            {
                isGrounded = true;

                jumpCount = 0;
            }
        }

        if (!groundRay)
        {
            groundRay = Physics2D.Raycast(transform.position - horizontalOffset, downDirection, 10, climbMask);

            groundDistance = Vector2.Distance(transform.position - horizontalOffset + bottomOffset, groundRay.point);

            if (groundDistance < groundDetectDistance && canJump && !canClimbUp)
            {
                if (!(jumpCount == 1 && lastJumpCount == 0))
                {
                    isGrounded = true;

                    jumpCount = 0;
                }
            }
        }

        //Dust Kick Particles
        if (isGrounded)
        {
            ParticleSystem.EmissionModule em = dustKickObject.GetComponent <ParticleSystem>().emission;
            em.enabled = true;
        }
        else
        {
            ParticleSystem.EmissionModule em = dustKickObject.GetComponent <ParticleSystem>().emission;
            em.enabled = false;
        }

        //Climb Up
        if (Input.GetKeyDown(KeyCode.W) && isGrounded && canClimbUp && isWithinBounds && !isParrying && !isRolling)
        {
            isMoving = false;

            rb.gravityScale = 0;

            isClimbing = true;
        }

        //Climb Down
        if (Input.GetKeyDown(KeyCode.S) && canClimbDown && !isParrying && !isRolling)
        {
            if (groundRay)
            {
                isMoving = false;

                groundRay.collider.gameObject.GetComponent <BoxCollider2D>().isTrigger = true;

                canClimbDown = false;

                canClimbUp = true;

                rb.gravityScale = 0;

                isClimbing = true;
            }
        }

        //Climb Movement
        if (Input.GetButton("Vertical") && isClimbing)
        {
            if (!isStealthed)
            {
                rb.velocity = new Vector2(0.0f, climbVelocity * Input.GetAxis("Vertical"));
            }
            else
            {
                rb.velocity = new Vector2(0.0f, stealthClimbVelocity * Input.GetAxis("Vertical"));
            }

            if (isGrounded && !wasGroundedLastFrame)
            {
                rb.gravityScale = gravityScale;

                isClimbing = false;
            }
        }
        else if (Input.GetButtonUp("Vertical") && isClimbing)
        {
            rb.velocity = Vector2.zero;
        }

        //Move left and right
        if (Input.GetButton("Horizontal") && !isClimbing && !isRolling && !isParrying)
        {
            isMoving = true;

            if (Input.GetKeyDown(KeyCode.D))
            {
                SetFacingDirection(1);
            }
            else if (Input.GetKeyDown(KeyCode.A))
            {
                SetFacingDirection(-1);
            }

            if (!isStealthed)
            {
                rb.velocity = new Vector2(runVelocity * Input.GetAxis("Horizontal"), rb.velocity.y);
            }
            else
            {
                rb.velocity = new Vector2(stealthVelocity * Input.GetAxis("Horizontal"), rb.velocity.y);
            }
        }
        //Drag after stopped moving
        else if (Input.GetButtonUp("Horizontal") && !isClimbing && !isRolling && !isParrying)
        {
            isMoving = false;

            if (!isStealthed)
            {
                rb.velocity = new Vector2(runDragVelocity * Input.GetAxis("Horizontal"), rb.velocity.y);
            }
            else
            {
                rb.velocity = new Vector2(stealthDragVelocity * Input.GetAxis("Horizontal"), rb.velocity.y);
            }
        }

        //Roll dodge
        if (Input.GetKeyDown(KeyCode.LeftShift) && rollDodgeTimer >= rollDodgeCooldown && isGrounded && !isParrying)
        {
            pa.RollDodge();

            isRolling = true;

            isMoving = false;

            rb.velocity = Vector2.zero;

            rollDodgeTimer = 0;

            float rollDodgeFacingDirection = Input.GetAxis("Horizontal") != 0 ? Input.GetAxis("Horizontal") : GetFacingDirectionWithMouse();

            if (rollDodgeFacingDirection > 0)
            {
                rollDodgeFacingDirection = 1;
            }
            else if (rollDodgeFacingDirection < 0)
            {
                rollDodgeFacingDirection = -1;
            }

            rollDodgeStartPos = transform.position;
            rollDodgeEndPos   = new Vector2(transform.position.x + (rollDodgeFacingDirection * rollDodgeDistance), transform.position.y);

            rollDodgeProgress = 0;
        }

        if (rollDodgeProgress < 1.0f)
        {
            rollDodgeProgress += Time.deltaTime * rollDodgeRate;

            transform.position = Vector3.Lerp(rollDodgeStartPos, rollDodgeEndPos, rollDodgeProgress);

            if (rollDodgeProgress >= 1.0f)
            {
                isRolling = false;
            }
        }

        //Stealth toggle
        if (Input.GetKeyDown(KeyCode.LeftControl) && isGrounded && !isClimbing && !isParrying && !isRolling)
        {
            ToggleStealth();
        }

        lastJumpCount = jumpCount;

        //Jumping while grounded
        if (Input.GetButtonDown("Jump") && isGrounded && jumpCount == 0 && !isClimbing && !isParrying && !isRolling)
        {
            jumpCount++;

            pa.Jump();

            if (isStealthed)
            {
                ToggleStealth();
            }

            rb.velocity = new Vector2(rb.velocity.x, jumpVelocity);
        }
        //Jumping while not grounded
        else if (Input.GetButtonDown("Jump") && !isGrounded && jumpCount <= maxAirJumps && jumpCount > 0 && !isClimbing && !isParrying && !isRolling)
        {
            jumpCount++;

            pa.DoubleJump();

            rb.velocity = new Vector2(rb.velocity.x, jumpVelocity);
        }
        #endregion

        #region Combat

        //Melee
        if (Input.GetButton("Fire1") && meleeTimer >= meleeCooldown && universalTimer >= universalCooldown && !isClimbing && !isParrying && !isRolling)
        {
            pa.MeleeAttack();

            Vector2 meleeDirection = new Vector2(GetFacingDirectionWithMouse(), 0);

            RaycastHit2D meleeRay = Physics2D.Raycast(transform.position, meleeDirection, Mathf.Infinity, enemyMask);

            if (meleeRay)
            {
                float meleeDistance = Vector2.Distance(transform.position + horizontalOffset, meleeRay.point);

                if (meleeDistance <= meleeRange)
                {
                    float sneakAttackMultiplier = isStealthed ? stealthDamageMultiplier : 1;

                    if (isStealthed)
                    {
                        ToggleStealth();
                    }

                    GameObject meleeTarget = meleeRay.collider.gameObject;

                    int totalMeleeDamage = (int)(meleeDamage * sneakAttackMultiplier);

                    if (meleeTarget.CompareTag("Enemy"))
                    {
                        meleeTarget.GetComponent <EnemyHealth>().TakeDamage(totalMeleeDamage);
                    }
                    else if (meleeTarget.CompareTag("Guard"))
                    {
                        meleeTarget.GetComponent <GuardHealth>().TakeDamage(totalMeleeDamage);
                    }
                }
            }

            meleeTimer = 0;

            universalTimer = 0;
        }

        /*Ranged
         * if (Input.GetButton("Fire2") && rangedTimer >= rangedCooldown && universalTimer >= universalCooldown && !isClimbing)
         * {
         *  Vector3 rangedDirection = new Vector3(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y);
         *
         *  Vector3 rangedOffset = new Vector3(rangedSpawnOffset * GetFacingDirectionWithMouse(), bc.offset.y);
         *
         *  Vector3 rangedSpawnPoint = transform.position + horizontalOffset + rangedOffset;
         *
         *  rangedDirection = Vector3.Normalize(rangedDirection - rangedSpawnPoint);
         *
         *  int sneakDamageMultiplier = isStealthed ? 2 : 1;
         *
         *  isStealthed = false;
         *
         *  pa.RangedAttack();
         *
         *  GameObject rangedObject = Instantiate(rangedPrefab, rangedSpawnPoint, Quaternion.identity) as GameObject;
         *  rangedObject.GetComponent<Projectile>().projectileSettings.direction = rangedDirection;
         *  rangedObject.GetComponent<Projectile>().projectileSettings.targetMask = enemyMask;
         *  rangedObject.GetComponent<Projectile>().projectileSettings.damage = rangedDamage * sneakDamageMultiplier;
         *  rangedObject.GetComponent<Projectile>().projectileSettings.velocity = rangedVelocity;
         *
         *  rangedTimer = 0;
         *
         *  universalTimer = 0;
         * }
         */

        //Parry
        if (Input.GetButton("Fire2") && universalTimer >= universalCooldown && !isClimbing && !isRolling)
        {
            isParrying = true;

            if (isGrounded)
            {
                rb.velocity = new Vector3(0f, rb.velocity.y);
            }

            isMoving = false;
        }
        else if (Input.GetButtonUp("Fire2"))
        {
            isParrying = false;

            universalTimer = 0;
        }

        #endregion

        #region Spells

        healSpellTimer += Time.deltaTime;

        //Heal Spell
        if (Input.GetKeyDown(KeyCode.R) && healSpellTimer >= healSpellCooldown)
        {
            pa.HealSpell();

            StartCoroutine(HealSpell());

            healSpellTimer = 0;

            if (isGrounded)
            {
                rb.velocity = new Vector3(0f, rb.velocity.y);
            }

            isMoving = false;
        }
        #endregion

        #region Interaction

        Vector2 leftMaxDistance  = transform.position - new Vector3(interactMaxDistance, 0);
        Vector2 rightMaxDistance = transform.position + new Vector3(interactMaxDistance, 0);

        RaycastHit2D interactRay = Physics2D.Linecast(leftMaxDistance, rightMaxDistance, interactMask);

        if (interactRay)
        {
            GameObject interactTarget = interactRay.collider.gameObject;

            if (GameObject.Find("InteractIndicator") == null)
            {
                Vector3    interactIndicatorPosition = new Vector3(interactTarget.transform.position.x, interactTarget.transform.position.y + interactIndicatorOffset);
                GameObject interactIndicator         = Instantiate(interactIndicatorPrefab, interactIndicatorPosition, Quaternion.identity) as GameObject;
                interactIndicator.name = "InteractIndicator";
            }

            if (Input.GetKeyDown(KeyCode.E))
            {
                interactTarget.GetComponent <QuestNPCController>().Interact();
            }
        }
        else
        {
            if (GameObject.Find("InteractIndicator") != null)
            {
                GameObject.Destroy(GameObject.Find("InteractIndicator"));
            }
        }

        #endregion
    }