コード例 #1
0
    // ====================================================================================================== //
    // update pockets for the selected party member
    private void updatePockets()
    {
        // units visibility & color of grid units
        _pocketGrid.UpdateElementsVisibility(Party.Instance.SelectedMember.Stats[Stat.POCKETS]);

        // move over all members, deactivate pocket items of the non-selected members & activate the selected member pocket items
        foreach (Creature member in Party.Instance.Members)
        {
            List <Item> currentMemberBeltItems = member.ItemsInPockets.Values.ToList();
            foreach (Item item in currentMemberBeltItems)
            {
                // set active if selected member, inactive otherwise
                item.gameObject.SetActive(Party.Instance.SelectedMember == member);

                // remove items from pockets when are placed in not exist pocket
                if (item.transform.parent.GetComponent <Pocket>().Index >= member.Stats[Stat.POCKETS])
                {
                    member.RemoveItemFromPockets(item);
                }
            }
        }
    }
コード例 #2
0
ファイル: Portrait.cs プロジェクト: galhajaj/CoolRoguelike
    void Update()
    {
        // look right/left animation
        if (_timeToChangeAnimation > 0)
        {
            _timeToChangeAnimation -= Time.deltaTime;
        }
        else
        {
            _timeToChangeAnimation = Random.Range(_changeAnimationMinTime, _changeAnimationMaxTime);
            int    rand = Random.Range(0, 5);
            string triggerName;
            if (rand == 0)
            {
                triggerName = "LookRightTrigger";
            }
            else if (rand == 1)
            {
                triggerName = "LookLeftTrigger";
            }
            else
            {
                triggerName = "BlinkTrigger";
            }
            GetComponent <Animator>().SetTrigger(triggerName);
        }

        // frame visibility
        bool isSelectedMember = (Party.Instance.SelectedMember == _creature);

        _frameRenderer.enabled = isSelectedMember;

        // units visibility & color of grid units
        _lifeUnitsGrid.UpdateElementsVisibility(_creature.Stats[Stat.HEARTS], _creature.Stats[Stat.MAX_HEARTS], (float)_creature.Stats[Stat.HIT_POINTS] / _creature.Stats[Stat.MAX_HIT_POINTS]);
        _spellUnitsGrid.UpdateElementsVisibility(_creature.Stats[Stat.MANA], _creature.Stats[Stat.MAX_MANA]);
        _actionUnitsGrid.UpdateElementsVisibility(_creature.ActionUnits, Consts.MAX_ACTION_UNITS);
    }