public override void OnStartServer()
        {
            timer     = interval;
            rtsPlayer = connectionToClient.identity.GetComponent <RtsPlayer>();

            health.ServerOnDie += ServerHandleDie;
            GameOverHandler.ServerOnGameOver += ServerHandleGameOver;
        }
        private void Update()
        {
            if (!rtsPlayer)
            {
                rtsPlayer = NetworkClient.connection.identity.GetComponent <RtsPlayer>();
            }

            if (!buildingPreviewInstance)
            {
                return;
            }
            UpdateBuildingPreview();
        }
Example #3
0
 private void Update()
 {
     if (rtsPlayer)
     {
         return;
     }
     rtsPlayer = NetworkClient.connection.identity.GetComponent <RtsPlayer>();
     if (!rtsPlayer)
     {
         return;
     }
     ClientHandleResourcesUpdated(rtsPlayer.GetResources());
     rtsPlayer.ClientOnResourcesUpdated += ClientHandleResourcesUpdated;
 }
        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());
        }
Example #5
0
    void Update()
    {
        if (rtsPlayer == null)
        {
            rtsPlayer = NetworkClient.connection.identity.GetComponent <RtsPlayer>();
        }

        if (Mouse.current.leftButton.wasPressedThisFrame)// TODO need to add logic not to deselect selected unit when pressing on it
        {
            //start selection area for multi select
            StartSelectionArea();
        }
        else if (Mouse.current.leftButton.wasReleasedThisFrame)
        {
            ClearSelectionArea();
        }
        else if (Mouse.current.leftButton.isPressed)
        {
            UpdateSelectionArea();
        }
    }
 private void Update()
 {
     if (!rtsPlayer)
     {
         rtsPlayer = NetworkClient.connection.identity.GetComponent <RtsPlayer>();
     }
     if (Mouse.current.leftButton.wasPressedThisFrame)
     {
         // reset units to be ready for reselecting when the left button is raised
         StartSelectionArea();
     }
     else if (Mouse.current.leftButton.IsPressed())
     {
         UpdateSelectionArea();
     }
     else if (Mouse.current.leftButton.wasReleasedThisFrame)
     {
         // get units and add to list of selectedUnits
         ClearSelectionArea();
     }
 }