Esempio n. 1
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();
            }
        }
    }