Example #1
0
        public Entity(InGameState Game, LineModel model, Vector2 position)
        {
            this.Game = Game;

            this.model = model;
            this.position = position;
        }
Example #2
0
        public override void Activate()
        {
            _gameState = InGameState.Configure;
            _gameIndex = 0;

            foreach (BaseGame game in FingerGames.Instance.GameManager.Games)
            {
                game.Reset();
            }
            SetActiveGame(FingerGames.Instance.GameManager.Games[0]);
            _justTransitioned = true;
        }
Example #3
0
        public Bullet(InGameState Game, Vector2 position, Vector2 direction , double startTime)
            : base(Game, null, position)
        {
            //we dont want bullets to loop around the screen when then go off the screen
            Loop = false;

            //we set the initial velocity which never lowers as theres no friction
            Velocity = direction * BulletSpeed;

            //set the start time so we cna kill off the bullet after an interval
            this.startTime = startTime;

            //Create a collision shape for the bullet
            hitbox = new CircleHitbox(this, 2);
        }
        public override ExecutionResult Execute(SuperMetroidModel model, InGameState inGameState, int times = 1, bool usePreviousRoom = false)
        {
            int ammoCost = Count * times;

            if (inGameState.IsResourceAvailable(model, AmmoType.GetConsumableResourceEnum(), ammoCost))
            {
                var resultingState = inGameState.Clone();
                resultingState.ApplyConsumeResource(model, AmmoType.GetConsumableResourceEnum(), ammoCost);
                return(new ExecutionResult(resultingState));
            }
            else
            {
                return(null);
            }
        }
        public IActionResult AddPlayer([FromBody] int roomId, int playerId)
        {
            var room   = _roomService.GetById(roomId);
            var player = _userService.GetById(playerId);

            room.Players.Add(player);

            //if all players here
            InGameState inGameState = new InGameState();

            inGameState.DoAction(room);


            return(Ok());
        }
 public override void UpdateConfigure(GameTime gameTime, ref InGameState gameState, bool justTransitioned)
 {
     if (justTransitioned)
     {
         _loadedMap = false;
     }
     else if (_loadedMap)
     {
         gameState = InGameState.Intro;
     }
     else
     {
         _mapPanel.Update(gameTime);
     }
 }
        /// <summary>
        /// Returns whether this farm cycle can be farmed "for free", without spending any resources during execution (regardless of drops).
        /// </summary>
        /// <param name="model">A model that can be used to obtain data about the current game configuration.</param>
        /// <param name="inGameState">The in-game state to use for execution. This will NOT be altered by this method.</param>
        /// <param name="times">The number of consecutive times that this should be executed.
        /// Only really impacts resource cost, since most items are non-consumable.</param>
        /// <param name="usePreviousRoom">If true, uses the last known room state at the previous room instead of the current room to answer
        /// (whenever in-room state is relevant).</param>
        /// <returns></returns>
        public bool IsFree(SuperMetroidModel model, InGameState inGameState, int times = 1, bool usePreviousRoom = false)
        {
            // Execute the requirements of this cycle once
            ExecutionResult executionResult = RequirementExecution.Execute(model, inGameState, times: times, usePreviousRoom: usePreviousRoom);

            // If we failed, this can't be farmed for free
            if (executionResult == null)
            {
                return(false);
            }
            // If any resource was reduced by the execution, this can't be farmed for free
            else
            {
                return(!executionResult.ResultingState.GetResourceVariationWith(inGameState).Any(variation => variation < 0));
            }
        }
Example #8
0
        public ExecutionResult Execute(SuperMetroidModel model, InGameState inGameState, int times = 1, bool usePreviousRoom = false)
        {
            // If there are no bypass strats, bypassing fails
            if (!NodeLock.BypassStrats.Any())
            {
                return(null);
            }

            // Look for the best bypass strat
            (Strat bestStrat, ExecutionResult result) = model.ExecuteBest(NodeLock.BypassStrats, inGameState, times: times, usePreviousRoom: usePreviousRoom);
            if (result != null)
            {
                result.AddBypassedLock(NodeLock, bestStrat);
            }
            return(result);
        }
Example #9
0
        public ExecutionResult Execute(SuperMetroidModel model, InGameState inGameState, int times = 1, bool usePreviousRoom = false)
        {
            // Can't open a lock that isn't active
            if (!NodeLock.IsActive(model, inGameState))
            {
                return(null);
            }

            // Look for the best unlock strat
            (Strat bestStrat, ExecutionResult result) = model.ExecuteBest(NodeLock.UnlockStrats, inGameState, times: times, usePreviousRoom: usePreviousRoom);
            if (result != null)
            {
                result.ApplyOpenedLock(NodeLock, bestStrat);
            }
            return(result);
        }
    // Use this for initialization
    void Start()
    {
        // search PLayers, Oponents and goalkeepers
        players        = GameObject.FindGameObjectsWithTag("PlayerTeam1");
        oponents       = GameObject.FindGameObjectsWithTag("OponentTeam");
        keeper         = GameObject.FindGameObjectWithTag("GoalKeeper");
        keeper_oponent = GameObject.FindGameObjectWithTag("GoalKeeper_Oponent");

        state = InGameState.PREPARE_TO_KICK_OFF;

        bFirstHalf = 0;


        // Load Team textures
        LoadTeams();
    }
Example #11
0
    public ClientState GetState(InGameState gameState)
    {
        foreach (ClientState gameScreen in m_screens)
        {
            if (gameScreen.m_targetGameState == gameState)
            {
                Debug.Log("returning state");

                return(gameScreen);
            }
        }

        //throw new Exception("state does not exist");
        Debug.Log("no state found ");
        return(null);
    }
Example #12
0
        private void LeftClick()
        {
            switch (inGameState)
            {
            case InGameState.Play:
                var  pos         = mouse.fakePos;
                bool hasSelected = false;

                foreach (var item in cellsWithTower)
                {
                    if (item.contains.boundingBox.Contains(pos))
                    {
                        Game1.SelectedObject = item.contains;
                        hasSelected          = true;
                        break;
                    }
                }
                if (!hasSelected)
                {
                    foreach (var item in CreepWave.inGameCreeps)
                    {
                        if (item.boundingBox.Contains(pos))
                        {
                            Game1.SelectedObject = item;
                            hasSelected          = true;
                            break;
                        }
                    }
                }

                if (!hasSelected)
                {
                    Game1.SelectedObject = null;
                }
                break;

            case InGameState.Add:
                if (ClipTowersToCell(true))
                {
                    inGameState = InGameState.Play;
                }
                break;

            default:
                break;
            }
        }
        public override ExecutionResult Execute(SuperMetroidModel model, InGameState inGameState, int times = 1, bool usePreviousRoom = false)
        {
            int damage = model.Rules.CalculateEnemyDamage(inGameState, Attack) * Hits * times;

            if (inGameState.IsResourceAvailable(model, ConsumableResourceEnum.ENERGY, damage))
            {
                InGameState resultingState = inGameState.Clone();
                resultingState.ApplyConsumeResource(model, ConsumableResourceEnum.ENERGY, damage);
                ExecutionResult result = new ExecutionResult(resultingState);
                result.AddDamageReducingItemsInvolved(model.Rules.GetEnemyDamageReducingItems(model, inGameState, Attack));
                return(result);
            }
            else
            {
                return(null);
            }
        }
