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();
            }
        }
    }
Esempio n. 2
0
    void OnEnemyConnect(NetworkMessage netMsg)
    {
        User       u     = netMsg.ReadMessage <User>();
        GameObject enemy = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs/enemy"), u.position, u.rotation);
        enemy      ecomp = enemy.GetComponent <enemy>();

        enemy.transform.Find("username").GetComponent <TextMesh>().text = u.username;
        enemy.name = "e" + u.id;
        ecomp.setId(u.id);
        ecomp.setMedia(u.media);
        ecomp.setKills(u.kills);
        players.Add(u.id, enemy);
    }