Esempio n. 1
0
    internal void Setup(BuildingModel ability, GameObject effectPrefab)
    {
        _building = ability;

        disposables.Clear();
        _building._State.Subscribe(_ => SetState()).AddTo(disposables);

        Name.SetProperty(ability.Name);
        UnlockPrice.SetProperty("Unlock (Science):");
        UnlockPrice.SetValue(float.MaxValue, -ability.UnlockCost);
        BuildPrice.SetProperty("Build (Minerals):");
        BuildPrice.SetValue(float.MaxValue, -ability.BuildCost);
        MaintenancePrice.SetProperty("Maintenance (Minerals):");
        MaintenancePrice.SetValue(float.MaxValue, ability.Effects[R.Minerals]);

        var list = _building.Effects.Keys.ToList();

        list.Sort();

        foreach (var key in list)
        {
            if (key == R.Minerals)
            {
                continue;
            }

            AddEffect(effectPrefab, key, _building.Effects[key]);
        }
    }
Esempio n. 2
0
    private void AddEffect(Transform container, R type, float value)
    {
        GameObject     go   = Instantiate(EffectPrefab, container);
        UIPropertyView uipv = go.GetComponent <UIPropertyView>();

        uipv.SetProperty(type.ToString());
        uipv.SetValue(float.MaxValue, value);
    }
Esempio n. 3
0
    private void AddEffect(R type, float value)
    {
        GameObject     go   = Instantiate(EffectPrefab, EffectsGrid);
        UIPropertyView uipv = go.GetComponent <UIPropertyView>();

        uipv.StringFormat = "";
        uipv.SetProperty(type.ToString());
        uipv.SetValue(float.MaxValue, value);
    }
Esempio n. 4
0
    private void OnHexChange(HexClickedMessage message)
    {
        disposables.Clear();
        _hex = message.Hex;

        _hex.Props[R.Altitude]._Value.Subscribe(_ => Altitude.SetValue(GetPropValue(_))).AddTo(disposables);
        //hex.Props[ R.Temperature ]._Value.Subscribe( _ => Temperature.SetValue( ( _ * 873 ) - 273 ) ).AddTo( disposables );
        _hex.Props[R.Temperature]._Value.Subscribe(_ => Temperature.SetValue(GetPropValue(_))).AddTo(disposables);
        _hex.Props[R.Pressure]._Value.Subscribe(_ => Pressure.SetValue(GetPropValue(_))).AddTo(disposables);
        _hex.Props[R.Humidity]._Value.Subscribe(_ => Humidity.SetValue(GetPropValue(_))).AddTo(disposables);
        _hex.Props[R.Radiation]._Value.Subscribe(_ => Radiation.SetValue(GetPropValue(_))).AddTo(disposables);
        _hex.Props[R.HexScore]._Value.Subscribe(_ => HexScore.SetValue(_)).AddTo(disposables);
    }
Esempio n. 5
0
    private void OnPlanetModelChange(PlanetModel value)
    {
        _life = value.Life;
        disposables.Clear();

        _life.Props[R.Population]._Value.Subscribe(_ => Population.SetValue(_)).AddTo(disposables);

        /*
         * _life.Props[ R.Energy ]._Value.Subscribe( _ => Food.SetValue( _, _life.Props[ R.Energy ].Delta ) ).AddTo( disposables );
         * _life.Props[ R.Science ]._Value.Subscribe( _ => Science.SetValue( _, _life.Props[ R.Science ].Delta ) ).AddTo( disposables );
         * _life.Props[ R.Minerals ]._Value.Subscribe( _ => Words.SetValue( _, _life.Props[ R.Minerals ].Delta ) ).AddTo( disposables );
         *
         * _life.Props[ R.Energy ]._Delta.Subscribe( _ => Food.SetValue( _life.Props[ R.Energy ].Value, _ ) ).AddTo( disposables );
         * _life.Props[ R.Science ]._Delta.Subscribe( _ => Science.SetValue( _life.Props[ R.Science ].Value, _ ) ).AddTo( disposables );
         * _life.Props[ R.Minerals ]._Delta.Subscribe( _ => Words.SetValue( _life.Props[ R.Minerals ].Value, _ ) ).AddTo( disposables );
         */
    }
