Exemple #1
0
        public override void Update(double elapsedClockSeconds)
        {
            switch (CurrentPantographState())
            {
            case PantographState.Down:
            case PantographState.Lowering:
            case PantographState.Raising:
                if (PowerOnTimer.Started)
                {
                    PowerOnTimer.Stop();
                }
                if (AuxPowerOnTimer.Started)
                {
                    AuxPowerOnTimer.Stop();
                }

                SetCurrentState(PowerSupplyState.PowerOff);
                SetCurrentAuxiliaryState(PowerSupplyState.PowerOff);
                SetPantographVoltageV((float)PantographFilter.Filter(0.0, elapsedClockSeconds));
                SetFilterVoltageV((float)VoltageFilter.Filter(0.0, elapsedClockSeconds));
                break;

            case PantographState.Up:
                SetPantographVoltageV((float)PantographFilter.Filter(LineVoltageV(), elapsedClockSeconds));

                switch (CurrentCircuitBreakerState())
                {
                case CircuitBreakerState.Open:
                    if (PowerOnTimer.Started)
                    {
                        PowerOnTimer.Stop();
                    }
                    if (AuxPowerOnTimer.Started)
                    {
                        AuxPowerOnTimer.Stop();
                    }

                    SetCurrentState(PowerSupplyState.PowerOff);
                    SetCurrentAuxiliaryState(PowerSupplyState.PowerOff);
                    SetFilterVoltageV((float)VoltageFilter.Filter(0.0f, elapsedClockSeconds));
                    break;

                case CircuitBreakerState.Closed:
                    if (!PowerOnTimer.Started)
                    {
                        PowerOnTimer.Start();
                    }
                    if (!AuxPowerOnTimer.Started)
                    {
                        AuxPowerOnTimer.Start();
                    }

                    SetCurrentState(PowerOnTimer.Triggered ? PowerSupplyState.PowerOn : PowerSupplyState.PowerOff);
                    SetCurrentAuxiliaryState(AuxPowerOnTimer.Triggered ? PowerSupplyState.PowerOn : PowerSupplyState.PowerOff);
                    SetFilterVoltageV((float)VoltageFilter.Filter(PantographVoltageV(), elapsedClockSeconds));
                    break;
                }
                break;
            }
        }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("f"))
        {
            Active = !Active;
        }

        Vector3 activityCenter;
        float   calcFOV;

        if (Active)
        {
            activityCenter = Herd.CenterOfActivity();
            calcFOV        = minFOV;
            float magHerdSize = Herd.GetBounds().size.magnitude;
            calcFOV = CKARTools.LinLin(magHerdSize, 6.0f, 20.0f, minFOV, maxFOV);
        }
        else
        {
            activityCenter = new Vector3(0.0f, 0.0f, 0.0f);
            calcFOV        = minFOV;
        }

        Vector3 filteredActivityCenter = filter.Filter(activityCenter);

        transform.LookAt(filteredActivityCenter, Vector3.up);
        cam.fieldOfView = fovFilter.Filter(calcFOV);
    }
    // Update is called once per frame
    void Update()
    {
        if (ShouldAct())
        {
            Generate();
        }

        TransformSpec = lsys.TransformSpec;

        scaleMultiplier = 0.25f + (velocityValueFilter.Filter() * 1.75f);
        SpeedMultiplier = 1.0f / speedValueFilter.Filter() * 0.25f;

        ApplyTransformSpec();
    }
Exemple #4
0
    void PositionUpdate()
    {
        Vector3 userAccleration = eye.transform.rotation * Input.gyro.userAcceleration;

        userAccleration = eye.transform.InverseTransformDirection(userAccleration);

        float x = userAccleration.x;
        float y = userAccleration.y;
        float z = userAccleration.z;

        x = x - low0Hz0.Filter(x);
        y = y - low0Hz1.Filter(y);
        z = z - low0Hz2.Filter(z);

        //x = Normalize(x, -0.5f, 0.5f);
        //y = Normalize(y, -0.5f, 0.5f);
        //z = Normalize(z, -0.5f, 0.5f);

        inputs.AddLast((new Vector3(x, y, z)) * 30);

        x = Joystick.Instance.InputDirection.x;
        y = Joystick.Instance.InputDirection.y;

        targets.AddLast(new Vector2(x, y));

        if (inputs.Count > seqLen)
        {
            inputs.RemoveFirst();
        }
        if (targets.Count > seqLen)
        {
            targets.RemoveFirst();
        }

        if (Training)
        {
            if (Joystick.Instance.InputDirection != Vector2.zero)
            {
                Vector3 direction = new Vector3(-Joystick.Instance.InputDirection.x, 0, Joystick.Instance.InputDirection.y);
                direction = eye.transform.TransformDirection(direction);
                GetComponent <Rigidbody>().transform.position += new Vector3(direction.x, 0, direction.z) * speed;
            }
            Train();
        }
        else
        {
            Test(); // move the player automatically
        }
    }
