Пример #1
0
 void Awake()
 {
     PauseMenu = new PausedState();
     PlayerAwake();
     Application.targetFrameRate = 144;
     ThisAudioManager            = new AudioManager(SFXEventNames, MusicEventNames, head);
     ThisAnim = GetComponent <Animator>();
 }
    private void Awake()
    {
        Debug.Log("Awake");

        StateMachine = new StateMachine();

        playing = new PlayingState();
        paused  = new PausedState();
        shop    = new ShopState();
    }
Пример #3
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     base.Initialize();
     // TODO: Add your initialization logic here
     DemoState     = new DemoState();
     PausedState   = new PausedState();
     PlayingState  = new PlayingState();
     GameOverState = new GameOverState();
     GameStateManager.PushState(DemoState);
 }
 void Awake()
 {
     PauseMenu = new PausedState();
     PV        = GetComponent <PhotonView>();
     UIElements.SetActive(false);
     PlayerAwake();
     //PV.RPC("PlayerAwake", RpcTarget.AllBuffered);
     Application.targetFrameRate = 144;
     ThisAudioManager            = new AudioManager(SFXEventNames, MusicEventNames, head);
     Debug.Log("CHARACTER CREATED");
 }
Пример #5
0
    public void Start()
    {
        // Add all posible states
        game   = gameObject.AddComponent <GameState>();
        paused = gameObject.AddComponent <PausedState>();

        // Default state
        state = paused.State();

        StartCoroutine(Run());
    }
    void Awake()
    {
        PauseMenu = new PausedState();
        PV        = GetComponent <PhotonView>();
        UIElements.SetActive(false);
        PlayerAwake();
        Application.targetFrameRate = 144;
        ThisAudioManager            = new AudioManager(SFXEventNames, MusicEventNames, head);



        ThisPlayer.AddRenderer(Surfaces.GetComponent <SkinnedMeshRenderer>());
        ThisPlayer.AddRenderer(Sheet.GetComponent <SkinnedMeshRenderer>());
        ThisPlayer.SetTransparency(0.2f);
    }
Пример #7
0
    public void Start()
    {
        fsm    = gameObject.GetComponent <StateMachine>();
        paused = gameObject.GetComponent <PausedState>();

        // Make ground
        ground = (GameObject)GameObject.Instantiate(Resources.Load("Ground"), new Vector3(0, 0, 0), Quaternion.identity);

        // Make spheres
        for (int y = -5; y < 0; y++)
        {
            for (int x = -6; x <= 5; x++)
            {
                Vector3 vector = new Vector3((x * 3) + (Random.value * 2) - 1, (y * -3) + (Random.value * 2) - 1, (Random.value * 24) - 12);
                GameObject.Instantiate(Resources.Load("Sphere"), vector, Quaternion.identity);
            }
        }
    }
        private PausedState CreatePausedState(ITAlertPhotonClient photonClient)
        {
            var pausedStateInput = new PausedStateInput(_director);
            var pausedState      = new PausedState(pausedStateInput);

            var onFeedbackStateSyncTransition = new OnMessageTransition(photonClient, ITAlertChannel.GameState, typeof(FeedbackMessage), FeedbackState.StateName);
            var toPlayingStateTransition      = new OnEventTransition(PlayingState.StateName);
            var toSettingsStateTransition     = new OnEventTransition(SettingsState.StateName);
            var quitTransition = new OnEventTransition(MenuState.StateName);

            pausedStateInput.ContinueClickedEvent += toPlayingStateTransition.ChangeState;
            pausedStateInput.SettingsClickedEvent += toSettingsStateTransition.ChangeState;
            pausedStateInput.QuitClickedEvent     += quitTransition.ChangeState;

            pausedState.AddTransitions(onFeedbackStateSyncTransition, toPlayingStateTransition, toSettingsStateTransition, quitTransition);

            return(pausedState);
        }
