Пример #1
0
 protected override void OnApplyCarEffect(CarProperties properties, bool triggeredPowerup)
 {
     if (!triggeredPowerup)
     {
         SetCarColor(properties);
     }
 }
Пример #2
0
 protected override void OnRemoveCarEffect(CarProperties properties, bool triggeredPowerup)
 {
     if (!triggeredPowerup)
     {
         ResetCarColor(properties);
     }
 }
Пример #3
0
 protected override void OnRemoveCarEffect(CarProperties properties, bool triggeredPowerup)
 {
     if (triggeredPowerup)
     {
         Destroy(_shieldObject);
     }
 }
 void OnDestroy()
 {
     if (instance == this)
     {
         instance = null;
     }
 }
Пример #5
0
 private void GetObjects()
 {
     inputManager            = FindObjectOfType <InputManager>();
     carProperties           = GetComponent <CarProperties>();
     _rigidbody              = GetComponent <Rigidbody>();
     centerOfMass            = GameObject.Find("CenterOfMass");
     _rigidbody.centerOfMass = centerOfMass.transform.localPosition;
 }
 protected override void OnRemoveCarEffect(CarProperties properties, bool triggeredPowerup)
 {
     if (triggeredPowerup)
     {
         properties.Scale      /= SCALE_FACTOR;
         properties.SpeedLimit /= SPEED_FACTOR;
         properties.Accel      /= SPEED_FACTOR;
         properties.TurnRate   /= TURN_FACTOR;
     }
 }
 protected override void OnApplyCarEffect(CarProperties properties, bool triggeredPowerup)
 {
     if (triggeredPowerup)
     {
         properties.Scale      *= SCALE_FACTOR;
         properties.SpeedLimit *= SPEED_FACTOR;
         properties.Accel      *= SPEED_FACTOR;
         properties.TurnRate   *= TURN_FACTOR;
     }
 }
 public void initialise(CarProperties carProp, T abilitySetup, Canvas canvas, bool didTriggerPowerup, bool isLocalAuthority, AbilityCallbacks callbacks)
 {
     Debug.Log("initialising ability");
     _ownCarProperties  = carProp;
     _abilitySetup      = abilitySetup;
     _playerCanvas      = canvas;
     _didTriggerPowerup = didTriggerPowerup;
     _isLocalAuthority  = isLocalAuthority;
     _callbacks         = callbacks;
 }
Пример #9
0
 public void Init(CarProperties properties)
 {
     stats             = properties;
     accelerationForce = properties.accelerationForce;
     maxSpeed          = properties.maxSpeed;
     rotationSpeed     = properties.rotationSpeed;
     driftFactor       = properties.driftFactor;
     carName           = properties.carName;
     waypointOffset    = properties.waypointOffset;
     brakeProbability  = properties.brakeProbability;
 }
        protected override void OnApplyCarEffect(CarProperties properties, bool triggeredPowerup)
        {
            if (triggeredPowerup)
            {
                _sparklesObj = GameObject.Instantiate(((SpeedAbilityProperties)_abilitySetup.AbilityProperties).SparklesPrefab);
                _sparklesObj.transform.SetParent(properties.transform, false);

                properties.SpeedLimit *= SPEED_FACTOR;
                properties.Accel      *= SPEED_FACTOR;
            }
        }
Пример #11
0
        protected override void OnApplyCarEffect(CarProperties properties, bool triggeredPowerup)
        {
            if (triggeredPowerup)
            {
                // Instantiate and keep track of the new instance
                _shieldObject = Instantiate(((ShieldAbilityProperties)_abilitySetup.AbilityProperties).ShieldPrefab);

                // Set parent
                _shieldObject.transform.SetParent(transform, false);
                _shieldObject.transform.localPosition = Vector3.zero;
            }
        }
