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(); } } }
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(); }
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); }