private void Start() { player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); ClientHandleResourcesUpdated(player.GetMyResources()); player.ClientOnResourcesUpdated += ClientHandleResourcesUpdated; }
private void CmdSpawnUnit() { if (queuedUnits == maxUnitQueue) { return; } RTSPlayer player = connectionToClient.identity.GetComponent <RTSPlayer>(); if (player.GetMyResources() < unitPrefab.GetResourceCost()) { return; } queuedUnits++; player.SetResources(player.GetMyResources() - unitPrefab.GetResourceCost()); }
private void Start() { //Get our connection, get the player object for our connection and on the player object get the RTSPlayer script player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); //Set Resorces To The UI ClientHandleResourcesUpdated(player.GetMyResources()); //Subscribe Event player.ClientOnResourcesUpdated += ClientHandleResourcesUpdated; }
private void Update() { timer -= Time.deltaTime; if (timer <= 0) { player.SetResources(player.GetMyResources() + resourcesPerInterval); timer += interval; } }
private void CmdSpawnUnit() { //If Queue is Full Then Not Spawn Unit if (queuedUnits == maxUnitQueue) { return; } RTSPlayer player = connectionToClient.identity.GetComponent <RTSPlayer>(); //If Player Resource Smaller Then Prefab Cost Then Not Spawn Unit if (player.GetMyResources() < unitPrefab.GetResourceCost()) { return; } queuedUnits++; //Set Player Resources To CurrentResources - UnitCost player.SetResources(player.GetMyResources() - unitPrefab.GetResourceCost()); }
private void Update() { //Reduce Timer timer -= Time.deltaTime; if (timer <= 0) //We Set it interval Value If It Reaches 0 Then { //Increase Resources player.SetResources(player.GetMyResources() + resourcesPerInterval); //Reset Timer To Beginning interval value timer += interval; } }
private void Update() { if (player == null) { player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); if (player != null) { ClientHandleResourcesUpdated(player.GetMyResources()); player.ClientOnResourcesUpdated += ClientHandleResourcesUpdated; } } }
public void OnPointerDown(PointerEventData eventData) { if (eventData.button != PointerEventData.InputButton.Left) { return; } if (player.GetMyResources() < building.GetPrice()) { return; } buildingPreviewInstance = Instantiate(building.GetBuildingPreview()); buildingRendererInstance = buildingPreviewInstance.GetComponentInChildren <Renderer>(); buildingPreviewInstance.SetActive(false); }
public void OnPointerDown(PointerEventData eventData) { if (eventData.button != PointerEventData.InputButton.Left) { return; } //Cheking If We Have Enough Resources To Build if (player.GetMyResources() < building.GetPrice()) { return; } //If We Click Mouse Left Button On This Object Instantiate Preview And Get Renderer buildingPreviewInstance = Instantiate(building.GetBuildingPreview()); buildingRendererInstance = buildingPreviewInstance.GetComponentInChildren <Renderer>(); //To Avoid Instantiate Object in (0,0,0) Position We Set It False At The Beginning buildingPreviewInstance.SetActive(false); }