Пример #12
0
        // alters the value property of the car materials' HSV
        public static void SetCarColor(CarProperties properties)
        {
            Material[] materials = properties.transform.FindChild("Car_Model").GetComponent <MeshRenderer> ().materials;

            foreach (var mat in materials)
            {
                Debug.Log(mat.name);
                if (mat.name.StartsWith("Body"))
                {
                    mat.color = Color.HSVToRGB(0f, 0f, 0f);
                }
            }
        }
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
            return;
        }
        instance = this;

        defaultSpeed.slider.onValueChanged.AddListener(SliderUpdated);
        overtakePercent.slider.onValueChanged.AddListener(SliderUpdated);
        leftMergeDistance.slider.onValueChanged.AddListener(SliderUpdated);
        mergeSpace.slider.onValueChanged.AddListener(SliderUpdated);
        overtakeEagerness.slider.onValueChanged.AddListener(SliderUpdated);
    }
    public void ChangeCurrentCar(int index)
    {
        if (!carPlatform.activeSelf)
        {
            carPlatform.SetActive(true);
        }

        Destroy(currentCar);

        currentCar           = Instantiate(cars[index], carPlatform.transform);
        currentCarProperties = currentCar.GetComponent <CarProperties>();

        InitStatBars();

        gameManager.SelectedProperties.SelectedCarIndex = index;
    }
Пример #15
0
        public static void RouteTag(String abilityTag, CarProperties carProperties, GameObject gameObject, BasePowerUpManager powerupManager, bool didTriggerPowerup, bool isLocalPlayer)
        {
            switch (abilityTag)
            {
            case SandboxInkAbility.TAG:
                Debug.Log("******** SANDBOX INKED! ********");
                SandboxInkAbility sandboxInkAbility = (SandboxInkAbility)gameObject.AddComponent(typeof(SandboxInkAbility));
                sandboxInkAbility.initialise(carProperties, (SandboxInkAbilitySetup)powerupManager.GetAbilitySetup(typeof(SandboxInkAbility)), powerupManager.PlayerCanvas, didTriggerPowerup, isLocalPlayer, (AbilityCallbacks)powerupManager);
                break;

            case InkAbility.TAG:
                Debug.Log("******** INKED! ********");
                InkAbility inkAbility = (InkAbility)gameObject.AddComponent(typeof(InkAbility));
                inkAbility.initialise(carProperties, (InkAbilitySetup)powerupManager.GetAbilitySetup(typeof(InkAbility)), powerupManager.PlayerCanvas, didTriggerPowerup, isLocalPlayer, (AbilityCallbacks)powerupManager);
                break;

            case SpeedAbility.TAG:
                Debug.Log("******** SPEED! ********");
                SpeedAbility speedAbility = (SpeedAbility)gameObject.AddComponent(typeof(SpeedAbility));
                speedAbility.initialise(carProperties, (SpeedAbilitySetup)powerupManager.GetAbilitySetup(typeof(SpeedAbility)), powerupManager.PlayerCanvas, didTriggerPowerup, isLocalPlayer, (AbilityCallbacks)powerupManager);
                break;

            case ShieldAbility.TAG:
                Debug.Log("******** SHIELD! ********");
                ShieldAbility shieldAbility = (ShieldAbility)gameObject.AddComponent(typeof(ShieldAbility));
                shieldAbility.initialise(carProperties, (ShieldAbilitySetup)powerupManager.GetAbilitySetup(typeof(ShieldAbility)), powerupManager.PlayerCanvas, didTriggerPowerup, isLocalPlayer, (AbilityCallbacks)powerupManager);
                break;

            case GrowAbility.TAG:
                Debug.Log("******** GROW! ********");
                GrowAbility growAbility = (GrowAbility)gameObject.AddComponent(typeof(GrowAbility));
                growAbility.initialise(carProperties, (GrowAbilitySetup)powerupManager.GetAbilitySetup(typeof(GrowAbility)), powerupManager.PlayerCanvas, didTriggerPowerup, isLocalPlayer, (AbilityCallbacks)powerupManager);
                break;

            case ShrinkAbility.TAG:
                Debug.Log("******** Shrink! ********");
                ShrinkAbility shrinkAbility = (ShrinkAbility)gameObject.AddComponent(typeof(ShrinkAbility));
                shrinkAbility.initialise(carProperties, (ShrinkAbilitySetup)powerupManager.GetAbilitySetup(typeof(ShrinkAbility)), powerupManager.PlayerCanvas, didTriggerPowerup, isLocalPlayer, (AbilityCallbacks)powerupManager);
                break;
            }
        }
        protected override void OnRemoveCarEffect(CarProperties properties, bool triggeredPowerup)
        {
            if (triggeredPowerup)
            {
                var ps = _sparklesObj.GetComponentsInChildren <ParticleSystem>();
                foreach (var p in ps)
                {
                    var em = p.emission;
                    em.enabled = false;
                }

                // SpeedAbility will be destroyed as soon as this function exits,
                // so attach a delayed destroyer component to destroy the sparkles
                // after they've all gone.
                var destroyer = _sparklesObj.AddComponent <ObjectDestroyer> ();
                destroyer.DelayedDestroy(SPARKLES_LIFETIME_SECONDS);

                properties.SpeedLimit /= SPEED_FACTOR;
                properties.Accel      /= SPEED_FACTOR;
            }
        }