Example #14
0
        public virtual void UpdatePause(GameTime gameTime, ref InGameState gameState, bool justTransitioned)
        {
            if (justTransitioned)
            {
                _transitionTime = gameTime.TotalGameTime.Add(TimeSpan.FromSeconds(this.PauseDelay));
            }
            else if (gameTime.TotalGameTime > _transitionTime)
            {
                _resumeButton.Tag = false;
                _resumeButton.Update(gameTime);

                if ((bool)_resumeButton.Tag)
                {
                    gameState = InGameState.Active;
                }
            }
        }
        public override ExecutionResult Execute(SuperMetroidModel model, InGameState inGameState, int times = 1, bool usePreviousRoom = false)
        {
            int damage = CalculateDamage(model, inGameState, times: times, usePreviousRoom: usePreviousRoom);

            if (inGameState.IsResourceAvailable(model, ConsumableResourceEnum.ENERGY, damage))
            {
                var resultingState = inGameState.Clone();
                resultingState.ApplyConsumeResource(model, ConsumableResourceEnum.ENERGY, damage);
                ExecutionResult result = new ExecutionResult(resultingState);
                result.AddDamageReducingItemsInvolved(GetDamageReducingItems(model, inGameState));
                return(result);
            }
            else
            {
                return(null);
            }
        }