Exemple #5
0
        public Electricity Get(float CurrentA, float Time)
        {
            Electricity input = new Electricity(0, 0);

            for (int i = 0; i < 3; i++)
            {
                Electricity e = Input.Get(CurrentA / 2.64f / 3, Time)[i];
                input.Voltage += Math.Abs(e.Voltage / 2.64f / 3); //Transformador y puente de diodos
                input.Current += Math.Abs(e.Current * 2.64f * 3);
            }
            input.Voltage = VFilter.Filter(input.Voltage, Time - LastTime); //Condensador
            input.Voltage = Math.Min(72, input.Voltage);                    //Zener
            LastTime      = Time;
            return(input);
        }
    void Update()
    {
        transform.localEulerAngles = new Vector3(transform.localEulerAngles[0], transform.localEulerAngles[1] + DegreesPerSecond * Time.deltaTime * Gen.SpeedMultiplier, transform.localEulerAngles[2]);
        float currentScale = scaleFilter.Filter(TargetScale);

        if (transform.childCount > 0)
        {
            transform.GetChild(0).transform.localScale = new Vector3(currentScale, currentScale, currentScale);
        }

        if (!alive && currentScale < 0.0002f)
        {
            Destroy(this);
        }
    }
    // Update is called once per frame
    void Update()
    {
        float scale = DefaultScale;

        float lowerBoundWidth;


        // bit a haaaaaack
        if (Camera.main.aspect > 1.7)
        {
            lowerBoundWidth = 9.25f;
        }
        else
        {
            lowerBoundWidth = 8.0f;
        }

        if (Active)
        {
            scale = DefaultScale;

            Bounds bounds = GetBounds();

            float widthScale = scale;
            float width      = bounds.extents.x / transform.localScale.x;

            if (width > 0.1)
            {
                widthScale = DefaultScale * (lowerBoundWidth / width);
            }

            float heightScale = scale;
            float height      = bounds.extents.y / transform.localScale.y;
            if (height > 0.1)
            {
                heightScale = DefaultScale * (LowerBoundHeight / height);
            }

            scale = widthScale;
            if (heightScale < scale)
            {
                scale = heightScale;
            }
        }

        scale = filter.Filter(scale);
        transform.localScale = new Vector3(scale, scale, scale);
    }
        public override void Update(float elapsedClockSeconds)
        {
            SetCurrentBatteryState(BatterySwitchOn() ? PowerSupplyState.PowerOn : PowerSupplyState.PowerOff);
            SetCurrentLowVoltagePowerSupplyState(BatterySwitchOn() ? PowerSupplyState.PowerOn : PowerSupplyState.PowerOff);
            SetCurrentCabPowerSupplyState(BatterySwitchOn() && MasterKeyOn() ? PowerSupplyState.PowerOn : PowerSupplyState.PowerOff);

            switch (CurrentPantographState())
            {
            case PantographState.Down:
            case PantographState.Lowering:
            case PantographState.Raising:
                if (PowerOnTimer.Started)
                {
                    PowerOnTimer.Stop();
                }
                if (AuxPowerOnTimer.Started)
                {
                    AuxPowerOnTimer.Stop();
                }

                if (CurrentMainPowerSupplyState() == PowerSupplyState.PowerOn)
                {
                    SignalEvent(Event.EnginePowerOff);
                    SetCurrentMainPowerSupplyState(PowerSupplyState.PowerOff);
                }
                SetCurrentAuxiliaryPowerSupplyState(PowerSupplyState.PowerOff);
                SetCurrentElectricTrainSupplyState(PowerSupplyState.PowerOff);
                SetPantographVoltageV(PantographFilter.Filter(0.0f, elapsedClockSeconds));
                SetFilterVoltageV(VoltageFilter.Filter(0.0f, elapsedClockSeconds));
                break;

            case PantographState.Up:
                SetPantographVoltageV(PantographFilter.Filter(LineVoltageV(), elapsedClockSeconds));

                switch (CurrentCircuitBreakerState())
                {
                case CircuitBreakerState.Open:
                case CircuitBreakerState.Closing:
                    // If circuit breaker is open, then it must be closed to finish the quick power-on sequence
                    if (QuickPowerOn)
                    {
                        QuickPowerOn = false;
                        SignalEventToCircuitBreaker(PowerSupplyEvent.QuickPowerOn);
                    }

                    if (PowerOnTimer.Started)
                    {
                        PowerOnTimer.Stop();
                    }
                    if (AuxPowerOnTimer.Started)
                    {
                        AuxPowerOnTimer.Stop();
                    }

                    if (CurrentMainPowerSupplyState() == PowerSupplyState.PowerOn)
                    {
                        SignalEvent(Event.EnginePowerOff);
                        SetCurrentMainPowerSupplyState(PowerSupplyState.PowerOff);
                    }
                    SetCurrentAuxiliaryPowerSupplyState(PowerSupplyState.PowerOff);
                    SetFilterVoltageV(VoltageFilter.Filter(0.0f, elapsedClockSeconds));
                    break;

                case CircuitBreakerState.Closed:
                    // If circuit breaker is closed, quick power-on sequence has finished
                    QuickPowerOn = false;

                    if (!PowerOnTimer.Started)
                    {
                        PowerOnTimer.Start();
                    }
                    if (!AuxPowerOnTimer.Started)
                    {
                        AuxPowerOnTimer.Start();
                    }

                    if (PowerOnTimer.Triggered && CurrentMainPowerSupplyState() == PowerSupplyState.PowerOff)
                    {
                        SignalEvent(Event.EnginePowerOn);
                        SetCurrentMainPowerSupplyState(PowerSupplyState.PowerOn);
                    }
                    SetCurrentAuxiliaryPowerSupplyState(AuxPowerOnTimer.Triggered ? PowerSupplyState.PowerOn : PowerSupplyState.PowerOff);
                    SetFilterVoltageV(VoltageFilter.Filter(PantographVoltageV(), elapsedClockSeconds));
                    break;
                }
                break;
            }

            SetCurrentDynamicBrakeAvailability(true);

            if (ElectricTrainSupplyUnfitted())
            {
                SetCurrentElectricTrainSupplyState(PowerSupplyState.Unavailable);
            }
            else if (CurrentAuxiliaryPowerSupplyState() == PowerSupplyState.PowerOn &&
                     ElectricTrainSupplySwitchOn())
            {
                SetCurrentElectricTrainSupplyState(PowerSupplyState.PowerOn);
            }
            else
            {
                SetCurrentElectricTrainSupplyState(PowerSupplyState.PowerOff);
            }
        }
 virtual public void ApplyTransformSpec()
 {
     gameObject.transform.localPosition    = new Vector3(TransformSpec.Position[0] * positionMultiplier, TransformSpec.Position[1] * positionMultiplier + floatUp.Filter(), TransformSpec.Position[2] * positionMultiplier);
     gameObject.transform.localScale       = new Vector3(TransformSpec.Scale[0] * scaleMultiplier, TransformSpec.Scale[1] * scaleMultiplier, TransformSpec.Scale[2] * scaleMultiplier);
     gameObject.transform.localEulerAngles = new Vector3(TransformSpec.Rotation[0], TransformSpec.Rotation[1], TransformSpec.Rotation[2]);
 }
