Esempio n. 1
0
        public async Task SyncTimeline(PlexTrack track, PlayingState state)
        {
            var parts = track.MetadataUrl.Split('/');

            var xml = await connection.RequestXml("/:/timeline", new NameValueCollection()
            {
                { "ratingKey", parts[parts.Length - 1] },
                { "key", track.MetadataUrl },
                { "state", new Func <string>(() =>
                    {
                        switch (state)
                        {
                        case PlayingState.Playing:
                            return("playing");

                        case PlayingState.Paused:
                            return("paused");

                        case PlayingState.Stopped:
                            return("stopped");

                        default:
                            return(null);
                        }
                    }
                                             )() },
                { "hasMDE", "1" },
                { "X-Plex-Session-Identifier", connection.DeviceInfo.ClientIdentifier }
            }, "POST");
        }
Esempio n. 2
0
 private void WhenPlay()
 {
     __InternalPlayable.Play();
     __State = PlayingState.Playing;
     OnPlayingStateChanged();
     __PlaybackTimer.Start();
 }
        void Initialize()
        {
            Debug.Log("Dirac Initialize");
            if (AudioSettings.outputSampleRate != 44100)
            {
                Debug.LogError("DiracLE pitch shifting only works at 44100 kHz. Use the InitScene to force 44.1 kHz output on iOS.");
                this.enabled = false;
                return;
            }

            int numBuffers;

            AudioSettings.GetDSPBufferSize(out _bufferSize, out numBuffers);

            AllocateNativeResources(_bufferSize);

            _initialized = true;

            _source = gameObject.GetComponent <AudioSource>();

            if (_source != null)
            {
                if (_source.playOnAwake == true && _source.clip != null)
                {
                    _playingState     = PlayingState.Playing;
                    _doProcess        = true;
                    _buffersNeedReset = true;
                }
            }

            if (alwaysProcess)
            {
                _doProcess = true;
            }
        }
Esempio n. 4
0
 /// <summary>
 /// </summary>
 /// <param name="playlistService">The playlist service.</param>
 /// <param name="player">The player.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="hotkeyService">The hotkey service.</param>
 public NonManagingPlayerService(IPlaylistService playlistService,
                                 IAudioPlayer player,
                                 IPublicTransport publicTransport,
                                 IConfigurationManager configurationManager,
                                 IGlobalHotkeyService hotkeyService)
 {
     state = PlayingState.Stopped;
     this.playlistService      = Guard.IsNull(() => playlistService);
     this.player               = Guard.IsNull(() => player);
     this.publicTransport      = Guard.IsNull(() => publicTransport);
     this.configurationManager = Guard.IsNull(() => configurationManager);
     this.hotkeyService        = Guard.IsNull(() => hotkeyService);
     Subscribe();
     prebufferSongs                 = configurationManager.GetValue("PrebufferSongs", 2, "PlayerService");
     PlayNextThreshold              = configurationManager.GetValue("PlayNextThreshnoldMs", 500d, "PlayerService");
     TrackInterchangeCrossfadeTime  = configurationManager.GetValue("TrackInterchangeCrossfadeTimeMs", 500d, "PlayerService");
     TrackInterchangeCrossFadeSteps = configurationManager.GetValue("TrackInterchangeCrossfadeSteps", 50, "PlayerService");
     maxBackStack              = configurationManager.GetValue("MaxBackStack", 2000, "PlayerService");
     LastPlayed                = configurationManager.GetValue("PlayerService.LastPlayed", Guid.Empty, KnownConfigSections.Hidden);
     LastPlayedOffset          = configurationManager.GetValue("PlayerService.LastPlayedOffset", 0d, KnownConfigSections.Hidden);
     VolumeValue               = configurationManager.GetValue("PlayerService.Volume", 1f, KnownConfigSections.Hidden);
     preBuffered               = new List <TrackContainer>(prebufferSongs.Value);
     backStack                 = new List <TrackContainer>(maxBackStack.Value);
     VolumeValue.ValueChanged += VolumeValueOnValueChanged;
     RegisterHotkeys();
     LoadLastPlayed();
     UpdateState();
     SendProgress();
 }
Esempio n. 5
0
 private void WhenPause()
 {
     __InternalPlayable.Pause();
     __State = PlayingState.Paused;
     OnPlayingStateChanged();
     __PlaybackTimer.Stop();
 }
