Esempio n. 1
0
 public void TriggerNodeCaptureChange(int newCapturePlayerId)
 {
     // Change color
     if (newCapturePlayerId < 0)           // If we are not captured
     {
         capturedColor    = ColorHub.HexToColor(ColorHub.Black);
         capturedPlayerId = newCapturePlayerId;
     }
     else
     {
         capturedPlayerId = newCapturePlayerId;
         if (networkPerspective == NetworkPerspective.Server)
         {
             if (server.players.ContainsKey(capturedPlayerId))
             {
                 ColorUtility.TryParseHtmlString("#" + server.players[capturedPlayerId].playerColor, out capturedColor);
             }
         }
         else
         {
             if (client.players.ContainsKey(capturedPlayerId))
             {
                 ColorUtility.TryParseHtmlString("#" + client.players[capturedPlayerId].playerColor, out capturedColor);
             }
         }
     }
 }
Esempio n. 2
0
    void Start()
    {
        rigidbody = GetComponent <Rigidbody2D>();

        if (GameObject.Find("[Client]"))
        {
            client = GameObject.Find("[Client]").GetComponent <Client>();
        }

        if (GameObject.Find("[Server]"))
        {
            server = GameObject.Find("[Server]").GetComponent <Server>();
            rigidbody.isKinematic = true;
        }

        // Set TetherLine material and textureMat
        tetherMat = new Material(tetherLineTexture.GetComponent <Renderer>().material);
        tetherLineTexture.GetComponent <Renderer>().material = tetherMat;
        tetherMat.SetColor("_Color", Color.Lerp(ColorHub.HexToColor(ColorHub.White), playerSprite.GetComponent <SpriteRenderer>().color, 0.5f));

        eventDie     += OnDie;
        eventRespawn += OnRespawn;

        if (networkPerspective == NetworkPerspective.Client)
        {
            cam          = GameObject.Find("[Cameras]").transform.Find("Camera Main").GetComponent <Camera>();
            mouseCamera  = cam.transform.Find("Mouse Camera").GetComponent <Camera>();
            aimIndicator = GameObject.Find("AimIndicator").transform;
        }
    }
Esempio n. 3
0
 void Update()
 {
     if (isDead == true)
     {
         spriteRenderer_Heart.color = Color.Lerp(spriteRenderer_Heart.color, ColorHub.HexToColor(ColorHub.White), 15 * Time.deltaTime);
         spriteRenderer_Body.color  = Color.Lerp(spriteRenderer_Body.color, ColorHub.HexToColor(ColorHub.Gray), 15 * Time.deltaTime);
     }
     else
     {
         spriteRenderer_Heart.color = Color.Lerp(spriteRenderer_Heart.color, capturedColor, 15 * Time.deltaTime);
         spriteRenderer_Body.color  = Color.Lerp(spriteRenderer_Body.color, ColorHub.HexToColor(ColorHub.Black), 15 * Time.deltaTime);
     }
 }
Esempio n. 4
0
    // Connection/Disconnection Methods
    private void SpawnPlayer(string playerName, int connectionId, int entityId, string playerColor)
    {
        Player newPlayer = new Player();

        // Spawn Player
        newPlayer.playerName       = playerName;
        newPlayer.connectionId     = connectionId;
        newPlayer.playerGameObject = (GameObject)Instantiate(prefab_Player);
        newPlayer.playerGameObject.GetComponentInChildren <TextMesh>().text = newPlayer.playerName;
        newPlayer.playerController          = newPlayer.playerGameObject.GetComponentInChildren <PlayerController>();
        newPlayer.playerController.entityId = entityId;
        newPlayer.playerColor = playerColor;
        Color colorParse = Color.black;

        ColorUtility.TryParseHtmlString("#" + playerColor, out colorParse);
        newPlayer.captureRegionMaterial       = new Material(captureRegionMaterialDefault);
        newPlayer.captureRegionMaterial.color = Color.Lerp(ColorHub.HexToColor(ColorHub.White), colorParse, 0.25f);
        newPlayer.playerController.playerSprite.GetComponent <SpriteRenderer>().color = colorParse;
        newPlayer.playerController.tetherCircle.GetComponent <SpriteRenderer>().color = Color.Lerp(ColorHub.HexToColor(ColorHub.White), colorParse, 0.5f);

        // Add player to entities
        if (entities.ContainsKey(entityId))
        {
            entities[entityId] = newPlayer.playerController;
        }
        else
        {
            entities.Add(entityId, newPlayer.playerController as Entity);
        }

        if (connectionId == ourClientId)           // Is this playerGameObject ours?
        {
            newPlayer.playerController.networkPerspective = NetworkPerspective.Client;
            newPlayer.playerGameObject.layer = LayerMask.NameToLayer("ClientPlayer");
            ui_LoginScreen.gameObject.SetActive(false);
            isLoaded = true;
            // Currently this is the point at which the client's player becomes active and the GUI closes, we should probably change that! D:
        }

        if (players.ContainsKey(connectionId))
        {
            players[connectionId] = newPlayer;
        }
        else
        {
            players.Add(connectionId, newPlayer);
        }
    }