Exemple #10
0
    // Update is called once per frame
    void Update()
    {
        if (startTime + GrowDelay > Time.time)
        {
            return;
        }

        float dtCounterWeight = Mathf.Clamp((1.0f - GrowWeight) * 60.0f * Time.deltaTime, 0.0f, 1.0f);
        float dtGrowWeight    = 1.0f - dtCounterWeight;

        if (alive)
        {
            CurrentRotation = CurrentRotation * dtGrowWeight + TargetRotation * dtCounterWeight;
            CurrentPosition = CurrentPosition * dtGrowWeight + TargetPosition * dtCounterWeight;

            windPhase += (deltaWindPhase * Time.deltaTime * Gen.SpeedMultiplier);
            Vector3 windRotation = CurrentRotation * WindStrength * Mathf.Sin(windPhase) * windStrengthFilter.Filter(Gen.SpeedMultiplier);


            transform.localEulerAngles = CurrentRotation + windRotation;
            transform.localPosition    = CurrentPosition;
            CurrentScale         = CurrentScale * dtGrowWeight + TargetScale * dtCounterWeight;
            transform.localScale = CurrentScale;
        }
        else
        {
            CurrentScale = transform.localScale;

            float xzW = 1.0f - Mathf.Clamp(0.02f * 60.0f * Time.deltaTime, 0.0f, 1.0f);
            float yW  = 1.0f - Mathf.Clamp(0.01f * 60.0f * Time.deltaTime, 0.0f, 1.0f);

            transform.localScale = new Vector3(CurrentScale[0] * xzW, CurrentScale[1] * yW, CurrentScale[2] * xzW);

            if (transform.localScale[1] < 0.001f)
            {
                Destroy(gameObject);
            }
        }
    }