Ejemplo n.º 1
0
    void OnEnemyDied(NetworkMessage netMsg)
    {
        PlayerDead playerDied = netMsg.ReadMessage <PlayerDead>();
        enemy      victim     = players[playerDied.victim].GetComponent <enemy>();

        if (playerDied.killer == id)
        {
            addKill();
            if (kills > maxPoints)
            {
                setRecordHolder(-1, kills);
            }

            if (baseDamage == -1 && victim.getMedia() != -1)
            {
                player.GetComponent <PController>().applyBoost(victim.getMedia());
            }
            else if (baseDamage != -1 && victim.getMedia() == -1)
            {
                player.GetComponent <PController>().applyBoost(-1);
            }
        }
        else
        {
            enemy en = players[playerDied.killer].GetComponent <enemy>();
            en.addKill();
            if (en.getKills() > maxPoints)
            {
                setRecordHolder(en.getId(), en.getKills());
            }
        }
        victim.die();
    }
Ejemplo n.º 2
0
    void OnEnemyUpdate(NetworkMessage netMsg)
    {
        //Debug.Log("NET UPDATE RECEIVED");
        PlayerUpdate enemyUpdate = netMsg.ReadMessage <PlayerUpdate>();
        //TODO: not necessary for now, check later if it's worth it.
        enemy e = players[enemyUpdate.id].GetComponent <enemy>();

        e.setRotation(enemyUpdate.rot);
        e.setDirection(enemyUpdate.dir.value, enemyUpdate.dir.b);
        e.setCorrection(enemyUpdate.pos);
        //e.setArmRotation(enemyUpdate.armRot);
        if (enemyUpdate.dead && players[enemyUpdate.id].transform.localScale == Vector3.one)
        {
            players[enemyUpdate.id].transform.localScale = Vector3.zero;
        }
        else if (!enemyUpdate.dead && players[enemyUpdate.id].transform.localScale == Vector3.zero)
        {
            players[enemyUpdate.id].transform.localScale = new Vector3(0.15f, 0.15f, 0.23f);;
        }

        if (enemyUpdate.kills != e.getKills())
        {
            e.setKills(enemyUpdate.kills);
            if (e.getKills() > maxPoints)
            {
                setRecordHolder(enemyUpdate.id, e.getKills());
            }
            else if (recordHolder == e.getId() && e.getKills() < maxPoints)
            {
                search4NewHolder();
            }
        }
    }
Ejemplo n.º 3
0
    public void Dead(int id)
    {
        NetInt dead = new NetInt();

        dead.value = id;
        nm.nc.Send(904, dead);
        UI.transform.localScale = new Vector3(0, 0, 0);
        respawnTimer.Start(nm.getConfiguration().respawnTime, "Sei stato eliminato da " + players[id].gameObject.transform.Find("username").GetComponent <TextMesh>().text);
        enemy e = players[id].GetComponent <enemy>();

        e.addKill();

        if (e.getKills() > maxPoints)
        {
            setRecordHolder(id, e.getKills());
        }
    }
Ejemplo n.º 4
0
    public void search4NewHolder()
    {
        int max       = 0;
        int maxholder = 0;

        foreach (GameObject c in players.Values)
        {
            enemy e      = c.GetComponent <enemy>();
            int   ckills = e.getKills();
            if (ckills > max)
            {
                max       = ckills;
                maxholder = e.getId();
            }
        }
        if (kills > max)
        {
            max       = kills;
            maxholder = -1;
        }
        setRecordHolder(maxholder, max);
    }