Example #16
0
        public override bool HandleEvent(Event e)
        {
            if (e is DiedEvent ev && ev.Who == this)
            {
                if (!GetComponent <HealthComponent>().Dead&& !died)
                {
                    died = true;
                    Done = false;

                    GetComponent <AudioEmitterComponent>().EmitRandomized("player_death");
                    RemoveComponent <PlayerInputComponent>();

                    Achievements.Unlock("bk:rip");
                    Items.Unlock("bk:dagger");

                    if (InGameState.EveryoneDied(this))
                    {
                        Audio.FadeOut();

                        ((InGameState)Engine.Instance.State).HandleDeath();

                        Camera.Instance.Targets.Clear();
                        Camera.Instance.Follow(this, 1);

                        Tween.To(0.3f, Engine.Instance.Speed, x => Engine.Instance.Speed = x, 0.5f).OnEnd = () => {
                            var t = Tween.To(1, Engine.Instance.Speed, x => Engine.Instance.Speed = x, 0.5f);

                            t.Delay = 0.8f;
                            t.OnEnd = () => ((InGameState)Engine.Instance.State).AnimateDoneScreen(this);

                            HandleEvent(e);
                            AnimateDeath(ev);

                            Done = true;
                        };
                    }
                    else
                    {
                        HandleEvent(e);
                        AnimateDeath(ev);
                    }

                    return(true);
                }
            }
Example #17
0
 public int PersoSelection(string message)
 {
     if (message.StartsWith(PrefixMessage.CharacterSelection.PersoInfo))
     {
         Character.ParseMessageFromServer(message);
         Socket.Send("AS" + Character.Id + CharNewLine + CharNull);
     }
     else if (message.StartsWith(PrefixMessage.CharacterSelection.PersoConnected))
     {
         Socket.Send("GC1" + CharNewLine + CharNull);
     }
     else if (message.StartsWith(PrefixMessage.CharacterSelection.MapDetails))
     {
         State = new InGameState(this);
         Socket.Send(PrefixMessage.MapLoading.AskInfo + CharNewLine + CharNull);
     }
     return(0);
 }
        public override ExecutionResult Execute(SuperMetroidModel model, InGameState inGameState, int times = 1, bool usePreviousRoom = false)
        {
            // If no in-room path is specified, then player is expected to have entered at fromNode and not moved
            IEnumerable <int> requiredInRoomPath = (InRoomPath == null || !InRoomPath.Any()) ? new[] { FromNodeId } : InRoomPath;

            // Find all runways from the previous room that can be retroactively attempted and are long enough.
            // We're calculating runway length to account for open ends, but using 0 for tilesSavedWithStutter because no charging is involved.
            IEnumerable <Runway> retroactiveRunways = inGameState.GetRetroactiveRunways(requiredInRoomPath, usePreviousRoom)
                                                      .Where(r => model.Rules.CalculateEffectiveRunwayLength(r, tilesSavedWithStutter: 0) >= UsedTiles);

            (_, var executionResult) = model.ExecuteBest(retroactiveRunways.Select(runway => runway.AsExecutable(comingIn: false)),
                                                         inGameState, times: times, usePreviousRoom: usePreviousRoom);

            return(executionResult);

            // Note that there are no concerns here about unlocking the previous door, because unlocking a door to use it cannot be done retroactively.
            // It has to have already been done in order to use the door in the first place.
        }
Example #19
0
    public IEnumerator ChangeStateCoroutine(InGameState gameState)
    {
        m_changingState = true;

        //game states
        ClientState currentState = null;
        ClientState newState     = null;

        if (m_clientGameState != InGameState.DEFAULT)
        {
            GetState(m_clientGameState);
        }

        if (gameState != InGameState.DEFAULT)
        {
            //get new state
            newState = GetState(gameState);
        }

        //Debug.Log("States Fetched");

        if (currentState != null)
        {
            //transittion from old state
            yield return(StartCoroutine(currentState.OnExit()));
        }

        //Debug.Log("Exited state");

        if (newState != null)
        {
            //transittion into new state
            yield return(StartCoroutine(newState.OnEnter()));
        }

        //Debug.Log("entered state");

        m_clientGameState = gameState;

        m_changingState = false;

        yield return(null);
    }
Example #20
0
        public Player(InGameState Game)
            : base(Game, new LineModel(Player.PlayerVectors), new Vector2(400, 300))
        {
            FlameModel = new LineModel(Player.PlayerFlameVectors);

            Vector2[] hitboxModel =
            {
                new Vector2(0, -27),
                new Vector2(15, 17),
                new Vector2(-15, 17),
            };
            hitbox = new PolygonHitbox(this, hitboxModel);

            //start the player off as in the "dead" state
            canRespawn = true;
            Alive = false;
            DrawFlame = false;
            Model.ModelColor = Color.Black;
        }
Example #21
0
        public override void UpdateEnd(GameTime gameTime, ref InGameState gameState, bool justTransitioned)
        {
            base.UpdateEnd(gameTime, ref gameState, justTransitioned);

            if (justTransitioned)
            {
                this._timeLabel.Text = string.Format("{0:0000.00} seconds", FingerGames.Instance.GameManager.Players[0].Score);
                if (FingerGames.Instance.GameManager.Players.Count > 1)
                {
                    this._timeLabel2.Text     = string.Format("{0:0000.00} seconds", FingerGames.Instance.GameManager.Players[1].Score);
                    this._timeLabel.Bounds    = new Rectangle(0, 0, 800, 35);
                    this._timeLabel2.Bounds   = new Rectangle(0, 0, 800, 35);
                    this._timeLabel.FontZoom  = 0.5f;
                    this._timeLabel2.FontZoom = 0.5f;
                    this._timePanel.ForceLayout();
                }
                else
                {
                    this._timeLabel2.Text    = "";
                    this._timeLabel.Bounds   = new Rectangle(0, 0, 800, 70);
                    this._timeLabel.FontZoom = 1;
                    this._timePanel.ForceLayout();
                }
            }

            if (gameState == InGameState.ScoreGame)
            {
                if (justTransitioned)
                {
                    // we need to rank our people
                    List <GamePlayer> players = new List <GamePlayer>(FingerGames.Instance.GameManager.Players);
                    players.Sort(new Comparison <GamePlayer>(CompareScores));

                    double topScore = players.Count * 1000;
                    for (int i = 0; i < players.Count; ++i)
                    {
                        players[i].OverallScore += topScore;
                        topScore -= 1000;
                    }
                }
            }
        }
Example #22
0
    //デバック時はmodelのインスペクター上で確認する
    public void InGameState(InGameState state)
    {
        switch (state)
        {
        case global::InGameState.Idle:
            Idle();
            break;

        case global::InGameState.MoveBlock:
            MoveBlock();
            break;

        case global::InGameState.MatchBlocks:
            MatchBlocks();
            break;

        case global::InGameState.DestroyBlock:
            DestroyBlocks().Forget();
            break;

        case global::InGameState.AddBlocks:
            AddBlocks().Forget();
            break;

        case global::InGameState.ChainBlocks:
            ChainBlocks().Forget();
            break;

        case global::InGameState.AddFeverBlock:
            AddFeverBlock();
            break;

        case global::InGameState.GameOver:
            GameOver();
            break;

        default:
            break;
        }
        //stateUI.text = state.ToString();
    }
Example #23
0
        /// <summary>
        /// Attempts to use this runway based on the provided in-game state (which will not be altered),
        /// by fulfilling its execution requirements.
        /// </summary>
        /// <param name="model">A model that can be used to obtain data about the current game configuration.</param>
        /// <param name="inGameState">The in-game state to use for execution. This will NOT be altered by this method.</param>
        /// <param name="comingIn">If true, tries to use the runway while coming into the room. If false, tries to use it when already in the room.</param>
        /// <param name="times">The number of consecutive times that this runway should be used.
        /// Only really impacts resource cost, since most items are non-consumable.</param>
        /// <param name="usePreviousRoom">If true, uses the last known room state at the previous room instead of the current room to answer
        /// (whenever in-room state is relevant).</param>
        /// <returns>An ExecutionResult describing the execution if successful, or null otherwise.
        /// The in-game state in that ExecutionResult will never be the same instance as the provided one.</returns>
        public ExecutionResult Execute(SuperMetroidModel model, InGameState inGameState, bool comingIn, int times = 1, bool usePreviousRoom = false)
        {
            // If we're coming in, this must be usable coming in
            if (!UsableComingIn && comingIn)
            {
                return(null);
            }

            // Return the result of the best strat execution
            (Strat bestStrat, ExecutionResult result) = model.ExecuteBest(Strats, inGameState, times: times, usePreviousRoom: usePreviousRoom);
            if (result == null)
            {
                return(null);
            }
            else
            {
                // Add a record of the runway being used
                result.AddUsedRunway(this, bestStrat);
                return(result);
            }
        }
Example #24
0
        public Asteroid(InGameState Game, Vector2 StartPosition, AsteroidSize size)
            : base(Game, new LineModel(AsteroidLarge1Vectors), StartPosition)
        {
            this.size = size;
            Velocity = Vector2.RandomVector2(new Vector2(-50, -50), new Vector2(50, 50)).Normalise() * 2;

            switch (size)
            {
                case AsteroidSize.Large:
                    this.Model.Scale = 1;
                    break;
                case AsteroidSize.Medium:
                    this.Model.Scale = 0.5;
                    break;
                case AsteroidSize.Small:
                    this.Model.Scale = 0.35;
                    break;
            }

            hitbox = new CircleHitbox(this, Model.GetRadius());
        }
Example #25
0
        public Asteroid(InGameState Game, Vector2 StartPosition, Vector2 velocity, AsteroidSize size)
            : base(Game, new LineModel(AsteroidLarge1Vectors), StartPosition)
        {
            this.size = size;
            Velocity = velocity;

            switch (size)
            {
                case AsteroidSize.Large:
                    this.Model.Scale = 1;
                    break;
                case AsteroidSize.Medium:
                    this.Model.Scale = 0.5;
                    break;
                case AsteroidSize.Small:
                    this.Model.Scale = 0.35;
                    break;
            }

            hitbox = new CircleHitbox(this, Model.GetRadius());
        }
        public SpawnMarkerIndicator(InGameState state, SpawnMarker entity, Camera camera) : base(entity, camera)
        {
            m_font         = UIFonts.Default;//Font.Get( "fonts/countdown.fnt" );
            m_textGeometry = new Geometry[m_font.PageCount + 2];
            m_textTextures = new Texture[m_font.PageCount + 2];
            for (int i = 0; i < m_textGeometry.Length; ++i)
            {
                m_textGeometry[i] = new Geometry(Primitive.Triangles, 8, 12, false);
            }

            m_leftArrowGeometry  = new Geometry(Primitive.Triangles, 4, 6, true);
            m_rightArrowGeometry = new Geometry(Primitive.Triangles, 4, 6, true);
            m_arrowTexture       = Texture.Get("gui/arrows.png", true);

            m_state    = state;
            m_selected = false;

            m_hover    = 0;
            m_holdTime = -1.0f;

            m_lastNumKey = null;
        }
Example #27
0
        public virtual void UpdateScore(GameTime gameTime, ref InGameState gameState, bool justTransitioned, bool showSummary)
        {
            if (justTransitioned)
            {
                _transitionTime = gameTime.TotalGameTime.Add(TimeSpan.FromSeconds(1));
                _scoreCenter.Prepare(GameManager, GameManager.GameUnits);
                _scoreCenter.Update(gameTime);
            }
            else
            {
                _scoreCenter.Tag = false;
                _scoreCenter.Update(gameTime);

                if (gameTime.TotalGameTime > _transitionTime)
                {
                    _scoreCenter.EnableContinueButton();

                    if ((bool)_scoreCenter.Tag)
                    {
                        gameState = InGameState.Exit;
                    }
                }
            }
        }
        public ExecutionResult Execute(SuperMetroidModel model, InGameState inGameState, int times = 1, bool usePreviousRoom = false)
        {
            times = times * model.LogicalOptions.NumberOfTries(this);

            ExecutionResult result = Requires.Execute(model, inGameState, times: times, usePreviousRoom: usePreviousRoom);

            if (result == null)
            {
                return(null);
            }

            // Iterate over intact obstacles that need to be dealt with
            foreach (StratObstacle obstacle in Obstacles.Where(o => !inGameState.GetDestroyedObstacleIds(usePreviousRoom).Contains(o.ObstacleId)))
            {
                // Try destroying the obstacle first
                ExecutionResult destroyResult = result.AndThen(obstacle.DestroyExecution, model, times: times, usePreviousRoom: usePreviousRoom);

                // If destruction fails, try to bypass instead
                if (destroyResult == null)
                {
                    result = result.AndThen(obstacle.BypassExecution, model, times: times, usePreviousRoom: usePreviousRoom);
                    // If bypass also fails, we cannot get past this obstacle. Give up.
                    if (result == null)
                    {
                        return(null);
                    }
                }
                // If destruction succeeded, carry on with the result of that
                else
                {
                    result = destroyResult;
                }
            }

            return(result);
        }
Example #29
0
 public ExecutionResult Execute(SuperMetroidModel model, InGameState inGameState, int times = 1, bool usePreviousRoom = false)
 {
     return(Runway.Execute(model, inGameState, ComingIn, times: times, usePreviousRoom: usePreviousRoom));
 }
 public override IEnumerable <Item> GetDamageReducingItems(SuperMetroidModel model, InGameState inGameState)
 {
     return(model.Rules.GetLavaDamageReducingItems(model, inGameState));
 }
Example #31
0
 public virtual void Update(GameTime gameTime, ref InGameState gameState, bool justTransitioned)
 {
     foreach (IDisposable asset in this.Assets)
     {
         asset.Dispose();
     }
     this.Assets.Clear();
 }
Example #32
0
	private void BussGoneAway()
	{
		state = InGameState.OTHERS_TURN;
		movePattern.StartPattern(2 + round / 2, 2.5f);
	}
Example #33
0
 public virtual void UpdateIntro(GameTime gameTime, ref InGameState gameState, bool justTransitioned)
 {
     if (_introStartTime == TimeSpan.MinValue)
     {
         _introStartTime = gameTime.TotalGameTime.Add(TimeSpan.FromSeconds(this.IntroDelay));
     }
     else if (gameTime.TotalGameTime > _introStartTime)
     {
         _introStartTime = TimeSpan.MinValue;
         gameState = InGameState.Active;
     }
 }
Example #34
0
	private void OnPatternPlayerTurnStart()
	{
		state = InGameState.PLAYER_TURN;
	}
Example #35
0
 public virtual bool HandleBackClick(ref InGameState gameState)
 {
     if (gameState == InGameState.Intro)
     {
         return true;
     }
     else if (gameState == InGameState.Active)
     {
         gameState = InGameState.Pause;
         return true;
     }
     return false;
 }
        /// <summary>
        /// Take N samples. Speed is number of alternating taps over that period
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime, ref InGameState gameState, bool justTransitioned)
        {
            if (justTransitioned)
            {
                //SoundManager.Play(this._runningSoundInstace);
            }
            foreach (FingerRunnerPlayer runner in _runPlayers)
            {
                if (runner.Update(gameTime))
                {
                    // this player has won
                    gameState = InGameState.End;
                    //SoundManager.Stop(this._runningSoundInstace);
                }
            }

            if (gameState == InGameState.End)
            {
                foreach (FingerRunnerPlayer runner in _runPlayers)
                {
                    runner.Player.Score = (_elapsedtime.TotalSeconds);
                }
            }
            else
            {
                TouchCollection touchCollection = TouchPanel.GetState();

                int activeTouches = 0;
                TouchLocation activeTouch = default(TouchLocation);
                foreach (TouchLocation touchLocation in touchCollection)
                {
                    if (touchLocation.State == TouchLocationState.Pressed || touchLocation.State == TouchLocationState.Moved)
                    {
                        activeTouch = touchLocation;
                        activeTouches++;
                    }
                }

                if (activeTouches > 0)
                {
                    if (_startTime == TimeSpan.MinValue)
                    {
                        _startTime = gameTime.TotalGameTime;
                        _elapsedtime = TimeSpan.Zero;
                    }
                }
                _elapsedtime = _elapsedtime.Add(gameTime.ElapsedGameTime);
            }
        }
