public override void Update(CVGameTime gameTime)
        {
            Random r;

            if (_spawnedEnemy != null && _spawnedEnemy.Active == false)
            {
                _spawnedEnemy   = null;
                r               = new Random();
                _enemySpawnTime = r.Next(200, 2000);
            }
            if (!this.CurrentStage.Game.LaunchParameters.ContainsKey("DoNotSpawnEnemies"))
            {
                if (_spawnedEnemy == null && CurrentStage.ScreenCoordinates().Intersects(VirtualBox()) && VirtualBox().Right > CurrentStage.ScreenCoordinates().Right)
                {
                    _enemySpawnTime -= gameTime.ElapsedGameTime.TotalMilliseconds;

                    if (_enemySpawnTime < 0)
                    {
                        Vector2 spawnLocation =
                            new Vector2(this.VirtualBox().Left + (this.CurrentStage.ScreenCoordinates().Right - this.VirtualBox().Left),
                                        VirtualBox().Bottom);

                        CurrentStage.AddEnemy(_enemyType, spawnLocation);

                        r = new Random();
                        // TODO: rework this so that enemies spawn more similarly to classic Contra
                        _enemySpawnTime = Math.Sqrt(r.Next(50000, 4000000));
                    }

                    base.Update(gameTime);
                }
            }
        }
Exemplo n.º 2
0
        public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e)
        {
            if (keyCode == Keycode.VolumeDown || keyCode == Keycode.VolumeUp)
            {
                lock (SelectedGestureClass)
                {
                    if (!_collectingData)
                    {
                        RelayToast("Listening...");
                        _collectingData = true;

                        ResetStage("Melee stage");
                        //CuePrompter?.MarkGestureStart();
                        Stopwatch.Stop();
                        SingleClickWatch.Restart();
                        Delay = Stopwatch.Elapsed;
                        CurrentStage.Activate();
                        return(true);
                    }
                }
                if (_collectingData)
                {
                    return(true);
                }
            }
            return(base.OnKeyDown(keyCode, e));
        }
 public override void Die(CVGameTime gameTime)
 {
     CurrentStage.AddExplosion(this.BoundingBox().Center.ToVector() - new Vector2(ExplosionAnimation.FrameWidth / 2, ExplosionAnimation.FrameHeight / 2), ExplosionAnimation, ExplosionSound);
     IsDead = true;
     VulnerableToBullets  = false;
     CollisionIsHazardous = false;
 }
Exemplo n.º 4
0
    private bool EndingConditionReached()
    {
        if (playerController.Health <= 0)
        {
            CurrentStage.SetStageResult(StageResult.Loss);
            AudioManager.Instance.PlaySoundAndPauseMusic(AudioGameOver);
            return(true);
        }
        if (CurrentStage.WinConditionReached())
        {
            CurrentStage.SetStageResult(StageResult.Win);
            if (gameState == GameState.Stage3)
            {
                AudioManager.Instance.PlaySoundAndPauseMusic(AudioWin);
            }
            else
            {
                AudioManager.Instance.PlaySound(AudioStageComplete);
            }
            return(true);
        }


        return(false);
    }
 /// <summary>
 /// Validates this instance.
 /// </summary>
 /// <exception cref="InvalidMessageBody"></exception>
 /// <exception cref="InvalidMessageHeader"></exception>
 /// <exception cref="InvalidMainActivityId"></exception>
 /// <exception cref="InvalidStageActivityId"></exception>
 /// <exception cref="InvalidBusinessTransactionException">
 /// </exception>
 /// <exception cref="InvalidStageNameException"></exception>
 public void Validate()
 {
     if (MessageBody.IsNullOrEmpty())
     {
         throw new InvalidMessageBody();
     }
     if (MessageHeader.IsNullOrEmpty())
     {
         throw new InvalidMessageHeader();
     }
     if (MainActivityId == default)
     {
         throw new InvalidMainActivityId();
     }
     if (StageActivityId == default)
     {
         throw new InvalidStageActivityId();
     }
     if (BusinessTransaction.IsNullOrEmpty())
     {
         throw new InvalidBusinessTransactionException();
     }
     if (BusinessProcess.IsNullOrEmpty())
     {
         throw new InvalidBusinessTransactionException();
     }
     if (CurrentStage.IsNullOrEmpty())
     {
         throw new InvalidStageNameException();
     }
 }
