/// <summary> /// Removes Agent from tracked <see cref="m_CurrentAgentsInside"/> /// </summary> void OnAgentRemoved(DamageableBehaviour targetable) { targetable.removed -= OnAgentRemoved; AgentYfb attackingAgent = targetable as AgentYfb; RemoveTarget(attackingAgent); }
/// <summary> /// Fired by the agents died event or when the current target moves out of range, /// Fires the lostTarget event. /// </summary> void OnTargetRemoved(DamageableBehaviour target) { target.removed -= OnTargetRemoved; if (m_CurrrentTargetable != null && target.configuration == m_CurrrentTargetable.configuration) { if (lostTarget != null) { lostTarget(); } m_HadTarget = false; m_TargetsInRange.Remove(m_CurrrentTargetable); m_CurrrentTargetable = null; m_XRotationCorrectionTime = 0.0f; } else //wasnt the current target, find and remove from targets list { for (int i = 0; i < m_TargetsInRange.Count; i++) { if (m_TargetsInRange[i].configuration == target.configuration) { m_TargetsInRange.RemoveAt(i); break; } } } }
void OnAgentRemoved(DamageableBehaviour targetable) { targetable.removed -= OnAgentRemoved; Enemy attackingAgent = targetable as Enemy; RemoveTarget(attackingAgent); }
/// <summary> /// If the tower is destroyed while other agents attack it, ensure it becomes null /// </summary> /// <param name="tower">The tower that has been destroyed</param> protected virtual void OnTargetTowerDestroyed(DamageableBehaviour tower) { if (m_TargetTower == tower) { m_TargetTower.removed -= OnTargetTowerDestroyed; m_TargetTower = null; } }
// Start is called before the first frame update void Start() { damageableBehaviour = GetComponent <DamageableBehaviour>(); bossAnimator = GetComponent <BossAnimate>(); //damageableBehaviour.enabled = false; barrier.SetActive(false); }
/// <summary> /// Caches attached DamageableBehaviour /// </summary> protected virtual void OnEnable() { if (m_DamageableBehaviour == null) { m_DamageableBehaviour = GetComponent <DamageableBehaviour>(); } m_DamageableBehaviour.configuration.died += OnDeath; }
private void OnRemoved(DamageableBehaviour damageableBehaviour) { LevelManager.instance.UpdateMoney((int)damageableBehaviour.configuration.maxHealth / 10); WaveManager.instance.DecrementEnemyNum(); LevelManager.instance.DetectAllEnemiesCleaned(); //Poolable.TryPool(gameObject); // a bug here so I have to change it to destroy Destroy(this.gameObject); }
//public void Punch(bool isLeftHand) public void Punch(int _left) { Transform hand = _left == 1 ? leftHand : rightHand; //Transform hand = isLeftHand == true ? leftHand : rightHand; DebugExtension.DebugWireSphere(hand.position, punchRadius, punchRadius); RaycastHit[] hits = Physics.SphereCastAll(hand.position, punchRadius, hand.forward, 0f); //Collider[] hitColliders = Physics.OverlapSphere(hand.position, punchRadius); List <PlayerController> playersHit = new List <PlayerController>(); foreach (var hit in hits) { RootFix playerRoot = hit.transform.GetComponent <RootFix>(); if (playerRoot != null) { PlayerController player = playerRoot.playerRoot.GetComponentInChildren <PlayerController>(); DamageableBehaviour damageable = playerRoot.playerRoot.GetComponent <DamageableBehaviour>(); var myAlignment = myDamageableBehaviour.configuration.AlignmentProvider; if (damageable != null && myAlignment != null) { float knockback = 1f + (damageable.configuration.CurrentDamage / 100f); //EDIT var hitInfo = new HitInfo { damageChangeInfo = new DamageChangeInfo(), damagePoint = hit.point }; bool canKnockBack = (myAlignment != damageable.configuration.AlignmentProvider); if (!playersHit.Contains(player)) { if (canKnockBack) { damageable.configuration.AddDamage(damagePerHit, hitInfo); playersHit.Add(player); } } MuscleCollisionBroadcaster broadcaster = hit.transform.GetComponent <MuscleCollisionBroadcaster>(); if (broadcaster != null && canKnockBack) { Vector3 heading = hit.point - hand.position; Vector3 direction = hand.transform.forward; broadcaster.Hit(5, direction * (baseKnockback * (knockback * (damageable.configuration.CurrentDamage / 100f))), hit.point); } } } } }
/// <summary> /// Looks for the damageableBehaviour if it is not already assigned /// It may be assigned in editor or from a previous LazyLoad() call /// </summary> protected void LazyLoad() { if (damageableBehaviour != null) { return; } damageableBehaviour = GetComponent <DamageableBehaviour>(); }
/// <summary> /// Raises on every unit die. /// </summary> /// <param name="obj">Object.</param> /// <param name="param">Parameter.</param> private void UnitDie(DamageableBehaviour damageableBehaviour) { // If this is object from my spawn buffer if (defendersList.ContainsKey(damageableBehaviour.gameObject) == true) { // Remove it from buffer defendersList.Remove(damageableBehaviour.gameObject); } }
/// <summary> /// This will null some stuff /// </summary> protected void ResetUnit(DamageableBehaviour removed) { m_Unit.removed -= ResetUnit; aSBoostsDictionary = null; resiBoostsDictionary = null; mSBoostsDictionary = null; effectFxList = null; }
/// <summary> /// Awake this instance. /// </summary> public virtual void Initialize() { if (m_DamageableBehaviour == null) { m_DamageableBehaviour = GetComponent <DamageableBehaviour>(); } m_DamageableBehaviour.configuration.healthChanged += OnHealthChanged; originHealthBarWidth = healthBar.localScale.x; }
public void Subscribe(DamageableBehaviour player) { player.configuration.LostLife += (damageInfo) => DeathExplosionParticle(damageInfo, player.Position); //player.configuration.Damaged += HitParticle; player.configuration.Damaged += HitParticle; PlayerController controller = player.transform.GetComponentInChildren <PlayerController>(); controller.JumpEvent += JumpParticle; controller.LandEvent += LandParticle; }
public virtual void DecrementNumberOfEnemies(DamageableBehaviour character) { for (int i = 0; i < participants.Count; i++) { if (participants[i] == character) { participants.Remove(participants[i]); } } if (participants.Count <= 0 && battleScene.battleSystem.GetCurrentState() == LevelState.AllEnemiesSpawned) { XEventBus.Instance.Post(EventId.GameResult, new XEventArgs(LevelState.Win)); } }
/// <summary> /// Fired then the enemy reached its final node, /// Starts the attack timer /// </summary> /// <param name="homeBase"></param> void OnDestinationReached(Node homeBase) { m_FinalDestinationDamageableBehaviour = homeBase.GetComponent <DamageableBehaviour>(); // start timer if (m_HomeBaseAttackTimer == null) { m_HomeBaseAttackTimer = new Timer(homeBaseAttackChargeTime, AttackHomeBase); } else { m_HomeBaseAttackTimer.Reset(); } m_IsChargingHomeBaseAttack = true; }
public void Initialize(int playerID, Vector3 position, Quaternion rotation) { //spawned[playerID] = true; var playerObject = Instantiate(playerPrefab, position, rotation, pool.parent); playerObject.name = (playerObject.name + playerID); PlayerController controller = playerObject.GetComponentInChildren <PlayerController>(); //if (controller == null) //Debug.LogError("ERROR: Couldn't find PlayerController"); DamageableBehaviour initDamageable = playerObject.GetComponentInChildren <DamageableBehaviour>(); //if (initDamageable == null) //Debug.LogError("ERROR: Couldn't find DamageableBehaviour"); controller.myID = playerID; PoolablePlayer PlayerInit = new PoolablePlayer { movementController = controller, damageableBehaviour = initDamageable }; if (PlayerInit.DamageableConfig != null) { PlayerInit.DamageableConfig.playerID = playerID; PlayerInit.DamageableConfig.AlignmentProvider = teams[playerID].alignment; var meshRenderer = PlayerInit.DamageableConfig.materialObject.GetComponentInChildren <SkinnedMeshRenderer>(); if (meshRenderer != null) { meshRenderer.material = teams[playerID].material; } PlayerInit.DamageableConfig.IsAlive = true; } else { //Debug.LogError("No DamageableBehaviour component on player object"); } PlayerJoined?.Invoke(playerID); players.Add(PlayerInit); }
/// <summary> /// Fired when a home base is destroyed /// </summary> protected virtual void OnPlayerStarcraftDestroyed(DamageableBehaviour starcraft) { // Decrement the number of home bases numberOfLivesLeft--; // Call the destroyed event if (playerStarcraftDestroyed != null) { playerStarcraftDestroyed(); } // If there are no home bases left and the level is not over then set the level to lost if ((numberOfLivesLeft == 0) && !isGameOver) { ChangeLevelState(LevelState.Lose); } }
/// <summary> /// Fired when a home base is destroyed /// </summary> protected virtual void OnHomeBaseDestroyed(DamageableBehaviour homeBase) { // Decrement the number of home bases numberOfHomeBasesLeft--; // Call the destroyed event if (homeBaseDestroyed != null) { homeBaseDestroyed(); } // If there are no home bases left and the wave is not over then set the wave to lost if ((numberOfHomeBasesLeft == 0) && !isGameOver) { ChangeWaveState(WaveState.Lose); } }
/// <summary> /// Removes all buffs on the ally, /// </summary> /// <param name="ally">the allie who is target by this methode</param> private void RemoveAllBuffs(DamageableBehaviour ally) { Unit m_Unit = ally.GetComponent <Unit>(); if (m_Unit == null) { return; } m_Unit.removed -= RemoveAllBuffs; if (healer) { if (alliesInRange.Count == 0) { StopAllCoroutines(); } m_Unit.RemoveFx(healFxPrefab); } if (isMouvmentSpeedBooster) { SetMsBuff(m_Unit, BuffStat.DeBuff); if (!m_Unit.GetMSBoostsDictionary().ContainsKey("SupportTowerBuffMS")) { m_Unit.RemoveFx(movementSpeedFxPrefab); } } if (isResistanceBooster) { SetResiBuff(m_Unit, BuffStat.DeBuff); if (!m_Unit.GetResiBoostsDictionary().ContainsKey("SupportTowerBuffResi")) { m_Unit.RemoveFx(resistanceFxPrefab); } } if (isAttackSpeedBooster) { SetASBuff(m_Unit, BuffStat.DeBuff); if (!m_Unit.GetASBoostsDictionary().ContainsKey("SupportTowerBuffAS")) { m_Unit.RemoveFx(attackSpeedFxPrefab); } } }
public void FireWeapon() { //lineRenderer.enabled = true; //lineRenderer.SetPosition(0, FirePoint.transform.position); ray.origin = FirePoint.transform.position; ray.direction = FirePoint.transform.forward; StartCoroutine(ShotEffect()); if (Physics.Raycast(ray, out rayHit, Range, HitMask)) { Debug.Log("RayHit " + rayHit.collider.name); DamageableBehaviour damageHandler = rayHit.collider.GetComponent <DamageableBehaviour>(); rayHit.collider.GetComponentInParent <DamageableBehaviour>().TakeDamage(Damage); //lineRenderer.SetPosition(1, rayHit.point); } else { //lineRenderer.SetPosition(1, ray.origin + ray.direction * Range); } }
private void Start() { if (root == null) { root = transform.root; } myDamageableBehaviour = GetComponentInParent <DamageableBehaviour>(); FindObjectOfType <UIManager>().Join(myDamageableBehaviour); //Debug.Log(string.Format("Component In Parent = {0}", myDamageableBehaviour.name)); _controller = GetComponent <CharacterController>(); _animator = GetComponent <Animator>(); FindObjectOfType <PauseMenu>().Menu += Menu; FindObjectOfType <EffectsManager>().Subscribe(myDamageableBehaviour); if (head != null) { _head = head.GetComponent <MuscleCollisionBroadcaster>(); _jumpNumber = 1; } }
/// <summary> /// Agent has died, remove affect /// </summary> void OnRemoved(DamageableBehaviour targetable) { m_Agent.removed -= OnRemoved; ResetAgent(); }
/// <summary> /// Closes the Tower UI on death of tower /// </summary> protected void OnTowerDied(DamageableBehaviour targetable) { towerUI.enabled = false; radiusVisualizerController.HideRadiusVisualizers(); DeselectTower(); }
void OnTargetDied(DamageableBehaviour targetable) { targetable.removed -= OnTargetDied; m_HomingTarget = null; }
protected void OnTargetDied(DamageableBehaviour targetable) { DeselectTarget(); }
// DamageableBehaviour records the health info the enemy and several events when it hurts or dies. private void OnDied(DamageableBehaviour damageableBehaviour) { died -= OnDied; OnRemoved(damageableBehaviour); }
public void SwingHit() { DebugExtension.DebugWireSphere(swingLocation.position, swingRadius, 0.25f); //Delete this RaycastHit[] _hits = Physics.SphereCastAll(swingLocation.position, swingRadius, transform.forward, 0f); PickUp weapon = _item.GetComponent <PickUp>(); List <PlayerController> playersHit = new List <PlayerController>(); foreach (RaycastHit hit in _hits) { RootFix playerRoot = hit.transform.GetComponent <RootFix>(); if (playerRoot != null) { PlayerController player = playerRoot.playerRoot.GetComponentInChildren <PlayerController>(); DamageableBehaviour damageable = playerRoot.playerRoot.GetComponent <DamageableBehaviour>(); var myAlignment = myDamageableBehaviour.configuration.AlignmentProvider; if (damageable != null && myAlignment != null) { float knockback = 1f + (damageable.configuration.CurrentDamage / 100f); //EDIT var hitInfo = new HitInfo { damageChangeInfo = new DamageChangeInfo(), damagePoint = hit.point }; bool canKnockBack = (myAlignment != damageable.configuration.AlignmentProvider); //print("Obj: " + player.name + ", Count: " + playersHit.Count + ", Contains: " + playersHit.Contains(player)); if (!playersHit.Contains(player)) { if (canKnockBack) { damageable.configuration.AddDamage((weapon != null ? weapon.damage : damagePerHit), hitInfo); playersHit.Add(player); } } MuscleCollisionBroadcaster broadcaster = hit.transform.GetComponent <MuscleCollisionBroadcaster>(); if (broadcaster != null && canKnockBack) { broadcaster.Hit(5, rightHand.transform.forward * (baseKnockback * (knockback * (damageable.configuration.CurrentDamage / 100f))), hit.point); } } } /* * if (_hit.transform.root != transform.root) * { * Debug.Log("RUGHAARINMIJNRIETJE TWEE"); * * //PlayerController _player = null; * DamageableBehaviour _damageable = null; * IAlignmentProvider myAlignment = null; * * if (_hit.transform.root.tag == "Player") * { * //_player = _hit.transform.root.GetComponentInChildren<PlayerController>(); * _damageable = _hit.transform.root.GetComponentInChildren<DamageableBehaviour>(); * } * * float knockback = 1f; * if (_damageable != null) * { * myAlignment = myDamageableBehaviour.configuration.AlignmentProvider; * * int weaponDamagePerHit = ((_item != null) ? _item.GetComponent<PickUp>().damage : damagePerHit); * * _damageable.configuration.CheckDamage(weaponDamagePerHit, myAlignment, swingLocation.position); * } * * MuscleCollisionBroadcaster broadcaster = _hit.transform.GetComponent<MuscleCollisionBroadcaster>(); * * if (broadcaster != null && _damageable.CanKnockback(myAlignment)) * { * Vector3 _heading = _hit.point - swingLocation.position; * float _distance = _heading.magnitude; * Vector3 _direction = _heading / _distance; * * broadcaster.Hit(5, _direction * (baseKnockback * knockback), _hit.point); //Edit this * } * } */ } }
public void Join(DamageableBehaviour player) { //print(player.configuration.playerID); players.Add(player); playerIcons[player.configuration.playerID].SetBool("PlayerJoined", true); }
private void OnTargetDied(DamageableBehaviour targetable) { targetable.removed -= OnTargetDied; target = null; }
/// <summary> /// Stops the attack on the home base /// </summary> void OnDied(DamageableBehaviour damageableBehaviour) { m_IsChargingHomeBaseAttack = false; }