void Idle() { if (stop) { timer += Time.deltaTime; if (infoAnimator.IsName("Idle")) { if (headAnimator.renderer.enabled == false) { headAnimator.renderer.enabled = true; elfCap.GetComponent <SpriteRenderer>().enabled = true; } } if (timer > nextBehaviour) { elfState = ElfStates.Attacking; nextBehaviour = UnityEngine.Random.Range(minTimeBetweenAttack, maxTimeBetweenAttack); timer = 0; } } else { elfState = ElfStates.None; } }
IEnumerator Attack() { yield return(new WaitForSeconds(1)); stop = true; elfState = ElfStates.Idle; }
void Surprised() { if (headAnimator.renderer.enabled == false) { headAnimator.renderer.enabled = true; elfCap.GetComponent <SpriteRenderer>().enabled = true; } headAnimator.SetTrigger("Surprised"); //play Surprised animation when player receives a gift elfState = ElfStates.Idle; //So elf returns to Idle state }
void Trolling() { if (headAnimator.renderer.enabled == false) { headAnimator.renderer.enabled = true; elfCap.GetComponent <SpriteRenderer>().enabled = true; } if (nextGift) { nextGift.transform.parent = null; nextGift.rigidbody2D.isKinematic = false; } headAnimator.SetTrigger("Troll"); //play Troll animation elfState = ElfStates.Idle; //So elf returns to Idle state }
void StartSpawner() { stop = false; elfState = ElfStates.None; }
void ReceiveAGift() { elfState = ElfStates.Surprised; }
public void ReceiveDamage() { minX += Mathf.Abs(minX * 0.1f); maxX -= Mathf.Abs(minX * 0.1f); elfState = ElfStates.Trolling; }
public void TooNarrow() { minX -= Mathf.Abs(minX * 0.1f); maxX += Mathf.Abs(minX * 0.1f); elfState = ElfStates.Surprised; }
void Attacking() { if (Time.timeSinceLevelLoad < 6) { return; } int giftIndex = 0; if (infoAnimator.IsName("Idle") && !(bodyAnimator.GetBool("Preparing") || bodyAnimator.GetBool("Rocket"))) { if (Random.value < rocketProbability / 100) { bodyAnimator.SetTrigger("Rocket"); headAnimator.renderer.enabled = false; elfCap.GetComponent <SpriteRenderer>().enabled = false; return; } else { headAnimator.SetTrigger("Scream"); //play Scream animation when one gift hit another one. bodyAnimator.SetTrigger("Preparing"); // Set the Jump animator trigger parameter. giftIndex = ChooseItem(); nextGift = PoolManager.Pools["props"].Spawn(gifts[giftIndex].gift.transform, bombaOh.position, transform.rotation).gameObject; nextGift.transform.parent = gameObject.transform; if (nextGift.rigidbody2D) { nextGift.rigidbody2D.isKinematic = true; } foreach (ParticleSystem p in GetComponentsInChildren <ParticleSystem>()) { p.Play(); } return; } } if (infoAnimator.IsName("Attack")) { if (nextGift == null) { return; } headAnimator.renderer.enabled = false; elfCap.GetComponent <SpriteRenderer>().enabled = false; nextGift.transform.parent = null; nextGift.rigidbody2D.isKinematic = false; if (nextGift.GetComponent <LaserBehaviour>() != null) { nextGift.rigidbody2D.AddForce(new Vector2(0, Random.Range(minY, maxY)), ForceMode2D.Impulse); } else { nextGift.rigidbody2D.AddForce(new Vector2(Random.Range(minX, maxX), Random.Range(minY, maxY)), ForceMode2D.Impulse); } nextGift.rigidbody2D.AddTorque(Random.Range(-360, 360)); elfState = ElfStates.Idle; return; } if (infoAnimator.IsName("Rocket")) { if (PlayerPrefs.GetInt("dificuldade") == 2 && PlayerPrefs.GetInt("Kill") == 5) { PoolManager.Pools["props"].Spawn(rocket[1].transform, new Vector3(transform.position.x - 10, transform.position.y, transform.position.z) + new Vector3(0f, 3f, 0f), Quaternion.identity); } else if (link.link == false) { PoolManager.Pools["props"].Spawn(rocket[0].transform, new Vector3(transform.position.x - 10, transform.position.y, transform.position.z) + new Vector3(0f, 3f, 0f), Quaternion.identity); } else { PoolManager.Pools["props"].Spawn(rocket[1].transform, new Vector3(transform.position.x - 10, transform.position.y, transform.position.z) + new Vector3(0f, 3f, 0f), Quaternion.identity); } ran = Random.Range(0, 4); if (ran == 2 && susto != null && PlayerStatus.playerStatus.rigidbody2D.velocity.y >= 0) { susto.SetTrigger("Susto"); } bodyAnimator.SetBool("Rocket", false); audio.PlayOneShot(rocketSFX, 0.5f); ///Vector3 wantedDirection = (PlayerStatus.playerStatus.transform.position + new Vector3(PlayerStatus.playerStatus.rigidbody2D.velocity.x/2,0,0))- newRocket.position; //newRocket.LookAt(wantedDirection); ///Vector3 relativeUp = newRocket.TransformDirection (Vector3.up); ///newRocket.rotation = Quaternion.LookRotation(wantedDirection,relativeUp); //Quaternion rot = Quaternion.LookRotation(wantedDirection, Vector3.up ); //test Vector3.forward //newRocket.rotation = rot; //newRocket.eulerAngles = new Vector3(0, 0,newRocket.eulerAngles.z); ///newRocket.rotation = new Quaternion( 0,0,newRocket.rotation.z, newRocket.rotation.w); elfCap.GetComponent <SpriteRenderer>().enabled = false; elfState = ElfStates.Idle; return; } }