Exemplo n.º 6
0
        public override void Die(CVGameTime gameTime)
        {
            IsDead = true;
            Active = false;
            Vector2 firstExplosionPosition = this.WorldPosition;

            CurrentStage.AddExplosion(firstExplosionPosition + new Vector2(0, 0), ExplosionAnimation.CreateCopy(), ExplosionSound, 0);
            CurrentStage.AddExplosion(firstExplosionPosition + new Vector2(-15, -10), ExplosionAnimation.CreateCopy(), ExplosionSound, 100);
            CurrentStage.AddExplosion(firstExplosionPosition + new Vector2(-15, 10), ExplosionAnimation.CreateCopy(), null, 200);
            CurrentStage.AddExplosion(firstExplosionPosition + new Vector2(5, -10), ExplosionAnimation.CreateCopy(), ExplosionSound, 300);
            CurrentStage.AddExplosion(firstExplosionPosition + new Vector2(5, 10), ExplosionAnimation.CreateCopy(), null, 400);
            CurrentStage.AddExplosion(firstExplosionPosition + new Vector2(25, -10), ExplosionAnimation.CreateCopy(), ExplosionSound, 500);
            CurrentStage.AddExplosion(firstExplosionPosition + new Vector2(25, 10), ExplosionAnimation.CreateCopy(), null, 600);
            CurrentStage.AddExplosion(firstExplosionPosition + new Vector2(45, -10), ExplosionAnimation.CreateCopy(), ExplosionSound, 700);
            CurrentStage.AddExplosion(firstExplosionPosition + new Vector2(45, 10), ExplosionAnimation.CreateCopy(), null, 800);
            CurrentStage.AddExplosion(firstExplosionPosition + new Vector2(65, -10), ExplosionAnimation.CreateCopy(), ExplosionSound, 900);
            CurrentStage.AddExplosion(firstExplosionPosition + new Vector2(65, 10), ExplosionAnimation.CreateCopy(), null, 1000);

            foreach (var tile in CurrentStage.StageTiles.Where(t => t.DestructionLayer1GID > 0))
            {
                tile.Status = StageTile.TileStatus.Destroyed;
            }

            CurrentStage.StartComplete(gameTime, this);
        }
Exemplo n.º 7
0
    IEnumerator DealDamage()
    {
        currentStage = CurrentStage.Spectating;
        foreach (Player player in toDamage.Keys)
        {
            while (player.GetComponent <Rigidbody2D>().velocity != Vector2.zero)
            {
                yield return(new WaitForFixedUpdate());
            }
        }
        foreach (Player player in toDamage.Keys)
        {
            player.attacked = false;
            cam.SetTarget(player.transform);
            yield return(new WaitForSeconds(0.25f));

            for (int i = 0; i < toDamage[player]; i++)
            {
                player.health--;
                yield return(new WaitForSeconds(0.02f));
            }
            yield return(new WaitForSeconds(0.25f));
        }
        toDamage = new Dictionary <Player, int>();
        cam.SetTarget(CurrentPlayer.transform);
        PostTurnEnd();
    }