Esempio n. 6
0
    void Start()
    {
        _unitTypesConfig = GameConfig.Get <UnitTypesConfig>();
        _unit            = _unitTypesConfig[UnitTypeIndex];
        GameModel.HandleGet <HexModel>(OnHexModelChange);

        Button.onClick.AddListener(OnButtonClick);

        Name.text = _unit.Name;
        Body.SetValue(_unit.Body);
        Mind.SetValue(_unit.Mind);
        Soul.SetValue(_unit.Soul);

        ResistanceTemperature.SetPosition(_unit.Temperature);
        ResistancePressure.SetPosition(_unit.Pressure);
        ResistanceHumidity.SetPosition(_unit.Humidity);
        ResistanceRadiation.SetPosition(_unit.Radiation);

        UIPropertyView currentEffect = Effect1;

        if (_unit.ITemperature != 0)
        {
            SetEffectValue(currentEffect, R.Temperature);
            currentEffect = Effect2;
        }
        if (_unit.IPressure != 0)
        {
            SetEffectValue(currentEffect, R.Pressure);
            currentEffect = Effect2;
        }
        if (_unit.IHumidity != 0)
        {
            SetEffectValue(currentEffect, R.Humidity);
            currentEffect = Effect2;
        }
        if (_unit.IRadiation != 0)
        {
            SetEffectValue(currentEffect, R.Radiation);
        }
    }
Esempio n. 7
0
    internal void Setup(SkillData skill, GameObject effectPrefab)
    {
        _skill         = skill;
        _message.Index = _skill.Index;
        _message.State = _skill.State;

        //disposables.Clear();
        //_skill._State.Subscribe( _ => SetState() ).AddTo( disposables );
        SetState(_skill.State);

        Name.SetProperty(_skill.Name);
        UnlockPrice.SetProperty("Unlock:");
        UnlockPrice.SetValue(float.MaxValue, -_skill.UnlockCost);

        foreach (KeyValuePair <R, float> effect in _skill.Effects)
        {
            if (effect.Value != 0)
            {
                AddEffect(effectPrefab, effect.Key, effect.Value);
            }
        }
    }
Esempio n. 8
0
    public void SetModel(R prop, UnitModel unit, bool canChange, string stringFormat = "N0", bool showMaxValue = false)
    {
        disposables.Clear();
        delta = 0;

        PropertyView.SetProperty(prop.ToString());
        PropertyView.StringFormat = stringFormat;

        unit.Props[prop]._Value
        .Subscribe(_ => PropertyView.SetValue(_))
        .AddTo(disposables);

        if (showMaxValue)
        {
            unit.Props[prop]._MaxValue
            .Subscribe(_ => PropertyView.SetDelta(_))
            .AddTo(disposables);
        }

        unit.Props[R.UpgradePoint]._Value
        .Subscribe(_ => UpgradeButton.interactable = _ > 0 ? true : false)
        .AddTo(disposables);

        if (canChange)
        {
            UpgradeButton.OnClickAsObservable()
            .Subscribe(_ =>
            {
                GameMessage.Send(new UnitPropUpgradeMessage(prop));
                PropertyView.SetDelta(++delta);
            })
            .AddTo(disposables);
        }
        else
        {
            UpgradeButton.gameObject.SetActive(false);
        }
    }
Esempio n. 9
0
 private void SetEffectValue(UIPropertyView Effect, R type)
 {
     Effect.SetProperty(type.ToString());
     Effect.SetValue(Convert.ToSingle(GetUnitImpactValue(_unit, type)));
 }
Esempio n. 10
0
    private void OnHexModel(HexModel value)
    {
        disposables.Clear();

        value.Props[ShowProperty]._Value.Subscribe(_ => PropertyView.SetValue(_)).AddTo(disposables);
    }