public void OnGenerateEnergy()
    {
        float[] speed = new[] {
            BattleObject.GetBattleSpeed(BattleObject.GetSpirit(0)),
            BattleObject.GetBattleSpeed(BattleObject.GetSpirit(1))
        };

        var maxSpeed = Math.Max(speed[0], speed[1]);

        if (BattleObject.weatherEffect != null)
        {
            maxSpeed = Mathf.Max(maxSpeed, BattleObject.weatherEffect.Speed);
        }
        var time_multiplicator = 100 / maxSpeed;

        BattleObject.activePlayer = null;
        stateMachine.SetProperty(props.SpiritReady, -1);
        for (int i = 0; i <= 1; ++i)
        {
            BattleObject.GetSpirit(i).CurrentStamina += speed[i] * Time.deltaTime * time_multiplicator;
            if (BattleObject.GetSpirit(i).CurrentStamina >= 100)
            {
                stateMachine.SetProperty(props.SpiritReady, i);
            }
        }

        for (int i = 0; i <= 1; ++i)
        {
            if (i == stateMachine.GetProperty <int>(props.SpiritReady))
            {
                BattleObject.activePlayer = i;
                break;
            }

//            var v = BUI.StaminaImages[i].localPosition;
//            v.x = BattleObject.GetSpirit(i).CurrentStamina/100*BUI.StaminaBar.rect.width - BUI.StaminaBar.rect.width/2;
//            BUI.StaminaImages[i].localPosition = v;
        }
        if (BattleObject.weatherEffect != null)
        {
            BattleObject.weatherEffect.Stamina += BattleObject.weatherEffect.Speed * Time.deltaTime * time_multiplicator;
            stateMachine.SetProperty(props.WeatherEffectReady, BattleObject.weatherEffect.Stamina >= 100);

            if (BattleObject.weatherEffect.Duration > 0)
            {
                BattleObject.weatherEffect.Duration -= BattleObject.weatherEffect.Speed * Time.deltaTime *
                                                       time_multiplicator;
            }
            else
            {
                BattleObject.weatherEffect = null;
            }
        }

        stateMachine.SetProperty(props.StateFinished, true);
    }