Esempio n. 6
0
 private void WhenPlay()
 {
     __InternalPlayable.Play();
     __State = PlayingState.Playing;
     OnPlayingStateChanged();
     __PlaybackTimer.Start();
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentBase" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="playlistService">The playlist service.</param>
 /// <param name="player">The player.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="hotkeyService">The hotkey service.</param>
 public NonManagingPlayerService(ILogger logger,
                                 IPlaylistService playlistService,
                                 IAudioPlayer player,
                                 IPublicTransport publicTransport,
                                 IConfigurationManager configurationManager,
                                 IGlobalHotkeyService hotkeyService)
     : base(logger)
 {
     playlistService.Guard("playlistService");
     player.Guard("player");
     publicTransport.Guard("publicTransport");
     configurationManager.Guard("configurationManager");
     state = PlayingState.Stopped;
     this.playlistService      = playlistService;
     this.player               = player;
     this.publicTransport      = publicTransport;
     this.configurationManager = configurationManager;
     this.hotkeyService        = hotkeyService;
     publicTransport.ApplicationEventBus.Subscribe <PlaylistUpdatedEvent>(OnPlaylistUpdated);
     publicTransport.ApplicationEventBus.Subscribe <ShuffleChangedEvent>(OnShuffleChanged);
     prebufferSongs                 = configurationManager.GetValue("PlayerService.PrebufferSongs", 2);
     PlayNextThreshold              = configurationManager.GetValue("PlayerService.PlayNextThreshnoldMs", 500d);
     TrackInterchangeCrossfadeTime  = configurationManager.GetValue("PlayerService.TrackInterchangeCrossfadeTimeMs", 500d);
     TrackInterchangeCrossFadeSteps = configurationManager.GetValue("PlayerService.TrackInterchangeCrossfadeSteps", 50);
     maxBackStack = configurationManager.GetValue("PlayerService.MaxBackStack", 2000);
     preBuffered  = new List <TrackContainer>(prebufferSongs.Value);
     backStack    = new List <TrackContainer>(maxBackStack.Value);
     RegisterHotkeys();
 }
Esempio n. 8
0
 private void WhenStop()
 {
     __PlaybackTimer.Stop();
     __State = PlayingState.Stopped;
     OnPlayingStateChanged();
     OnSecondsPlayedChanged();
 }
Esempio n. 9
0
    IEnumerator PlayFadeInCoroutine()
    {
        if (fadeInDelay > 0)
        {
            yield return(new WaitForSeconds(fadeInDelay));
        }
        if (isPlaying)
        {
            yield break;
        }
        nowState  = PlayingState.FadeIn;
        isPlaying = true;

        while (progress < 1.0f)
        {
            progress += Time.deltaTime / fadeInTime;
            yield return(null);
        }

        isPlaying = false;
        nowState  = PlayingState.Stop;
        progress  = 1.0f;
        if (onFinishFadeIn != null)
        {
            onFinishFadeIn.Invoke();
        }
        FinishInChange();
    }
Esempio n. 10
0
        public void Initialize()
        {
            lock (SourceLock)
            {
                if (_state != PlayingState.NONE)
                {
                    // Already initialized
                    return;
                }

                var method  = RtspRequest.RtspMethod.OPTIONS;
                var builder = RtspRequest.CreateBuilder().Uri(_currentUri).Method(method);

                // TODO(frank.lamar): Add check for supported operations.  Otherwise this call
                // is meaning less.
                CheckResponse(_client.Send(builder.Build()), method);

                // Send Describe to server
                method = RtspRequest.RtspMethod.DESCRIBE;
                var response = CheckResponse(_client.Send(builder.Method(method).Build()), method);

                _tracks = MediaTracks.FromSdp(response.GetBodyAsSdp(), _currentUri, _filter);

                // Initialize our session refresh timmer.
                _sessionRefreshTimer           = new Timer();
                _sessionRefreshTimer.AutoReset = true;
                _sessionRefreshTimer.Elapsed  += SessionRefreshTimer_Elapsed;

                _state = PlayingState.INITIALIZED;
            }
        }
Esempio n. 11
0
        private bool CheckPaused()
        {
            // ポーズ無効な状態判定
            if (stateMachine == null)
            {
                return(false);
            }
            PlayingState state = stateMachine.CurrentState;

            if ((state == PlayingState.Initialize) ||
                (state == PlayingState.Ready) ||
                (state == PlayingState.GameOver) ||
                (state == PlayingState.AskContinue))
            {
                return(false);
            }
            if (BattleManager.Instance?.IsPaused == true)
            {
                return(true);
            }
            else if (CheckTriggeredKey(KeyIndex.Start))
            {
                // ポーズ入力チェック
                BattleManager.Instance?.RequestPause();
            }

            return(false);
        }
Esempio n. 12
0
    public LevelFinishedState()
    {
        playingState = GameEnvironment.GameStateManager.GetGameState("playingState") as PlayingState;
        SpriteGameObject overlay = new SpriteGameObject("Sprites/Starbackground");

        star1 = new SpriteGameObject("Sprites/Star");
        star2 = new SpriteGameObject("Sprites/Star");
        star3 = new SpriteGameObject("Sprites/Star");

        overlay.Position = new Vector2(GameEnvironment.Screen.X, GameEnvironment.Screen.Y) / 2 - overlay.Center;
        star1.Position   = overlay.Position + new Vector2(star1.Width / 2, star1.Height / 5);
        star3.Position   = overlay.Position + new Vector2(star2.Width * 3, star1.Height / 5);
        star2.Position   = overlay.Position + new Vector2(overlay.Width / 2 - 50, star1.Height / 5);

        this.Add(overlay);
        this.Add(star1);
        this.Add(star2);
        this.Add(star3);
        star2.Visible       = false;
        star3.Visible       = false;
        quitButton          = new Button("Sprites/spr_button_quit", 100);
        quitButton.Position = new Vector2(GameEnvironment.Screen.X - quitButton.Width - 10, 10);
        this.Add(quitButton);
        nextButton          = new Button("Sprites/spr_button_next", 100);
        nextButton.Position = new Vector2(GameEnvironment.Screen.X - quitButton.Width - 10, 130);
        this.Add(nextButton);
    }
Esempio n. 13
0
    IEnumerator PlayFadeOutCoroutine()
    {
        if (fadeOutDelay > 0)
        {
            yield return(new WaitForSeconds(fadeOutDelay));
        }
        if (isPlaying)
        {
            yield break;
        }
        nowState  = PlayingState.FadeOut;
        isPlaying = true;
        if (onStartFadeOut != null)
        {
            onStartFadeOut.Invoke();
        }

        while (progress < 1.0f)
        {
            progress += Time.deltaTime / fadeOutTime;
            yield return(null);
        }

        isPlaying = false;
        nowState  = PlayingState.Stop;
        progress  = 1.0f;
        FinishOutChange();
    }
Esempio n. 14
0
 public Vcr()
 {
     StoppedState = new StoppedState(this);
     PlayingState = new PlayingState(this);
     RecordingState = new RecordingState(this);
     State = StoppedState;
 }
Esempio n. 15
0
 // Use this for initialization
 void Start()
 {
     MicroGameState = PlayingState.Starting;
     //DontDestroyOnLoad(this);
     seconds = timeLimit;
     //StartCoroutine(CountDown());
 }
 public Player(TechCraftGame game, PlayingState state, World world, Vector3 startPosition)
 {
     _game     = game;
     _world    = world;
     _position = startPosition;
     _state    = state;
 }
Esempio n. 17
0
        public HostLobbyState()
        {
            //Initialize playingState
            playingState = GameWorld.GameStateManager.GetGameState("playing") as PlayingState;
            this.Add(new MenuCursor());
            //Background
            background = new SpriteGameObject("menuBackground");
            this.Add(background);

            //Make buttons
            //New Game
            createAsHumanity          = new Button("button", "buttonFont", "font", 0, "Humanity", 0);
            createAsHumanity.Position = new Vector2(300, 150);
            this.Add(createAsHumanity);

            createAsNature          = new Button("button", "buttonFont", "font", 0, "Nature", 0);
            createAsNature.Position = new Vector2(300, 280);
            this.Add(createAsNature);


            //Options
            exitGame          = new Button("button", "buttonFont", "font", 0, "Exit", 0);
            exitGame.Position = new Vector2(300, 410);
            this.Add(exitGame);
        }
Esempio n. 18
0
 private IEnumerator audioFadeOut(float fadeTime)
 {
     while (state == PlayingState.FadeIn || state == PlayingState.FadeOut)
     {
         yield return(null);
     }
     if (fadeTime > 0)
     {
         state = PlayingState.FadeOut;
         float timer       = fadeTime;
         float startVolume = audioSource.volume;
         while (audioSource.volume > 0)
         {
             audioSource.volume = startVolume * timer / fadeTime;
             timer -= Time.deltaTime;
             if (timer < 0)
             {
                 timer = 0;
             }
             yield return(null);
         }
         audioSource.volume = startVolume;
     }
     lastPlayingTrackTime = audioSource.time;
     audioSource.Stop();
     state = PlayingState.NotPlaying;
 }
Esempio n. 19
0
 public Vcr()
 {
     StoppedState   = new StoppedState(this);
     PlayingState   = new PlayingState(this);
     RecordingState = new RecordingState(this);
     State          = StoppedState;
 }
Esempio n. 20
0
        public void JumpFrames(int framesToJump)
        {
            if (this._playingState == PlayingState.NoRender)
            {
                return;
            }
            this._time = this._render.JumpFrames(framesToJump);
            switch (this._playingState)
            {
            case PlayingState.Finished:
                if (this._render.CurrentFrame != this._render.MaxFrame)
                {
                    this._playingState = PlayingState.Paused;
                }
                break;

            case PlayingState.Playing:
                break;

            case PlayingState.Paused:
                if (this._render.CurrentFrame == this._render.MaxFrame)
                {
                    this._playingState = PlayingState.Finished;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            this.UpdateVisuals();
        }
Esempio n. 21
0
 private IEnumerator audioFadeIn(float fadeTime, AudioClip musicClip, bool loop, float startPlayTime)
 {
     while (state == PlayingState.FadeIn || state == PlayingState.FadeOut)
     {
         yield return(null);
     }
     audioSource.clip = musicClip;
     audioSource.time = startPlayTime;
     audioSource.loop = loop;
     lastLoopStatus   = loop;
     lastPlayingTrack = musicClip;
     if (fadeTime > 0)
     {
         state = PlayingState.FadeIn;
         float timer = 0f;
         audioSource.volume = 0f;
         audioSource.Play();
         while (audioSource.volume < maxVolume)
         {
             audioSource.volume = maxVolume * timer / fadeTime;
             timer += Time.deltaTime;
             yield return(null);
         }
     }
     else
     {
         audioSource.Play();
     }
     state = PlayingState.Playing;
     audioSource.volume = maxVolume;
 }
Esempio n. 22
0
        public void TogglePlaying()
        {
            switch (this._playingState)
            {
            case PlayingState.Finished:
                this._playingState = PlayingState.Playing;
                this._time         = 0;
                this.UpdatePlaybackRow();
                break;

            case PlayingState.NoRender:
                break;

            case PlayingState.Paused:
                this._playingState = PlayingState.Playing;
                this.UpdatePlaybackRow();
                break;

            case PlayingState.Playing:
                this._playingState = PlayingState.Paused;
                this.UpdatePlaybackRow();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 23
0
    static void Main(string[] args)
    {
        FieldInfo assetManagerField = typeof(GameEnvironment).GetField("assetManager", BindingFlags.Static | BindingFlags.NonPublic);

        assetManagerField.SetValue(null, new EmptyAssetManager());

        LocalServer  server = new LocalServer();
        RemoteClient rc     = new RemoteClient(server);

        //JoinServerEvent jse = new JoinServerEvent();
        //jse.clientName = "test";
        LevelUpdatedEvent lue = new LevelUpdatedEvent();

        lue.updatedLevel = server.Level;

        rc.Send(lue);


        IFormatter formatter = new BinaryFormatter();
        Stream     stream    = new FileStream("MyTestFile.bin", FileMode.Open, FileAccess.Read, FileShare.Read);
        Event      obj       = (Event)formatter.Deserialize(stream);

        stream.Close();



        startTime = DateTime.UtcNow;

        playingState = new PlayingState();

        Timer timer = new Timer(tick, null, 0, (int)(1000f / 60f));

        Console.Read();
    }
Esempio n. 24
0
    /// <summary>
    /// React to the input
    /// </summary>
    /// <param name="inputHelper">The inputhelper to react to input</param>
    public override void HandleInput(InputHelper inputHelper)
    {
        base.HandleInput(inputHelper);
        inputHelper.Update();

        //Check if the continueButton is being pressed to go back to the game, starting from the last checkpoint
        if (continueButton.ButtonIsPressed)
        {
            game.IsMouseVisible = false;
            Mouse.SetPosition(GameEnvironment.Screen.X / 2, GameEnvironment.Screen.Y / 2);
            if (File.Exists("Content\\SaveFile.txt"))
            {
                using (StreamReader stream = new StreamReader("Content\\SaveFile.txt"))
                {
                    string       line         = stream.ReadLine();
                    PlayingState playingState = GameEnvironment.GameStateManager.GetGameState("playingState") as PlayingState;
                    if (line != null)
                    {
                        playingState.RoomCounter = int.Parse(line);
                    }
                    else
                    {
                        playingState.RoomCounter = 0;
                    }
                }
            }
            GameEnvironment.GameStateManager.SwitchTo("playingState");
            bgPosY = 0;
        }

        //Check if the exitbutton is being pressed, to switch back to the main menu
        if (exitButton.ButtonIsPressed)
        {
            foreach (Sound sound in MusicPlayer.Music)
            {
                sound.PlaySound();
            }
            bgPosY = 0;
            GameEnvironment.GameStateManager.SwitchTo("titleScreenState");
        }

        //Change visibility of mouseoverbutton
        if (continueButton.IsMouseOver)
        {
            continueButtonMouseOver.Visible = true;
        }
        else
        {
            continueButtonMouseOver.Visible = false;
        }

        if (exitButtonMouseOver.IsMouseOver)
        {
            exitButtonMouseOver.Visible = true;
        }
        else
        {
            exitButtonMouseOver.Visible = false;
        }
    }
Esempio n. 25
0
        public static void UpdateAABBPlayerCollision(PlayingState playingState)
        {
            IEnumerable<Guid> playerEntities = playingState.Entities.Where(x => (x.ComponentFlags & ComponentMasks.Player) == ComponentMasks.Player).Select(x => x.ID);
            IEnumerable<Guid> levelObjectEntities = playingState.Entities.Where(x => (x.ComponentFlags & ComponentMasks.LevelObjects) == ComponentMasks.LevelObjects).Select(x => x.ID);

            //create aa non velocity component for our level objects
            VelocityComponent levelObjectVelocityComponent = new VelocityComponent();
            levelObjectVelocityComponent.xVelocity = 0f;
            levelObjectVelocityComponent.yVelocity = 0f;

            foreach (Guid playerid in playerEntities)
            {
                AABBComponent playerAABBComponent = playingState.AABBComponents[playerid];
                VelocityComponent playerVelocityComponent = playingState.VelocityComponents[playerid];

                foreach (Guid lobjectid in levelObjectEntities)
                {
                    AABBComponent levelAABBComponent = playingState.AABBComponents[lobjectid];
                    Manifold manifold = overlapAABB(playerAABBComponent.BoundedBox, playerVelocityComponent, levelAABBComponent.BoundedBox, levelObjectVelocityComponent);
                    if (manifold.a != null)
                    {
                        resolveCollision(playerAABBComponent.BoundedBox, playerVelocityComponent, levelAABBComponent.BoundedBox, levelObjectVelocityComponent, manifold, playingState, playerid);
                    }

                }
            }

        }
Esempio n. 26
0
    public LevelMenuState()
    {
        PlayingState playingState = GameEnvironment.GameStateManager.GetGameState("playingState") as PlayingState;
        List <Level> levels       = playingState.Levels;

        // add a background
        SpriteGameObject background = new SpriteGameObject("Backgrounds/spr_levelselect", 0, "background");

        Add(background);

        // add the level buttons
        for (int i = 0; i < 12; i++)
        {
            int         row    = i / 4;
            int         column = i % 4;
            LevelButton level  = new LevelButton(i + 1, levels[i], 1);
            level.Position = new Vector2(column * (level.Width + 20), row * (level.Height + 20)) + new Vector2(390, 180);
            Add(level);
        }

        // add a back button
        backButton          = new Button("Sprites/spr_button_back", 1);
        backButton.Position = new Vector2((GameEnvironment.Screen.X - backButton.Width) / 2, 750);
        Add(backButton);
    }
Esempio n. 27
0
        public static void UpdateEnemyPath(Guid enemyId, PlayingState playingState)
        {
            AIComponent enemyAIComponent = playingState.AIComponents[enemyId];

            //hrmm our current path goal is empty, lets get back to patrolling
            if (enemyAIComponent.PathGoal == Vector2.Zero || enemyAIComponent.ActivePath.Count <= 0 || enemyAIComponent.ActiveState.Peek() == AIState.ATTACK)
            {
                if (enemyAIComponent.ActiveState.Peek() == AIState.PATROL)
                {
                    //set our current path point to our first patrol path point
                    if (enemyAIComponent.PathGoal == Vector2.Zero)
                    {
                        enemyAIComponent.PathGoal = enemyAIComponent.PatrolPath[0];
                    }

                    if (enemyAIComponent.ActivePath.Count <= 0)
                    {
                        //we have reached our current path goal, update it to the next
                        //take the current path and move it to the bottom of the list
                        var currentPathGoal = enemyAIComponent.PatrolPath.First();
                        enemyAIComponent.PatrolPath.RemoveAt(0);
                        enemyAIComponent.PatrolPath.Add(currentPathGoal);

                        enemyAIComponent.PathGoal = enemyAIComponent.PatrolPath[0];

                    }
                    playingState.AIComponents[enemyId] = enemyAIComponent;

                    //set an active path too
                    SetActivePath(enemyId, playingState);
                }
                else if (enemyAIComponent.ActiveState.Peek() == AIState.ATTACK)
                {
                    PositionComponent attackPosition = playingState.PositionComponents[enemyAIComponent.EntityToAttack];
                    Vector2 attackPathGoal = attackPosition.Position;

                    //we can optimize this method by checking if the attack position has changed at all and ignoring the rest
                    if (enemyAIComponent.PathGoal == Vector2.Zero || !Vector2.Equals(enemyAIComponent.PathGoal, attackPosition))
                    {
                        enemyAIComponent.PathGoal = attackPathGoal;
                    }

                    if (enemyAIComponent.ActiveState.Count <= 0)
                    {
                        enemyAIComponent.PathGoal = attackPathGoal;
                    }

                    if (UpdateTimedEvents)
                    {
                        playingState.AIComponents[enemyId] = enemyAIComponent;

                        //set an active path too
                        SetActivePath(enemyId, playingState);
                    }
                }



            }
        }
Esempio n. 28
0
    public void SwitchTo(string name)
    {
        if (gameStates.ContainsKey(name))
        {
            currentGameState = gameStates[name];

            if (name == "playingState")
            {
                GameEnvironment.camera.Reset();
                PlayingState PS = currentGameState as PlayingState;
                PS.setFocus();
            }
            else if (name == "gameOverState")
            {
                GameOverState PS = currentGameState as GameOverState;
                PS.setFocus();
            }
            else if (name == "levelFinishedState")
            {
                LevelFinishedState PS = currentGameState as LevelFinishedState;
                PS.setFocus();
            }
            else
            {
                GameEnvironment.camera.Reset();
            }
        }
        else
        {
            throw new KeyNotFoundException("Could not find game state: " + name);
        }
    }
Esempio n. 29
0
    public override void HandleInput(InputHelper inputHelper)
    {
        base.HandleInput(inputHelper);

        // if the back button is pressed, go back to the title screen
        if (backButton.Pressed)
        {
            ExtendedGame.GameStateManager.SwitchTo(PenguinPairs.StateName_Title);
        }

        // if a (non-locked) level button has been pressed, go to that level
        foreach (LevelButton button in levelButtons)
        {
            if (button.Pressed && button.Status != LevelStatus.Locked)
            {
                // go to the playing state
                ExtendedGame.GameStateManager.SwitchTo(PenguinPairs.StateName_Playing);

                // load the correct level
                PlayingState playingState = (PlayingState)ExtendedGame.GameStateManager.GetGameState(PenguinPairs.StateName_Playing);
                playingState.LoadLevel(button.LevelIndex);

                return;
            }
        }
    }
Esempio n. 30
0
    private void ActivateBuildingState()
    {
        buildingManager.enabled = true;

        inGameUI.DisplayBuildingUI();
        currentPlayingState = PlayingState.BUILDING;
    }
Esempio n. 31
0
    public void SkipTutorialAndGoToWait() // used to go directly from "tutorial" to wait for ready
    {
        StopCoroutine("StartCalibrationVoice");
        StopCoroutine("StartRumblePractices");
        RumblePracticeStart = false;

        //AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.VibrationExplain);

        //yield return new WaitForSeconds(AudioManager.Instance.VibrationExplain.length);



        if (ControllerGUIToRumble != null)
        {
            ControllerGUIToRumble.SetActive(false);
        }

        MissionBase m;

        foreach (GameObject p in Players)
        {
            m = p.GetComponent <MissionBase>();
            m.StopPracticeRumbleController();
            m.StopAllRumble();
        }

        StartCoroutine(RemoveAnimations());

        PlayingState = PlayingState.PraticeMode;
        AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.PracticeAudio);
    }
Esempio n. 32
0
        public void LoadWorld(WorldProvider worldProvider, INetworkProvider networkProvider)
        {
            PlayingState playState = new PlayingState(this, GraphicsDevice, worldProvider, networkProvider);

            LoadingWorldState loadingScreen = new LoadingWorldState();

            GameStateManager.AddState("loading", loadingScreen);
            GameStateManager.SetActiveState("loading");

            worldProvider.Load(loadingScreen.UpdateProgress).ContinueWith(task =>
            {
                GameStateManager.RemoveState("play");
                GameStateManager.AddState("play", playState);

                if (networkProvider.IsConnected)
                {
                    GameStateManager.SetActiveState("play");
                }
                else
                {
                    GameStateManager.RemoveState("play");
                    worldProvider.Dispose();
                }

                GameStateManager.RemoveState("loading");
            });
        }
Esempio n. 33
0
 /// <summary>
 /// Plays the given music.
 /// </summary>
 /// <param name="music">Music.</param>
 /// <param name="loop">If set to <c>true</c> loop.</param>
 public void PlayMusic(Sound music, bool loop = true)
 {
     bgmSource.clip = music.clip;
     bgmSource.loop = loop;
     bgmSource.Play();
     musicState = PlayingState.Playing;
 }
Esempio n. 34
0
        public static void CheckForEnemy(Guid enemyId, PlayingState playingState, LevelCollisionDetection levelCollisionDetection)
        {
            AIComponent enemyAIComponent = playingState.AIComponents[enemyId];

            //determine if the player is in line of site
            IEnumerable<Guid> playerEntities = playingState.Entities.Where(x => (x.ComponentFlags & ComponentMasks.Player) == ComponentMasks.Player).Select(x => x.ID);
            foreach (Guid playerid in playerEntities)
            {
                //get the enemy direction
                DirectionComponent enemyDirectionComponent = playingState.DirectionComponents[enemyId];
                float direction = enemyDirectionComponent.Direction;
                if (enemyAIComponent.ActiveState.Peek() != AIState.ATTACK)
                {
                    bool playerSeen = LineOfSiteRayCast.CalculateLineOfSight(playingState.PositionComponents[enemyId].Position, playingState.PositionComponents[playerid].Position, enemyAIComponent.LineOfSight, playingState.DirectionComponents[enemyId].Direction, playingState);
                    if (playerSeen)
                    {
                        //set our path goal
                        enemyAIComponent.EntityToAttack = playerid;
                        enemyAIComponent.ActiveState.Push(AIState.ATTACK);

                        playingState.AIComponents[enemyId] = enemyAIComponent;

                        UpdateEnemyPath(enemyId, playingState);
                        AttackEnemy(enemyId, playingState, levelCollisionDetection);
                    }
                }
            }
        }
Esempio n. 35
0
 /// <summary>
 /// Resumes the music.
 /// </summary>
 public void ResumeMusic()
 {
     if (musicState == PlayingState.Paused)
     {
         audioSource.UnPause();
         musicState = PlayingState.Playing;
     }
 }
Esempio n. 36
0
        public static void DrawPlayingStateDisplayEntities(PlayingState playingState, FollowCamera followCamera, SpriteBatch spriteBatch, Texture2D spriteSheet, GraphicsDeviceManager graphicsDevice)
        {
            IEnumerable<Guid> drawableEntities = playingState.Entities.Where(x => (x.ComponentFlags & ComponentMasks.Drawable) == ComponentMasks.Drawable).Select(x => x.ID);
            foreach (Guid id in drawableEntities)
            {
                Rectangle source = playingState.DisplayComponents[id].Source;
                Vector2 origin = new Vector2(source.Width / 2, source.Height / 2);
                spriteBatch.Draw(spriteSheet, playingState.PositionComponents[id].Position, source, Color.White, playingState.DirectionComponents[id].Direction, origin, 1f, SpriteEffects.None, 0);

            }
        }
Esempio n. 37
0
        public static void DetectAABBProjectileCollision(PlayingState playingState)
        {
            IEnumerable<Guid> projectileEntites = playingState.Entities.Where(x => (x.ComponentFlags & ComponentMasks.Projectile) == ComponentMasks.Projectile).Select(x => x.ID);
            IEnumerable<Guid> playerEntities = playingState.Entities.Where(x => (x.ComponentFlags & ComponentMasks.Player) == ComponentMasks.Player).Select(x => x.ID);
            IEnumerable<Guid> enemyEntities = playingState.Entities.Where(x => (x.ComponentFlags & ComponentMasks.Enemy) == ComponentMasks.Enemy).Select(x => x.ID);

            List<Guid> EntitiesToRemove = new List<Guid>();
            foreach (Guid projectileid in projectileEntites)
            {
                PositionComponent projectilePosition = playingState.PositionComponents[projectileid];
                //foreach (Guid playerid in playerEntities)
                //{
                //    PositionComponent playerPosition = playingState.PositionComponents[projectileid];
                //    if (RectCollision(projectilePosition.Destination, playerPosition.Destination))
                //    {
                //        HealthComponent playerHealthComponent = playingState.HealthComponents[playerid];
                //        DamageComponent projectileDamageComponent = playingState.DamageComponents[projectileid];

                //        playerHealthComponent.Health -= projectileDamageComponent.Damage;

                //        Console.WriteLine("Player Health: " + playerHealthComponent.Health);

                //        playingState.HealthComponents[playerid] = playerHealthComponent;
                //        playingState.DestroyEntity(projectileid);
                //    }
                //}

                foreach (Guid enemyid in enemyEntities)
                {
                    PositionComponent enemyPosition = playingState.PositionComponents[enemyid];
                    AABBComponent aABBComponent = playingState.AABBComponents[enemyid];
                    if (RectCollision(aABBComponent.BoundedBox, aABBComponent.BoundedBox))
                    {
                        HealthComponent enemyHealthComponent = playingState.HealthComponents[enemyid];
                        DamageComponent projectileDamageComponent = playingState.DamageComponents[projectileid];

                        enemyHealthComponent.Health -= projectileDamageComponent.Damage;

                        Console.WriteLine("Enemy Health: " + enemyHealthComponent.Health);

                        playingState.HealthComponents[enemyid] = enemyHealthComponent;
                        EntitiesToRemove.Add(projectileid);
                    }
                }
            }

            foreach (Guid projectileid in EntitiesToRemove)
            {
                playingState.DestroyEntity(projectileid);
            }

        }
Esempio n. 38
0
        public static void DrawDebugTiles(PlayingState playingState, SpriteBatch spriteBatch, Texture2D spriteSheet, GraphicsDevice graphicsDevice)
        {
            Texture2D rect = new Texture2D(graphicsDevice, 80, 30);

            Color[] data = new Color[80 * 30];
            for (int i = 0; i < data.Length; ++i) data[i] = Color.DarkRed;
            rect.SetData(data);

            var debugPaths = playingState.DebugComponents.ToList().Select(d => d.Value.Position);
            foreach (var path in debugPaths)
            {
                Rectangle neighborBoundedBox = new Rectangle((int)(path.X), (int)(path.Y), 16, 16);
                spriteBatch.Draw(rect, neighborBoundedBox, Color.DarkRed);
            }
        }
Esempio n. 39
0
        internal Card PlayCard()
        {
            var context = new PlayingContext(mGame);
            var rootState = new PlayingState(context);

            var validMoves = rootState.GetValidMoves();

            // Exit if only one move is possible.
            if (BitwiseCardHelper.GetGroupCount(validMoves) == 1)
                return GetRandomCard(validMoves);

            bool isCheater = (mGame.Options.DifficultyLevel == GameDifficultyLevel.Cheater);
            var bestNode = TreeSearcher.Search(rootState, 100000, !isCheater);

            return GetRandomCard(bestNode.Move.Group);
        }
Esempio n. 40
0
        public static void DrawEnemyNeighbors(PlayingState playingState, SpriteBatch spriteBatch, Texture2D spriteSheet, GraphicsDevice graphicsDevice)
        {
            Texture2D rect = new Texture2D(graphicsDevice, 80, 30);

            Color[] data = new Color[80 * 30];
            for (int i = 0; i < data.Length; ++i) data[i] = Color.Violet;
            rect.SetData(data);

            IEnumerable<Guid> enemies = playingState.Entities.Where(x => (x.ComponentFlags & ComponentMasks.Enemy) == ComponentMasks.Enemy).Select(x => x.ID);
            foreach (Guid enemyid in enemies)
            {
                var position = playingState.PositionComponents[enemyid].Position;
                var lineOfSite = playingState.AIComponents[enemyid].LineOfSight;
                Rectangle neighborBoundedBox = new Rectangle((int)(position.X - (lineOfSite)), (int)(position.Y - (lineOfSite)), lineOfSite * 2, lineOfSite * 2);
                spriteBatch.Draw(rect, neighborBoundedBox, Color.White);
            }
        }
Esempio n. 41
0
        public static void DrawAABBComponents(PlayingState playingState, SpriteBatch spriteBatch, GraphicsDevice graphicsDevice)
        {
            Texture2D rect = new Texture2D(graphicsDevice, 80, 30);

            Color[] data = new Color[80 * 30];
            for (int i = 0; i < data.Length; ++i) data[i] = Color.Chocolate;
            rect.SetData(data);

            var aabbComponents = playingState.AABBComponents;
            foreach (var aabb in aabbComponents)
            {
                Rectangle destination = aabb.Value.BoundedBox;

                spriteBatch.Draw(rect, destination, Color.White);

            }
        }
Esempio n. 42
0
 public void ResetGame(bool firstTime, bool resetScore)
 {
     playingState = PlayingState.FirstPlayerTurn;
     for (int x = 0; x < 7; x++)
     {
         for (int y = 0; y < 6; y++)
         {
             cells[y * 7 + x] = new Cell(x, y, Cell.Type.Empty);
         }
     }
     if (!firstTime)
     {
         CalculateSizes(new Vector2(0, 0), new Vector2(Game1.G.graphics.PreferredBackBufferWidth,
                 Game1.G.graphics.PreferredBackBufferHeight));
     }
     if (resetScore)
     {
         firstWins = 0; secondWins = 0;
     }
 }
Esempio n. 43
0
        public static void UpdateProjectiles(PlayingState playingState)
        {
            //IEnumerable<Guid> projectileEntities = playingState.Entities.Where(x => (x.ComponentFlags & ComponentMasks.Projectile) == ComponentMasks.Projectile).Select(x => x.ID).ToList();
            //foreach (Guid projectileId in projectileEntities)
            //{
            //    PositionComponent positionComponent = playingState.PositionComponents[projectileId];
            //    DirectionComponent directionComponent = playingState.DirectionComponents[projectileId];
            //    VelocityComponent speedComponent = playingState.VelocityComponents[projectileId];

            //    double vX = speedComponent.xVelocity * Math.Cos(directionComponent.Direction);
            //    double vY = speedComponent.yVelocity *Math.Sin(directionComponent.Direction);

            //    Vector2 newPosition = new Vector2(positionComponent.Position.X + (float)vX, positionComponent.Position.Y + (float)vY);
            //    Rectangle destination = new Rectangle((int)newPosition.X, (int)newPosition.Y, positionComponent.Destination.Width, positionComponent.Destination.Height);

            //    positionComponent.Position = newPosition;
            //    positionComponent.Destination = destination;

            //    playingState.PositionComponents[projectileId] = positionComponent;
            //}
        }
Esempio n. 44
0
        public static void DrawEnemyActivePath(PlayingState playingState, SpriteBatch spriteBatch, Texture2D spriteSheet, GraphicsDevice graphicsDevice)
        {
            Texture2D rect = new Texture2D(graphicsDevice, 80, 30);

            Color[] data = new Color[80 * 30];
            for (int i = 0; i < data.Length; ++i) data[i] = Color.Violet;
            rect.SetData(data);

            IEnumerable<Guid> enemies = playingState.Entities.Where(x => (x.ComponentFlags & ComponentMasks.Enemy) == ComponentMasks.Enemy).Select(x => x.ID);
            foreach (Guid enemyid in enemies)
            {
                AIComponent aiComponent = playingState.AIComponents[enemyid];
                if (aiComponent.ActivePath != null)
                {
                    foreach (var path in aiComponent.ActivePath)
                    {
                        Rectangle activePathTile = new Rectangle((int)(path.TilePosition.X), (int)(path.TilePosition.Y), 16, 16);
                        spriteBatch.Draw(rect, activePathTile, Color.White);
                    }
                }
            }
        }
Esempio n. 45
0
    private void Awake()
    {
        // http://clearcutgames.net/home/?p=437
        // First we check if there are any other instances conflicting
        if (_instance != null && _instance != this)
        {
            // If that is the case, we destroy other instances
            Destroy(gameObject);
        }

        // Here we save our singleton instance
        _instance = this;

        // Furthermore we make sure that we don't destroy between scenes (this is optional)
        DontDestroyOnLoad(gameObject);

        Screen.showCursor = false;

        this.PlayingState = PlayingState.TalkingBeforeControllerCalibration;
        ReadyNotYetSpawned = false;

        readyCounter = -1;
    }
Esempio n. 46
0
 void Stabalize()
 {
     if (_currentAIState == AIStates.PARALYZED)
     {
         if (Time.time > stablizeTime + stablizeCooldown)
         {
             stablizeTime = Time.time;
             rb.velocity = Vector3.zero;
             rb.angularVelocity = Vector3.zero;
             _currentAIState = AIStates.DECIDING;
         }
     }
     else if (_currentPlayingState == PlayingState.STUNNED)
     {
         if (Time.time > playStablizeTime + playStablizeCooldown)
         {
             playStablizeTime = Time.time;
             rb.velocity = Vector3.zero;
             rb.angularVelocity = Vector3.zero;
             _currentPlayingState = PlayingState.SETTING_UP;
         }
     }
 }
Esempio n. 47
0
 void ResetAIStates()
 {
     idleTimeLeft = Random.Range(5, 10);
     _currentReturningState = ReturningState.NONE;
     _currentIdleState = IdleState.NONE;
     _currentRoamingState = RoamingState.NONE;
     _currentPlayingState = PlayingState.NONE;
 }
Esempio n. 48
0
 void Playing()
 {
     switch (_currentPlayingState)
     {
         case PlayingState.NONE:
             break;
         case PlayingState.SETTING_UP:
             targetLocation = ExerciseNode.transform.position;
             _currentPlayingState = PlayingState.MOVING;
             break;
         case PlayingState.WAITING:
             transform.position = new Vector3(transform.position.x, lastLocation.y + ((float)Math.Sin(Time.time) / floatingStrength), transform.position.z);
             break;
         case PlayingState.STUNNED:
             break;
         case PlayingState.MOVING:
             transform.position = Vector3.MoveTowards(transform.position, targetLocation,Time.deltaTime / 3);
             if (ReachedTarget())
                 _currentPlayingState = PlayingState.WAITING;
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
Esempio n. 49
0
        void CheckParalyze()
        {
            if (rb.velocity != Vector3.zero && rb.angularVelocity != Vector3.zero)
            {
                if (_currentAIState == AIStates.PLAYING)
                    _currentPlayingState = PlayingState.STUNNED;
                else
                    _currentAIState = AIStates.PARALYZED;

            }

            //_currentAIState = AIStates.IDLING;
        }
Esempio n. 50
0
 public void Play()
 {
     _currentAIState = AIStates.PLAYING;
     if (_currentPlayingState == PlayingState.NONE)
         _currentPlayingState = PlayingState.SETTING_UP;
 }
Esempio n. 51
0
        public void CreateBoundingRects(TmxList<TmxObject> rectangles, PlayingState playingState)
        {
            foreach (TmxObject rectangle in rectangles)
            {
                Guid id = playingState.CreateEntity();
                playingState.Entities.Where(l => l.ID == id).First().ComponentFlags = ComponentMasks.LevelObjects;
                Vector2 position = new Vector2((float)rectangle.X, (float)rectangle.Y);
                Rectangle boundedBox = new Rectangle((int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, (int)rectangle.Height);

                playingState.DirectionComponents[id] = new DirectionComponent() { Direction = 0f };
                playingState.DisplayComponents[id] = new DisplayComponent() { Source = new Rectangle(342, 108, TileMap.TileSize, TileMap.TileSize) };
                playingState.PositionComponents[id] = new PositionComponent() { Position = position };
                playingState.AABBComponents[id] = new AABBComponent() { BoundedBox = boundedBox };
                playingState.MapObjectComponents[id] = new MapObjectComponent() { Type = MapObjectType.Wall };
            }
        }
Esempio n. 52
0
    /*public void Pause()
    {
        if (PlayingState != PlayingState.Paused)
        {
            lastState = PlayingState;

            PlayingState = PlayingState.Paused;
            Time.timeScale = 0;
            MainLight.enabled = false;
        }
        else if (PlayingState == PlayingState.Paused)
        {
            Time.timeScale = 1;
            PlayingState = lastState;
            MainLight.enabled = true;

        }
    }*/
    IEnumerator StartRumblePractices()
    {
        if (RumblePracticeStart) // only if not skipped
            this.PlayingState = PlayingState.ControllerCalibration;

        if (ControllerGUIToRumble != null)
        {
            ControllerGUIToRumble.SetActive(true);
            ControllerGUIToRumble.GetComponent<Animator>().enabled = false;
        }

        MissionBase m;
        for (int i = 0; i < Players.Count; i++)
        {
            if (RumblePracticeStart) // only if not skipped
            {

                m = Players[i].GetComponent<MissionBase>();

                if (GUIRumbleCounter < 5)
                {
                    //MissionManager.Instance.PracticeControllerRumbleGUI(number-1);

                    bool showPunchTween = (i == 0); // only player index 0 makes HUD iTween

                    m.StartPracticeRumbleController(GUIRumbleCounter, showPunchTween);
                }
                else
                {
                    m.StopPracticeRumbleController();

                    if (ControllerGUIToRumble.GetComponent<Animator>() != null)
                    {
                        if (ControllerGUIToRumble.GetComponent<Animator>().enabled == false)
                        {
                            AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.VibrationExplain);
                            yield return new WaitForSeconds(AudioManager.Instance.VibrationExplain.length - 2.5f);
                            if (ControllerGUIToRumble.GetComponent<Animator>() != null)
                                ControllerGUIToRumble.GetComponent<Animator>().enabled = true;
                        }

                    }

                    StartCoroutine(RemoveAnimations());
                }
            }
        }

        float waitTime = 0;
        switch (GUIRumbleCounter)
        {
            case 0:
            case 1:
                waitTime = 1;
                break;

            case 2:
                waitTime = 1.8f;
                break;

            case 3:
                waitTime = 2.3f;
                break;

            default:
                waitTime = 2.5f;
                break;

        }
        yield return new WaitForSeconds(waitTime);
        MissionManager.Instance.HideControllerGUIs();

        yield return new WaitForSeconds(0.5f);
        if (GUIRumbleCounter < 5)
        {
            GUIRumbleCounter++;

            if (RumblePracticeStart) // only repeat if this is true
                StartCoroutine(StartRumblePractices());

        }
        else
            SkipTutorialAndGoToWait();
    }
Esempio n. 53
0
    void Update()
    {
        if (PlayingState == PlayingState.Playing)
        {
            TimeLeft -= Time.deltaTime;

            if (TimeLeft <= 0 && CurrentRoundJustEnded == false)
            {
                CurrentRoundJustEnded = true;
                PlayingState = PlayingState.DisplayingScore;
                MissionManager.Instance.RemoveAllMissions();
                GoKitTweenExtensions.shake(Camera.main.transform, 0.5f, new Vector3(0.8f, 0.8f, 0.8f), GoShakeType.Position);

                // TODO: who won?

                int highestScore = -10000;
                int numberOfPeopleWithSameHighScore = 0;

                // check highest score
                TargetIDColorState winningColor = TargetIDColorState.NotAssigned;
                foreach (GameObject g in Players)
                {
                    Player p = g.GetComponent<Player>();
                    if (p.Points >= highestScore)
                    {
                        highestScore = p.Points;
                        winningColor = g.GetComponent<TargetIDColor>().TargetIDColorState;
                    }
                }

                // check if draw
                foreach (GameObject g in Players)
                {
                    Player p = g.GetComponent<Player>();

                    if (p.Points == highestScore)
                    {
                        //Debug.Log(p.ToString() + p.Points);
                        numberOfPeopleWithSameHighScore++;
                    }
                }

                if (numberOfPeopleWithSameHighScore > 1) // draw?
                    winningColor = TargetIDColorState.NotAssigned;

                Destroy(GameObject.Find("Music")); // dont play game music when showing score
                switch(winningColor)
                {
                    case TargetIDColorState.RedOne:
                        AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.WinRed);
                        if (DataSaver.Instance != null)
                        {
                            foreach (var score in DataSaver.Instance.highScores)
                                score.RedWins++;
                        }
                        //Debug.Log("Red won");
                        break;

                    case TargetIDColorState.BlueTwo:
                        AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.WinBlue);
                        if (DataSaver.Instance != null)
                        {
                            foreach (var score in DataSaver.Instance.highScores)
                                score.BlueWins++;
                        }
                        //Debug.Log("blue won");
                        break;

                    case TargetIDColorState.GreenThree:
                        AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.WinGreen);
                        if (DataSaver.Instance != null)
                        {
                            foreach (var score in DataSaver.Instance.highScores)
                                score.GreenWins++;
                        }
                        //Debug.Log("green won");
                        break;

                    case TargetIDColorState.PinkFour:
                        AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.WinPink);
                        if (DataSaver.Instance != null)
                        {
                            foreach (var score in DataSaver.Instance.highScores)
                                score.PinkWins++;
                        }
                        //Debug.Log("pink won");
                        break;

                    case TargetIDColorState.NotAssigned:
                        AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.WinDraw);
                        //Debug.Log("draw won");
                        break;

                }
                Instantiate(Congratulations);
                if (DataSaver.Instance != null)
                    DataSaver.Instance.SaveScoresToDataFile();
            }
        }
        /*if (PlayingState == PlayingState.DisplayingScore)
            Camera.GetComponent<GlitchEffect>().enabled = true;
        else
            Camera.GetComponent<GlitchEffect>().enabled = false;*/

        if (Input.GetKeyDown(KeyCode.Escape))
            Application.Quit();

        if (Input.GetKeyDown(KeyCode.R))
            Application.LoadLevel(0);
    }
Esempio n. 54
0
    public void ResetLevel()
    {
        /*if (!musicIsPlaying)
        {
            Instantiate(MusicPlayer);
            musicIsPlaying = true;
        }*/
        PlayingState = PlayingState.Playing;

        if (ControllerGUIToRumble != null)
            Destroy(ControllerGUIToRumble);

        foreach (ResetObjectPosition r in AllObjectsToReset) // reset all objects to initial state
            r.ResetMyPosition();

        TimeLeft = TimePerRound;
        CurrentRoundJustEnded = false;

        CurrentRound--;

        if (CurrentRound <= 0)
        {
            PlayingState = PlayingState.GameIsOver;
            return;
        }

        PlayingState = PlayingState.WaitingForEverbodyToGetReady;
        AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.NewMissionsFirstTime);

        foreach (GameObject p in Players)
            p.GetComponent<Player>().Reset();

        InvokeRepeating("AllReady", 0, 0.01f);

        MissionManager.Instance.GetNewMissions();

        //GoKitTweenExtensions.shake(Camera.main.transform, 0.5f, new Vector3(0.2f, 0.2f, 0.2f), GoShakeType.Position);

        //if(WaitForReady)
        //{

        //}
        //else
          //  PlayingState = PlayingState.Playing;
    }