Пример #9
0
            public IAnimationState Update(GameTime gameTime)
            {
                IAnimationState toReturn = this;

                if (animation.IsPlaying)
                {
                    // Add to the time counter. - J Mor
                    animation.timeSinceLastFrameChange += (float)gameTime.ElapsedGameTime.TotalSeconds;

                    // If enough time has gone by to actually flip frames... - J Mor
                    if (animation.timeSinceLastFrameChange >= animation.SecondsPerFrame)
                    {
                        // ...then update the frame, and... - J Mor
                        animation.CurrentFrame++;
                        // ...if the current frame is the last, ... - J Mor
                        if (animation.CurrentFrame >= animation.Animation.NumFrames)
                        {
                            if (animation.IsLooped)                             // ...and the animation is set to wrap... - J Mor
                            {
                                // ...then update the frame # & the times looped. - J Mor
                                animation.CurrentFrame = 0;
                                animation.TimesLooped++;
                            }
                            else                             // if not, the animation is done, and should be removed soon. - J Mor
                            {
                                toReturn = new CompletedState(animation);
                                animation.CurrentFrame--;                                 // To avoid IndexOutOfBounds error. - J Mor
                            }
                        }
                        //SpriteSheet.UpdateImgSourceRectangle();
                        // Remove one "frame" worth of time
                        animation.timeSinceLastFrameChange -= animation.SecondsPerFrame;
                    }
                }
                else
                {
                    toReturn = new PausedState(animation);
                }

                return(toReturn);
            }
Пример #10
0
        public Machine()
        {
            LocalTimeSource             = new SlaveTimeSource(this);
            LocalTimeSource.TimePassed += HandleTimeProgress;

            collectionSync        = new object();
            pausingSync           = new object();
            disposedSync          = new object();
            clockSource           = new BaseClockSource();
            localNames            = new Dictionary <IPeripheral, string>();
            PeripheralsGroups     = new PeripheralsGroupsManager(this);
            ownLifes              = new HashSet <IHasOwnLife>();
            pausedState           = new PausedState(this);
            SystemBus             = new SystemBus(this);
            registeredPeripherals = new MultiTree <IPeripheral, IRegistrationPoint>(SystemBus);
            userStateHook         = delegate
            {
            };
            userState = string.Empty;
            SetLocalName(SystemBus, SystemBusName);
        }
Пример #11
0
        public void Draw(Graphics graphics) {
            // TODO GameManager.State에 따라 다른 형태의 화면 표시가 필요함
            
            var world = _manager.GetWorld();

            var entities = world.EntityManager.Entities;

            float width = _control.DisplayRectangle.Right - _control.DisplayRectangle.Left;
            float height = _control.DisplayRectangle.Bottom - _control.DisplayRectangle.Top;

            var factorWidth = width / world.Size.Width;
            var factorHeight = height / world.Size.Height;
            graphics.FillRectangle(Brushes.Black, 0, 0, world.Size.Width * factorWidth, world.Size.Height * factorHeight);
            graphics.DrawString($@"Game state: {_manager.State switch {
                PlayingState _ => "Playing",
                PausedState _ => "Paused",
                CompleteState _ => "Complete",
                CompleteAllState _ => "CompleteAll",
                IntermediateState _ => "Intermediate",
                GameOverState _ => "GameOver",
                _ => "Else"
            }}", new Font("Arial", 16), Brushes.White, 0, 0);
Пример #12
0
        public VideoNodeState SetState(MediaElementState mediaState, IVideoNode context)
        {
            if (_states.ContainsKey(mediaState + "State"))
            {
                return(_states[mediaState + "State"]);
            }

            switch (mediaState)
            {
            case MediaElementState.Buffering:
                var bufferingState = new BufferingState(this, context);
                _states.Add(bufferingState.GetType().Name, bufferingState);
                return(bufferingState);

            case MediaElementState.Playing:
                var playingState = new PlayingState(this, context);
                _states.Add(playingState.GetType().Name, playingState);
                return(playingState);

            case MediaElementState.Stopped:
                var stoppedState = new StoppedState(this, context);
                _states.Add(stoppedState.GetType().Name, stoppedState);
                return(stoppedState);

            case MediaElementState.Opening:
                var openingState = new OpeningState(this, context);
                _states.Add(openingState.GetType().Name, openingState);
                return(openingState);

            case MediaElementState.Paused:
                var pausedState = new PausedState(this, context);
                _states.Add(pausedState.GetType().Name, pausedState);
                return(pausedState);

            default:
                return(null);
            }
        }
