private void CmdSpawnUnit() { if (queuedUnits == maxUnitQueue) { return; } rtsPlayer = connectionToClient.identity.GetComponent <RtsPlayer>(); int resources = rtsPlayer.GetResources(); if (resources < unitPrefab.GetResourceCost()) { return; } queuedUnits++; rtsPlayer.SetResources(rtsPlayer.GetResources() - unitPrefab.GetResourceCost()); }
private void Update() { timer -= Time.deltaTime; if (timer > 0) { return; } timer = interval; rtsPlayer.SetResources(rtsPlayer.GetResources() + resourcesPerInterval); }
public void OnPointerDown(PointerEventData eventData) { if (eventData.button != PointerEventData.InputButton.Left) { return; } if (rtsPlayer.GetResources() < building.GetPrice()) { return; } buildingPreviewInstance = Instantiate(building.GetBuildingPreview()); buildingRendererInstance = buildingPreviewInstance.GetComponentInChildren <Renderer>(); buildingPreviewInstance.SetActive(false); }
private void Update() { if (rtsPlayer) { return; } rtsPlayer = NetworkClient.connection.identity.GetComponent <RtsPlayer>(); if (!rtsPlayer) { return; } ClientHandleResourcesUpdated(rtsPlayer.GetResources()); rtsPlayer.ClientOnResourcesUpdated += ClientHandleResourcesUpdated; }