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
    internal void Setup(CompoundJSON compound)
    {
        disposables.Clear();

        _compound = compound;
        _compound._CanCraft.Subscribe(_ => SetState(_ ? 1 : 0)).AddTo(disposables);
        _compoundSelectMessage.Index  = _compound.Index;
        _compoundControlMessage.Index = _compound.Index;

        Name.SetProperty(_compound.Name);

        compoundIcon.Setup(_compound);

        for (int i = 0; i < ElementsGrid.childCount; i++)
        {
            if (i >= _compound.Elements.Count)
            {
                ElementsGrid.GetChild(i).GetComponent <CompoundElementAmountView>().Setup(null);
            }
            else
            {
                ElementsGrid.GetChild(i).GetComponent <CompoundElementAmountView>().Setup(_compound.Elements[i]);
            }
        }

        foreach (KeyValuePair <R, float> effect in _compound.Effects)
        {
            AddEffect(effect.Key, effect.Value);
        }
    }
Esempio n. 3
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. 4
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. 5
0
    // Use this for initialization
    void Start()
    {
        _universeConfig = GameConfig.Get <UniverseConfig>();
        GameMessage.Listen <HexClickedMessage>(OnHexChange);

        Altitude.SetProperty(R.Altitude.ToString());
        Temperature.SetProperty(R.Temperature.ToString());
        Pressure.SetProperty(R.Pressure.ToString());
        Humidity.SetProperty(R.Humidity.ToString());
        Radiation.SetProperty(R.Radiation.ToString());
        HexScore.SetProperty(R.HexScore.ToString());
    }
Esempio n. 6
0
    // Use this for initialization
    void Start()
    {
        GameModel.HandleGet <PlanetModel>(OnPlanetModelChange);

        Population.SetProperty(R.Population.ToString());
        Food.SetProperty(R.Energy.ToString());
        Science.SetProperty(R.Science.ToString());
        Words.SetProperty(R.Minerals.ToString());

        Props.Add(R.Energy, Food);
        Props.Add(R.Science, Science);
        Props.Add(R.Minerals, Words);
        LastProps.Add(R.Energy, 0);
        LastProps.Add(R.Science, 0);
        LastProps.Add(R.Minerals, 0);

        GameMessage.Listen <ClockTickMessage>(OnClockTick);
    }
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)));
 }