Exemple #1
0
    void OnPlayerKilled(string data)
    {
        HealthChangeJson userJson = HealthChangeJson.CreateFromJson(data);

        print("Player killed another player: " + userJson.killerName);
        Destroy(GameObject.Find(userJson.name));

        leaderboardManager.ChangeScore(userJson.killerName, "kills", userJson.killerCount);
    }
Exemple #2
0
    void OnOtherPlayerDisconnect(string data)
    {
        HealthChangeJson userJson = HealthChangeJson.CreateFromJson(data);

        print("Player disconnected: " + userJson.name);
        Destroy(GameObject.Find(userJson.name));

        leaderboardManager.ChangeScore(userJson.name, "kills", -1);
    }
Exemple #3
0
    private void OnProjectileDamage(string data)
    {
        HealthChangeJson hcJSON = HealthChangeJson.CreateFromJson(data);

        GameObject playerDealtTo = GameObject.Find(hcJSON.name);

        if (playerDealtTo != null)
        {
            //Works for local player receiving damage from bullets
            //Possibly improve on this area so that damage is applied to enemy instances?
            HealthBar dealtToHealthBar = playerDealtTo.GetComponent <HealthBar>();
            dealtToHealthBar.TakeDamage(hcJSON.damage);
            if (hcJSON.killerName != null)
            {
                leaderboardManager.ChangeScore(hcJSON.killerName, "kills", hcJSON.killerCount);
            }
        }
    }
Exemple #4
0
    void OnPlayerDamage(string data)
    {
        print("Player was damaged");
        HealthChangeJson hcJSON = HealthChangeJson.CreateFromJson(data);

        // todo player damage, use UserHealthJson or HealthChangeJson?
        // send message with damage = true and calculate damage and possible kill in server
        GameObject playerDealtTo = GameObject.Find(hcJSON.name);

        if (playerDealtTo != null)
        {
            //Works for local player receiving damage from bullets
            //Possibly improve on this area so that damage is applied to enemy instances?
            HealthBar dealtToHealthBar = playerDealtTo.GetComponent <HealthBar>();
            dealtToHealthBar.TakeDamage(hcJSON.damage);
            if (hcJSON.killerName != null)
            {
                leaderboardManager.ChangeScore(hcJSON.killerName, "kills", 1);
            }
        }
    }