void OnTriggerEnter2D(Collider2D aCollider) { if (!myIsAlive) { return; } if (aCollider.gameObject.name == "shotgun-pickup") { myIsUsingMachineGun = false; Destroy(aCollider.gameObject); return; } if (aCollider.gameObject.name == "Boss-Attack") { BossAttack attack = aCollider.gameObject.GetComponent <BossAttack>(); if (attack.myIsActive) { myIsAlive = false; EventManager.TriggerEvent("PlayerDied"); myAudioSource.PlayOneShot(myPlayerDeath); } return; } }
private Vector3 originalPosition; //originalPosition of boss before flying // Start is called before the first frame update void Start() { bossAttack = GetComponent <BossAttack>(); isNotOffStage = true; tempPosition = transform.position; bossAttack2 = GetComponent <BossAttack2>(); }
private void GetAvailebleAttacks() { AvailebleAttacks.Clear(); BossAttack highestPriorityAttack = null; if (RightHand == null && LeftHand == null) { triggers.Remove(triggers.Find(t => t.bossAttack.name == "Hand swing")); triggers.Remove(triggers.Find(t => t.bossAttack.name == "Punch")); } foreach (BossTrigger trigger in triggers) { if (trigger.PlayerInTrigger) { if (highestPriorityAttack == null) { highestPriorityAttack = trigger.bossAttack; } if (trigger.bossAttack.Priority > highestPriorityAttack.Priority) { AvailebleAttacks.Add(trigger.bossAttack); } else if (trigger.bossAttack.Priority == highestPriorityAttack.Priority) { AvailebleAttacks.Add(trigger.bossAttack); } } } }
private void hitEnemy() { BossAttack ba = Enemy.GetComponent <BossAttack> (); ba.increaseEnergy(-hitDamage); Debug.Log(ba.Energy); }
private bool ChooseAttack() { _currentAttack = null; float probabilitySum = _currentAttacksInRange.Aggregate(0f, (sum, next) => sum + next.GetBossAttackData().AttackProbability); float diceThrow = Random.Range(1f, probabilitySum); float temp = 0f; foreach(BossAttack alienAttack in _currentAttacksInRange.OrderByDescending(attack => attack.GetBossAttackData().AttackProbability)) { float attackProbability = alienAttack.GetBossAttackData().AttackProbability; if(!(diceThrow >= temp && diceThrow <= temp + attackProbability)) { temp += attackProbability; continue; } _currentAttack = alienAttack; break; } return _currentAttack != null; }
// public Slider healthBar; // Start is called before the first frame update void Start() { bossAttack = GameObject.Find("Boss").GetComponent <BossAttack>(); bossAttack.canDoCooldown = true; bossAttack2 = GetComponent <BossAttack2>(); playerMovement = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>(); }
// Attack void AttackRandom() { BossAttack attack = (BossAttack)Random.Range(0, 3); switch (attack) { case BossAttack.Fireball: AttackFireball(); break; case BossAttack.Meteor: AttackMeteor(); break; case BossAttack.Shield: OpenShield(); AttackRandom(); break; case BossAttack.Slow: AttackSlow(); break; default: break; } }
void StompAttackStartupChecks() { //Search for a stomp attack in the list of attacks int stompAtkCount = 0; foreach (BossAttack attack in attacks) { if (attack.GetComponent <StompAttack>() != null) { stompAttack = attack; stompAtkCount++; } } if (stompAtkCount > 1) { Debug.LogWarning("Found more than 1 Stomp Attacks for boss: " + name + ". Can only use the one with the largest index in the attacks array"); } //Get the stomp attack trigger distance from that script into this one if (stompAttack != null) { stompAtkDistance = stompAttack.GetComponent <StompAttack>().stompDistance; } else { Debug.LogWarning("No stomp attack found, boss " + gameObject.name + " will not use it."); } }
public void RegisterDamage() { BossAttack bossAttack = GameObject.FindWithTag("Boss").GetComponent <BossAttack>(); playerHealth = playerHealth - bossAttack.damage; //TODO Set up damage parameters print(playerHealth); }
private async Task OnBossAttack(BossAttack x, CancellationToken ct) { System.Diagnostics.Debug.WriteLine("OnBossAttack " + Thread.CurrentThread.ManagedThreadId); System.Diagnostics.Debug.WriteLine($"Boss attacks"); await playArea.ShowAttack(x); }
public void Chooses_Attacks_Randomly() { SetupTest(); BossPhase phase = CreatePhase("test", 0, 0, 10); BossAttack attack = engine.GetNextAttack(phase.Attacks); Assert.True(phase.Attacks.Contains(attack)); }
public void Chooses_Attacks_Single() { SetupTest(); BossPhase phase = CreatePhase("test", 0, 0, 1); BossAttack attack = engine.GetNextAttack(phase.Attacks); Assert.AreEqual(attack, phase.Attacks[0]); }
private void Start() { bossAttack = GetComponent <BossAttack>(); bossAnimations = GetComponent <BossAnimations>(); audioSystem = GameObject.FindWithTag("AudioSystem").GetComponent <AudioSystem>(); scoreSystem = GameObject.FindWithTag("ScoreSystem").GetComponent <ScoreSystem>(); }
private void Awake() { canvas = GameObject.FindGameObjectWithTag("GameUICanvas").GetComponent <RectTransform>(); bossAttack = GetComponent <BossAttack>(); enemyHealthUITrans = enemyHealthUIObj.GetComponent <RectTransform>(); enemyHealthUI = enemyHealthUIObj.GetComponent <Slider>(); enemyAnimCtrl = GetComponent <EnemyAnimationController>(); }
public void Chooses_Attacks_No_Duplicates() { SetupTest(); BossPhase phase = CreatePhase("test", 0, 0, 2); BossAttack attack1 = engine.GetNextAttack(phase.Attacks); BossAttack attack2 = engine.GetNextAttack(phase.Attacks, attack1); Assert.AreNotEqual(attack1.Name, attack2.Name); }
public void SetData(DataAttack data) { this.data = data; foreach (DataAttackNext dan in data.nextAttacks) { nextAttacks.Add(new BossAttackNext(boss, dan, mgLevel)); } elseAttack = boss.GetAttack(data.elseNextAttack); }
bool Equals(BossAttack other) { return(this.name == other.name && this.angle == other.angle && this.closeRadius == other.closeRadius && this.farRadius == other.farRadius && this.damage == other.damage && this.frequency == other.frequency); }
bool CheckCurrentAttack(BossAttack attack, int attackID) { if (attack.currentCooldown <= 0f && distanceTarget < attack.maxAttackRange) { LaunchAttack(attackID); return(true); } return(false); }
public async Task ShowAttack(BossAttack attack) { bossAttackPanel.DataContext = attack; bossAttackPanel.Visibility = Visibility.Visible; await _bossAttackAnimation.PlayAsync(); bossAttackPanel.Visibility = Visibility.Collapsed; }
// Use this for initialization void Start() { bossAttack = GameObject.Find("DragonBoss").GetComponent <BossAttack>(); Time.timeScale = 1; BossFly = false; TimeCount = 30.0f; Timer = this.GetComponent <Text>(); Timer.color = Color.green; }
// Use this for initialization void Start() { navScript = GetComponent<BossNavigationScript>(); attackScript = GetComponent<BossAttack>(); attackScript.Damage = damage; cooldown = attackSpeed; }
public IEnumerator Attack(int phase) { if (attacks.ContainsKey(phase)) { BossAttack attack = attacks[phase][Random.Range(0, attacks[phase].Count)]; yield return(StartCoroutine(attack.Attack())); } else { Debug.unityLogger.Log("Boss cannot attack because are no attacks in this phase."); } }
void Attack() { if (currentAttack != null) { currentAttack.attackComplete = false; } int attackIndex = Random.Range(0, attacks.Length); currentAttack = attacks[attackIndex]; attacks[attackIndex].DoAttack(); }
void OnTriggerEnter2D(Collider2D otherCollider) { BossAttack boss = otherCollider.gameObject.GetComponent <BossAttack>(); if (boss != null) { // 判断子弹归属,避免误伤 if (boss.isEnemy == 1) { boss.Hp -= 5; } } }
public IEnumerator StartBasicAttack(BossAttack ba) { StartCoroutine(ba.StartCooldown()); StartCoroutine(AttackCooldown(ba.delay)); yield return(new WaitForSeconds(ba.delay)); Collider2D pc = GetPlayerColliderInCollider(ba.collider); if (pc != null) { pc.SendMessage("applyDamage", 3.0f); } }
private void Start() { // get the components on the object we need ( should not be null due to require component so no need to check ) anim = GetComponent <Animator>(); playerHealth = target.GetComponent <PlayerHealth>(); bossHealth = GetComponent <BossHealth>(); bossAttack = GetComponentInChildren <BossAttack>(); agent = GetComponentInChildren <UnityEngine.AI.NavMeshAgent>(); character = GetComponent <ThirdPersonCharacter>(); agent.updateRotation = true; agent.updatePosition = true; }
private void AttacksVerification() { TypeStateCharacter typeState = TypeStateCharacter.Attack; BossAttack bossAttack = null; //if (isRandomAttack) //{ // if (listAttacks.Count > 1) // { // float rand = Random.Range(0f, 1f); // Debug.Log("Ramdom: " + rand); // //TypeStateCharacter typeState = VerifyAttackState(rand); // //EnterState(typeState); // bossAttack = GetAttackBoss(TypeSortBossAttackt.RandomPercentMin, rand); // if (bossAttack != null && bossAttack.isSpecialAttack && !bossAttack.IsCooldownActive) // { // typeState = AttackToState(bossAttack.type); // actualBossAttackSpecial = bossAttack; // } // EnterState(typeState); // } // else if (listAttacks.Count == 1) // { // typeState = AttackToState(listAttacks[0].type); // EnterState(typeState); // } // else // EnterState(TypeStateCharacter.Attack); //} //else //{ float hpPercent = EnemyStatus.HPPercent; //TypeStateCharacter typeState = VerifyAttackState(hpPercent); typeState = TypeStateCharacter.Attack; bossAttack = GetAttackBoss(TypeSortBossAttackt.HpPercent, hpPercent); if (bossAttack.isSpecialAttack && !bossAttack.IsCooldownActive) { typeState = AttackToState(bossAttack.type); actualBossAttackSpecial = bossAttack; } EnterState(typeState); //} }
// Start is called before the first frame update void Start() { selfTr = this.gameObject.GetComponent <Transform>(); playerTr = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>(); nvAgent = this.gameObject.GetComponent <NavMeshAgent>(); animator = this.gameObject.GetComponent <Animator>(); soundController = GameObject.FindGameObjectWithTag("SoundController").GetComponent <SoundController>(); audioSource = this.gameObject.GetComponent <AudioSource>(); bossAttack = this.gameObject.GetComponent <BossAttack>(); nvAgent.destination = playerTr.position; StartCoroutine(this.CheckState()); StartCoroutine(this.CheckStateForAction()); }
void Awake() { rigBody = GetComponent <Rigidbody2D>(); waypoints = new LinkedList <Transform>(waypointsArray); destination = waypoints.First; isAggressive = false; anim = GetComponent <Animator>(); player = GameObject.FindGameObjectWithTag("Player"); audioSource = GetComponent <AudioSource>(); enemyHealth = GetComponent <EnemyHealth>(); bossAttack = GetComponent <BossAttack>(); enemyHealth.Death += OnDeath; groundCheck = transform.Find("GroundCheck").transform; }
public void setAttack(int attackNumber) { CancelInvoke(); BossAttack newAttack = attackDict[attackNumber]; // If the new attack is slow, and this is not the first attack we are doing, // save the attack as a reference to the previous attack if (newAttack.frequency > Parameters.SLOW_ATTACK_LIMIT && this.currentAttack != null) { this.previousAttack = this.currentAttack; this.previousAttackNumber = this.currentAttackNumber; } // Set the current attack to be the new attack this.currentAttack = newAttack; this.currentAttackNumber = attackNumber; // Set fill and mask for the attack area if (radialFillControl != null) { radialFillControl.SetMirroredFill((int)this.currentAttack.angle); } if (attackMaskControl != null) { attackMaskControl.SetSize(this.currentAttack.closeRadius, this.currentAttack.farRadius); } GameObject currentAttackButton = GameObject.Find("Passive " + attackNumber); if (currentAttackButton != null) { this.currentCooldownBehaviour = currentAttackButton.GetComponentInChildren <CooldownBehaviour> (); if (this.currentCooldownBehaviour != null) { this.currentCooldownBehaviour.StartCooldown(this.currentAttack.frequency); } } InvokeRepeating("doAttack", 0, this.currentAttack.frequency); // If the current attack is slow, wait a little and set back to the previous attack if (this.currentAttack.frequency > Parameters.SLOW_ATTACK_LIMIT) { this.currentActiveAttack = this.currentAttack; StartCoroutine(WaitAndSetBackAttack(1.0f)); } }
public void performAttack() { if (Attacks != null && Attacks.Count > 0) { BossAttack attack = ChooseAttack(); if (attack) { attack.Activate(); } //print("BossAttackManager/performAttack: " + attack.name); } else { print("BossAttackManager/performAttack: no attacks avaiable"); } }
private void RangedAttack() { if(_bossDetectionScript.currentState == DarkGodStateMachine.BossState.Attack) { currentAttack = BossAttack.Ranged; _bossDetectionScript.Speed = 0f; _myAnimator.SetBool("IsWalking", false); _myAnimator.SetTrigger("RangedAttack"); StartCoroutine(WaitForAttackToFinish(1.2f, true, "range", 0.8f)); //GameObject range = Instantiate(rangedObject, projectileSpawn.transform.position, Quaternion.identity)as GameObject; //StartCoroutine( _bossDetectionScript.ChangeState(DarkGodStateMachine.BossState.Search)); //Debug.Log ("RAAAAAAAAAAAAAAANGE!!!"); //rangedData.totalTimesUsed += 1; lastAttack = BossAttack.Ranged; } }
private void PetrificationAttack() { if(_bossDetectionScript.currentState == DarkGodStateMachine.BossState.Attack) { currentAttack = BossAttack.Petrification; _bossDetectionScript.Speed = 0f; _myAnimator.SetBool("IsWalking", false); _myAnimator.SetTrigger("PetrifyAttack"); //Debug.Log ("PETRRRRRIFFFFY!!!"); StartCoroutine(WaitForAttackToFinish(2.5f, true, "petrify", 0.7f)); //GameObject petrify = Instantiate(petrificationObject, transform.position + new Vector3(0f, 1f, 1f), Quaternion.identity)as GameObject; //petrify.transform.SetParent(this.transform); //petrificationData.totalTimesUsed += 1; lastAttack = BossAttack.Petrification; } }
private void ClawAttack() { if(_bossDetectionScript.currentState == DarkGodStateMachine.BossState.Attack) { currentAttack = BossAttack.Claw; _bossDetectionScript.Speed = 0f; //spookyAttack.Play(); _myAnimator.SetBool("IsWalking", false); _myAnimator.SetTrigger("ClawAttack"); //clawData.totalTimesUsed += 1; lastAttack = BossAttack.Claw; StartCoroutine(WaitForAttackToFinish(0.7f, false, "none", 0.5f)); //Debug.Log ("CLAAAAAAAAAAAAAWWWW!!!"); } }
private void AoeAttack() { if(_bossDetectionScript.currentState == DarkGodStateMachine.BossState.Attack) { currentAttack = BossAttack.Aoe; _bossDetectionScript.Speed = 0f; _myAnimator.SetBool("IsWalking", false); _myAnimator.SetTrigger("TentacleAttack"); //Debug.Log ("AAAAAAOOOOOOOOEEEEE!!!"); StartCoroutine(WaitForAttackToFinish(2f, false, "aoe", 0.8f)); //aoeData.totalTimesUsed += 1; //StartCoroutine(ActivateAOE()); lastAttack = BossAttack.Aoe; } }