Ejemplo n.º 1
0
    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();
        }
    }
Ejemplo n.º 2
0
    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}");
        }
    }
Ejemplo n.º 3
0
    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();
        }
    }
Ejemplo n.º 4
0
    private void Start()
    {
        player = NetworkClient.connection.identity.GetComponent <RTSPlayer>();

        ClientHandleResourcesUpdated(player.GetResources());
        player.ClientOnResourcesUpdated += ClientHandleResourcesUpdated;
    }
Ejemplo n.º 5
0
    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;
 }
Ejemplo n.º 8
0
    public override void OnStartServer()
    {
        RTSPlayer player = connectionToClient.identity.GetComponent <RTSPlayer>();

        //Debug.Log($"TeamColorSetter {player} , color {player.GetTeamColor()} ");
        teamColor = player != null?player.GetTeamColor() : Color.red;
    }
Ejemplo n.º 9
0
 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);
    }
Ejemplo n.º 11
0
    public override void OnStartServer()
    {
        //Find Which Player Owns This Object
        RTSPlayer player = connectionToClient.identity.GetComponent <RTSPlayer>();

        //Get Color Belongs To Us
        teamColor = player.GetTeamColor();
    }
Ejemplo n.º 12
0
    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
    }
Ejemplo n.º 13
0
    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;
    }
Ejemplo n.º 14
0
    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>();
    }
Ejemplo n.º 15
0
    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);
    }
Ejemplo n.º 16
0
    public override void OnStartServer()
    {
        player = NetworkClient.connection.identity.GetComponent <RTSPlayer>();

        if (FindObjectOfType <NetworkManager>().numPlayers == 1)
        {
            InvokeRepeating("SpawnEnemy", 0.1f, this.spawnInterval);
        }
    }
Ejemplo n.º 17
0
    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;
    }
Ejemplo n.º 18
0
    private void Start()
    {
        Input.simulateMouseWithTouches = true;
        mainCamera = Camera.main;

        player = NetworkClient.connection.identity.GetComponent <RTSPlayer>();

        Unit.AuthorityOnUnitDespawned    += AuthorityHandleUnitDespawned;
        GameOverHandler.ClientOnGameOver += ClientHandleGameOver;
    }
Ejemplo n.º 19
0
    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();
    }
Ejemplo n.º 20
0
    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>();
    }
Ejemplo n.º 21
0
 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;
    }
Ejemplo n.º 24
0
    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;
    }
Ejemplo n.º 25
0
    private void Update()
    {
        if (player == null)
        {
            player = NetworkClient.connection.identity.GetComponent <RTSPlayer>();
        }

        if (buildingPreviewInstance == null)
        {
            return;
        }
        UpdateBuildingPreview();
    }
Ejemplo n.º 26
0
    private void Update()
    {
        if (player == null)
        {
            player = NetworkClient.connection.identity.GetComponent <RTSPlayer>();
        }

        if (!isRelase && buildingPrevievInstance != null && Mouse.current.leftButton.wasPressedThisFrame)
        {
            TryPutBuilding();
        }

        UpdateBuildingInstance();
    }
Ejemplo n.º 27
0
    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);
    }
Ejemplo n.º 28
0
    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;
            }
        }
    }
Ejemplo n.º 29
0
    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;
            }
        }
    }
Ejemplo n.º 30
0
    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());
    }