Exemplo n.º 8
0
        public List <StageTile> getCurrentPlatformTiles()
        {
            List <StageTile> currentPlatformTiles = new List <StageTile>();

            if (this.IsOnGround)
            {
                Rectangle actorbounds = this.BoundingBox();

                //TODO: borrowing code from HandleCollisions, possible consolidation?
                int leftTile   = (int)Math.Floor((float)actorbounds.Left / CurrentStage.TileWidth);
                int rightTile  = (int)Math.Ceiling(((float)actorbounds.Right / CurrentStage.TileWidth)) - 1;
                int bottomTile = (int)Math.Ceiling(((float)actorbounds.Bottom / CurrentStage.TileHeight)) - 1;

                for (int iIndex = leftTile; iIndex <= rightTile; iIndex++)
                {
                    currentPlatformTiles.Add(CurrentStage.getStageTileByGridPosition(iIndex, bottomTile));
                }

                return(currentPlatformTiles);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 9
0
    void CreateGhosts()
    {
        var ghostPlaceList = CurrentStage.GetGhostStartPlace();

        for (int i = 0; i < ghostPlaceList.Count; i++)
        {
            Ghost ghost;
            switch (i % 4)
            {
            case 1:
                ghost = Instantiate(prefPinky).GetComponent <Pinky>();
                break;

            case 2:
                ghost = Instantiate(prefInky).GetComponent <Inky>();
                break;

            case 3:
                ghost = Instantiate(prefClyde).GetComponent <Clyde>();
                break;

            default:
                ghost = Instantiate(prefBlinky).GetComponent <Blinky>();
                break;
            }
            ghost.Init(ghostPlaceList[i], CurrentStage.Min, CurrentStage.Max);
            GhostList.Add(ghost);
        }
    }
Exemplo n.º 10
0
    public void CheckStageOver()
    {
        int foodCount = FoodList.Count;

        eatenFoodCount = 0;

        foreach (var child in FoodList)
        {
            if (child.IsEaten)
            {
                eatenFoodCount++;
            }
        }

        if (!isFruitCreated && eatenFoodCount > foodCount * 0.5f)
        {
            Vector3 createPosition = CurrentStage.GetFruitCreatePosition();
            Fruit   fruit          = Instantiate(prefFruit, createPosition, Quaternion.identity).GetComponent <Fruit>();
            fruit.Init(fruitIndex);
            isFruitCreated = true;
        }

        if (eatenFoodCount == foodCount)
        {
            SetGameState(EState.StageOver);
        }
    }
Exemplo n.º 11
0
 protected void SetupLevelStage(bool runStageScript)
 {
     if (runStageScript)
     {
         CurrentStage.Start();
     }
 }
Exemplo n.º 12
0
        public void SetStageVariables()
        {
            CurrentStage.Restart();

            notesMissed = 0;

            piggyBankSpawner.Stop();
            if (CurrentStage.HasFlag(Stage.StageFlags.PigsEnabled))
            {
                piggyBankSpawner.Start();
            }

            vacuumSpawner.Stop();
            if (CurrentStage.HasFlag(Stage.StageFlags.VacuumsEnabled))
            {
                vacuumSpawner.Interval = CurrentStage.VacuumSpawnTime;
                vacuumSpawner.Start();
            }

            noteSpawner.Stop();
            if (CurrentStage.HasFlag(Stage.StageFlags.NotesEnabled))
            {
                noteSpawner.Interval = CurrentStage.NoteSpawnTime;
                noteSpawner.Start();
            }

            if (!CurrentStage.HasFlag(Stage.StageFlags.LaserPlayerEnabled))
            {
                laserPlayer.FiringLaser = false;
                SoundController.StopAllLoops();
            }
        }
Exemplo n.º 13
0
 void FixedUpdate()
 {
     if (CurrentStage)
     {
         CurrentStage.FixedUpdate();
     }
 }
Exemplo n.º 14
0
        public override bool OnKeyUp([GeneratedEnum] Keycode keyCode, KeyEvent e)
        {
            if (keyCode == Keycode.VolumeDown || keyCode == Keycode.VolumeUp)
            {
                if (_collectingData && !_finalizingGesture)
                {
                    lock (SelectedGestureClass)
                    {
                        _collectingData    = false;
                        _finalizingGesture = true;

                        // Halt the gesture-collection stage and query it.
                        Task.Run(async() =>
                        {
                            await Task.Delay(250);

                            var resultData = CurrentStage.StopAndReturnResults();
                            var resultSeq  = new Sequence <DKS>()
                            {
                                SourcePath = resultData
                            };
                            resultSeq.Metadata = CurrentStage.GetMetadata(GetAccelForDatapoint);
                            ResolveEndOfGesture(resultSeq);
                        });
                        return(true); // Handled it, thanks.
                    }
                }
            }
            return(base.OnKeyUp(keyCode, e));
        }
Exemplo n.º 15
0
 public General(DateTime birthDate, string name, string description, CurrentStage stage, string userId)
 {
     BirthDate   = birthDate;
     Name        = name;
     Description = description;
     Stage       = stage;
     UserId      = userId;
 }
Exemplo n.º 16
0
        private void Update()
        {
            var currentColor = text.color;

            if (currentStage == CurrentStage.wait)
            {
                waitedAlready += Time.deltaTime;
                if (waitedAlready >= wait)
                {
                    currentStage = CurrentStage.fadeOut;
                }
                else
                {
                    return;
                }
            }

            if (fadeIn && currentStage == CurrentStage.fadeIn)
            {
                var targetAlpha = initialColor.a;
                currentColor.a += speed * Time.deltaTime;
                text.color      = currentColor;

                if (currentColor.a >= initialColor.a)
                {
                    if (fadeOut)
                    {
                        if (wait <= 0)
                        {
                            currentStage = CurrentStage.fadeOut;
                        }
                        else
                        {
                            currentStage = CurrentStage.wait;
                        }

                        return;
                    }
                    else
                    {
                        Final();
                    }
                }
            }

            if (fadeOut && currentStage == CurrentStage.fadeOut)
            {
                if (currentColor.a > 0)
                {
                    currentColor.a -= speed * Time.deltaTime;
                    text.color      = currentColor;
                }
                else
                {
                    Final();
                }
            }
        }
Exemplo n.º 17
0
        public void SetStage(GameStage.Stage name)
        {
            GameStage stage;

            if (stages.TryGetValue(name, out stage))
            {
                CurrentStage = stage;
                CurrentStage.Start();
            }
        }
Exemplo n.º 18
0
 void PreTurnEnd()
 {
     if (preTurnOver)
     {
         return;
     }
     currentStage       = CurrentStage.Turn;
     preTurnLengthDelta = preTurnLength;
     preTurnOver        = true;
 }
Exemplo n.º 19
0
 void TrackerDestroyed()
 {
     if (toDamage.Count != 0)
     {
         StartCoroutine(DealDamage());
     }
     else
     {
         currentStage = CurrentStage.PostTurn;
     }
 }
Exemplo n.º 20
0
    public void SetGameState(EState state)
    {
        GameState = state;

        switch (state)
        {
        case EState.Reset:
            Player.ResetData();

            foreach (var child in GhostList)
            {
                child.ResetData();
            }

            SetGameState(EState.Prepare);
            break;

        case EState.Prepare:
            CurrentStage.SetActiveReadyText(true);
            AudioManager.Instance.PlaySound(EBgmId.StartMusic);
            AudioManager.Instance.SetVolume(0.5f);
            StartCoroutine(CountDownPrepareTime());
            break;

        case EState.Play:
            AudioManager.Instance.SetVolume(1.0f);
            AudioManager.Instance.PlayRandomBgm();
            AudioManager.Instance.PlayGhostSound(true);
            CurrentStage.SetActiveReadyText(false);
            break;

        case EState.PacManDie:
            Player.Die();
            lifeCount--;
            StageUIManager.Instance.SetLifeCount(lifeCount);
            StartCoroutine(CountDownResetTime());
            break;

        case EState.GameOver:
            AudioManager.Instance.StopBgm();
            StartCoroutine(StartGameOverAnimation());
            break;

        case EState.StageOver:
            AudioManager.Instance.StopBgm();
            AudioManager.Instance.PlayGhostSound(false);
            fruitIndex++;
            StartCoroutine(CountDownStageOverTime());
            ScoreManager.Instance.SaveCurrentScore();
            break;
        }
    }
Exemplo n.º 21
0
        public void InitializeBridge(ContentManager content, Point coordinates, int BridgeLength)
        {
            StageTile bridgestart = CurrentStage.getStageTileByWorldPosition(coordinates.X, coordinates.Y);

            //for (int i = 0; i < currentStage.; i++)
            for (int i = 0; i < BridgeLength; i++)
            {
                bridgepieces.Add(CurrentStage.getStageTileByGridPosition(bridgestart.X + i, bridgestart.Y));
            }

            _explosionSound          = content.Load <SoundEffect>("Sounds/Explosion2");
            _explosionAnimationStrip = content.Load <Texture2D>("Sprites/Explosion2");
        }
Exemplo n.º 22
0
        public void LoadGameData(string heroName)
        {
            var heroSave = Storage.GetHero(heroName);

            try
            {
                CurrentStage = StageFactory.LoadStage(this, heroName, heroSave.CurrentStage);
                CurrentStage.RefreshFieldOfView(CurrentStage.CurrentHero.Position);
            }
            catch (StageNotFoundExpection ex)
            {
                throw;
            }
        }
Exemplo n.º 23
0
    public void TakeTurn()
    {
        currentStage              = CurrentStage.PreTurn;
        preTurnOver               = false;
        CurrentPlayer.isTurn      = true;
        CurrentPlayer.isDangerous = true;

        Camera.main.transform.GetComponent <GameCamera>().SetTarget(CurrentPlayer.transform);
        CurrentPlayer.PreTurnEnd += PreTurnEnd;
        CurrentPlayer.TurnEnd    += TurnEnd;
        if (reticle != null)
        {
            reticle.root = CurrentPlayer.transform;
        }
    }
Exemplo n.º 24
0
 private void HandleStageFinished()
 {
     if (CurrentStage.HasBoss() == true)
     {
         StartBossFight();
     }
     else if (Stages.HasAnyElement() == false)
     {
         HandleGameWon();
     }
     else
     {
         PrepareNextStage();
     }
 }
Exemplo n.º 25
0
 void TurnEnd()
 {
     turnLengthDelta           = turnLength;
     CurrentPlayer.isDangerous = false;
     if (CurrentPlayer.fired != null)
     {
         cam.SetTarget(CurrentPlayer.fired.transform);
         currentStage       = CurrentStage.Spectating;
         cam.waitForDestroy = true;
     }
     else
     {
         currentStage = CurrentStage.PostTurn;
     }
 }
Exemplo n.º 26
0
        private void ExplodeBridgePiece(int iPiece)
        {
            bridgepieces[iPiece].Status        = StageTile.TileStatus.Destroyed;
            bridgepieces[iPiece].MetaGID       = 0;
            bridgepieces[iPiece].BackgroundGID = 0;
            bridgepieces[iPiece].CollisionType = StageTile.TileCollisionType.None;

            Animation explosion         = new Animation();
            Vector2   explosionLocation = new Vector2(this.WorldPosition.X + (iPiece * CurrentStage.TileWidth), this.WorldPosition.Y);

            explosion.Initialize(_explosionAnimationStrip, explosionLocation, 32, 32, 5, 150, Color.White, 1f, false, false, CurrentStage);
            CurrentStage.AddExplosion(explosionLocation, explosion, _explosionSound);

            _explosionSoundInstance = _explosionSound.CreateInstance();
            _explosionSoundInstance.Play();
        }
Exemplo n.º 27
0
        public Exception CreatePipelinePropagationException(Exception ex)
        {
            var builder = new StringBuilder(1000);

            builder
            .AppendLargeHeader(InitialHeader)
            .Append("Pipeline Stage Throwing Exception: ").AppendLine(CurrentStage.GetErrorInfo());
            AppendInitialStages(builder);
            builder
            .AppendSmallHeader("Exception")
            .AppendLine(ex.Message)
            .AppendLine();
            AppendPipelineTrace(builder);

            return(new PipelineException(builder.ToString(), ex));
        }
Exemplo n.º 28
0
        protected override void OnResume()
        {
            WhistleFX = new Effect("Whistle", Resource.Raw._98195_whistling);
            //StillnessDisplay = new BargraphData(this, "Steadiness");

            base.DoOnResume(async() =>
            {
                await System.Threading.Tasks.Task.Delay(150);
                WhistleFX.PlayDiminuendo(TimeSpan.FromMilliseconds(750));
                //await System.Threading.Tasks.Task.Delay(500);
                //await Speech.SayAllOf("Cracking open the toolkit.  Select a tool onscreen.  Note, sometimes you'll get further information from repeating a measurement.");
            });

            CurrentStage?.Deactivate();
            SeekReadyPosition();
        }
Exemplo n.º 29
0
        public void NextStage()
        {
            if (BiddingStages.Any() && !CurrentStage.IsFinished())
            {
                throw new InvalidOperationException("Can't got to next bidding stage, untill current is finished");
            }
            var newStagePlayersCount = _playersCount;

            if (BiddingStages.Any())
            {
                newStagePlayersCount = CurrentStage.PlayersCount -
                                       CurrentStage.Bids.Values.Count(x => x.IsAllIn() || x.IsFold());
            }
            var newStage = new BiddingStage(newStagePlayersCount);

            BiddingStages.Add(newStage);
        }
Exemplo n.º 30
0
    // Update is called once per frame
    void Update()
    {
        if (addControlPanel)
        {
            addControlPanel = false;
            if (!gameObject.GetComponent <ControlPanel>())
            {
                gameObject.AddComponent <ControlPanel>();
            }
        }

        if (!firstFrame)
        {
            switch (currentStage)
            {
            case CurrentStage.expanding:
                //Debug.Log("Expanding");
                if (!Expand())
                {
                    //Debug.Log("Expanded!");
                    currentStage = CurrentStage.contracting;
                }

                break;

            case CurrentStage.contracting:
                if (!Contract())
                {
                    ResetLocalPosition();
                    CreateSensor();
                    //Debug.Log("Contracting");
                    currentStage = CurrentStage.ready;
                }

                break;

            case CurrentStage.ready:

                Exec();

                break;
            }
        }

        firstFrame = false;
    }