protected override void act() { shaking = true; shakeAmount = 1.0f; AbilityPlacedMessage message = new AbilityPlacedMessage(transform.position.x, transform.position.y, AbilityType.PossessionLure); MessageCenter.Instance.Broadcast(message); //GamePad.SetVibration(PlayerIndex.One, 1f, 1f); }
void HandleAbilityPlaced(Message message) { AbilityPlacedMessage apmess = message as AbilityPlacedMessage; string path = ""; if (prefabPaths.TryGetValue(apmess.AType, out path)) { GameObject.Instantiate(Resources.Load(path), new Vector3(apmess.X, apmess.Y), Quaternion.identity); } }
void abilityPlacedListener(Message message) { AbilityPlacedMessage placedMessage = message as AbilityPlacedMessage; if (placedMessage.AType.Equals(AbilityType.PossessionLure)) { Vector3 possessedPosition = new Vector3(placedMessage.X, placedMessage.Y); if (Vector3.Distance(transform.position, possessedPosition) <= GetComponent <CircleCollider2D>().radius) { scare(possessedPosition); } } }
protected override void HandleInput(){ base.HandleInput(); if((Input.GetButtonDown("A")||Input.GetKeyDown(KeyCode.D))&& canPlace && luresPlaced < luresAllowed){ AbilityPlacedMessage message = new AbilityPlacedMessage (transform.position.x,transform.position.y, type); MessageCenter.Instance.Broadcast (message); luresPlaced++; if(luresPlaced >= luresAllowed){ Exit(); } } if( Input.GetKeyDown(KeyCode.Backspace) || Input.GetButtonDown("B") ) { Exit(); } }
public void onPossess() { audio.PlayOneShot (popSound); string popLocation = "Particles/Particle System_critterpop"; GameObject pop = (GameObject)Instantiate (Resources.Load (popLocation), Vector3.zero, Quaternion.identity); pop.transform.SetParent (transform, false); pop.GetComponent<ParticleSystem> ().Play (); // Destroy objects float duration = pop.GetComponent<ParticleSystem> ().duration; Destroy (pop, duration); Destroy (gameObject, duration); Vector3 position = gameObject.transform.position; AbilityPlacedMessage message = new AbilityPlacedMessage (position.x, position.y, AbilityType.PossessionScare); MessageCenter.Instance.Broadcast (message); }
protected override void HandleInput() { base.HandleInput(); if ((Input.GetButtonDown("A") || Input.GetKeyDown(KeyCode.D)) && canPlace && luresPlaced < luresAllowed) { AbilityPlacedMessage message = new AbilityPlacedMessage(transform.position.x, transform.position.y, type); MessageCenter.Instance.Broadcast(message); luresPlaced++; if (luresPlaced >= luresAllowed) { Exit(); } } if (Input.GetKeyDown(KeyCode.Backspace) || Input.GetButtonDown("B")) { Exit(); } }
protected void scare() { //base.scare(); //shaking = true; float clipLength = 0; if (!scaring) { AudioClip scare = (AudioClip)bushScareSounds[Random.Range (0, bushScareSounds.Length)]; clipLength = scare.length; audio.PlayOneShot (scare, 1.0f); Animator anim = gameObject.GetComponent<Animator>(); anim.SetTrigger("Lure"); AbilityPlacedMessage message = new AbilityPlacedMessage(transform.position.x, transform.position.y, AbilityType.PossessionScare); MessageCenter.Instance.Broadcast(message); } scaring = true; if (clipLength > 0) scaredCooldownSeconds = clipLength; scareTimeLeft = scaredCooldownSeconds; //GamePad.SetVibration(PlayerIndex.One, 1f, 1f); }
protected void lure() { //base.lure(); //blinking = true; float clipLength = 0; if (!luring) { AudioClip lure = (AudioClip)bushLureSounds[Random.Range (0, bushLureSounds.Length)]; clipLength = lure.length; audio.PlayOneShot (lure, 1.0f); Animator anim = gameObject.GetComponent<Animator>(); anim.SetTrigger("Lure"); AbilityPlacedMessage message = new AbilityPlacedMessage(transform.position.x, transform.position.y, AbilityType.PossessionLure); MessageCenter.Instance.Broadcast(message); } luring = true; if (clipLength > 0) lureCooldownSeconds = clipLength; lureTimeleft = lureCooldownSeconds; //anim.SetBool("Lure", false); }