Example #1
0
    /// <summary>
    /// Transitions the giant to <see cref="GiantStunnedState"/> if it is within range of the player
    /// </summary>
    /// <param name="eventInfo"> Contains info from the <see cref="EventInfo"/></param>
    public void StunGiant(EventInfo eventInfo)
    {
        StunGiantEventInfo se = (StunGiantEventInfo)eventInfo;

        if (Vector3.Distance(se.playerPosition, transform.position) < se.stunDistance)
        {
            TransitionTo <GiantStunnedState>();
        }
    }
Example #2
0
    /// <summary>
    /// Uses different runes depending on the <see cref="CurrentRune"/> value. And enables the selection of rune.
    /// </summary>
    private void RuneKeys()
    {
        if (Input.GetButtonDown("Rune activation key") || (Input.GetAxisRaw("Rune activation axis") > 0 && XboxInputLeftTriggerNotOnCooldown == true))
        {
            XboxInputLeftTriggerNotOnCooldown = false;
            owner.StartCoroutine(owner.XboxCooldown());
            if (CurrentRune != null && CurrentRune.ReadyToUse() && !Source.isPlaying)
            {
                CurrentRune.Used();
                switch (CurrentRune.GetRuneValue())
                {
                case 1:
                    AudioClip clip = StunGiantSound;
                    Source.PlayOneShot(clip);
                    StunGiantEventInfo sgei = new StunGiantEventInfo {
                        playerPosition = Position.position, stunDistance = StunRange
                    };
                    EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.StunGiant, sgei);
                    MadeANoise(clip.length);
                    break;

                case 2:
                    CalmCowEvent cce = new CalmCowEvent {
                        playerPosition = Position.position
                    };
                    EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.CalmCow, cce);
                    MadeANoise(1);
                    break;

                case 3:
                    LocateCowEventInfo lcei = new LocateCowEventInfo {
                        playerPosition = Position.position
                    };
                    EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.LocateCow, lcei);
                    MadeANoise(1);
                    break;

                default:
                    break;
                }
            }
        }

        if (Input.GetButton("Change rune key") || (Input.GetAxisRaw("Change rune axis") < 0 && XboxInputDownNotOnCooldown == true))
        {
            if (CurrentRune != null)
            {
                XboxInputDownNotOnCooldown = false;
                owner.StartCoroutine(owner.XboxCooldown());
                int temp = CurrentRune.Index;
                temp++;
                if (temp >= RuneNumber)
                {
                    temp = 0;
                }
                CurrentRune = Runes[temp];
                Debug.Log("Sending change rune event with value " + CurrentRune.GetRuneValue());
                ChangeRuneEventInfo crei = new ChangeRuneEventInfo {
                    newRune = CurrentRune
                };
                EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.ChangeRune, crei);
            }
        }
    }