Пример #17
0
    // Update is called once per frame
    void Update()
    {
        if (Input.touchCount > 0)
        {
            Touch touch = Input.touches[0];

            if (touch.phase == TouchPhase.Began)
            {
                startPos = touch.position;
            }
            if (touch.phase == TouchPhase.Moved)
            {
                if (isCameraOn == true)
                {
                    cars[currentCarNumber - 1].GetComponent<Automate>().enabled = false;
                    Vector2 tempSwipeDist = new Vector2((Input.mousePosition.x - startPos.x), 0);

                        if (tempSwipeDist.x > 100)
                        {
                            tempSwipeDist.x = 100;
                        }
                        else if (tempSwipeDist.x < -100)
                        {
                            tempSwipeDist.x = -100;
                        }

                    cars[currentCarNumber - 1].transform.Rotate(new Vector3(0.0f, -tempSwipeDist.x * Time.deltaTime, 0.0f));
                }

            }

            if (touch.phase == TouchPhase.Ended)
            {
                //swipeDist = (new Vector2(0, touch.position.y, 0) - new Vector3(0, startPos.y, 0)).magnitude;
                //swipeDist = new Vector2(0, (touch.position.y - startPos.y));
                swipeDistx = new Vector2(0, (touch.position.x - startPos.x));
                // avgDistance = Mathf.Sqrt((swipeDist*swipeDist) + (swipeDistx*swipeDistx));
                //float avgDistY = touch.position.y - startPos.y;

                if (isSelectingPerk == false && isCameraOn == false)
                {
                    if (swipeDistx.x > (Screen.height / 5))
                    {
                        if (currentCarNumber < numberOfCars)
                            currentCarNumber++;
                    }
                    else if (swipeDistx.x < -(Screen.height / 5))
                    {
                        if (currentCarNumber > 1)
                        {
                            //spawnParticlesPrefab = (GameObject)Instantiate(spawnParticles, spawnParticlesPoint.position, spawnParticlesPoint.rotation);
                            currentCarNumber--;
                        }
                    }
                }
            }
        }

        MoveCamera();
        for (int i = 1; i <= numberOfCars; i++)
        {
            if (currentCarNumber == i)
            {
                transform.position = Vector3.Lerp(transform.position, new Vector3((i - 1) * 10, transform.position.y, transform.position.z), 5.0f * Time.deltaTime);

                int temp = i - 1;
                tempCarProperties = cars[temp].GetComponent<CarProperties>();
                carLevel.text = "Car Level " + tempCarProperties.carLevel;

                CheckCarPerk(temp);

                if(tempCarProperties.carLevel == 0)
                {
                    oldvalue = 0;
                    newValue = 0;

                    upgradeButton.Play(true);
                    unlockButton.Play(false);
                    raceButton.Play(true);
                    purchaseSticker2.Play(false);
                    stickerButtons.Play(true);

                    slot1.localPosition = new Vector3(slot1.localPosition.x, slot1.localPosition.y, 2000);
                    slot2.localPosition = new Vector3(slot2.localPosition.x, slot2.localPosition.y, 2000);
                    slot3.localPosition = new Vector3(slot3.localPosition.x, slot3.localPosition.y, 2000);

                    sun.intensity = 0.2f;
                    upgradeCostLabel.text = "Unlock $" + cars[temp].GetComponent<CarProperties>().coinsToUnlock.ToString();
                }
                else if (tempCarProperties.carLevel == 1)
                {
                    oldvalue = 0;
                    newValue = 1;
                    upgradeButton.Play(false);
                    unlockButton.Play(true);
                    if (isCameraOn == true)
                    {
                        raceButton.Play(true);
                        stickerButtons.Play(true);
                    }
                    else
                    {
                        raceButton.Play(false);
                        stickerButtons.Play(false);
                    }

                    sun.intensity = 8.0f;

                    slot1.localPosition = new Vector3(slot1.localPosition.x, slot1.localPosition.y, 0);
                    slot2.localPosition = new Vector3(slot2.localPosition.x, slot2.localPosition.y, 2000);
                    slot3.localPosition = new Vector3(slot3.localPosition.x, slot3.localPosition.y, 2000);
                }
                else if (tempCarProperties.carLevel == 2)
                {
                    oldvalue = 1;
                    newValue = 2;
                    if (isCameraOn == true)
                    {
                        raceButton.Play(true);
                        stickerButtons.Play(true);
                    }
                    else
                    {
                        raceButton.Play(false);
                        stickerButtons.Play(false);
                    }

                    slot1.localPosition = new Vector3(slot1.localPosition.x, slot1.localPosition.y, 0);
                    slot2.localPosition = new Vector3(slot2.localPosition.x, slot2.localPosition.y, 0);
                    slot3.localPosition = new Vector3(slot3.localPosition.x, slot3.localPosition.y, 2000);

                    upgradeButton.Play(false);
                    sun.intensity = 8.0f;
                }
                else if (tempCarProperties.carLevel == 3)
                {
                    oldvalue = 2;
                    newValue = 2;
                    upgradeButton.Play(true);
                    unlockButton.Play(true);
                    if (isCameraOn == true)
                    {
                        raceButton.Play(true);
                        stickerButtons.Play(true);
                    }
                    else
                    {
                        raceButton.Play(false);
                        stickerButtons.Play(false);
                    }

                    slot1.localPosition = new Vector3(slot1.localPosition.x, slot1.localPosition.y, 0);
                    slot2.localPosition = new Vector3(slot2.localPosition.x, slot2.localPosition.y, 0);
                    slot3.localPosition = new Vector3(slot3.localPosition.x, slot3.localPosition.y, 0);

                    sun.intensity = 8.0f;
                    upgradeCostLabel.text = "MAX LEVEL";
                }

                newSpeed.foreground.localScale = new Vector3(tempCarProperties.speedLevels[newValue], newSpeed.foreground.localScale.y, newSpeed.foreground.localScale.z);
                speed.foreground.localScale = new Vector3(tempCarProperties.speedLevels[oldvalue], speed.foreground.localScale.y, speed.foreground.localScale.z);

                newAcc.foreground.localScale = new Vector3(tempCarProperties.accelerationLevels[newValue], newAcc.foreground.localScale.y, newAcc.foreground.localScale.z);
                acceleration.foreground.localScale = new Vector3(tempCarProperties.accelerationLevels[oldvalue], acceleration.foreground.localScale.y, acceleration.foreground.localScale.z);

                newHandling.foreground.localScale = new Vector3(tempCarProperties.handlingLevels[newValue], newHandling.foreground.localScale.y, newHandling.foreground.localScale.z);
                handling.foreground.localScale = new Vector3(tempCarProperties.handlingLevels[oldvalue], handling.foreground.localScale.y, handling.foreground.localScale.z);

                newShield.foreground.localScale = new Vector3(tempCarProperties.ShieldLevels[newValue], newShield.foreground.localScale.y, newShield.foreground.localScale.z);
                shield.foreground.localScale = new Vector3(tempCarProperties.ShieldLevels[oldvalue], shield.foreground.localScale.y, shield.foreground.localScale.z);
            }
        }
    }
 public void DeactivateAll()
 {
     carPlatform.SetActive(false);
     Destroy(currentCar);
     currentCarProperties = null;
 }
Пример #19
0
        public static void ResetCarColor(CarProperties properties)
        {
            Material[] materials = properties.transform.FindChild("Car_Model").GetComponent <MeshRenderer> ().materials;

            GameUtils.SetCarMaterialColoursFromHue(materials, properties.OriginalHue);
        }
 protected virtual void OnRemoveCarEffect(CarProperties properties, bool triggeredPowerup)
 {
 }
 //  ...plus, clone all the other constructors
 public CarTreeNode(CarProperties car) : base(car.name)
 {
     Car = car;
 }