Exemple #1
0
 private void OnCruiseChange(CruiseState newState)
 {
     if (CruiseStateChanged != null)
     {
         CruiseStateChanged(this, newState);
     }
 }
Exemple #2
0
 private void HandleCruiseChange(CruiseEngine sender, CruiseState newState)
 {
     if (newState == CruiseState.Charging)
     {
         engine.Drifting = false;
     }
 }
Exemple #3
0
    public static void ClampShipVelocity(Rigidbody rb, ShipPhysicsStats stats, CruiseState state)
    {
        float currentMaxSpeed = 0;

        switch (state)
        {
        case CruiseState.Off:
            currentMaxSpeed = stats.maxAfterburnSpeed;
            break;

        case CruiseState.Charging:
            currentMaxSpeed = stats.maxNormalSpeed;
            break;

        case CruiseState.On:
            currentMaxSpeed = stats.maxCruiseSpeed;
            break;

        case CruiseState.Disrupted:
            currentMaxSpeed = stats.maxAfterburnSpeed;
            break;

        default:
            break;
        }

        rb.velocity = Vector3.ClampMagnitude(rb.velocity, currentMaxSpeed);
    }
Exemple #4
0
    private IEnumerator ChargeCruiseCoroutine()
    {
        State = CruiseState.Charging;

        yield return(new WaitForSeconds(stats.chargeDuration));

        chargeCoroutine = null;
        State           = CruiseState.On;
    }
Exemple #5
0
    public void StopAnyCruise()
    {
        if (State == CruiseState.Off)
        {
            return;
        }

        if (State == CruiseState.Charging)
        {
            StopCoroutine(chargeCoroutine);
        }

        State = CruiseState.Off;
    }
        public void CruiseStateTest()
        {
            var state = new CruiseState(5);

            robot.Acceleration = 0.0;
            robot.Speed        = 0.0;
            robot.Orientation  = 0.0;
            robot.Location     = new Environment.Point(0.0, 0.0);
            brain.CurrentState = state;
            env.Tick();
            Assert.NotEqual(0.0, robot.Acceleration, 3);
            env.Tick();
            Assert.NotEqual(0.0, robot.Speed, 3);
            env.Tick();
            Assert.Equal(0.0, robot.Location.X, 3);
            Assert.NotEqual(0.0, robot.Location.Y, 3);
        }
Exemple #7
0
    public bool TryChargeCruise(bool skipChargeDuration = false)
    {
        if (State != CruiseState.On)
        {
            return(false);
        }

        if (skipChargeDuration)
        {
            State = CruiseState.On;
            return(true);
        }

        else
        {
            chargeCoroutine = ChargeCruiseCoroutine();
            StartCoroutine(chargeCoroutine);
            return(true);
        }
    }
Exemple #8
0
    public void ToggleCruiseEngines()
    {
        switch (State)
        {
        case CruiseState.Off:
            chargeCoroutine = ChargeCruiseCoroutine();
            StartCoroutine(chargeCoroutine);
            break;

        case CruiseState.Charging:
            StopCoroutine(chargeCoroutine);
            State = CruiseState.Off;
            break;

        case CruiseState.On:
            State = CruiseState.Off;
            break;

        default:
            break;
        }
    }
Exemple #9
0
    private void HandleCruiseChanged(CruiseEngine sender, CruiseState newState)
    {
        switch (sender.State)
        {
        case CruiseState.Charging:
            chargeCruiseEffect.Play();
            break;

        case CruiseState.On:
            chargeCruiseEffect.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
            fullCruiseEffect.Play();
            break;

        case CruiseState.Off:
        case CruiseState.Disrupted:
            chargeCruiseEffect.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
            fullCruiseEffect.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
            break;

        default:
            break;
        }
    }
Exemple #10
0
    private void SetCruiseText(CruiseState cruiseState)
    {
        switch (cruiseState)
        {
        case CruiseState.Off:
            cruiseText.text = "Engines Nominal";
            break;

        case CruiseState.Charging:
            cruiseText.text = "Charging Cruise...";
            SpawnNotification(cruiseText.text);
            break;

        case CruiseState.On:
            cruiseText.text = "Cruising";
            SpawnNotification(cruiseText.text);
            break;

        case CruiseState.Disrupted:
            cruiseText.text = "Disrupted";
            SpawnNotification(cruiseText.text);
            break;
        }
    }
Exemple #11
0
 private void HandleCruiseChanged(CruiseEngine sender, CruiseState newState)
 {
     SetCruiseText(sender.State);
 }