Example #37
0
 public InteractWithNodeAction(string intent, SuperMetroidModel model, InGameState initialInGameState, ExecutionResult executionResult) :
     base(intent, model, initialInGameState, executionResult)
 {
 }
Example #38
0
	private void OnPatternComplete()
	{
		state = InGameState.PATTERN_COMPLETE;
	}
 public override bool HandleBackClick(ref InGameState gameState)
 {
     return base.HandleBackClick(ref gameState);
 }
Example #40
0
	private void OnPatternFailed()
	{
		--HeartCounter.totalHearts;
		redFlash.TriggerFlash();

		if (HeartCounter.totalHearts <= 0) 
		{
			player.Faint ();
			movePattern.StopPattern ();
			state = InGameState.AMBULANCE_COMING;
			ambulanceBuss.StartBussComing ();
		}
	}
Example #41
0
        public virtual void UpdateScore(GameTime gameTime, ref InGameState gameState, bool justTransitioned, bool showSummary)
        {
            if (justTransitioned)
            {
                _transitionTime = gameTime.TotalGameTime.Add(TimeSpan.FromSeconds(1));
                _scoreCenter.Prepare(GameManager, GameManager.GameUnits);
                _scoreCenter.Update(gameTime);
            }
            else
            {
                _scoreCenter.Tag = false;
                _scoreCenter.Update(gameTime);

                if (gameTime.TotalGameTime > _transitionTime)
                {
                    _scoreCenter.EnableContinueButton();

                    if ((bool)_scoreCenter.Tag)
                    {
                        gameState = InGameState.Exit;
                    }
                }
            }
        }