Esempio n. 55
0
 protected void EndCheck(Cell cell, bool win)
 {
     if (cell.type == Cell.Type.FirstPlayer)
     {
         if (win)
         {
             playingState = PlayingState.FirstPlayerWin;
             firstWins++;
         }
         else if (!win && cells.All(x => x.type != Cell.Type.Empty))
             playingState = PlayingState.DrawGame;
         else
             playingState = PlayingState.SecondPlayerTurn;
     }
     else
     {
         if (win)
         {
             playingState = PlayingState.SecondPlayerWin;
             secondWins++;
         }
         else if (!win && cells.All(x => x.type != Cell.Type.Empty))
             playingState = PlayingState.DrawGame;
         else
             playingState = PlayingState.FirstPlayerTurn;
     }
 }
Esempio n. 56
0
        public void CreatePlayerSpawn(TmxList<TmxObject> playerSpawns, PlayingState playingState)
        {
            foreach (TmxObject playerspawn in playerSpawns)
            {
                Guid id = playingState.CreateEntity();
                playingState.Entities.Where(x => x.ID == id).First().ComponentFlags = ComponentMasks.Player;

                playingState.DirectionComponents[id] = new DirectionComponent() { Direction = 0f };
                playingState.DisplayComponents[id] = new DisplayComponent() { Source = new Rectangle(451, 470, TileMap.TileSize, TileMap.TileSize) };
                playingState.HealthComponents[id] = new HealthComponent() { Health = 100 };
                playingState.PositionComponents[id] = new PositionComponent() { Position = new Vector2((float)playerspawn.X, (float)playerspawn.Y) };
                playingState.VelocityComponents[id] = new VelocityComponent() { xVelocity = 0f, yVelocity = 0f, xTerminalVelocity = 6f, yTerminalVelocity = 6f };
                playingState.AccelerationComponents[id] = new AccelerationComponent() { xAcceleration = 6f, yAcceleration = 6f };

                //our origin is going to offset our bounded box
                playingState.AABBComponents[id] = new AABBComponent(){ BoundedBox = new Rectangle((int)playerspawn.X - (TileMap.TileSize / 2), (int)playerspawn.Y - (TileMap.TileSize / 2), TileMap.TileSize, TileMap.TileSize)};
            }
        }
