示例#1
0
    // function to fire event........
    // return current state....
    public GhostState fireEvent(int trigerEventt)
    {
        // code to handle the ChasePac State
        // Convert into Enum value
        GhostEvent trigerEvent = (GhostEvent)trigerEventt;

        if (State.Equals(GhostState.ChasePac))
        {
            switch (trigerEvent)
            {
            case GhostEvent.MoveRandom:
                State = GhostState.ChasePac;
                return(State);

            case GhostEvent.EatPacMan:
                State = GhostState.ChasePac;
                return(State);

            case GhostEvent.PacManEatSuperTab:
                State = GhostState.Sacredghost;
                return(State);

            default:
                inValid = true;
                return(State);
            }
        }
        // code to handle the Sacred ghost state
        else if (State.Equals(GhostState.Sacredghost))
        {
            switch (trigerEvent)
            {
            case GhostEvent.PacEatScaredGhost:
                State = GhostState.EyeState;
                return(State);

            case GhostEvent.SuperPacManTimeOut:
                State = GhostState.ChasePac;
                return(State);

            default:
                inValid = true;
                return(State);
            }
        }
        // code to handle the Eye state
        else
        {
            switch (trigerEvent)
            {
            case GhostEvent.MoveToIntialState:
                State = GhostState.ChasePac;
                return(State);

            default:
                inValid = true;
                return(State);
            }
        }
    }
示例#2
0
    public void TriggerEvent()
    {
        if (!hasBeenTriggered)
        {
            switch (eventToTrigger.eventType)
            {
            case EventType.Sound:
                SoundEvent soundEvent = (SoundEvent)eventToTrigger;
                audioSource.PlayOneShot(soundEvent.audioClip, soundEvent.volumeSetting);
                break;

            case EventType.Animation:
                AnimationEvent animationEvent = (AnimationEvent)eventToTrigger;
                animatedObject.GetComponent <Animator>().SetTrigger(animationEvent.parameterToTrigger);
                break;

            case EventType.Debug:
                Debug.Log("Event Triggered");
                break;

            case EventType.GhostEvent:
                GhostEvent ghostEvent = (GhostEvent)eventToTrigger;
                switch (ghostEvent.thisGhostEvent)
                {
                case GhostEventType.ActivateGhost:
                    ghost.OnFirstActivateGhost();
                    break;
                }
                break;
            }
            hasBeenTriggered = true;
        }
    }
示例#3
0
文件: Ghost.cs 项目: NyanSir/GGJ-2019
    private List <Player> playerlist; // players be found

    // Use this for initialization
    void Start()
    {
        Found             = false;
        playerlist        = new List <Player>();
        currentRouteIndex = 2;
        particle.SetActive(false);
        me = LevelEventManager.Instance.GetComponent <GhostEvent>();
        transform.LookAt(me.MigratePoints[currentRouteIndex].position);
    }