private void AbilityEnd(DragonNPCAbility ability) { if (ability == DragonNPCAbility.TAIL_ATTACK) { disableMultipleCollisition[DragonNPCAbility.TAIL_ATTACK].Clear(); EnableDisableTailColliders(false); } }
void Combat() { //nije primio damage x vremena -> return if (Time.time - lastDamageTime > combatNoDamageTime) { SwitchState(State.RETURN); return; } //izašao iz leaveCombatMaxRange -> return if (Vector3.Distance(patrolPoint, transform.position) >= leaveCombatMaxRange) { SwitchState(State.RETURN); return; } //damage check if (Time.time - lastDamageCheck > damageCheckTime) { ChooseNextEnemy(); lastDamageCheck = Time.time; } if (enemy == null) { SwitchState(State.RETURN); return; } if (enemy && enemy.data.dead) { ChooseNextEnemy(); if (enemy == null) { SwitchState(State.RETURN); return; } } if (!parabolaController.Animation) { //agent.enabled = true; jumping = false; } if (!usingAbility) { if (!onCooldown) { //da ne skače uvijek kad si u njemu nego da napravi stomp //možda bolje da napravi neki novi ability int random = Random.Range(1, 7); if (Physics.CheckSphere(transform.position, 0.5f)) { random = Random.Range(1, 5); if (random == 2) { animationRig.weight = 0; ability = DragonNPCAbility.JUMP; usingAbility = true; Jump(); ServerSend.NPCDoAbility(id, (int)DragonNPCAbility.JUMP, (int)GameObjectType.dragon, transform.position, NetworkManager.visibilityRadius); } else { random = 3; } } if (random == 1 && Vector3.Distance(transform.position, enemy.transform.position) >= fireRange) { animationRig.weight = 0; ability = DragonNPCAbility.FIRE; usingAbility = true; anim.anim.SetTrigger("FireAttack"); ServerSend.NPCDoAbility(id, (int)DragonNPCAbility.FIRE, (int)GameObjectType.dragon, transform.position, NetworkManager.visibilityRadius); } //ovjde provjeriti attack range za bite else if (random == 2 && Vector3.Distance(transform.position, enemy.transform.position) <= biteRange) { biteCollider.enabled = true; animationRig.weight = 1; ability = DragonNPCAbility.BITE; usingAbility = true; ServerSend.NPCDoAbility(id, (int)DragonNPCAbility.BITE, (int)GameObjectType.dragon, transform.position, NetworkManager.visibilityRadius); } else if (random == 3 && Vector3.Distance(transform.position, enemy.transform.position) >= stompRange) { animationRig.weight = 0; ability = DragonNPCAbility.STOMP; usingAbility = true; anim.anim.SetTrigger("Stomp"); ServerSend.NPCDoAbility(id, (int)DragonNPCAbility.STOMP, (int)GameObjectType.dragon, transform.position, NetworkManager.visibilityRadius); } else if (random == 4 && Vector3.Distance(transform.position, enemy.transform.position) >= fireRange) { animationRig.weight = 0; ability = DragonNPCAbility.FLY_FIRE; usingAbility = true; anim.anim.SetTrigger("FlyFire"); ServerSend.NPCDoAbility(id, (int)DragonNPCAbility.FLY_FIRE, (int)GameObjectType.dragon, transform.position, NetworkManager.visibilityRadius); } else if (random == 5 && Vector3.Distance(transform.position, enemy.transform.position) >= tailAttackRange) { EnableDisableTailColliders(true); animationRig.weight = 0; ability = DragonNPCAbility.TAIL_ATTACK; usingAbility = true; anim.anim.SetTrigger("TailAttack"); ServerSend.NPCDoAbility(id, (int)DragonNPCAbility.TAIL_ATTACK, (int)GameObjectType.dragon, transform.position, NetworkManager.visibilityRadius); } else if (random == 6 && health < maxHealth * 0.2f) { animationRig.weight = 0; ability = DragonNPCAbility.JUMP; usingAbility = true; Jump(); ServerSend.NPCDoAbility(id, (int)DragonNPCAbility.JUMP, (int)GameObjectType.dragon, transform.position, NetworkManager.visibilityRadius); } } } //face target if (usingAbility && (ability == DragonNPCAbility.FIRE || ability == DragonNPCAbility.BITE || ability == DragonNPCAbility.FLY_FIRE || ability == DragonNPCAbility.TAIL_ATTACK)) { FaceTarget(enemy.transform.position); } if (Vector3.Distance(enemy.transform.position, transform.position) > combatRadiusMax) { state = State.CHASE; SwitchState(state); } //chase target, stop when reached combatRadiusMin /*if (Vector3.Distance(enemy.position, transform.position) > combatRadiusMax) * { * anim.anim.SetBool("Run", true); * ChaseTarget(combatRadiusMax); * } * else if (Vector3.Distance(enemy.position, transform.position) <= combatRadiusMin) * { * Debug.Log(Vector3.Distance(enemy.position, transform.position)); * StopAgent(); * }*/ }
public Ability(DragonNPC npc, DragonNPCAbility ability, float multiplier = 0) { this.npc = npc; this.ability = ability; this.multiplier = multiplier; }