Ejemplo n.º 1
0
    private void OnResistanceUpgrade(ResistanceUpgradeMessage value)
    {
        float delta = Mathf.Abs(value.Delta);

        if (_selectedUnit.Resistance[value.Type].ChangePosition(value.Delta))
        {
            delta = -delta;
        }

        _unitDefenseUpdateCommand.Execute(_selectedUnit);
        //_selectedUnit.AbilitiesDelta[ R.Science ].Value = _selectedUnit.AbilitiesDelta[ R.Science ].Value.Sum( delta );
    }
Ejemplo n.º 2
0
    public void Execute(HexModel hex)
    {
        if (_planet == null)
        {
            return;
        }

        /**/
        UpdateProp(Temperature, hex.Props[R.Temperature]);
        UpdateProp(Pressure, hex.Props[R.Pressure]);
        UpdateProp(Humidity, hex.Props[R.Humidity]);
        //UpdateProp( Radiation, hex.Props[ R.Radiation ] );
        /**/

        float altitude = hex.Props[R.Altitude].Value / 2f;

        if (Humidity.Value > altitude)
        {
            hex.Props[R.Humidity].Value     = 1f;
            hex.Props[R.Pressure].Value    += ((float)Humidity.Value - altitude) * 1f;
            hex.Props[R.Temperature].Value -= (hex.Props[R.Temperature].Value - .5f) * .33f;
        }

        hex.Props[R.Temperature].Color = Color.Lerp(Color.red, Color.green, _resistanceConfig[R.Temperature].GetFloatAt(hex.Props[R.Temperature].Value));
        hex.Props[R.Humidity].Color    = Color.Lerp(Color.red, Color.green, _resistanceConfig[R.Humidity].GetFloatAt(hex.Props[R.Humidity].Value));
        hex.Props[R.Pressure].Color    = Color.Lerp(Color.red, Color.green, _resistanceConfig[R.Pressure].GetFloatAt(hex.Props[R.Pressure].Value));

        if (hex.Unit != null)
        {
            _unitDefenseUpdateCommand.Execute(hex.Unit);
        }
    }
Ejemplo n.º 3
0
    private void ApplyCompoundEffects(CompoundJSON compound, int sign = -1)
    {
        if (compound.Type == CompoundType.Armor)
        {
            foreach (KeyValuePair <R, float> item in compound.Effects)
            {
                if (item.Key == R.Temperature || item.Key == R.Pressure || item.Key == R.Humidity || item.Key == R.Radiation)
                {
                    _unitController.SelectedUnit.Resistance[item.Key].ChangePosition(PPMath.Round((sign * item.Value) / 100f));
                }
                else
                {
                    _unitController.SelectedUnit.Props[item.Key].Value += (int)item.Value * sign;
                }
            }

            _unitDefenseUpdateCommand.Execute(_unitController.SelectedUnit);
        }

        if (compound.Type == CompoundType.Weapon)
        {
            foreach (KeyValuePair <R, float> item in compound.Effects)
            {
                if (item.Key == R.Temperature || item.Key == R.Pressure || item.Key == R.Humidity || item.Key == R.Radiation)
                {
                    _unitController.SelectedUnit.Impact[item.Key].Value     += (int)(item.Value * sign);
                    _planetController.SelectedPlanet.Impact[item.Key].Value += (int)(item.Value * sign);
                }
                else
                {
                    _unitController.SelectedUnit.Props[item.Key].Delta += (int)item.Value * sign;
                }
            }
        }
    }