/// <summary> /// Removes the given item from the collection /// </summary> /// <returns>True, if the item was removed, otherwise False</returns> /// <param name="item">The item that should be removed</param> public override bool Remove(IModelElement item) { IProcessingResourceSpecification processingResourceSpecificationItem = item.As <IProcessingResourceSpecification>(); if (((processingResourceSpecificationItem != null) && this._parent.ActiveResourceSpecifications_ResourceContainer.Remove(processingResourceSpecificationItem))) { return(true); } if ((this._parent.ResourceEnvironment_ResourceContainer == item)) { this._parent.ResourceEnvironment_ResourceContainer = null; return(true); } IResourceContainer resourceContainerItem = item.As <IResourceContainer>(); if (((resourceContainerItem != null) && this._parent.NestedResourceContainers__ResourceContainer.Remove(resourceContainerItem))) { return(true); } if ((this._parent.ParentResourceContainer__ResourceContainer == item)) { this._parent.ParentResourceContainer__ResourceContainer = null; return(true); } return(false); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { IProcessingResourceSpecification activeResourceSpecifications_ResourceContainerCasted = item.As <IProcessingResourceSpecification>(); if ((activeResourceSpecifications_ResourceContainerCasted != null)) { this._parent.ActiveResourceSpecifications_ResourceContainer.Add(activeResourceSpecifications_ResourceContainerCasted); } if ((this._parent.ResourceEnvironment_ResourceContainer == null)) { IResourceEnvironment resourceEnvironment_ResourceContainerCasted = item.As <IResourceEnvironment>(); if ((resourceEnvironment_ResourceContainerCasted != null)) { this._parent.ResourceEnvironment_ResourceContainer = resourceEnvironment_ResourceContainerCasted; return; } } IResourceContainer nestedResourceContainers__ResourceContainerCasted = item.As <IResourceContainer>(); if ((nestedResourceContainers__ResourceContainerCasted != null)) { this._parent.NestedResourceContainers__ResourceContainer.Add(nestedResourceContainers__ResourceContainerCasted); } if ((this._parent.ParentResourceContainer__ResourceContainer == null)) { IResourceContainer parentResourceContainer__ResourceContainerCasted = item.As <IResourceContainer>(); if ((parentResourceContainer__ResourceContainerCasted != null)) { this._parent.ParentResourceContainer__ResourceContainer = parentResourceContainer__ResourceContainerCasted; return; } } }
private void Init() { _mods = new ModContainer(_stats, _events); Instance = this; _health = GetComponent <IHealthContainer>(); _unlocks = GetComponent <IUnlockList>(); _resources = GetComponent <IResourceContainer>(); _inventory = GetComponent <IInventory>(); if (_resources != null) { _resources?.ChangeResource(CreditsResource, 0); } ResourceEarningMultiplier = new Dictionary <string, IStatReference>(); _resourceFractionTrackers = new Dictionary <string, float>(); Resource[] resources = Content.GetAll <Resource>("*/Resources"); foreach (Resource resource in resources) { ResourceEarningMultiplier.Add(resource.Identifier, _stats.AddStat(GenerateStatInfo(resource), 1f)); _resourceFractionTrackers.Add(resource.Identifier, 0f); } OnNewPlayerInstance?.Invoke(this); }
public override ISimplePlacement GetPlacement(IPurchasable purchasable, IResourceContainer resources) { var placement = new StructurePlacement(() => resources.HasEnough(purchasable.Cost) ? null : "Not enough resources"); placement.OnPlaced += OnPlaced; return(placement); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { IResourceContainer connectedResourceContainers_LinkingResourceCasted = item.As <IResourceContainer>(); if ((connectedResourceContainers_LinkingResourceCasted != null)) { this._parent.ConnectedResourceContainers_LinkingResource.Add(connectedResourceContainers_LinkingResourceCasted); } if ((this._parent.CommunicationLinkResourceSpecifications_LinkingResource == null)) { ICommunicationLinkResourceSpecification communicationLinkResourceSpecifications_LinkingResourceCasted = item.As <ICommunicationLinkResourceSpecification>(); if ((communicationLinkResourceSpecifications_LinkingResourceCasted != null)) { this._parent.CommunicationLinkResourceSpecifications_LinkingResource = communicationLinkResourceSpecifications_LinkingResourceCasted; return; } } if ((this._parent.ResourceEnvironment_LinkingResource == null)) { IResourceEnvironment resourceEnvironment_LinkingResourceCasted = item.As <IResourceEnvironment>(); if ((resourceEnvironment_LinkingResourceCasted != null)) { this._parent.ResourceEnvironment_LinkingResource = resourceEnvironment_LinkingResourceCasted; return; } } }
public static void AddResources(this IResourceContainer container, IResourceCost resources) { foreach (var resource in resources.GetCost()) { container.ChangeResource(resource.Key, resource.Value); } }
public MapEntity CreateEntity(IRegionEntityFactory factory, IResourceContainer resources, bool scrollAffected) { MapEntity result = null; switch (EntityType) { case EntityType.None: result = new MapEntity(factory, scrollAffected); break; case EntityType.Building: result = new BuildingEntity(factory, scrollAffected); break; case EntityType.Player: result = new PlayerEntity(factory, scrollAffected); break; case EntityType.Npc: result = new NPCEntity(factory, scrollAffected); break; case EntityType.Door: //result = new EntityDoor(); break; } if (result != null) { result.TemplateID = this.ID; } return(result); }
private void Awake() { Instance = this; _resourceContainer = GetComponent <IResourceContainer>(); _all = LoadResearch().ToList(); InitResearch(_all); }
/// <summary> /// Calls each decorator for the specified resource container /// </summary> public void AddResourceContainerDecorations(IResourceContainer container, CodeTypeDeclaration codeClass) { logger.Debug("AddResourceContainerDecorations called for {0}", container.Name); foreach (IResourceContainerDecorator dec in decorators) { dec.DecorateClass(container, codeClass); } }
/// <summary> /// Calls each decorator for the specified resource container /// </summary> public void AddResourceContainerDecorations(IResourceContainer container, CodeTypeDeclaration codeClass) { logger.Debug("AddResourceContainerDecorations called for {0}", container.Name); foreach (IResourceContainerDecorator dec in decorators) { dec.DecorateClass(container, codeClass); } }
public void AddContainer(IResourceContainer r) { _resourceContainers.Add(r); if (_running) { _newResourceContainers.Add(r); } }
private void Start() { Button.onClick.AddListener(() => HandlePurchase()); _resourceContainer = GetComponent <IResourceContainer>(); _resourceContainer.OnResourceChanged += OnResourceChanged; UpdateGraphics(); UpdateInteractable(); }
public override void Start() { IResourceContainer container = Player.Player.Resources; foreach (Multiplier multiplier in GetMultipliers()) { Resource resource = Resource.GetResource(multiplier.ResourceIdentifier); container.SetResource(resource, Mathf.RoundToInt(container.GetResource(resource) * multiplier.Value)); } }
public void DecorateClass(IResourceContainer service, CodeTypeDeclaration serviceClass) { foreach (var pair in service.Resources) { IEnumerable <string> otherNames = service.Resources.Keys.Without(pair.Key); IResource resource = pair.Value; serviceClass.Members.Add(CreateResourceGetter(resource, otherNames)); serviceClass.Members.Add(CreateResourceField(resource, otherNames)); } }
private void Start() { IResourceContainer container = GetComponent <IResourceContainer>(); foreach (var resource in Resources.GetCost()) { container.ChangeResource(resource.Key, resource.Value); } Destroy(this); }
public void DecorateClass(IResourceContainer service, CodeTypeDeclaration serviceClass) { foreach (var pair in service.Resources) { IEnumerable<string> otherNames = service.Resources.Keys.Without(pair.Key); IResource resource = pair.Value; serviceClass.Members.Add(CreateResourceGetter(resource, otherNames)); serviceClass.Members.Add(CreateResourceField(resource, otherNames)); } }
public static object FindResource(this IResourceContainer resourceContainer, object resourceKey) { object value; if (resourceContainer.TryGetResource(resourceKey, out value)) { return(value); } throw new Granular.Exception("Resource \"{0}\" is not found", resourceKey); }
public ResourceReferenceExpression(IResourceContainer resourceContainer, object resourceKey) { this.resourceContainer = resourceContainer; this.resourceKey = resourceKey; observableValue = new ObservableValue(); observableValue.ValueChanged += (sender, e) => ValueChanged.Raise(this, e); observableValue.Value = GetResourceValue(); resourceContainer.ResourcesChanged += OnResourcesChanged; }
private void miAddResource_Click(object sender, EventArgs e) { IResourceContainer c = (IResourceContainer)tvManifest.SelectedNode.Tag; ResourceType r = new ResourceType(); c.Resources.Add(r); Forms.PropertyEditor.Show(c); tvManifest.SelectedNode.Expand(); }
public IExpression CreateExpression(DependencyObject dependencyObject, DependencyProperty dependencyProperty) { IResourceContainer resourceContainer = dependencyObject as IResourceContainer; if (resourceContainer == null) { throw new Granular.Exception("ResourceReferenceExpression cannot be attached to \"{0}\" as it does not implement \"{1}\"", dependencyObject.GetType().Name, typeof(IResourceContainer).Name); } return(new ResourceReferenceExpression(resourceContainer, resourceKey)); }
public ResourceReferenceExpression(IResourceContainer resourceContainer, object resourceKey) { this.resourceContainer = resourceContainer; this.resourceKey = resourceKey; observableValue = new ObservableValue(); observableValue.ValueChanged += (sender, oldValue, newValue) => ValueChanged.Raise(this, oldValue, newValue); observableValue.BaseValue = GetResourceValue(); resourceContainer.ResourcesChanged += OnResourcesChanged; }
public bool TrySetContextParent(IContextElement contextParent) { if (IsFrozen) { return(false); } this.ContextParent = contextParent; ParentResourceContainer = contextParent as IResourceContainer; return(true); }
public static bool TrySpend(this IResourceContainer container, IResourceCost cost) { if (HasEnough(container, cost)) { foreach (var element in cost.GetCost()) { container.ChangeResource(element.Key, -element.Value); } return(true); } return(false); }
private void Start() { _resourceContainer = GetComponent <IResourceContainer>(); _resourceContainer.OnResourceChanged += OnResourceChanged; Controller.OnResearchBegun += OnResearchBegun; Controller.OnResearchCancelled += OnReseachCancelled; Controller.OnResearchCompleted += OnResearchCompleted; Controller.OnResearchProgressed += OnResearchProgressed; UpdateAvailableCount(); Close(); }
/// <summary> /// Returns a safe and appropriate class name for the specified resource container. /// </summary> public static string GetClassName(IResourceContainer resource, IEnumerable <string> wordsUsedInContext) { string name = resource.Name; if ((resource is IService) == false) { // Add a suffix to all resource containers (except the main service) name += ResourceContainerSuffix; } return(GetSafeMemberName( wordsUsedInContext, TargetCase.ToUpper, name, resource.Name + "Res", name + "Object")); }
private void Start() { _conversionSpeed = Stats.AddStat(ConversionSpeedInfo, BaseConversionSpeed); _conversionTarget = Stats.AddStat(ConversionTargetInfo, BaseConversionTarget); _resourceContainer = GetComponent <IResourceContainer>(); _roundController.IfExists(x => { x.OnWaveStarted += OnWaveStarted; x.OnWaveFinished += OnWaveFinished; SetPause(x.State != RoundController.RoundState.InProgress); }); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(NMF.Models.IModelElement item) { IResourceContainer containerCasted = item.As <IResourceContainer>(); if ((containerCasted != null)) { this._parent.Container.Add(containerCasted); } IResourceLink linksCasted = item.As <IResourceLink>(); if ((linksCasted != null)) { this._parent.Links.Add(linksCasted); } }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { IProcessingResourceSpecification activeResourceSpecifications_ResourceContainerCasted = item.As <IProcessingResourceSpecification>(); if ((activeResourceSpecifications_ResourceContainerCasted != null)) { this._parent.ActiveResourceSpecifications_ResourceContainer.Add(activeResourceSpecifications_ResourceContainerCasted); } IResourceContainer nestedResourceContainers__ResourceContainerCasted = item.As <IResourceContainer>(); if ((nestedResourceContainers__ResourceContainerCasted != null)) { this._parent.NestedResourceContainers__ResourceContainer.Add(nestedResourceContainers__ResourceContainerCasted); } }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { ILinkingResource linkingResources__ResourceEnvironmentCasted = item.As <ILinkingResource>(); if ((linkingResources__ResourceEnvironmentCasted != null)) { this._parent.LinkingResources__ResourceEnvironment.Add(linkingResources__ResourceEnvironmentCasted); } IResourceContainer resourceContainer_ResourceEnvironmentCasted = item.As <IResourceContainer>(); if ((resourceContainer_ResourceEnvironmentCasted != null)) { this._parent.ResourceContainer_ResourceEnvironment.Add(resourceContainer_ResourceEnvironmentCasted); } }
/// <summary> /// Removes the given item from the collection /// </summary> /// <returns>True, if the item was removed, otherwise False</returns> /// <param name="item">The item that should be removed</param> public override bool Remove(NMF.Models.IModelElement item) { if ((this._parent.Environment == item)) { this._parent.Environment = null; return(true); } IResourceContainer resourceContainerItem = item.As <IResourceContainer>(); if (((resourceContainerItem != null) && this._parent.Connects.Remove(resourceContainerItem))) { return(true); } return(false); }
/// <summary> /// Removes the given item from the collection /// </summary> /// <returns>True, if the item was removed, otherwise False</returns> /// <param name="item">The item that should be removed</param> public override bool Remove(NMF.Models.IModelElement item) { IResourceContainer resourceContainerItem = item.As <IResourceContainer>(); if (((resourceContainerItem != null) && this._parent.Container.Remove(resourceContainerItem))) { return(true); } IResourceLink resourceLinkItem = item.As <IResourceLink>(); if (((resourceLinkItem != null) && this._parent.Links.Remove(resourceLinkItem))) { return(true); } return(false); }
/// <summary> /// Removes the given item from the collection /// </summary> /// <returns>True, if the item was removed, otherwise False</returns> /// <param name="item">The item that should be removed</param> public override bool Remove(IModelElement item) { ILinkingResource linkingResourceItem = item.As <ILinkingResource>(); if (((linkingResourceItem != null) && this._parent.LinkingResources__ResourceEnvironment.Remove(linkingResourceItem))) { return(true); } IResourceContainer resourceContainerItem = item.As <IResourceContainer>(); if (((resourceContainerItem != null) && this._parent.ResourceContainer_ResourceEnvironment.Remove(resourceContainerItem))) { return(true); } return(false); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(NMF.Models.IModelElement item) { if ((this._parent.Environment == null)) { IResourceEnvironment environmentCasted = item.As <IResourceEnvironment>(); if ((environmentCasted != null)) { this._parent.Environment = environmentCasted; return; } } IResourceContainer connectsCasted = item.As <IResourceContainer>(); if ((connectsCasted != null)) { this._parent.Connects.Add(connectsCasted); } }
protected override void OnInheritanceParentChanged(DependencyObject oldInheritanceParent, DependencyObject newInheritanceParent) { ParentResourceContainer = newInheritanceParent as IResourceContainer; }
protected void SetResourceInheritanceParent(IResourceContainer parent) { this.ResourceInheritanceParent = parent; }
public MapEntity CreateEntity(IRegionEntityFactory factory, IResourceContainer resources, bool scrollAffected) { MapEntity result = null; switch (EntityType) { case EntityType.None: result = new MapEntity(factory, scrollAffected); break; case EntityType.Building: result = new BuildingEntity(factory, scrollAffected); break; case EntityType.Player: result = new PlayerEntity(factory, scrollAffected); break; case EntityType.Npc: result = new NPCEntity(factory, scrollAffected); break; case EntityType.Door: //result = new EntityDoor(); break; } if (result != null) result.TemplateID = this.ID; return result; }
protected override void Load(IResourceContainer resourceContainer) { // nothing to load }
protected override void LoadCommonResources(IResourceContainer container) { container.Load(x => x.LoadTextureAtals("g.txt"), x => x.LoadTexture("indicator"), x => x.LoadFont("fnt"), x => x.LoadSoundEffect("flap", "flap"), x => x.LoadSoundEffect("hit", "hit"), x => x.LoadSoundEffect("boom", "boom")); }
protected GameStage() { _container = CreateContainer(); }
public virtual void Destroy() { _containers.Clear(); _container = null; }
/// <summary> /// Initializes a new instance of the <see cref="ResourceContainer" /> class /// using the given name and <see cref="IResourceContainer" />. /// </summary> /// <param name="name">The name of the new ResourceContainer.</param> /// <param name="container">The <see cref="IResourceContainer" /> to wrap.</param> public ResourceContainer(string name, IResourceContainer container) : this(name, container.Resources.Source.AbsoluteUri) { if (null == container) throw new ArgumentNullException(nameof(container)); }
protected override void OnLogicalParentChanged(UIElement oldLogicalParent, UIElement newLogicalParent) { ResourceInheritanceParent = (LogicalParent ?? VisualParent) as FrameworkElement; }
protected override void OnVisualParentChanged(Visual oldVisualParent, Visual newVisualParent) { base.OnVisualParentChanged(oldVisualParent, newVisualParent); Initialize(); ResourceInheritanceParent = (LogicalParent ?? VisualParent) as FrameworkElement; }