Esempio n. 57
0
        public void CreateEnemySpawns(TmxList<TmxObject> enemySpawns, PlayingState playingState)
        {
            LevelCollisionDetection levelCollisionDetection = new LevelCollisionDetection(TileMap, TileMap.TileSize);
            foreach (TmxObject enemypawn in enemySpawns)
            {
                Guid id = playingState.CreateEntity();
                playingState.Entities.Where(x => x.ID == id).First().ComponentFlags = ComponentMasks.Enemy;                

                playingState.DirectionComponents[id] = new DirectionComponent() { Direction = (float)(enemypawn.Rotation * (Math.PI / 180)) };
                playingState.DisplayComponents[id] = new DisplayComponent() { Source = new Rectangle(343, 470, TileMap.TileSize, TileMap.TileSize) };
                playingState.HealthComponents[id] = new HealthComponent() { Health = 15 };
                playingState.PositionComponents[id] = new PositionComponent() { Position = new Vector2((float)enemypawn.X + (TileMap.TileSize / 2), (float)enemypawn.Y + (TileMap.TileSize / 2)) };
                playingState.VelocityComponents[id] = new VelocityComponent() { xVelocity = 0f, yVelocity = 0f, xTerminalVelocity = 3f, yTerminalVelocity = 3f };
                playingState.AccelerationComponents[id] = new AccelerationComponent() { xAcceleration = 3f, yAcceleration = 3f };
                playingState.DamageComponents[id] = new DamageComponent()
                {
                    AttackRange = 1 * TileMap.TileSize,
                    Damage = 5
                };

                //our origin is going to offset our bounded box
                playingState.AABBComponents[id] = new AABBComponent() { BoundedBox = new Rectangle((int)enemypawn.X, (int)enemypawn.Y, TileMap.TileSize, TileMap.TileSize) };

                //parse patrol paths
                string patrolPaths = enemypawn.Properties["PatrolPath"];
                List<Vector2> PatrolVectors = new List<Vector2>();
                if (!string.IsNullOrWhiteSpace(patrolPaths))
                {
                    string[] newPaths = patrolPaths.Split('|'); 
                    
                    for (int i = 0; i < newPaths.Length; i++)
                    {
                        newPaths[i] = newPaths[i].Replace("(", "");
                        newPaths[i] = newPaths[i].Replace(")", "");
                        int x = Int32.Parse(newPaths[i].Split(',')[0]);
                        int y = Int32.Parse(newPaths[i].Split(',')[1]);

                        //center our points too
                        x = (x * TileMap.TileSize) + (TileMap.TileSize / 2);
                        y = (y * TileMap.TileSize) + (TileMap.TileSize / 2);

                        PatrolVectors.Add(new Vector2(x, y));
                    }
                }

                playingState.AIComponents[id] = new AIComponent()
                {
                    ActiveState = new Stack<AIState>(),
                    LineOfSight = 6 * TileMap.TileSize,
                    PatrolPath = PatrolVectors,
                    ActivePath = new LinkedList<Tile>(),
                    Astar = TileMap.aStar,
                    AITree = AIPawnSystem.CreatePawnTree(id, playingState, levelCollisionDetection, TileMap.TileSize, TileMap.TileSize)
                };
                playingState.AIComponents[id].ActiveState.Push(AIState.STILL);
                playingState.LabelComponents[id] = new LabelComponent() { Label = "", Position = new Vector2((float)enemypawn.X, (float)(enemypawn.Y - 5)) };
            }
        }
