private void Update() { if (_player == null) { try { _player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); } catch (NullReferenceException nullReferenceException) { Debug.LogWarning("Player is null , might trying to get component before player instantiated \n" + nullReferenceException); } } if (Mouse.current.leftButton.wasPressedThisFrame) { StartSelectionArea(); } else if (Mouse.current.leftButton.wasReleasedThisFrame) { ClearSelectionArea(); } else if (Mouse.current.leftButton.isPressed) { UpdateSelectionArea(); } }
private void UpdateTimerDisplay() { //unitProgressImage.fillAmount = 0.5f; //Debug.Log(6); //unitTimer = 0f; float newProgress = unitTimer / unitSpawnDuration; if (newProgress < unitProgressImage.fillAmount) { //Debug.Log(newProgress); unitProgressImage.fillAmount = newProgress; } else { RTSPlayer player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); //the yellow effect unitProgressImage.fillAmount = Mathf.SmoothDamp( unitProgressImage.fillAmount, newProgress, ref progressImageVelocity, 0.1f ); //Debug.Log($"5 {unitProgressImage.fillAmount}"); } }
private void Update() { if (player == null) { // todo: this causes a known error which will be addressed in a later lesson player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); } // first press -- START NEW SELECTION if (Mouse.current.leftButton.wasPressedThisFrame) { StartSelectionArea(); } // drag -- MOVING MOUSE else if (Mouse.current.leftButton.isPressed) { UpdateSelectionArea(); } // release -- COMPLETE SELECTION else if (Mouse.current.leftButton.wasReleasedThisFrame) { CompleteSelectionArea(); } }
private void Start() { player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); ClientHandleResourcesUpdated(player.GetResources()); player.ClientOnResourcesUpdated += ClientHandleResourcesUpdated; }
public override void OnStartServer() { //Get player and get teamcolor from player RTSPlayer player = connectionToClient.identity.GetComponent <RTSPlayer>(); teamColor = player.GetTeamColor(); }
public override void OnStartServer() { timer = interval; player = connectionToClient.identity.GetComponent <RTSPlayer>(); health.ServerOnDie += ServerHandleDie; GameOverHandler.ServerOnGameOver += ServerHandleGameOver; }
void Start() { mainCamera = Camera.main; player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); Unit.AuthorityOnUnitDespawned += AuthorityHandleUnitDespawned; GameOverHandler.ClientOnGameOver += ClientHandleGameOver; }
public override void OnStartServer() { RTSPlayer player = connectionToClient.identity.GetComponent <RTSPlayer>(); //Debug.Log($"TeamColorSetter {player} , color {player.GetTeamColor()} "); teamColor = player != null?player.GetTeamColor() : Color.red; }
private void Start() { mainCamera = Camera.main; iconImage.sprite = building.GetIcon(); priceText.text = building.GetPrice().ToString(); player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); //Get the identity component of the client connection calling this script. This allows us to get RTSPlayer component buildingCollider = building.GetComponent <BoxCollider>(); }
public override void OnServerDisconnect(NetworkConnection conn) { RTSPlayer player = conn.identity.GetComponent <RTSPlayer>(); Players.Remove(player); base.OnServerDisconnect(conn); }
public override void OnStartServer() { //Find Which Player Owns This Object RTSPlayer player = connectionToClient.identity.GetComponent <RTSPlayer>(); //Get Color Belongs To Us teamColor = player.GetTeamColor(); }
private void Start() { player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); ClientHandleResourcesUpdated(player.GetResources()); // first update the UI player.ClientOnResourcesUpdated += ClientHandleResourcesUpdated; // then update with further resoruce updates }
public override void OnStartServer() { resourceTimer = interval; player = connectionToClient.identity.GetComponent <RTSPlayer>(); //Can get this component like this because it starts existing when world spawns. health.ServerOnDie += ServerHandleDie; GameOverHandler.ServerOnGameOver += ServerHandleGameOver; }
private void Start() { mainCamera = Camera.main; iconImage.sprite = building.GetIcon(); priceText.text = building.GetPrice().ToString(); buildingCollider = building.GetComponent <BoxCollider>(); player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); }
public override void OnServerDisconnect(NetworkConnection conn) { //Gets player player that disconnects from server & removes from list. RTSPlayer player = conn.identity.GetComponent <RTSPlayer>(); Players.Remove(player); base.OnServerDisconnect(conn); }
public override void OnStartServer() { player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); if (FindObjectOfType <NetworkManager>().numPlayers == 1) { InvokeRepeating("SpawnEnemy", 0.1f, this.spawnInterval); } }
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 Start() { Input.simulateMouseWithTouches = true; mainCamera = Camera.main; player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); Unit.AuthorityOnUnitDespawned += AuthorityHandleUnitDespawned; GameOverHandler.ClientOnGameOver += ClientHandleGameOver; }
void Update() { if (player == null) { // todo: this causes a known error which will be addressed in a later lesson player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); } UpdateBuildingPreview(); }
private void Start() { mainCamera = Camera.main; iconImage.sprite = building.GetIcon(); priceText.text = building.GetPrice().ToString(); //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>(); buildingCollider = building.GetComponent <BoxCollider>(); }
private void Update() { if (player == null) { player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); if (player != null) { ClientHandleResourcesUpdated(player.Resources); player.ClientOnResourcesChanged += ClientHandleResourcesUpdated; } } }
private void Start() { mainCamera = Camera.main; //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>(); //Subscribe Unit.AuthorityOnUnitDeSpawned += AuthorityHandleUnitDeSpawned; //For Disable This Script When We Die GameOverHandler.ClientOnGameOver += ClientHandleGameOver; }
private void Start() { //set camera to be main camera for raycasts mainCamera = Camera.main; player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); //Subscribe to events Unit.AuthorityOnUnitDespawned += AuthorityHandleUnitDespawn; //This event is used to stop a dead player selecting units GameOverHandler.ClientOnGameOver += ClientHandleGameOver; }
public override void OnStartServer() { //To Reducing Interval We Set It To The Timer timer = interval; player = connectionToClient.identity.GetComponent <RTSPlayer>(); //Subscribing Events //When It Dies health.ServerOnDie += ServerHandleDie; //When Game is Over GameOverHandler.ServerOnGameOver += ServerHandleGameOver; }
private void Update() { if (player == null) { player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); } if (buildingPreviewInstance == null) { return; } UpdateBuildingPreview(); }
private void Update() { if (player == null) { player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); } if (!isRelase && buildingPrevievInstance != null && Mouse.current.leftButton.wasPressedThisFrame) { TryPutBuilding(); } UpdateBuildingInstance(); }
public override void OnServerAddPlayer(NetworkConnection conn) { base.OnServerAddPlayer(conn); RTSPlayer player = conn.identity.GetComponent <RTSPlayer>(); players.Add(player); player.SetDisplayName($"Player {players.Count}"); player.SetTeamColour(UnityEngine.Random.ColorHSV(0f, 1f, 0.8f, 1f, 0.8f, 1f)); player.SetPartyOwner(players.Count == 1); }
private void Update() { if (player == null) { // todo: this causes a known error which will be addressed in a later lesson player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); if (player != null) { ClientHandleResourcesUpdated(player.GetResources()); player.ClientOnResourcesChanged += ClientHandleResourcesUpdated; } } }
private void Update() { if (player == null) { //This set player on Update. Only sets it until not null player = NetworkClient.connection.identity.GetComponent <RTSPlayer>(); //Get the identity component of the client connection calling this script. This allows us to get RTSPlayer component //Once player is found Update UI & subscribe to future Server ResourceUpdates if (player != null) { ClientHandleResourcesUpdated(player.GetResources()); player.ClientOnResourcesUpdated += ClientHandleResourcesUpdated; } } }
private void CmdSpawnUnit() { if (queuedUnits == maxUnitQueue) { return; } RTSPlayer player = connectionToClient.identity.GetComponent <RTSPlayer>(); if (player.GetResources() < unitPrefab.GetResourceCost()) { return; } queuedUnits++; player.SetResources(player.GetResources() - unitPrefab.GetResourceCost()); }