Пример #1
0
        void Awake()
        {
            for (var i = 0; i < resourceConfiguration.Length; i++)
            {
                var newBar = Instantiate(ResourceBarPrefab, transform);
                newBar.transform.position += transform.TransformVector((Vector3)(offset * i));
                var config      = resourceConfiguration[i];
                var resourceBar = newBar.GetComponent <ResourceBar>();

                resourceBar.setResourceType(config.type, config.icon, ResourceConfiguration.resourceColoring[config.type]);

                resourceBars[config.type] = resourceBar;
            }

            inventoryToTrack.ResourceCapacityChangedAsObservable()
            .Subscribe(change =>
            {
                setMaxForType(change.type, change.newValue);
            }).AddTo(this);
            inventoryToTrack.ResourceAmountsChangedAsObservable()
            .Subscribe(change =>
            {
                setValue(change.type, change.newValue);
            }).AddTo(this);
        }