Esempio n. 58
0
    IEnumerator StartCalibrationVoice()
    {
        this.PlayingState = PlayingState.TalkingBeforeControllerCalibration;

        float length = AudioManager.Instance.CalibrationAudio.length;
        AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.CalibrationAudio);

        yield return new WaitForSeconds(length);
        StartCoroutine(StartRumblePractices());
    }
Esempio n. 59
0
    // used to go directly from "tutorial" to wait for ready
    public void SkipTutorialAndGoToWait()
    {
        StopCoroutine("StartCalibrationVoice");
        StopCoroutine("StartRumblePractices");
        RumblePracticeStart = false;

        //AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.VibrationExplain);

        //yield return new WaitForSeconds(AudioManager.Instance.VibrationExplain.length);

        if (ControllerGUIToRumble != null)
            ControllerGUIToRumble.SetActive(false);

        MissionBase m;
        foreach (GameObject p in Players)
        {
            m = p.GetComponent<MissionBase>();
            m.StopPracticeRumbleController();
            m.StopAllRumble();
        }

        StartCoroutine(RemoveAnimations());

        PlayingState = PlayingState.PraticeMode;
        AudioManager.Instance.PlayAnnouncerVoice(AudioManager.Instance.PracticeAudio);
    }
Esempio n. 60
0
        public void ImportTMX(ContentManager content, string filepath, int tilesize, SpriteFont font, PlayingState playingState)
        {
            TileMap = new TileMap();

            var map = new TmxMap(filepath);
            TileMap.RowCount = map.Width;
            TileMap.ColumnCount = map.Height;


            //get and set tile map details
            var tileMap = map.Tilesets["Basic"];
            CreateTileMap(tileMap);

            //get and set level layer
            var levelLayer = map.Layers["Level"];
            CreateTileArray(levelLayer);

            //get and set level bounding rects
            var boudingRects = map.ObjectGroups["Level Rects"].Objects;
            CreateBoundingRects(boudingRects, playingState);

            //get and set player spawn
            var playersSpawn = map.ObjectGroups["Player Spawn"].Objects;
            CreatePlayerSpawn(playersSpawn, playingState);

            //get and set enemy spawns
            var enemySpawns = map.ObjectGroups["Enemy Spawns"].Objects;
            CreateEnemySpawns(enemySpawns, playingState);

            this.Font = font;
        }