Example #42
0
	private void BussArrived()
	{
		state = InGameState.BUSS_LEAVING;
		SpawnCharacters();
	}
 /// <summary>
 /// Compares the two provided game states, using the comparer returned by <see cref="GetInGameStateComparer"/>.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 public int CompareInGameStates(InGameState x, InGameState y)
 {
     return(GetInGameStateComparer().Compare(x, y));
 }
    // Update is called once per frame
    void Update()
    {
        // little time between states
        timeToChangeState -= Time.deltaTime;

        if (timeToChangeState < 0.0f)
        {
            // Handle all states related to match

            switch (state)
            {
            case InGameState.PLAYING:

                if (scorerTime.minutes > 44.0f && bFirstHalf == 0)
                {
                    bFirstHalf = 1;
                }

                if (scorerTime.minutes > 45.0f && bFirstHalf == 1)
                {
                    sphere.transform.position = center.position;

                    foreach (GameObject player in players)
                    {
                        player.transform.position = player.GetComponent <Player_Script>().resetPosition;
                        player.GetComponent <Animation>().Play("rest");
                    }

                    foreach (GameObject player in oponents)
                    {
                        player.transform.position = player.GetComponent <Player_Script>().resetPosition;
                        player.GetComponent <Animation>().Play("rest");
                    }

                    bFirstHalf = 2;

                    scoredbylocal    = true;
                    scoredbyvisiting = false;
                    state            = InGameState.PREPARE_TO_KICK_OFF;
                }

                if (scorerTime.minutes > 90.0f && bFirstHalf == 2)
                {
                    PlayerPrefs.SetInt("ScoreLocal", score_local);
                    PlayerPrefs.SetInt("ScoreVisit", score_visiting);

                    Application.LoadLevel("Select_Team");
                }


                break;

            case InGameState.THROW_IN:

                whoLastTouched = lastTouched;

                foreach (GameObject go in players)
                {
                    go.GetComponent <Player_Script>().state = Player_Script.Player_State.RESTING;
                }
                foreach (GameObject go in oponents)
                {
                    go.GetComponent <Player_Script>().state = Player_Script.Player_State.RESTING;
                }


                sphere.owner = null;

                if (whoLastTouched.tag == "PlayerTeam1")
                {
                    candidateToThrowIn = SearchPlayerNearBall(oponents);
                }
                else
                {
                    candidateToThrowIn = SearchPlayerNearBall(players);
                }


                candidateToThrowIn.transform.position = new Vector3(positionSide.x, candidateToThrowIn.transform.position.y, positionSide.z);

                if (whoLastTouched.tag == "PlayerTeam1")
                {
                    candidateToThrowIn.GetComponent <Player_Script>().temporallyUnselectable = true;
                    candidateToThrowIn.GetComponent <Player_Script>().timeToBeSelectable     = 1.0f;

                    candidateToThrowIn.transform.LookAt(SearchPlayerNearBall(oponents).transform.position);
                }
                else
                {
                    candidateToThrowIn.transform.LookAt(center);
                }


                candidateToThrowIn.transform.Rotate(0, sphere.fHorizontal * 10.0f, 0);
                candidateToThrowIn.GetComponent <Player_Script>().state = Player_Script.Player_State.THROW_IN;

                sphere.GetComponent <Rigidbody>().isKinematic = true;
                sphere.gameObject.transform.position          = candidateToThrowIn.GetComponent <Player_Script>().hand_bone.position;

                target_throw_in = candidateToThrowIn.transform.position + candidateToThrowIn.transform.forward;


                candidateToThrowIn.GetComponent <Animation>().Play("saque_banda");
                candidateToThrowIn.GetComponent <Animation>()["saque_banda"].time  = 0.1f;
                candidateToThrowIn.GetComponent <Animation>()["saque_banda"].speed = 0.0f;

                state = InGameState.THROW_IN_CHASING;

                break;

            case InGameState.THROW_IN_CHASING:


                candidateToThrowIn.transform.position = new Vector3(positionSide.x, candidateToThrowIn.transform.position.y, positionSide.z);
                candidateToThrowIn.transform.LookAt(target_throw_in);
                candidateToThrowIn.GetComponent <Player_Script>().state = Player_Script.Player_State.THROW_IN;

                sphere.GetComponent <Rigidbody>().isKinematic = true;
                sphere.gameObject.transform.position          = candidateToThrowIn.GetComponent <Player_Script>().hand_bone.position;

                if (whoLastTouched.tag != "PlayerTeam1")
                {
                    target_throw_in += new Vector3(0, 0, sphere.fHorizontal / 10.0f);

                    if (sphere.bPassButton)
                    {
                        candidateToThrowIn.GetComponent <Animation>().Play("saque_banda");
                        state = InGameState.THROW_IN_DOING;
                    }
                }
                else
                {
                    timeToSaqueOponent -= Time.deltaTime;

                    if (timeToSaqueOponent < 0.0f)
                    {
                        timeToSaqueOponent = 3.0f;
                        sphere.gameObject.GetComponent <Rigidbody>().isKinematic = true;
                        candidateToThrowIn.GetComponent <Animation>().Play("saque_banda");
                        state = InGameState.THROW_IN_DOING;
                    }
                }

                break;

            case InGameState.THROW_IN_DOING:

                candidateToThrowIn.GetComponent <Animation>()["saque_banda"].speed = 1.0f;

                if (candidateToThrowIn.GetComponent <Animation>()["saque_banda"].normalizedTime < 0.5f && sphere.gameObject.GetComponent <Rigidbody>().isKinematic == true)
                {
                    sphere.gameObject.transform.position = candidateToThrowIn.GetComponent <Player_Script>().hand_bone.position;
                }

                if (candidateToThrowIn.GetComponent <Animation>()["saque_banda"].normalizedTime >= 0.5f && sphere.gameObject.GetComponent <Rigidbody>().isKinematic == true)
                {
                    sphere.gameObject.GetComponent <Rigidbody>().isKinematic = false;
                    sphere.gameObject.GetComponent <Rigidbody>().AddForce(candidateToThrowIn.transform.forward * 4000.0f + new Vector3(0.0f, 1300.0f, 0.0f));
                }



                if (candidateToThrowIn.GetComponent <Animation>().IsPlaying("saque_banda") == false)
                {
                    state = InGameState.THROW_IN_DONE;
                }


                break;

            case InGameState.THROW_IN_DONE:
                candidateToThrowIn.GetComponent <Player_Script>().state = Player_Script.Player_State.MOVE_AUTOMATIC;
                state = InGameState.PLAYING;

                break;



            case InGameState.CORNER:

                whoLastTouched = lastTouched;

                if (whoLastTouched.tag == "GoalKeeper_Oponent")
                {
                    whoLastTouched.tag = "OponentTeam";
                }
                if (whoLastTouched.tag == "GoalKeeper")
                {
                    whoLastTouched.tag = "PlayerTeam1";
                }



                // decidimos si es Corner o Saque de puerta

                if (cornerTrigger.tag == "Corner_Oponent" && whoLastTouched.tag == "PlayerTeam1")
                {
                    state = InGameState.GOAL_KICK;
                    break;
                }
                if (cornerTrigger.tag != "Corner_Oponent" && whoLastTouched.tag == "OponentTeam")
                {
                    state = InGameState.GOAL_KICK;
                    break;
                }



                foreach (GameObject go in players)
                {
                    go.GetComponent <Player_Script>().state = Player_Script.Player_State.RESTING;
                }
                foreach (GameObject go in oponents)
                {
                    go.GetComponent <Player_Script>().state = Player_Script.Player_State.RESTING;
                }


                sphere.owner = null;

                if (whoLastTouched.tag == "PlayerTeam1")
                {
                    PutPlayersInCornerArea(players, Player_Script.TypePlayer.DEFENDER);
                    PutPlayersInCornerArea(oponents, Player_Script.TypePlayer.ATTACKER);
                    candidateToThrowIn = SearchPlayerNearBall(oponents);
                }
                else
                {
                    PutPlayersInCornerArea(oponents, Player_Script.TypePlayer.DEFENDER);
                    PutPlayersInCornerArea(players, Player_Script.TypePlayer.ATTACKER);
                    candidateToThrowIn = SearchPlayerNearBall(players);
                }

                candidateToThrowIn.transform.position = new Vector3(cornerSource.position.x, candidateToThrowIn.transform.position.y, cornerSource.position.z);


                if (whoLastTouched.tag == "PlayerTeam1")
                {
                    candidateToThrowIn.GetComponent <Player_Script>().temporallyUnselectable = true;
                    candidateToThrowIn.GetComponent <Player_Script>().timeToBeSelectable     = 1.0f;

                    candidateToThrowIn.transform.LookAt(SearchPlayerNearBall(oponents).transform.position);
                }
                else
                {
                    candidateToThrowIn.transform.LookAt(center);
                }



                candidateToThrowIn.transform.Rotate(0, sphere.fHorizontal * 10.0f, 0);
                candidateToThrowIn.GetComponent <Player_Script>().state = Player_Script.Player_State.CORNER_KICK;

                sphere.GetComponent <Rigidbody>().isKinematic = true;
//					sphere.gameObject.transform.position = candidateTosaqueBanda.GetComponent<Player_Script>().hand_bone.position;

                sphere.gameObject.transform.position = cornerSource.position;


                target_throw_in = candidateToThrowIn.transform.position + candidateToThrowIn.transform.forward;


                candidateToThrowIn.GetComponent <Animation>().Play("rest");
                state = InGameState.CORNER_CHASING;

                break;


            case InGameState.CORNER_CHASING:


                candidateToThrowIn.transform.LookAt(target_throw_in);
                candidateToThrowIn.GetComponent <Player_Script>().state = Player_Script.Player_State.CORNER_KICK;

                sphere.GetComponent <Rigidbody>().isKinematic = true;

                if (whoLastTouched.tag != "PlayerTeam1")
                {
                    target_throw_in += Camera.main.transform.right * (sphere.fHorizontal / 10.0f);

                    if (sphere.bPassButton)
                    {
                        candidateToThrowIn.GetComponent <Animation>().Play("backwards");
                        state = InGameState.CORNER_DOING;
                    }
                }
                else
                {
                    timeToSaqueOponent -= Time.deltaTime;

                    if (timeToSaqueOponent < 0.0f)
                    {
                        timeToSaqueOponent = 3.0f;
                        sphere.gameObject.GetComponent <Rigidbody>().isKinematic = true;
                        candidateToThrowIn.GetComponent <Animation>().Play("backwards");
                        state = InGameState.CORNER_DOING;
                    }
                }



                break;


            case InGameState.CORNER_DOING:

                candidateToThrowIn.transform.position -= candidateToThrowIn.transform.forward * Time.deltaTime;

                if (candidateToThrowIn.GetComponent <Animation>().IsPlaying("backwards") == false)
                {
                    candidateToThrowIn.GetComponent <Animation>().Play("saque_esquina");
                    state = InGameState.CORNER_DOING_2;
                }

                break;


            case InGameState.CORNER_DOING_2:


                if (candidateToThrowIn.GetComponent <Animation>()["saque_esquina"].normalizedTime >= 0.5f && sphere.gameObject.GetComponent <Rigidbody>().isKinematic == true)
                {
                    sphere.gameObject.GetComponent <Rigidbody>().isKinematic = false;
                    sphere.gameObject.GetComponent <Rigidbody>().AddForce(candidateToThrowIn.transform.forward * 7000.0f + new Vector3(0.0f, 3300.0f, 0.0f));
                }


                if (candidateToThrowIn.GetComponent <Animation>().IsPlaying("saque_esquina") == false)
                {
                    state = InGameState.CORNER_DONE;
                }



                break;



            case InGameState.CORNER_DONE:

                candidateToThrowIn.GetComponent <Player_Script>().state = Player_Script.Player_State.MOVE_AUTOMATIC;
                state = InGameState.PLAYING;

                break;


            case InGameState.GOAL_KICK:

                sphere.transform.position = goal_kick.position;
                sphere.gameObject.GetComponent <Rigidbody>().isKinematic = true;
                goalKeeper.transform.rotation = goal_kick.transform.rotation;
                goalKeeper.transform.position = new Vector3(goal_kick.transform.position.x, goalKeeper.transform.position.y, goal_kick.transform.position.z) - (goalKeeper.transform.forward * 1.0f);
                goalKeeper.GetComponent <GoalKeeper_Script>().state = GoalKeeper_Script.GoalKeeper_State.GOAL_KICK;


                foreach (GameObject go in players)
                {
                    go.GetComponent <Player_Script>().state = Player_Script.Player_State.GO_ORIGIN;
                }
                foreach (GameObject go in oponents)
                {
                    go.GetComponent <Player_Script>().state = Player_Script.Player_State.GO_ORIGIN;
                }

                sphere.owner = null;


                goalKeeper.GetComponent <Animation>().Play("backwards");
                state = InGameState.GOAL_KICK_RUNNING;


                break;

            case InGameState.GOAL_KICK_RUNNING:

                goalKeeper.transform.position -= goalKeeper.transform.forward * Time.deltaTime;

                if (goalKeeper.GetComponent <Animation>().IsPlaying("backwards") == false)
                {
                    goalKeeper.GetComponent <Animation>().Play("saque_esquina");
                    state = InGameState.GOAL_KICK_KICKING;
                }


                break;

            case InGameState.GOAL_KICK_KICKING:

                goalKeeper.transform.position += goalKeeper.transform.forward * Time.deltaTime;

                if (goalKeeper.GetComponent <Animation>()["saque_esquina"].normalizedTime >= 0.5f && sphere.gameObject.GetComponent <Rigidbody>().isKinematic == true)
                {
                    sphere.gameObject.GetComponent <Rigidbody>().isKinematic = false;
                    float force = Random.Range(5000.0f, 12000.0f);
                    sphere.gameObject.GetComponent <Rigidbody>().AddForce((goalKeeper.transform.forward * force) + new Vector3(0, 3000.0f, 0));
                }

                if (goalKeeper.GetComponent <Animation>().IsPlaying("saque_esquina") == false)
                {
                    goalKeeper.GetComponent <GoalKeeper_Script>().state = GoalKeeper_Script.GoalKeeper_State.GO_ORIGIN;
                    state = InGameState.PLAYING;
                }

                break;

            case InGameState.GOAL:


                foreach (GameObject go in players)
                {
                    go.GetComponent <Player_Script>().state = Player_Script.Player_State.THROW_IN;
                    go.GetComponent <Animation>().Play("rest");
                }
                foreach (GameObject go in oponents)
                {
                    go.GetComponent <Player_Script>().state = Player_Script.Player_State.THROW_IN;
                    go.GetComponent <Animation>().Play("rest");
                }

                keeper_oponent.GetComponent <GoalKeeper_Script>().state = GoalKeeper_Script.GoalKeeper_State.RESTING;
                keeper.GetComponent <GoalKeeper_Script>().state         = GoalKeeper_Script.GoalKeeper_State.RESTING;

                timeToKickOff -= Time.deltaTime;

                if (timeToKickOff < 0.0f)
                {
                    timeToKickOff = 4.0f;
                    state         = InGameState_Script.InGameState.PREPARE_TO_KICK_OFF;
                }


                break;



            case InGameState.KICK_OFF:


                foreach (GameObject go in players)
                {
                    go.GetComponent <Player_Script>().state = Player_Script.Player_State.MOVE_AUTOMATIC;
                    go.transform.position = go.GetComponent <Player_Script>().initialPosition;
                }
                foreach (GameObject go in oponents)
                {
                    go.GetComponent <Player_Script>().state = Player_Script.Player_State.MOVE_AUTOMATIC;
                    go.transform.position = go.GetComponent <Player_Script>().initialPosition;
                }

                keeper.GetComponent <GoalKeeper_Script>().state         = GoalKeeper_Script.GoalKeeper_State.RESTING;
                keeper_oponent.GetComponent <GoalKeeper_Script>().state = GoalKeeper_Script.GoalKeeper_State.RESTING;

                sphere.owner = null;
                sphere.gameObject.transform.position = center.position;
                sphere.gameObject.GetComponent <Rigidbody>().drag = 0.5f;
                state = InGameState_Script.InGameState.PLAYING;

                break;


            case InGameState.PREPARE_TO_KICK_OFF:


                sphere.transform.position = center.position;



                foreach (GameObject go in players)
                {
                    go.transform.LookAt(sphere.transform);
                }
                foreach (GameObject go in oponents)
                {
                    go.transform.LookAt(sphere.transform);
                }


                if (scoredbyvisiting)
                {
                    passer.transform.position = sphere.transform.position + new Vector3(0.0f, 0, 1.0f);
                    passer.transform.LookAt(sphere.transform.position);
                    passed.transform.position = passer.transform.position + (passer.transform.forward * 5.0f);
                    passer.state = Player_Script.Player_State.KICK_OFFER;
                    sphere.owner = passer.gameObject;
                }

                if (scoredbylocal)
                {
                    passer_oponent.transform.position = sphere.transform.position + new Vector3(0.0f, 0, -1.0f);
                    passer_oponent.transform.LookAt(sphere.transform.position);
                    passed_oponent.transform.position = passer_oponent.transform.position + (passer_oponent.transform.forward * 5.0f);
                    passer_oponent.state = Player_Script.Player_State.KICK_OFFER;
                    sphere.owner         = passer_oponent.gameObject;
                }


                scoredbylocal    = false;
                scoredbyvisiting = false;

                break;
            }
        }
    }
