// Set up the references to other scripts when the game starts void Start() { animator = GetComponent <Animator>(); photonView = GetComponent <PhotonView>(); navMeshAgent = GetComponent <NavMeshAgent>(); playerChampion = GetComponent <PlayerChampion>(); }
/// <summary> /// Removes the enemy from the list of enemies within range. /// <param name="enemy">The entity who exited the radius</param> /// </summary> public void EnemyLeaveRadius(Entity enemy) { enemies.Remove(enemy); if (!enemies.Contains(currentTarget)) { ResetDamage(); currentTarget = null; if (enemies.Count > 0) { // Smarter prioritising for which enemy to target; players will be targeted last foreach (Entity e in enemies) { if (e == null) { continue; } PlayerChampion c = e.GetComponent <PlayerChampion>(); if (c == null) { currentTarget = e; } } if (currentTarget == null) { currentTarget = enemies[0]; } } else { StopCoroutine("TargetEnemies"); started = false; } } }
// The respawn timer IEnumerator RespawnTimer(PlayerChampion playerChampion) { GameUIHandler.Instance.deathBar.SetActive(true); float timeLeft = 6; float reductionSpeed = 0.1f; // While the player is still dead, update the death countdown timer while (timeLeft > 0) { timeLeft -= reductionSpeed; int timeLeftInt = (int)Mathf.Ceil(timeLeft); if (timeLeftInt > 0) { GameUIHandler.Instance.deathBarText.text = "Respawning in " + timeLeftInt + " seconds"; if (timeLeftInt == 1) { GameUIHandler.Instance.deathBarText.text = "Respawning in " + timeLeftInt + " second"; } } yield return(new WaitForSeconds(reductionSpeed)); } // Once the death timer has ended, respawn the player on the network playerChampion.PhotonView.RPC("Heal", PhotonTargets.All, playerChampion.Champion.maxHealth); playerChampion.PhotonView.RPC("GiveMana", PhotonTargets.All, playerChampion.Champion.maxMana); Camera.main.GetComponent <UnityStandardAssets.ImageEffects.ColorCorrectionCurves>().saturation = 1; playerChampion.Respawn(); GameUIHandler.Instance.deathBar.SetActive(false); }
void Update() { if (photonView.isMine && !gameEnded) { if (!playerChampion.IsDead) { if (!playerChampion.IsStunned()) { if (target != null) { PlayerChampion targetChampion = target.GetComponent <PlayerChampion>(); Entity targetEntity = target.GetComponent <Entity>(); // Check to make sure the target is still alive if (targetChampion != null) { if (targetChampion.IsDead) { target = null; } } if (targetEntity != null) { if (targetEntity.GetIsDead()) { target = null; } } // Is the target stil alive? if (target == null) { playerMovement.StopMovement(); } else { if (target.GetComponent <PhotonView>() != photonView) { if (Vector3.Distance(target.transform.position, transform.position) < playerChampion.Champion.range) { if (Time.time >= (lastShotTime + cooldownTime)) { lastShotTime = Time.time; photonView.RPC("Shoot", PhotonTargets.All, 100f, PhotonNetwork.player.GetTeam(), playerChampion.Champion.attackDamage, target.transform.position, target.GetComponent <PhotonView>().viewID, photonView.viewID); navMeshAgent.destination = transform.position; } } else { navMeshAgent.destination = target.transform.position; navMeshAgent.isStopped = false; } } } } } } } }
void Start() { photonView = GetComponent <PhotonView>(); playerChampion = GetComponent <PlayerChampion>(); playerMovement = GetComponent <PlayerMovement>(); navMeshAgent = GetComponent <NavMeshAgent>(); GameHandler.onGameEnd += OnGameEnd; }
// Set up references and event listeners when the game begins. void Start() { photonView = GetComponent <PhotonView>(); playerChampion = GetComponent <PlayerChampion>(); playerAnimator = GetComponent <PlayerAnimator>(); playerMovement = GetComponent <PlayerMovement>(); abilityHandler = AbilityHandler.Instance; ability = abilityHandler.GetChampionAbility(playerChampion.Champion, abilityKey); GameUIHandler.Instance.abilityE.GetComponent <Button>().onClick.AddListener(delegate { AttemptAbility(true); }); }
/// <summary> /// Checks to see whether this entity is dead. /// </summary> /// <returns> /// True if the entity is dead; false if not. /// </returns> public bool GetIsDead() { PlayerChampion playerChampion = GetComponent <PlayerChampion>(); if (playerChampion) { return(playerChampion.IsDead); } return(IsDead); }
// Assign listeners and references to other scripts when the game starts. void Start() { GameUIHandler.Instance.abilityF.GetComponent <Button>().onClick.AddListener(AttemptAbility); abilityHandler = AbilityHandler.Instance; photonView = GetComponent <PhotonView>(); playerChampion = GetComponent <PlayerChampion>(); playerMovement = GetComponent <PlayerMovement>(); navMeshAgent = GetComponent <NavMeshAgent>(); ability = abilityHandler.GetChampionAbility(playerChampion.Champion, abilityType); }
// Subscribe to delegates and assign references when the game starts. void Start() { GameHandler.onGameEnd += OnGameEnd; trueRot = Quaternion.identity; photonView = GetComponent <PhotonView>(); navMeshAgent = GetComponent <NavMeshAgent>(); playerChampion = GetComponent <PlayerChampion>(); defaultAttack = GetComponent <DefaultAttack>(); playerAnimator = GetComponent <PlayerAnimator>(); champion = playerChampion.Champion; mapProperties = MapManager.Instance.GetMapProperties(); }
// Damages the player on collision void OnTriggerEnter(Collider other) { PlayerChampion playerChampion = other.GetComponent <PlayerChampion>(); if (playerChampion != null) { PhotonView photonView = playerChampion.GetComponent <PhotonView>(); if (photonView.isMine) { photonView.RPC("Damage", PhotonTargets.All, damage, null); } } }
// Start the heal coroutines if the player is local void Start() { photonView = GetComponent <PhotonView>(); // Only heal the local player if (photonView.isMine) { playerChampion = GetComponent <PlayerChampion>(); champion = playerChampion.Champion; StartCoroutine("RegenHealth"); StartCoroutine("RegenMana"); } }
public void SetMovementSpeed(float speed) { PlayerChampion champion = GetComponent <PlayerChampion>(); Minion minion = GetComponent <Minion>(); if (champion != null) { champion.Champion.movementSpeed = speed; } if (minion != null) { minion.speed = speed; } }
// Will stop the health regen if the player isn't on the team of this side void OnTriggerExit(Collider other) { PlayerChampion playerChampion = other.gameObject.GetComponent <PlayerChampion>(); if (playerChampion) { PhotonView photonView = other.gameObject.GetComponent <PhotonView>(); if (photonView.isMine && photonView.owner.GetTeam() == team) { playerChampion.Champion.healthRegen -= regenAmount; playerChampion.Champion.manaRegen -= regenAmount; } } }
/// <summary> /// Calculates the entity's movement speed. /// </summary> /// <returns> /// The movement speed of the entity; 0 as a fallback. /// </returns> public float GetMovementSpeed() { PlayerChampion champion = GetComponent <PlayerChampion>(); Minion minion = GetComponent <Minion>(); if (champion != null) { return(champion.Champion.movementSpeed); } if (minion != null) { return(minion.speed); } return(0); }
// Set up references and event listeners when the game begins. void Start() { abilityHandler = AbilityHandler.Instance; photonView = GetComponent <PhotonView>(); playerMovement = GetComponent <PlayerMovement>(); playerChampion = GetComponent <PlayerChampion>(); ability = abilityHandler.GetChampionAbility(playerChampion.Champion, abilityKey); StopChannel(); // Listeners GameHandler.onGameEnd += OnGameEnd; PlayerMovement.onPlayerMove += StopChannel; PlayerChampion.onPlayerDamaged += StopChannel; AbilityHandler.onAbilityActivated += OnAbilityActivated; GameUIHandler.Instance.abilityB.GetComponent <Button>().onClick.AddListener(AttemptRecall); }
void EntityDamage(float amount, int attackerId) { // Update the health bar UI and kill the entity if necessary if (useEntityBehaviour) { health = Mathf.Max(health - amount, 0f); if (healthBarFill != null) { healthBarFill.fillAmount = health / maxHealth; } if (health <= 0f) { IsDead = true; // Give XP to all enemy champions who are not in the area if (PhotonNetwork.isMasterClient) { Collider[] hitColliders = Physics.OverlapSphere(transform.position, XPRadius); for (int i = 0; i < hitColliders.Length; i++) { PlayerChampion playerChampion = hitColliders[i].GetComponent <PlayerChampion>(); if (playerChampion != null) { if (playerChampion.PhotonView.owner.GetTeam() != team) { ChampionXP championXP = playerChampion.GetComponent <ChampionXP>(); championXP.photonView.RPC("GiveXP", PhotonTargets.All, XPOnDeath, false); } } } } // Tell other scripts we're dead if (onEntityDeath != null) { onEntityDeath(attackerId); } // Destroy the bullet if (PhotonNetwork.isMasterClient) { PhotonNetwork.Destroy(gameObject); } } } }
//initalizer for the pannel public void Init(PlayerChampion championArg) { //if there is no champion to pass in... hide this panel if (championArg == null) { HidePanel(); return; } attachedChampion = championArg; panelCollider = gameObject.GetComponent <BoxCollider2D>(); nameText = gameObject.transform.GetChild(0).GetComponent <TextMeshPro>(); HPText = gameObject.transform.GetChild(1).GetComponent <TextMeshPro>(); MPText = gameObject.transform.GetChild(2).GetComponent <TextMeshPro>(); panelImage = gameObject.transform.GetChild(3).GetComponent <Image>(); UpdateInfo(); }
// Set up event listeners and references to other scripts void Start() { Entity.onEntityDeath += OnEntityDeath; photonView = GetComponent <PhotonView>(); champion = GetComponent <PlayerChampion>(); }
// Called when the bullet collides with an object void OnCollide(GameObject collision) { PlayerChampion playerChampion = collision.GetComponent <PlayerChampion>(); Entity entity = collision.GetComponent <Entity>(); Turret turret = collision.GetComponent <Turret>(); Inhibitor inhibitor = collision.GetComponent <Inhibitor>(); Nexus nexus = collision.GetComponent <Nexus>(); // Collision with player champion if (playerChampion != null) { PhotonView photonView = playerChampion.GetComponent <PhotonView>(); if (PhotonNetwork.isMasterClient && photonView.owner.GetTeam() != team) { photonView.RPC("Damage", PhotonTargets.All, damage, shooterId); } } // Collision with turret else if (turret != null) { PhotonView photonView = turret.GetComponent <PhotonView>(); Targetable targetable = turret.GetComponent <Targetable>(); if (PhotonNetwork.isMasterClient && targetable.allowTargetingBy == team) { photonView.RPC("Damage", PhotonTargets.All, damage, shooterId); } } // Collision with inhibitor else if (inhibitor != null) { PhotonView photonView = inhibitor.GetComponent <PhotonView>(); Targetable targetable = inhibitor.GetComponent <Targetable>(); if (PhotonNetwork.isMasterClient && targetable.allowTargetingBy == team) { photonView.RPC("Damage", PhotonTargets.All, damage, shooterId); } } // Collision with nexus else if (nexus != null) { PhotonView photonView = nexus.GetComponent <PhotonView>(); Targetable targetable = nexus.GetComponent <Targetable>(); if (PhotonNetwork.isMasterClient && targetable.allowTargetingBy == team) { photonView.RPC("Damage", PhotonTargets.All, damage, shooterId); } } // Collision with entity (ie. minion) else if (entity != null) { PhotonView photonView = entity.GetComponent <PhotonView>(); if (PhotonNetwork.isMasterClient && entity.team != team) { photonView.RPC("EntityDamage", PhotonTargets.All, damage, shooterId); } } // Destroy the bullet regardless of the above Destroy(gameObject); }
// Assign variables when the game starts. void Start() { photonView = GetComponent <PhotonView>(); chatHandler = ChatHandler.Instance; playerChampion = GetComponent <PlayerChampion>(); }
/// <summary> /// Saturates the game screen and begins the death timer. /// </summary> /// <param name="playerChampion">The champion that died</param> /// <remarks> /// Called when the local Champion dies. /// </remarks> public void OnDeath(PlayerChampion playerChampion) { Camera.main.GetComponent <UnityStandardAssets.ImageEffects.ColorCorrectionCurves>().saturation = 0; StartCoroutine(RespawnTimer(playerChampion)); }