Ejemplo n.º 1
0
    /// <summary>
    /// Makes the cow follow the player if it is within <see cref="hearingRange"/>.
    /// </summary>
    /// <param name="eventInfo">contains infomation brought from <see cref="EventInfo"/></param>
    public void CallTheCow(EventInfo eventInfo)
    {
        //if(CurrentState.GetType() == typeof(CowDyingState))

        CallCowEventInfo callCowInfo = (CallCowEventInfo)eventInfo;

        if (CurrentState.GetType() != typeof(CowCapturedState) && CurrentState.GetType() != typeof(CowFollowState) && Vector3.Distance(transform.position, callCowInfo.playerPosition) < hearingRange) // cowMove, cowidle
        {
            Called = true;
            Player = callCowInfo.player;
            TransitionTo <CowFollowState>();
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Activates various songs depending on key input.
    /// </summary>
    private void SongInput()
    {
        if (Input.GetButton("Call Cow") && !Source.isPlaying)
        {
            ClipIndex = Random.Range(1, 4);
            AudioClip clip = CallCowSounds[ClipIndex];
            Source.PlayOneShot(clip);
            CallCowSounds[ClipIndex] = CallCowSounds[0];
            CallCowSounds[0]         = clip;
            MadeANoise(clip.length);
            CallCowEventInfo ccei = new CallCowEventInfo
            {
                playerPosition = Position.position,
                player         = Position.gameObject
            };

            EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.CallCow, ccei);
        }

        if (Input.GetButton("Stop/Collect Cow") && !Source.isPlaying)
        {
            ClipIndex = Random.Range(1, 2);
            AudioClip clip = StopCowSounds[ClipIndex];
            Source.PlayOneShot(clip);
            StopCowSounds[ClipIndex] = StopCowSounds[0];
            StopCowSounds[0]         = clip;
            MadeANoise(clip.length);
            StopCowEventInfo scei = new StopCowEventInfo
            {
                playerPosition = Position.position
            };

            EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.StopCow, scei);

            foreach (GameObject wolf in GameComponents.WolfList)
            {
            }
            foreach (GameObject giant in GameComponents.GiantList)
            {
            }
        }

        if (Input.GetButton("Stop/Collect Cow"))
        {
            GameObject penInDistance = null;
            foreach (GameObject animalPen in GameComponents.AnimalPens)
            {
                if (Mathf.Abs(Vector3.Distance(animalPen.transform.position, owner.transform.position)) < animalPen.GetComponent <AnimalPen>().CowCollectionDistance)
                {
                    penInDistance = animalPen;
                }
            }

            if (penInDistance != null)
            {
                CollectCowEventInfo ccei = new CollectCowEventInfo {
                    closestPen = penInDistance
                };
                EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.CollectCow, ccei);
            }
            MadeANoise(0);
        }
    }