Example #45
0
        public override void Update(GameTime gameTime)
        {
            InGameState oldState = _gameState;

            base.Update(gameTime);

            switch (_gameState)
            {
                case InGameState.Configure:
                    {
                        _activeGame.UpdateConfigure(gameTime, ref _gameState, _justTransitioned);
                    }
                    break;
                case InGameState.Intro:
                    {
                        _activeGame.UpdateIntro(gameTime, ref _gameState, _justTransitioned);
                    }
                    break;
                case InGameState.Active:
                    {
                        _activeGame.Update(gameTime, ref _gameState, _justTransitioned);
                    }
                    break;
                case InGameState.Pause:
                    {
                        _activeGame.UpdatePause(gameTime, ref _gameState, _justTransitioned);
                    }
                    break;
                case InGameState.End:
                    {
                        _activeGame.UpdateEnd(gameTime, ref _gameState, _justTransitioned);
                    }
                    break;
                case InGameState.ScoreSummary :
                case InGameState.ScoreGame:
                    {
                        _activeGame.UpdateScore(gameTime, ref _gameState, _justTransitioned, (InGameState.ScoreSummary == _gameState));
                    }
                    break;
                case InGameState.Exit:
                    {
                        if (_gameIndex + 1 < FingerGames.Instance.GameManager.Games.Count)
                        {
                            _gameIndex++;
                            SetActiveGame(FingerGames.Instance.GameManager.Games[_gameIndex]);
                            _gameState = InGameState.Configure;
                        }
                        else
                        {
                            FingerGames.Instance.GoBack();
                        }
                    }
                    break;
            }

            _justTransitioned = (oldState != _gameState);
        }
