Example #1
0
    private void Remove(LifeElementModel value)
    {
        GameObject go = _children[value];

        go.transform.SetParent(null);
        DestroyImmediate(go);
        _children.Remove(value);
    }
Example #2
0
    private void AddListener(LifeElementModel compoundElement, ReactiveDictionary <int, LifeElementModel> elements)
    {
        //set compound element amount when life's element amount change
        elements[compoundElement.Index]._Amount
        .Subscribe(_ => compoundElement.Amount = _)
        .AddTo(disposables);

        //when element is full, check if all elements in the compound are full too
        compoundElement._IsFull
        .Subscribe(_ => CheckCanCraft())
        .AddTo(disposables);
    }
Example #3
0
    private int SortChildrenKeys(LifeElementModel x, LifeElementModel y)
    {
        if (x.Index > y.Index)
        {
            return(1);
        }
        if (x.Index < y.Index)
        {
            return(-1);
        }

        return(0);
    }
Example #4
0
    private void Add(LifeElementModel value)
    {
        GameObject unitGO = Instantiate(
            Prefab,
            new Vector3(0, 0, 0),
            Quaternion.identity);

        unitGO.transform.SetParent(this.transform);
        unitGO.GetComponent <LifeElementView>().SetModel(value);
        _children.Add(value, unitGO);

        SetOrder();
    }
Example #5
0
    private int CompareLifeElement(LifeElementModel x, LifeElementModel y)
    {
        if (x.Index > y.Index)
        {
            return(1);
        }
        if (x.Index < y.Index)
        {
            return(-1);
        }

        return(0);
    }
Example #6
0
    public void Setup(LifeElementModel compoundElementModel)
    {
        disposables.Clear();

        if (compoundElementModel == null)
        {
            ElementSymbolAndAmountText.text = "";
        }
        else
        {
            ElementSymbolAndAmountText.text = compoundElementModel.Symbol + compoundElementModel.MaxAmount.ToString();
            compoundElementModel._IsFull.Subscribe(_ => ElementSymbolAndAmountText.color = _ ? GreenColor : RedColor).AddTo(disposables);
        }
    }
Example #7
0
    public void SetModel(LifeElementModel lifeElementModel)
    {
        disposables.Clear();
        _model = lifeElementModel;

        SymbolText.text = _model.Symbol;
        Bar.MaxValue    = _model.MaxAmount;
        _model._Amount.Subscribe(_ =>
        {
            Bar.Value       = _;
            AmountText.text = _.ToString();
            gameObject.SetActive(_ > 0);
        }).AddTo(disposables);
    }