void checkForPlayers() { //Debug.Log("Checking for players yup I am it seems"); for (int i = 0; i < attackSpots.Length; i++) { AttackSpot temp = attackSpots[i]; if (temp.containsPlayer) { //Debug.Log("Oh it looks the counter is : " + potAttCounter+" and the position is : "+i); //potentialAttacks[potAttCounter] = i; //Debug.Log("Before it is " + potAttCounter); potentiaAttacks.Add(potAttCounter++, i); //Debug.Log("We just mapped : "+potAttCounter+" to "+i); } } }
private IEnumerator BasicAttack() { checkForPlayers(); if (potAttCounter <= 0) { Debug.Log("No players, no need to bother attacking"); } else { anim.SetBool("Smash", true); basic_attack_sound.Play(); int randomNum = Random.Range(0, potAttCounter); int positionKey = potentiaAttacks[randomNum]; AttackSpot selectedSpot = attackSpots[positionKey]; //selectedSpot.Warning(); selectedSpot.GetComponent <SpriteRenderer>().enabled = true; yield return(new WaitForSeconds(0.4f)); GameObject drop = Instantiate(drop_stuff, selectedSpot.transform); yield return(new WaitForSeconds(0.6f)); if (enem.currentHealth <= enem.maxHealth / 2) { selectedSpot.Attack(Random.Range(20, 40)); } else { selectedSpot.Attack(Random.Range(10, 20)); } anim.SetBool("Smash", false); selectedSpot.GetComponent <SpriteRenderer>().enabled = false; } potAttCounter = 0; //Debug.Log("Now the thing is " + potAttCounter); potentiaAttacks = new Dictionary <int, int>(); yield return(new WaitForSeconds(1f)); // animation time }
private void OnDeath() { if (currentHealth <= 0) { cam.cullingMask &= ~(1 << 9); if (isMonster) { flashLight.SetActive(true); Trail.SetActive(true); Instantiate(MonsterSauce, transform.position, transform.rotation); } anim.SetBool("IsMonster", false); isMonster = false; //flashLight.GetComponent<Light>().color = new Color32(55, 193, 187, 255); gameObject.tag = "Player"; move_speed = reg_speed; currentHealth = maxHealth; healthbar.maxValue = maxHealth; healthbar.value = currentHealth; transform.localScale = new Vector3(1f, 1f, 1f); //gameObject.SetActive(false); //for(int i = 0; i < spawnPoints.Length; i++) //{ // if(spawnPoints[i].bounds.Contains()) //} for (int i = 0; i < spawnPoints.Length; i++) { if (!spawnPoints[i].GetComponent <AttackSpot>().containsMonster) { notOccupiedSpots.Add(spawnPoints[i]); } } int go_here = Random.Range(0, notOccupiedSpots.Count); Debug.Log(go_here); Debug.Log(notOccupiedSpots); AttackSpot temp = notOccupiedSpots[go_here]; transform.position = places[temp].position; notOccupiedSpots.Clear(); } }