Пример #13
0
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            this.RegisterGlobalComponent(new AudioManager(this.Game, @"Content\Audio\RpgAudio.xgs", @"Content\Audio\Wave Bank.xwb", @"Content\Audio\Sound Bank.xsb"));
            _SceneManager  = new SceneManager();
            _MainMenuState = new MainMenuState();
            _PausedState   = new PausedState();
            _OptionsState  = new OptionsState();
//#if DEBUG
//            AudioManager.Instance.MusicEnabled = false;
//#endif
            // Start off in game.
            //_SceneManager.ChangeScene("BasicLevel", false);
            //StateManager.PushState(_SceneManager);
            StateManager.PushState(_MainMenuState);
            AudioManager.PlayMusic("Title1");
            AudioManager.SetMusicVolume(0.5f);
            CreateNewPlayer();
            GraphicsManager.ApplyChanges();

//#if DEBUG
            _SceneManager.AddComponent(new DebugComponent(_SceneManager));
//#endif
        }
Пример #14
0
            internal ActiveState(AnimationInstance animation)
            {
                //this.animation = animation;
                Update = (GameTime gameTime) =>
                {
                    IAnimationState toReturn = this;
                    if (animation.IsPlaying)
                    {
                        // Add to the time counter. - J Mor
                        animation.timeSinceLastFrameChange += (float)gameTime.ElapsedGameTime.TotalSeconds;

                        // If enough time has gone by to actually change frames...
                        while (animation.timeSinceLastFrameChange >= animation.SecondsPerFrame)
                        {
                            // ...then update the frame, and...
                            animation.CurrentFrame++;
                            // ...if the current frame is the last, ...
                            if (animation.CurrentFrame >= animation.Animation.NumFrames)
                            {
                                if (animation.IsLooped)                                 // ...and the animation is set to wrap...
                                {
                                    // ...then update the frame # & the times looped.
                                    animation.CurrentFrame = 0;
                                    animation.TimesLooped++;
                                }
                                else                                 // if not, the animation is done, and should be removed soon.
                                {
                                    toReturn = new CompletedState(animation);
                                    animation.CurrentFrame--;                                     // To avoid IndexOutOfBounds error in draw func.
                                }
                            }
                            // Remove one "frame" worth of time
                            animation.timeSinceLastFrameChange -= animation.SecondsPerFrame;

                            // If the animation isn't allowed to skip animation frames, then break out of the loop.
                            if (!animation.CanSkipFrames)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        toReturn = new PausedState(animation);
                    }

                    return(toReturn);
                };
                Draw = (SpriteBatch batch) =>
                {
                    if (animation.Posit == null)
                    {
                        if (animation.Animation.UseEachFramesDrawEffects)
                        {
                            animation.AnimationFrames[animation.CurrentFrame].DrawSprite(batch);
                        }
                        else
                        {
                            animation.AnimationFrames[animation.CurrentFrame].DrawSprite(batch, animation.Animation.DrawEffects);
                        }
                    }
                    else
                    {
                        if (animation.Animation.UseEachFramesDrawEffects)
                        {
                            animation.AnimationFrames[animation.CurrentFrame].DrawSprite(batch, null, animation.Posit.Value);
                        }
                        else
                        {
                            animation.AnimationFrames[animation.CurrentFrame].DrawSprite(batch, animation.Animation.DrawEffects, animation.Posit.Value);
                        }
                    }
                    //throw new NotImplementedException();
                };
            }
Пример #15
0
 public void Pause()
 {
     State = new PausedState();
     // do the pause logic here
 }