/* Use a specified resource (returns false if used up) */ public bool UseResource(ContractAssignee ResourceType) { ZoneInShip ThisZone = null; switch (ResourceType) { case ContractAssignee.BLUE: ThisZone = BlueZone.gameObject.GetComponent <ZoneInShip>(); break; case ContractAssignee.GREEN: ThisZone = GreenZone.gameObject.GetComponent <ZoneInShip>(); break; case ContractAssignee.RED: ThisZone = RedZone.gameObject.GetComponent <ZoneInShip>(); break; case ContractAssignee.YELLOW: ThisZone = YellowZone.gameObject.GetComponent <ZoneInShip>(); break; } if (ThisZone == null) { return(false); } ThisZone.ResourceCount -= ResourceDepletionRate[(int)ResourceType]; return(ThisZone.ResourceCount > 0.0f); }
/* Convert a zone's resources into a resource entity */ public void ConvertResourcesToEntity(ContractAssignee zoneType) { //Get the zone that this resource is coming from ZoneInShip ThisZone = null; switch (zoneType) { case ContractAssignee.BLUE: ThisZone = BlueZone.gameObject.GetComponent <ZoneInShip>(); break; case ContractAssignee.GREEN: ThisZone = GreenZone.gameObject.GetComponent <ZoneInShip>(); break; case ContractAssignee.RED: ThisZone = RedZone.gameObject.GetComponent <ZoneInShip>(); break; case ContractAssignee.YELLOW: ThisZone = YellowZone.gameObject.GetComponent <ZoneInShip>(); break; } if (ThisZone == null) { return; } //We have some resources to distribute, so spawn the entity GameObject NewResourceEntity = Instantiate(resourceObject, ResourceSpawnSpots[(int)zoneType]) as GameObject; NewResourceEntity.transform.localScale = new Vector3(1, 1, 1); NewResourceEntity.GetComponent <ContractInShip>().ResourceRemaining = ThisZone.ResourceCount; NewResourceEntity.GetComponent <ContractInShip>().ResourceMax = ThisZone.ResourceCount; NewResourceEntity.GetComponent <ContractInShip>().SetResourceAssignee(zoneType); NewResourceEntity.transform.parent = ContractSpawnSpot.transform; ContractsInside.Add(NewResourceEntity); //Depleat the resource we took ThisZone.ResourceCount = 0; }
/* Check to see if a resource is empty */ public bool ResourceIsEmpty(ContractAssignee ResourceType) { ZoneInShip ThisZone = null; switch (ResourceType) { case ContractAssignee.BLUE: ThisZone = BlueZone.gameObject.GetComponent <ZoneInShip>(); break; case ContractAssignee.GREEN: ThisZone = GreenZone.gameObject.GetComponent <ZoneInShip>(); break; case ContractAssignee.RED: ThisZone = RedZone.gameObject.GetComponent <ZoneInShip>(); break; case ContractAssignee.YELLOW: ThisZone = YellowZone.gameObject.GetComponent <ZoneInShip>(); break; } return(ThisZone == null || ThisZone.ResourceCount <= 0.0f); }
public void SetResourceAssignee(ContractAssignee worth) { ResourceExAssignee = worth; ThisWorthSprite.sprite = WorthSprites[(int)worth]; }