Example #46
0
 public virtual void UpdateConfigure(GameTime gameTime, ref InGameState gameState, bool justTransitioned)
 {
     gameState = InGameState.Intro;
 }
Example #47
0
    public void StageStart()
    {
		state = InGameState.BUSS_COMING;
		++round;

		if (round == 1)
			ChangeSpeed(1.3333f);
		if (round == 2)
			ChangeSpeed(1.5f);
		if (round == 3)
			ChangeSpeed(1.6666f);
		if (round == 4)
			ChangeSpeed(1.6666f);

		if (musicClips.Count >= round)
			musicPlayer.playMusic(musicClips[round - 1]);

		if (musicClips.Count >= round)
			musicPlayer.playMusic(musicClips[round - 1]);

		buss.StartBussComing();
    }
Example #48
0
 public override bool HandleBackClick(ref InGameState gameState)
 {
     return(base.HandleBackClick(ref gameState));
 }
Example #49
0
 public SpawnManager(InGameState Game, List<Entity> entityList, Player player)
 {
     this.Game = Game;
     this.entityList = entityList;
     this.player = player;
 }
Example #50
0
	private void AmbulanceArrived()
	{
		state = InGameState.AMBULANCE_LEAVING;
		KillCharacters();
	}
        public override void UpdateEnd(GameTime gameTime, ref InGameState gameState, bool justTransitioned)
        {
            base.UpdateEnd(gameTime, ref gameState, justTransitioned);

            if (justTransitioned)
            {
                this._timeLabel.Text = string.Format("{0:0000.00} seconds", FingerGames.Instance.GameManager.Players[0].Score);
                if (FingerGames.Instance.GameManager.Players.Count > 1)
                {
                    this._timeLabel2.Text = string.Format("{0:0000.00} seconds", FingerGames.Instance.GameManager.Players[1].Score);
                    this._timeLabel.Bounds = new Rectangle(0, 0, 800, 35);
                    this._timeLabel2.Bounds = new Rectangle(0, 0, 800, 35);
                    this._timeLabel.FontZoom = 0.5f;
                    this._timeLabel2.FontZoom = 0.5f;
                    this._timePanel.ForceLayout();
                }
                else
                {
                    this._timeLabel2.Text = "";
                    this._timeLabel.Bounds = new Rectangle(0, 0, 800, 70);
                    this._timeLabel.FontZoom = 1;
                    this._timePanel.ForceLayout();
                }
            }

            if (gameState == InGameState.ScoreGame)
            {
                if (justTransitioned)
                {
                    // we need to rank our people
                    List<GamePlayer> players = new List<GamePlayer>(FingerGames.Instance.GameManager.Players);
                    players.Sort(new Comparison<GamePlayer>(CompareScores));

                    double topScore = players.Count * 1000;
                    for (int i = 0; i < players.Count; ++i)
                    {
                        players[i].OverallScore += topScore;
                        topScore -= 1000;
                    }
                }
            }
        }
