示例#1
0
文件: CowSM.cs 项目: Flargy/Portfolio
 /// <summary>
 /// Turn following cows in to the animal pen if it is within distance
 /// </summary>
 /// <param name="eventInfo">contains infomation brought from <see cref="EventInfo"/></param>
 public void TurnInTheCow(EventInfo eventInfo)
 {
     if (CurrentState.GetType() == typeof(CowFollowState))
     {
         CollectCowEventInfo ccei = (CollectCowEventInfo)eventInfo;
         this.Pen = ccei.closestPen;
         TransitionTo <CowCapturedState>();
     }
 }
示例#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);
        }
    }