void Start() { //GET REFERENCES //rb = GetComponent<Rigidbody>(); input = GetComponent <PlayerInput>(); profile = GetComponentInChildren <SpaceshipStructure>().profile; animator = GetComponentInChildren <Animator>(); Debug.Log(profile.name); //INITIALIZE PARAMTERES maxSpeed = profile.engineProfile.maxSpeed; maxAcceleration = profile.engineProfile.maxAcceleration; maxBrake = profile.engineProfile.maxBrake; accelerationCurve = profile.engineProfile.accelerationCurve; brakeCurve = profile.engineProfile.brakeCurve; handling = profile.chassisProfile.handling; handlingCurve = profile.chassisProfile.handlingCurve; }
private void Start() { //GET PARAMETERS FROM MENU IF SELECTED SPACESHIP ON GAME MANAGER IS NOT NULL if (GameManager.Instance.selectedSpaceship != null) { spaceship = GameManager.Instance.selectedSpaceship; } //INSTANTIATE SPACESHIP spaceship = Instantiate(spaceship, transform.position, transform.rotation); spaceship.transform.parent = transform; spaceship.name = spaceship.name.Replace("(Clone)", ""); spaceship.GetComponent <SpaceshipStructure>().profile = Resources.Load <SpaceshipProfile>("Scriptables/Spaceships/" + spaceship.name); //GET REFERENCES playerInput = GetComponent <PlayerInput>(); spaceshipProfile = spaceship.GetComponent <SpaceshipStructure>().profile; upgradesProfile = spaceship.GetComponent <SpaceshipStructure>().upgradesProfile; //INITIALIZE SPACESHIP PARAMETERS if (spaceshipProfile != null) { //----------------------------------------------------------------------- //----------------------------------------------------------- FROM ENGINE if (spaceshipProfile.engineProfile != null) { // SPEED engineParameters.maxSpeed = spaceshipProfile.engineProfile.maxSpeed; // ACCELERATION engineParameters.maxAcceleration = spaceshipProfile.engineProfile.maxAcceleration; engineParameters.accelerationCurve = spaceshipProfile.engineProfile.accelerationCurve; // BRAKE engineParameters.maxBrake = spaceshipProfile.engineProfile.maxBrake; engineParameters.brakeCurve = spaceshipProfile.engineProfile.brakeCurve; if (upgradesProfile.engineUpgrades != null) { engineParameters.maxSpeed += upgradesProfile.engineUpgrades.bonusMaxSpeed; engineParameters.maxAcceleration += upgradesProfile.engineUpgrades.bonusMaxAcceleration; engineParameters.maxBrake += upgradesProfile.engineUpgrades.bonusMaxBrake; } } else { Debug.LogWarning("There is no Engine Profile on " + spaceshipProfile.name + ". Loading default parameters..."); } //----------------------------------------------------------------------- //---------------------------------------------------------- FROM CHASSIS if (spaceshipProfile.chassisProfile != null) { // LIMIT SPEED chassisParameters.limitSpeed = spaceshipProfile.chassisProfile.limitSpeed; // HANDLING chassisParameters.maxHandlingSpeed = spaceshipProfile.chassisProfile.handling; chassisParameters.handlingCurve = spaceshipProfile.chassisProfile.handlingCurve; // ROLL DASH chassisParameters.handlingRollMultiplier = spaceshipProfile.chassisProfile.handlingRollMultiplier; // RESISTANCE chassisParameters.knockback = spaceshipProfile.chassisProfile.knockback; if (upgradesProfile.chassisUpgrades != null) { chassisParameters.maxHandlingSpeed += upgradesProfile.chassisUpgrades.bonusMaxHandling; chassisParameters.knockback += upgradesProfile.chassisUpgrades.bonusKnockback; } } else { Debug.LogWarning("There is no Chassis Profile on " + spaceshipProfile.name + ". Loading default parameters..."); } //----------------------------------------------------------------------- //--------------------------------------------------------- FROM BLASTERS if (spaceshipProfile.blasterProfile != null) { // PROJECTILE blasterParameters.projectile = spaceshipProfile.blasterProfile.projectile; // CADENCE blasterParameters.cadence = spaceshipProfile.blasterProfile.cadence; if (upgradesProfile.blastersUpgrades != null) { blasterParameters.cadence += upgradesProfile.blastersUpgrades.bonusCadence; } } else { Debug.LogWarning("There is no Blaster Profile on " + spaceshipProfile.name + ". Loading default parameters..."); } //----------------------------------------------------------------------- //------------------------------------------------------------- FROM JETS if (spaceshipProfile.jetProfile != null) { //BOOST jetParameters.boostAcceleration = spaceshipProfile.jetProfile.boost; jetParameters.boostConsumption = spaceshipProfile.jetProfile.boostIntake; //SUPERBOOST jetParameters.superBoostAcceleration = spaceshipProfile.jetProfile.superBoost; jetParameters.superBoostConsumption = spaceshipProfile.jetProfile.superBoostIntake; if (upgradesProfile.jetsUpgrades != null) { jetParameters.boostAcceleration += upgradesProfile.jetsUpgrades.bonusMaxBoost; jetParameters.superBoostAcceleration += upgradesProfile.jetsUpgrades.bonusMaxSuperBoost; jetParameters.boostConsumption += upgradesProfile.jetsUpgrades.bonusBoostIntake; jetParameters.superBoostConsumption += upgradesProfile.jetsUpgrades.bonusSuperBoostIntake; } } else { Debug.LogWarning("There is no Jet Profile on " + spaceshipProfile.name + ". Loading default parameters..."); } //----------------------------------------------------------------------- //------------------------------------------------------------- FROM TANK if (spaceshipProfile.tankProfile != null) { // ENERGY TANK CAPACITY energyParameters.maxEnergy = spaceshipProfile.tankProfile.capacity; if (upgradesProfile.tanksUpgrades != null) { energyParameters.maxEnergy += upgradesProfile.tanksUpgrades.bonusCapacity; } } else { Debug.LogWarning("There is no Tank Profile on " + spaceshipProfile.name + ". Loading default parameters..."); } } else { Debug.Log("There isn't any profile to load. Initializing with default parameters..."); } //INITIALIZE LOCAL VARIABLES l_maxSpeed = engineParameters.maxSpeed; l_energy = energyParameters.initialEnergy; l_cadence = blasterParameters.cadence; l_nitroInputTime = superBoostInputTime; l_handlingRollMultiplier = 1; //SET INITIAL POSITION transform.position = TrackManager.Instance.GetPositionAtDistance(initialDistance) + transform.up * initialVerticalOffset + transform.right * initialHorizontalOffset; distanceTravelled = initialDistance; horizontalMove = initialHorizontalOffset; verticalMove = initialVerticalOffset; //SET FORWARD VECTOR forwardDirection = TrackManager.Instance.GetDirectionAtDistance(distanceTravelled); transform.forward = forwardDirection.normalized; //SET FOG INITIAL VALUE TO FALSE isInsideFog = false; //SET LAPCHECKER endedLap = false; }