Example #52
0
 public virtual void UpdateEnd(GameTime gameTime, ref InGameState gameState, bool justTransitioned)
 {
     if (justTransitioned)
     {
         _transitionTime = gameTime.TotalGameTime.Add(TimeSpan.FromSeconds(this.EndDelay));
     }
     else if (gameTime.TotalGameTime > _transitionTime)
     {
         gameState = InGameState.ScoreGame;
     }
 }
 public override ExecutionResult Execute(SuperMetroidModel model, InGameState inGameState, int times = 1, bool usePreviousRoom = false)
 {
     return(null);
 }
        /// <summary>
        /// Take N samples. Speed is number of alternating taps over that period
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime, ref InGameState gameState, bool justTransitioned)
        {
            TouchCollection touchCollection = TouchPanel.GetState();

            int activeTouches = 0;

            Dictionary<int, TouchLocation> touches = new Dictionary<int, TouchLocation>();
            foreach (TouchLocation touchLocation in touchCollection)
            {
                if (touchLocation.State == TouchLocationState.Pressed || touchLocation.State == TouchLocationState.Moved)
                {
                    touches.Add(touchLocation.Id, touchLocation);
                    activeTouches++;
                }
            }

            if (_state == TwisterState.Waiting)
            {
                _state = TwisterState.PlayerInstruction;
            }
            else
            {
                // If we pull off of a circle (when not transitioning) we lose
                foreach (TwisterCircle circle in _circles)
                {
                    if (circle.Digit != null && !circle.IsBlinking)
                    {
                        if (!touches.ContainsKey(circle.Digit.TouchId))
                        {
                            bool found = false;
                            foreach (TouchLocation touchLoc in touchCollection)
                            {
                                Point searchPoint = new Point((int)touchLoc.Position.X, (int)touchLoc.Position.Y);
                                if (circle.Contains(searchPoint))
                                {
                                    //if (touches.ContainsKey(touchLoc.Id))
                                    //{
                                    //    //
                                    //}
                                    //else
                                    {
                                        circle.Digit.TouchId = touchLoc.Id;
                                        found = true;
                                    }
                                }
                            }

                            if (!found)
                            {
                                circle.MissingCount++;

                                if (circle.MissingCount > 20)
                                {
                                    // game over
                                    _winnerLabel.Text = string.Format("{0} Loses ({1} touches)!", circle.Digit.Player.Name, circle.Digit.Player.Score);
                                    gameState = InGameState.End;
                                }
                            }
                        }
                        else
                        {
                            TouchLocation location = touches[circle.Digit.TouchId];
                            Point searchPoint = new Point((int)location.Position.X, (int)location.Position.Y);
                            if (!circle.Contains(searchPoint))
                            {
                                // game over
                                _winnerLabel.Text = string.Format("{0} Loses ({1} touches)!", circle.Digit.Player.Name, circle.Digit.Player.Score);
                                gameState = InGameState.End;
                            }
                            else
                            {
                                circle.MissingCount = 0;
                            }
                        }
                    }
                }

                if (_state == TwisterState.Feedback)
                {
                    if ((gameTime.TotalGameTime - _messageTime).TotalSeconds > 2)
                    {
                        _state = TwisterState.PlayerInstruction;
                    }
                }
                else if (_state == TwisterState.PlayerInstruction)
                {
                    if (_newIndex < 0)
                    {
                        int circleIndex = 0;
                        List<int> inactiveIndices = new List<int>();
                        foreach (TwisterCircle circle in _circles)
                        {
                            if (null == circle.Digit)
                            {
                                inactiveIndices.Add(circleIndex);
                            }
                            circleIndex++;
                        }
                        _newIndex = inactiveIndices[FingerGames.Randomizer.Next(0, inactiveIndices.Count())];

                        if (null != _activeDigit.ActiveCircle)
                        {
                            _activeDigit.ActiveCircle.IsBlinking = true;
                        }
                        _circles[_newIndex].IsBlinking = true;
                        _circles[_newIndex].MissingCount = 0;
                    }
                    else
                    {
                        Dictionary<int, TwisterDigit> digitTouches = new Dictionary<int, TwisterDigit>();

                        foreach (TwisterDigit digit in _digits)
                        {
                            if (digit.TouchId != 0)
                            {
                                if (!touches.ContainsKey(digit.TouchId))
                                {
                                    // digit picked up his finger -- game over
                                    //return true;
                                }
                                else if (!digitTouches.ContainsKey(digit.TouchId))
                                {
                                    digitTouches.Add(digit.TouchId, digit);
                                }
                            }
                        }
                        foreach (TouchLocation location in touches.Values)
                        {
                            if (!digitTouches.ContainsKey(location.Id))
                            {
                                // new id
                                _activeDigit.TouchId = location.Id;
                                break;
                            }
                        }

                        if (_activeDigit.TouchId != 0 && touches.ContainsKey(_activeDigit.TouchId))
                        {
                            // Our finger is down
                            TouchLocation loc = touches[_activeDigit.TouchId];

                            if (_circles[_newIndex].Contains(new Point((int)loc.Position.X, (int)loc.Position.Y)))
                            {
                                // we got it...
                                if (null != _activeDigit.ActiveCircle)
                                {
                                    _activeDigit.ActiveCircle.Digit = null;
                                    _activeDigit.ActiveCircle.IsBlinking = false;
                                }
                                _circles[_newIndex].Digit = _activeDigit;
                                _circles[_newIndex].IsBlinking = false;
                                _circles[_newIndex].MissingCount = 0;
                                _activeDigit.ActiveCircle = _circles[_newIndex];

                                _activeDigit.Player.Score++;
                                float playerMod = (GameManager.Players.IndexOf(_activeDigit.Player) == 0) ? -0.5f : 0.5f;
                                SoundManager.Play(PopSound, 1.0f, playerMod, playerMod);

                                _newIndex = -1;
                                int index = _digits.IndexOf(_activeDigit);
                                index = (index + 1) % _digits.Count();

                                _activeDigit = _digits[index];

                                _state = TwisterState.Feedback;
                                _message = "Well Done!";
                                _messageTime = gameTime.TotalGameTime;
                            }
                        }
                    }
                }
            }

            foreach (TwisterCircle circle in _circles)
            {
                circle.Update(gameTime);
            }
        }
 public override void UpdateConfigure(GameTime gameTime, ref InGameState gameState, bool justTransitioned)
 {
     if (justTransitioned)
     {
         _needsConfigure = true;
     }
     else if (!_needsConfigure)
     {
         gameState = InGameState.Intro;
     }
     else
     {
         _configurePanel.Update(gameTime);
     }
 }
 public override void UpdateEnd(GameTime gameTime, ref InGameState gameState, bool justTransitioned)
 {
     base.UpdateEnd(gameTime, ref gameState, justTransitioned);
 }
Example #57
0
 // Inherited from IExecutable.
 public abstract ExecutionResult Execute(SuperMetroidModel model, InGameState inGameState, int times = 1, bool usePreviousRoom = false);
 public override void UpdateIntro(GameTime gameTime, ref InGameState gameState, bool justTransitioned)
 {
     gameState = InGameState.Active;
 }
Example #59
0
        public virtual void UpdatePause(GameTime gameTime, ref InGameState gameState, bool justTransitioned)
        {
            if (justTransitioned)
            {
                _transitionTime = gameTime.TotalGameTime.Add(TimeSpan.FromSeconds(this.PauseDelay));
            }
            else if (gameTime.TotalGameTime > _transitionTime)
            {
                _resumeButton.Tag = false;
                _resumeButton.Update(gameTime);

                if ((bool)_resumeButton.Tag)
                {
                    gameState = InGameState.Active;
                }
            }
        }
Example #60
0
	void Update ()
    {
		if (state == InGameState.BUSS_COMING) 
		{
			if (buss.isArrived)
				BussArrived ();
		}
		else if (state == InGameState.BUSS_LEAVING) {
			if (buss.isGoneAway)
				BussGoneAway ();
		} 
		else if (state == InGameState.PATTERN_FAIL) 
		{
			--HeartCounter.totalHearts;
			if (HeartCounter.totalHearts <= 0) {
				state = InGameState.AMBULANCE_COMING;
				ambulanceBuss.StartBussComing ();
			}
			else
			{
			}
		}
		else if (state == InGameState.PATTERN_COMPLETE) 
		{
			state = InGameState.END_BUSS_COMING;
			buss.StartBussComing();
		}
		else if (state == InGameState.AMBULANCE_COMING) 
		{
			if (ambulanceBuss.isArrived)
				AmbulanceArrived();
		}
		else if (state == InGameState.AMBULANCE_LEAVING) 
		{
			if (ambulanceBuss.isGoneAway) 
			{
				AmbulanceGoneAway ();
				state = InGameState.IDLE;
			}
		}
		else if (state == InGameState.END_BUSS_COMING) 
		{
			if (buss.isArrived) 
			{
				KillCharacters();
				state = InGameState.END_BUSS_LEAVING;
			}
		}
		else if (state == InGameState.END_BUSS_LEAVING) 
		{
			if (buss.isGoneAway) 
			{
				StageStart ();
			}
		} 

		if (beatIndicatorSprite) 
		{
			Color color = Color.red;
			if (state != InGameState.OTHERS_TURN &&	state != InGameState.PLAYER_TURN)
				color.a = 0.0f;
			beatIndicatorSprite.color = color;
		}

		if (player)
		{
			int moveIndex = -1;

			if (Input.GetButtonDown("Move1"))
				moveIndex = 0;
			else if (Input.GetButtonDown("Move2"))
				moveIndex = 1;
			else if (Input.GetButtonDown("Move3"))
				moveIndex = 2;
			else if (Input.GetButtonDown("Move4"))
				moveIndex = 3;
			
			if (moveIndex != -1) 
			{
				player.DoMoveAnimation(moveIndex);
				movePattern.PlayerDidMove(moveIndex);
			}
		}
	}