// Use this for initialization void Start() { // EL meu personatge pv = GetComponent <PhotonView>(); rb = GetComponent <Rigidbody>(); CombatSystem cs = GetComponent <CombatSystem>(); // Còpia del personatge a la xarxa Unidad unidad = this.gameObject.GetComponent <Unidad>(); unidad.Initialize(); pdc.playerHealthBar.maxValue = unidad.GetMaxHealth(); pdc.playerHealthBar.value = unidad.GetHealth(); cs.playerHealthBar = pdc.playerHealthBar; // Nom de la unitat if (cs.GetTeam() == 0) { pdc.playerNameText.color = Color.blue; } else if (cs.GetTeam() == 1) { pdc.playerNameText.color = Color.red; } else { pdc.playerNameText.color = Color.black; } }
public void RefreshHudTop(string mort, string assassi) { GameObject goMort = GameObject.Find(mort); GameObject goAssassi = GameObject.Find(assassi); Unidad unMort = goMort.GetComponent <Unidad>(); Unidad unAssassi = goMort.GetComponent <Unidad>(); unMort.SetDeaths(unMort.GetDeaths() + 1); unAssassi.SetAssassinations(unAssassi.GetAssassinations() + 1); GameObject[] playersList = GameObject.FindGameObjectsWithTag("Player"); AssTeam1 = 0; AssTeam2 = 0; foreach (GameObject player in playersList) { CombatSystem cmbtPlayer = player.GetComponent <CombatSystem>(); Unidad uPlayer = player.GetComponent <Unidad>(); if (cmbtPlayer.GetTeam() == 0) { AssTeam1 += uPlayer.GetAssassinations(); } else { AssTeam2 += uPlayer.GetAssassinations(); } } netManager.playerHUD.AssMor.text = AssTeam1 + " vs " + AssTeam2; }
void OnTriggerEnter(Collider other) { GameObject otherGO = other.gameObject; if (otherGO != this.skill.gameObject) { CombatSystem otherCS = other.GetComponent <CombatSystem>(); CombatSystem myCS = this.skill.GetCombatSystem(); if (otherCS.GetTeam() != myCS.GetTeam()) { this.skill.Return(other.gameObject); this.photonView.RPC("AutoDestroy", PhotonTargets.All, null); } } }
public void LevelGold(string mort, string jugador) { GameObject goJugador = GameObject.Find(jugador); Unidad unJugador = goJugador.GetComponent <Unidad>(); GameObject[] playersList = GameObject.FindGameObjectsWithTag("Player"); switch (mort) { case "Champion": unJugador.SetGold(unJugador.GetGold() + 200); unJugador.SetExperience(unJugador.GetExperience() + 300); break; case "Torre": foreach (GameObject player in playersList) { CombatSystem cmbtPlayer = player.GetComponent <CombatSystem>(); Unidad uPlayer = player.GetComponent <Unidad>(); if (cmbtPlayer.GetTeam() == unJugador.GetCombatSystem().GetTeam()) { uPlayer.SetGold(unJugador.GetGold() + 300); uPlayer.SetExperience(unJugador.GetExperience() + 500); } } break; case "Blue": unJugador.SetGold(unJugador.GetGold() + 150); unJugador.SetExperience(unJugador.GetExperience() + 150); break; case "Red": unJugador.SetGold(unJugador.GetGold() + 150); unJugador.SetExperience(unJugador.GetExperience() + 150); break; case "Dragon": foreach (GameObject player in playersList) { CombatSystem cmbtPlayer = player.GetComponent <CombatSystem>(); Unidad uPlayer = player.GetComponent <Unidad>(); if (cmbtPlayer.GetTeam() == unJugador.GetCombatSystem().GetTeam()) { unJugador.SetGold(unJugador.GetGold() + 400); unJugador.SetExperience(unJugador.GetExperience() + 500); } } break; case "Baron": foreach (GameObject player in playersList) { CombatSystem cmbtPlayer = player.GetComponent <CombatSystem>(); Unidad uPlayer = player.GetComponent <Unidad>(); if (cmbtPlayer.GetTeam() == unJugador.GetCombatSystem().GetTeam()) { unJugador.SetGold(unJugador.GetGold() + 600); unJugador.SetExperience(unJugador.GetExperience() + 500); } } break; } if (unJugador.GetExperience() >= 500) { unJugador.SetLevel(unJugador.GetLevel() + 1); unJugador.SetExperience(unJugador.GetExperience() - 500); unJugador.SetMaxHealth(unJugador.GetMaxHealth() + 50); unJugador.SetMaxMana(unJugador.GetMaxMana() + 50); unJugador.SetHealthRegen(unJugador.GetHealthRegen() + 2); unJugador.SetManaRegen(unJugador.GetManaRegen() + 2); unJugador.SetAtackDamage(unJugador.GetAtackDamage() + 7); unJugador.SetAtackSpeed(unJugador.GetAtackSpeed() + 7); unJugador.SetAbilityPower(unJugador.GetAbilityPower() + 7); unJugador.SetArmour(unJugador.GetArmour() + 1); unJugador.SetMagicArmour(unJugador.GetMagicArmour() + 1); //this.netManager.experiencia.value = unJugador.GetExperience(); //this.netManager.nivell.text = unJugador.GetLevel().ToString(); } }
// Use this for initialization void Start() { // EL meu personatge pv = GetComponent <PhotonView>(); rb = GetComponent <Rigidbody>(); object[] data; data = this.pv.instantiationData; CombatSystem cs = GetComponent <CombatSystem>(); cs.SetTeam((int)data[1]); if (pv.isMine) { GetComponent <PlayerController>().enabled = true; GetComponent <Rigidbody>().isKinematic = false; GetComponent <Rigidbody>().useGravity = true; GameObject camera = GameObject.FindGameObjectWithTag("MainCamera"); if (camera != null) { PlayerCamera pc = camera.GetComponent <PlayerCamera>(); pc.enabled = true; pc.player = GetComponent <PlayerController>(); } GameObject netManagerOBJ = GameObject.FindGameObjectWithTag("NetManager"); NetManager netManagerScript = netManagerOBJ.GetComponent <NetManager>(); cs.playerHealthBar = netManagerScript.playerHUD.playerHealthBar; cs.playerManaBar = netManagerScript.playerHUD.playerManaBar; if (cs.mr_skill != null) { netManagerScript.playerHUD.skill_qImg.sprite = cs.mr_skill.skillSprite; cs.mr_skill.coolDownSlider = netManagerScript.playerHUD.skill_q; } if (cs.q_skill != null) { netManagerScript.playerHUD.skill_eImg.sprite = cs.q_skill.skillSprite; cs.q_skill.coolDownSlider = netManagerScript.playerHUD.skill_e; } if (cs.e_skill != null) { netManagerScript.playerHUD.skill_mlImg.sprite = cs.e_skill.skillSprite; cs.e_skill.coolDownSlider = netManagerScript.playerHUD.skill_ml; } if (cs.b_skill != null) { netManagerScript.playerHUD.skill_mrImg.sprite = cs.b_skill.skillSprite; cs.b_skill.coolDownSlider = netManagerScript.playerHUD.skill_mr; } } else { string nomJugador = (string)data[0]; // Còpia del personatge a la xarxa this.playerDataCanvas = (GameObject)Instantiate(this.playerDataCanvasPrefab, this.transform.position + Vector3.up * 2, Quaternion.Euler(new Vector3(50, 0, 0))); this.playerDataCanvas.name = "PDC" + nomJugador; PlayerDataCanvas pdc = this.playerDataCanvas.GetComponent <PlayerDataCanvas>(); pdc.targetPlayer = this.transform; pdc.playerNameText.text = nomJugador; this.gameObject.name = nomJugador; Unidad unidad = this.gameObject.GetComponent <Unidad>(); unidad.Initialize(); pdc.playerHealthBar.maxValue = unidad.GetMaxHealth(); pdc.playerHealthBar.value = unidad.GetHealth(); cs.playerHealthBar = pdc.playerHealthBar; // Nom del campió dels equips if (cs.GetTeam() == 0) { pdc.playerNameText.color = Color.blue; } else { pdc.playerNameText.color = Color.red; } } }