Пример #1
0
        public void AddTire(Tire newTire, float degradeInterval, int degradeValue)
        {
            if (tireDegrader != null)
            {
                this.StopCoroutine(tireDegrader);
                this.RemoveKartModifier(tireModifier);
            }
            tire = newTire;
            ChangeTireMesh();

            //Need to copy values in a better way, but for now just copying the grip is ok.
            tireModifier = new AddativeKartModifier();
            tireModifier.modifiers.grip = tire.GetModifier().modifiers.grip;

            tireDegrader = this.StartCoroutine(TireDegrader(degradeInterval, degradeValue));
        }
Пример #2
0
        private IEnumerator TireDegrader(float degradeInterval, int degradeValue)
        {
            this.AddKartModifier(tireModifier);
            float startgrip      = tireModifier.modifiers.grip;
            float lowGripWarning = 0.3f;

            while (tireModifier.modifiers.grip > 0)
            {
                yield return(new WaitForSeconds(degradeInterval));

                if (this.IsControlled())
                {
                    tireModifier.modifiers.grip -= degradeValue;
                    if (tireModifier.modifiers.grip < startgrip * lowGripWarning)
                    {
                        OnLowGrip.Invoke();
                    }
                }
            }

            this.RemoveKartModifier(tireModifier);
            tireModifier = null;
        }