Пример #1
0
    private void ActivateDrawPhase()
    {
        remainingActions++;
        StartCoroutine(MinDelayPhase());
        currentPhase = BattlePhase.Draw;

        if (currentTeamTurn == playerTeam)
        {
            if (turnCounter == 1)
            {
                PlayerDeckManager.instance.DrawCardFromDeck(); PlayerDeckManager.instance.DrawCardFromDeck();
            }

            for (int i = 0; i < cardsPerDraw; i++)
            {
                if (PlayerDeckManager.instance.playerHand.Count < maxHandSize)
                {
                    PlayerDeckManager.instance.DrawCardFromDeck();
                }
            }
        }

        FindObjectOfType <BattleArenaUIManager>().UpdateHandDisplay();

        remainingActions--;
    }
Пример #2
0
    public void startAttack()
    {
        currentBattlePhase = BattlePhase.StartAttack;

        StartCoroutine(FadeOutUI(menuButtons, 15f));
        slash.SetActive(true);
    }
Пример #3
0
        protected async void StartPlanningPhase()
        {
            phaseTaskCompletionSource         = new TaskCompletionSource <object>();
            phaseTimerCancellationTokenSource = new CancellationTokenSource();

            battlePhase = BattlePhase.PlanningPhase;

            orders.Clear();
            foreach (var unit in battleData.unitsOnBoard)
            {
                if (unit.direction != MoveDirection.None)
                {
                    orders.Add(new UnitOrderMove(battleData.id, unit.unitInstanceId, GetNextX(unit.x, unit.direction), GetNextY(unit.y, unit.direction)));
                }
            }

            await SendBattleCommandStartPlannigPhase();

            nextTurnTime = DateTime.Now.AddMilliseconds(turnTime);

            try
            {
                await Task.Delay(turnTime, phaseTimerCancellationTokenSource.Token);
            }
            catch (TaskCanceledException)
            {
                int turnTimerRemainingMs = (int)(DateTime.Now - nextTurnTime).TotalMilliseconds;
                await Task.Delay(Math.Min(turnTimerRemainingMs, turnEndingTime));
            }

            phaseTaskCompletionSource.TrySetResult(true);
        }
Пример #4
0
 public virtual void StartPhase(BattlePhase phase = null)
 {
     // TODO: init actor's statuses
     //  Set animation
     // Assign actors to scenario animation clip
     // play music
 }
Пример #5
0
    private void TakeDamage(int hitType, float damage)
    {
        damage -= monster.baseDEF;
        if (damage <= 0)
        {
            damage = 0;

            spawnDamageText(Vector3.zero, damage, hitType);
            StartCoroutine(ShakeEnemy(0.125f, .25f));
            return;
        }
        enemyHp -= damage;
        if (enemyHp <= 0)
        {
            enemyHp = 0;

            enemyAnimator.SetTrigger("Die");
            currentBattlePhase = BattlePhase.Ending;
        }
        enemyHpSlider.value = (enemyHp / monster.baseHP);
        enemyHpText.text    = Mathf.Ceil(enemyHp).ToString() + "/" + monster.baseHP;

        spawnDamageText(Vector3.zero, damage, hitType);

        StartCoroutine(ShakeEnemy(0.25f, .5f));

        return;
    }
Пример #6
0
 private void StartActionPhase()
 {
     Log.Info(LogTag, "Starting action phase.", this);
     battlePhase = BattlePhase.ActionPhase;
     enableTimerDisplay.Value = false;
     //throw new NotImplementedException();
 }
Пример #7
0
 public Battle(Uwudle u1, Uwudle u2, float turnTime = 2)
 {
     _u1        = u1;
     _u2        = u2;
     _delayTime = (int)(turnTime * 1000);
     Phase      = BattlePhase.Starting;
 }
Пример #8
0
    void Awake()
    {
        //Singleton pattern
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }
        actParam = new ActNumber?[2];

        playerReady      = false;
        otherPlayerReady = false;
        canNextAction    = true;
        battlePhase      = BattlePhase.ready;

        playerStatus      = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerStatus>();
        otherPlayerStatus = GameObject.FindGameObjectWithTag("OtherPlayer").GetComponent <OtherPlayerStatus>();

        DontDestroyOnLoad(this);

        DecideFirstActor();
    }
Пример #9
0
    void Update()
    {
        if (phase == BattlePhase.myCommandWait)
        {
            TimeETCount  = 3;
            TimeECWCount = 4;
        }

        if (phase == BattlePhase.enemyCommandWait)
        {
            TimeECWCount -= Time.deltaTime;
            if (TimeECWCount <= 0)
            {
                phase = BattlePhase.enemyTurn;
            }
        }

        if (phase == BattlePhase.enemyTurnEnd)
        {
            TimeETCount -= Time.deltaTime;
            if (TimeETCount <= 0)
            {
                Attack.SetActive(true);
                Defense.SetActive(true);
                Magic.SetActive(true);
                Recovery.SetActive(true);
                phase = BattlePhase.myCommandWait;
            }
        }



        switch (phase)
        {
        case BattlePhase.myCommandWait:
            Debug.Log("コマンド待機中");
            messageScript.SetStartMessage();
            break;

        case BattlePhase.myTurn:
            phase = BattlePhase.myTurnEnd;
            break;

        case BattlePhase.myTurnEnd:
            phase = BattlePhase.enemyCommandWait;
            break;

        case BattlePhase.enemyCommandWait:
            Debug.Log("敵行動待機中");
            break;

        case BattlePhase.enemyTurn:
            enemyController.EnemyMovement();
            phase = BattlePhase.enemyTurnEnd;
            break;

        case BattlePhase.enemyTurnEnd:
            break;
        }
    }
Пример #10
0
    private void ActivateUpkeepPhase()
    {
        remainingActions++;
        StartCoroutine(MinDelayPhase());
        currentPhase = BattlePhase.Upkeep;

        if (currentTeamTurn == playerTeam)
        {
            currentTeamTurn = otherTeam;
        }
        else
        {
            currentTeamTurn = playerTeam;
        }

        RefreshAllTokens();

        if (currentTeamTurn == playerTeam)
        {
            turnCounter++;
            CurrencyManager.instance.AddTurnGold();
            // increase gold income by 1 every 3rd turn
            if (turnCounter % goldIncomeIncrementEveryXTurns == 0)
            {
                CurrencyManager.instance.IncreaseGoldPerTurn(1);
            }
            FindObjectOfType <BattleArenaUIManager>().UpdateGoldDisplay();
        }

        remainingActions--;
    }
Пример #11
0
    void FinishChoosingAction()
    {
        choosingAction = false;

        if (playerTurnChooseAction)
        {
            playerTurnChooseAction = false; //reset

            activeBattlerIndex = 0;
            activeBattler      = battlers[activeBattlerIndex].GetComponent <Battler>();
            currentBattlePhase = BattlePhase.DoAction;

            for (int i = 0; i < battlers.Length; i++)
            {
                battlers[i].GetComponent <Battler>().StartRoundAction();
            }
        }
        else
        {
            activeBattlerIndex++;
            if (activeBattlerIndex < battlers.Length)
            {
                activeBattler = battlers[activeBattlerIndex].GetComponent <Battler>();

                if (activeBattler == playerBattler)
                {
                    playerTurnChooseAction = true;
                }
            }
            else //all non-player battlers have chosen their action
            {
                playerTurnChooseAction = true;
            }
        }
    }
Пример #12
0
 public void BossPhase()
 {
     Debug.Log("보스전투");
     gameSateUI.gameObject.SetActive(true);
     gameSateUI.UpdateStateUI("보스 공격 : " + Boss.instance.misscombate + "체크" + Boss.instance.CombatCheck);
     Boss.instance.BossAttack();
     phase = BattlePhase.BossPhase;
 }
Пример #13
0
 public void CharacterPhase()
 {
     Debug.Log("캐릭터 전투");
     UpkeepButtonEvent.instance.UpkeepStepEnd();
     FinalBattlePanel.SetActive(true);
     UpkeepButtonEvent.instance.ShowInventory();
     phase = BattlePhase.CharacterPhaseSelect;
 }
Пример #14
0
 public static BattlePhase GetInstance()
 {
     if (instance == null)
     {
         instance = new BattlePhase();
     }
     return(instance);
 }
Пример #15
0
 public static AsyncOperation GetNextLoadLevelAsync(BattlePhase iPhase)
 {
     if (iPhase == BattlePhase.FlagshipWreck)
     {
         return(Application.LoadLevelAsync(Generics.Scene.Strategy.ToString()));
     }
     return(null);
 }
Пример #16
0
 protected virtual bool ChkChangePhase(BattlePhase iPhase)
 {
     if (BattleTaskManager.GetPhase() != BattlePhase.BattlePhase_BEF)
     {
         return((BattleTaskManager.GetPhase() == iPhase) ? true : false);
     }
     return(true);
 }
Пример #17
0
        public void AddNotification(BattlePhase Phase, string Data)
        {
            if (notifications.Count(x => x.Key == Phase) > 0)
            {
                return;
            }

            notifications.Add(Phase, Data);
        }
Пример #18
0
 private void Start()
 {
     // Calculate how many enemies
     enemyCount = Random.Range(1, EnemySpawnPoints.Length);
     // Spawn the enemies in
     StartCoroutine(SpawnEnemies());
     // Set the begginning battle phase
     phase = BattlePhase.PlayerAttack;
 }
Пример #19
0
    public void CharacterAttack()
    {
        Debug.Log("캐릭터 공격");
        FinalBattlePanel.SetActive(false);

        Debug.Log(Character.instance.CombatCheck + Boss.instance.BossCombatRating);
        DiceController.instance.SetDice(Character.instance.CombatCheck + Boss.instance.BossCombatRating, Character.instance.minDiceSucc, 6, DiceController.Use.FinalBattle);
        phase = BattlePhase.CharacterAttack;
    }
Пример #20
0
        private void StartPlanningPhase()
        {
            Log.Info(LogTag, "Starting planning phase.", this);
            battlePhase = BattlePhase.PlanningPhase;
            enableTimerDisplay.Value = true;

            StartCoroutine(StartTurnTimer());

            //throw new NotImplementedException();
        }
Пример #21
0
    public void BeginBombardment(PlayerShip player, Ship other)
    {
        InvokeRepeating("TimerCountDown", 0, 1);
        phase = BattlePhase.BOMBARDMENT;

        playerShip = player;
        otherShip  = other;

        fleeButton.interactable = false;
        fleeButton.gameObject.SetActive(true);
    }
Пример #22
0
    private void ActivateOrdersPhase()
    {
        remainingActions++;
        currentPhase = BattlePhase.Orders;

        if (currentTeamTurn != playerTeam)
        {
            EnemyTeamAI();
            remainingActions--;
        }
    }
Пример #23
0
 public void Next()
 {
     canNextAction    = true;
     playerReady      = false;
     otherPlayerReady = false;
     battlePhase++;
     if (battlePhase > BattlePhase.play)
     {
         battlePhase = BattlePhase.ready;
     }
 }
Пример #24
0
 public void _StartPhase(BattlePhase phase = null)
 {
     if (phase != null)
     {
         Debug.Log($"Scenario {this.name} StartPhase: {phase.name}");
         StartPhase(phase);
     }
     else
     {
         Debug.Log($"Scenario StartPhase: Phase is Null.");
     }
 }
Пример #25
0
    public void CharacterPhase()
    {
        Debug.Log("캐릭터 전투");
        UpkeepButtonEvent.instance.UpkeepStepEnd();
        FinalBattlePanel.SetActive(true);


        Transform parentOj     = GameObject.FindGameObjectWithTag("Inventory").transform;
        Vector3   parentvector = parentOj.transform.position;

        UpkeepButtonEvent.instance.ShowInventory(new Vector3(parentvector.x - 380, parentvector.y, parentvector.z));
        phase = BattlePhase.CharacterPhaseSelect;
    }
Пример #26
0
 public void OnClickDefense()
 {
     if (phase == BattlePhase.myCommandWait)
     {
         Attack.SetActive(false);
         Defense.SetActive(false);
         Magic.SetActive(false);
         Recovery.SetActive(false);
         phase = BattlePhase.myTurn;
     }
     Debug.Log("" + monsterController.defense + "のダメージを防いだ。");
     messageScript.SetdefenseMessage();
 }
Пример #27
0
 public void OnClickRecovery()
 {
     if (phase == BattlePhase.myCommandWait)
     {
         Attack.SetActive(false);
         Defense.SetActive(false);
         Magic.SetActive(false);
         Recovery.SetActive(false);
         phase = BattlePhase.myTurn;
     }
     Debug.Log("HPを" + monsterController.recover + "回復した。");
     messageScript.SetRecoveryMessage();
 }
Пример #28
0
        public override void Init(Game _game)
        {
            base.Init(_game);
            background          = new Sprite(Game.Content, "fie_burn");
            background.Position = new Vector2(230, 0);
            background.Depth    = 0.0f;


            Player = new Player(_game.Content);
            Player.Init(Game.Content);

            Computer = new Computer();
            Computer.Init(Game.Content);

            switch (first)
            {
            case ePlayerId.PLAYER:
                Player.IsTurn   = true;
                Computer.IsTurn = false;
                break;

            case ePlayerId.COMPUTER:
                Player.IsTurn   = false;
                Computer.IsTurn = true;
                break;

            default:
                break;
            }


            YNDialog          = new YesNoDialog(_game.Content, "String");
            YNDialog.Position = new Vector2(
                x: this.Game.Window.ClientBounds.Center.X - YNDialog.Sprite.Bound.Width / 2,
                y: this.Game.Window.ClientBounds.Center.Y - YNDialog.Sprite.Bound.Height / 2);

            phaseSelector = new PhaseSelector(_game.Content);
            phaseSelector.DrawPhaseButton.ButtonEvent += new Action(DrawPhaseButton_ButtonEvent);
            phaseSelector.StandbyButton.ButtonEvent   += new Action(StandbyButton_ButtonEvent);
            phaseSelector.Main1Button.ButtonEvent     += new Action(Main1Button_ButtonEvent);
            phaseSelector.EndPhaseButton.ButtonEvent  += new Action(EndPhaseButton_ButtonEvent);
            phaseSelector.Main2Button.ButtonEvent     += new Action(Main2Button_ButtonEvent);
            phaseSelector.BattleButton.ButtonEvent    += new Action(BattleButton_ButtonEvent);

            _rasterizerState = new RasterizerState()
            {
                ScissorTestEnable = true
            };
            DetailSideBar = new DetailSideBar(_game.Content);
            battlePhase   = new BattlePhase(_game.Content);
        }
Пример #29
0
        public KeyValuePair <BattlePhase, string> RetrieveFirstNotification(BattlePhase Phase)
        {
            var scope = notifications.Where(x => x.Key == Phase);

            if (scope.Count() == 0)
            {
                return(new KeyValuePair <BattlePhase, string>(BattlePhase.Draw, "ERROR"));
            }

            var notification = notifications.OrderBy(x => x.Key).First();

            notifications.Remove(notification.Key);
            return(notification);
        }
Пример #30
0
 public void OnClickMagic()
 {
     if (phase == BattlePhase.myCommandWait)
     {
         Attack.SetActive(false);
         Defense.SetActive(false);
         Magic.SetActive(false);
         Recovery.SetActive(false);
         phase = BattlePhase.myTurn;
     }
     monsterController.MP = monsterController.MP - monsterController.needMP;
     Debug.Log("MPを" + monsterController.needMP + "消費した。残りMPは" + monsterController.MP + "");
     Debug.Log("攻撃力が" + monsterController.magic + "上がった。");
     messageScript.SetMagicMessage();
 }
Пример #31
0
    public void ChangePhase(BattlePhase newPhase)
    {
        this.CurrentPhase = newPhase;

        if (this.onBattlePhaseChange != null)
        {
            this.onBattlePhaseChange(newPhase);
        }

        switch (this.CurrentPhase)
        {
            case BattlePhase.NextRound:
                this.NextRound();
                break;
            default: 
                break;
        }
    }
Пример #32
0
        public void SelectATK(BattlePhase _battlephase,Player _player, Computer _computer)
        {
            Card monsterbeATK;
            int minBattlePoint;
            Card monsteratk;
            if (_player.MonsterField.ListCard.Any())
            {
                // chọn trước lá bị tấn công
                minBattlePoint = _player.MonsterField.ListCard.Min(card => (card as Monster).BattlePoint);
                monsterbeATK = _player.MonsterField.ListCard.Where(card => (card as Monster).BattlePoint == minBattlePoint).First();
            }
            else
            {
                minBattlePoint = 0;
                monsterbeATK = null;
            }
            if (_battlephase.List_monsterATK.Any())
            {
                LinkedList<Card> list = new LinkedList<Card>(
                    _battlephase.List_monsterATK
                    .Where(card =>  (card as Monster).Atk > minBattlePoint));

                if (list.Any())
                {
                    monsteratk = list
                        .OrderBy(card => (card as Monster).Atk)
                        .First();
                }
                else
                    monsteratk = null;
            }
            else
            {
                monsteratk = null;
            }
            _battlephase.MonsterATK = monsteratk as Monster;
            if (_battlephase.MonsterATK != null)
                _battlephase.MonsterBeATK = monsterbeATK as Monster;
            else
                _battlephase.MonsterBeATK = null;
        }
Пример #33
0
    void Start()
    {
        m_enemyMgr = EnemyManager.Get();
        m_playerMgr = PlayerManager.Get();
        m_gestureHandler = InputManager.Get();

        m_gestureStart = false;
        m_beginFinisher = false;

        m_gestureState = GestureState.START;
        m_phase = BattlePhase.START;

        gaugeCount = 0;

        m_win = true;

        Service.Init();
        m_HUDService = Service.Get<HUDService>();
        m_HUDService.StartScene();

        // Create Battle HUD
        m_HUDService.CreateBattleHUD();
        m_HUDService.ShowBottom(false);
        m_HUDService.HUDControl.SetSpecialEnable(false);

        // Create Sound Service
        m_soundService = Service.Get<SoundService>();
        m_soundService.PreloadSFXResource(new string[13]{"attack01", "attack02", "attack03",
                                                            "countdown", "enemyattack", "finalstrokeappear",
                                                            "gaugefull", "magicnotecorrect", "playermoveattack",
                                                            "sceneswish", "supermove", "win", "LadyKnight_Shine"});

        m_BGM = Resources.Load("Music/" + m_bgmMusic) as AudioClip;
        m_SPECIAL = Resources.Load("Music/supermove_jingle" ) as AudioClip;
        m_soundService.PlayMusic(m_BGM, true);
        // Create Battle HUD

        if (nextBattleArea == 1) {
            m_bgTexture.mainTexture = Resources.Load ("Texture/BG_battle3") as Texture;
        }
        else if (nextBattleArea == 2) {
            m_bgTexture.mainTexture = Resources.Load ("Texture/BG_battle2") as Texture;
        }
    }
Пример #34
0
    void Update()
    {
        switch(m_phase)
        {
            case BattlePhase.START:
            {
                m_phase = BattlePhase.ATTACK;

            }
            break;
            case BattlePhase.ATTACK:
            {
                m_gestureHandler.DisableGesture = true;
                if(gaugeCount >= m_fullgaugeCount)
                {
                    if(m_beginFinisher)
                    {
                        m_phase = BattlePhase.SPECIAL;
                        m_beginFinisher = false;
                    }
                }
            }
            break;
            case BattlePhase.SPECIAL:
            {
                if(m_gestureState == GestureState.START)
                {
                    m_gestureHandler.DisableGesture = false;
                    m_gestureState = GestureState.SHOWING;
                    m_gestureStart = true;
                    m_coroutine = CommenceAtkInterval();

                    GestureGenerateMethod = m_gestureGenerator.GenerateEasyGesture;
                    StartCoroutine(m_coroutine);
                }
            }
            break;
            case BattlePhase.END:
            {
                if(m_win)
                {
                    StartCoroutine(Utility.DelayInSeconds( 4.0f,
                                                        (res) =>
                                                        {
                                                            m_soundService.StopMusic(m_SPECIAL);

                                                            m_boardCollider.SetActive(true);
                                                            if(m_boardHandler != null)
                                                                m_boardHandler.Init(m_win);
                                                        } ));
                }
                else
                {
                    m_win = true; // Reset win
                    GameObject obj = Instantiate(Resources.Load("Prefabs/GeneralPopUp")) as GameObject;
                    GeneralPopUp popuphandler = obj.GetComponent<GeneralPopUp>();
                    popuphandler.Init("Use 1 Gem to Revive with full HP.", "Yes", "No", Revive, Exit);
                    m_HUDService.HUDControl.AttachMid(ref obj);

                }

                m_phase = BattlePhase.TOTAL;
            }
            break;
        }
    }
Пример #35
0
    IEnumerator CommenceAtkInterval()
    {
        // Testing for Emiko's Proposal
        // yield return new WaitForSeconds(m_interval);
        if (GestureGenerateMethod != null) {
            GestureGenerateMethod ();
        }

        m_HUDService.HUDControl.ShowTip(true);

        // Display Special Effect
        m_FXObj = Instantiate(Resources.Load ("Prefabs/FX/Special_Attack_Fx")) as GameObject;
        m_FXObj.transform.SetParent(m_itemParent.transform, false);
        m_FXObj.transform.localPosition = new Vector3(720, m_FXObj.transform.localPosition.y, -20);

        // Remove HUD
        m_HUDService.HUDControl.ShowTop(false);
        m_HUDService.HUDControl.ShowHPBars(false);
        m_HUDService.ShowQuestTime(false);

        m_cntDwnRnt = Utility.DelayInSeconds(m_gestureInv - m_specialCountDown,
                        (res) =>
                        {
                            GameObject obj = Instantiate(Resources.Load("Prefabs/Battle/CountDown")) as GameObject;
                            obj.transform.SetParent(m_HUDService.HUDControl.transform, false);
                            obj.transform.localScale = new Vector3(180, 180, 1);
                        } );
        StartCoroutine(m_cntDwnRnt);

        // Count Down till Gesture Failure
        yield return new WaitForSeconds(m_gestureInv);

        ClearGesture();

        m_playerMgr.RemoveBB();
        m_HUDService.HUDControl.ShowTop (true);
        m_HUDService.HUDControl.ShowHPBars(true);
        m_HUDService.ShowQuestTime(true);
        m_soundService.StopMusic(m_SPECIAL);
        m_soundService.PlayMusic(m_BGM, true);

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

        m_gestureState = GestureState.END;
        gaugeCount = 0;

        ResetGauge();

        m_phase = BattlePhase.ATTACK;

        // Move Camera to view Enemy
        Service.Get<MapService>().TweenPos(new Vector3(703f, -3.76f, 0.0f),
                                                    new Vector3(-703f, -3.76f, 0.0f),
                                                    UITweener.Method.EaseInOut,
                                                    UITweener.Style.Once,
                                                    null,
                                                    "");
    }
Пример #36
0
 void Revive()
 {
     m_playerMgr.Recover(100);
     m_HUDService.HUDControl.ShowActionButtons(true);
     if(m_HUDService.HUDControl.GetSpecialAmount == 1.0f)
     {
         SoundService ss = Service.Get<SoundService>();
         ss.PlaySound(ss.GetSFX("gaugefull"), false);
         m_HUDService.HUDControl.SetSpecialFxGlow(true);
         m_HUDService.HUDControl.SetSpecialEnable(true);
     }
     m_phase = BattlePhase.ATTACK;
 }
Пример #37
0
        private void ChangePokemon(GameTime gameTime)
        {
            ChangingPokemonState = ChangingPokemon.None;

            _textPanel.TextPromptArrow.WaitingForTextToAppear(gameTime);

            if (ActiveAlliedPokemon.PokemonInstance.CurrentHealth == 0)
            {
                foreach (var pokemon in AlliedTrainer.PokemonSet.Where(pokemon => pokemon.CurrentHealth > 0))
                {
                    ActiveAlliedPokemon.PokemonInstance = pokemon;
                    ActiveAlliedPokemon.PokemonInstance.PrepareForCombat(RenderingPosition.Ally);
                    _attackMenu.SetPokemon(ActiveAlliedPokemon.PokemonInstance);
                    _allyPokemonPanel.SetPokemon(ActiveAlliedPokemon.PokemonInstance);

                    ChangingPokemonState = ChangingPokemon.Ally;
                    CurrentPhase = BattlePhase.AllyTurn;
                    AttackState = AttackState.Undecided;
                    break;
                }

                if (ChangingPokemonState == ChangingPokemon.None)
                {
                    BattleConclusion = BattleConclusion.PlayerLost;
                    Game1.StateManager.ChangeState(((Game1) Game).GameOverScreen);
                }
            }
            else if (ActiveEnemyPokemon.PokemonInstance.CurrentHealth == 0)
            {
                foreach (var pokemon in EnemyTrainer.PokemonSet.Where(pokemon => pokemon.CurrentHealth > 0))
                {
                    ActiveEnemyPokemon.PokemonInstance = pokemon;
                    ActiveEnemyPokemon.PokemonInstance.PrepareForCombat(RenderingPosition.Enemy);
                    _enemyPokemonPanel.SetPokemon(ActiveEnemyPokemon.PokemonInstance);

                    ChangingPokemonState = ChangingPokemon.Enemy;
                    CurrentPhase = BattlePhase.AllyTurn;
                    AttackState = AttackState.Undecided;
                    break;
                }

                if (ChangingPokemonState == ChangingPokemon.None)
                {
                    if (EnemyTrainer.Name.Equals("Lehmann"))
                        Game1.StateManager.ChangeState(((Game1)Game).VictoryScreen);
                }
            }

            if (ChangingPokemonState == ChangingPokemon.None)
            {
                CurrentPhase = BattlePhase.Ending;
                if (ActiveEnemyPokemon.PokemonInstance.CurrentHealth == 0)
                {
                    AudioController.RequestTrack("battle").Stop();
                    AudioController.RequestTrack("victory").Play();
                    BattleConclusion = BattleConclusion.PlayerWon;
                }
                else
                {
                    BattleConclusion = BattleConclusion.PlayerLost;
                }
            }
        }
Пример #38
0
    public void SpecialCorrect()
    {
        if(m_coroutine != null)
            StopCoroutine(m_coroutine);
        m_gestureState = GestureState.START;

        m_playerMgr.RemoveBB();

        m_HUDService.HUDControl.ShowTop (true);
        m_HUDService.HUDControl.ShowHPBars(true);
        m_HUDService.ShowQuestTime(true);

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

        m_phase = BattlePhase.ATTACK;
        gaugeCount = 0;
        ResetGauge();
    }
Пример #39
0
        /// <summary>
        /// Handles the update logic for the enemy EnemyTrainer turn
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of the gametime</param>
        public void EnemyTurn(GameTime gameTime)
        {
            EnemyChosenAttackIndex = Random.Next(0, ActiveEnemyPokemon.PokemonInstance.Moves.Count);

            CurrentPhase = BattlePhase.DetermineFirstToPerformAction;
        }
Пример #40
0
        private void DetermineFirstToPerformAction()
        {
            float alliedPokemonSpeed = ActiveAlliedPokemon.PokemonInstance.CombatStats[Stats.Speed].CurrentStatValue;
            float enemyPokemonSpeed = ActiveEnemyPokemon.PokemonInstance.CombatStats[Stats.Speed].CurrentStatValue;

            if (alliedPokemonSpeed > enemyPokemonSpeed)
                CurrentPhase = BattlePhase.AllyPerformsActionFirst;
            else if (alliedPokemonSpeed > enemyPokemonSpeed)
                CurrentPhase = BattlePhase.EnemyPerformsActionFirst;
            else
                CurrentPhase = Random.Next(0,2) == 1 ? BattlePhase.AllyPerformsActionFirst : BattlePhase.EnemyPerformsActionFirst;
        }
Пример #41
0
        private void TryToRun(GameTime gameTime)
        {
            if(!EnemyTrainer.Name.Equals("Tall Grass"))
            {
                _textPanel.BattleText.FirstLine = "You can't run from an enemy trainer!";
                _textPanel.BattleText.SecondLine = "";
                _textPanel.TextPromptArrow.WaitingForTextToAppear(gameTime);

                if (_textPanel.TextPromptArrow.State == TextArrowState.Clicked)
                    CurrentPlayerTurnPhase = PlayerTurnPhase.ChoosingAction;
            }
            else
            {
                CurrentPhase = BattlePhase.Ending;
                BattleConclusion = BattleConclusion.PlayerRan;
            }
        }
Пример #42
0
        /// <summary>
        /// Lets Enemy pokemon perform it's action
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of the gametime</param>
        public void EnemyPerformsAttack(GameTime gameTime)
        {
            if (AttackState == AttackState.Undecided)
            {
                ActiveEnemyPokemon.PokemonInstance.AnimationState = AttackAnimationState.Ready;
                _textPanel.BattleText.FirstLine = "Enemy " + ActiveEnemyPokemon.PokemonInstance.Archetype.Name + " used " + ActiveEnemyPokemon.PokemonInstance.Moves[EnemyChosenAttackIndex].Archetype.Name + "!";
                CalculateHitOrMiss(ActiveEnemyPokemon.PokemonInstance.Moves[EnemyChosenAttackIndex], ActiveEnemyPokemon.PokemonInstance);
            }

            AttackTimer += gameTime.ElapsedGameTime.Milliseconds;

            if (AttackTimer >= AttackTimerLength)
            {
                if (AttackState == AttackState.Hit)
                {
                    if (ActiveEnemyPokemon.PokemonInstance.AnimationState == AttackAnimationState.Ready)
                        ActiveEnemyPokemon.PokemonInstance.AnimationState = AttackAnimationState.Starting;

                    if (ActiveEnemyPokemon.PokemonInstance.FrameCounter == ActiveEnemyPokemon.PokemonInstance.FramesToApex)
                    {
                        ProcessHit(ActiveEnemyPokemon.PokemonInstance.Moves[EnemyChosenAttackIndex], ActiveEnemyPokemon.PokemonInstance);
                        AudioController.RequestTrack("hit").Play();
                    }

                    _textPanel.TextPromptArrow.WaitingForTextToAppear(gameTime, 1000);
                    if (_textPanel.TextPromptArrow.State == TextArrowState.Clicked)
                    {
                        CurrentPhase = CurrentPhase == BattlePhase.EnemyPerformsActionFirst ? BattlePhase.AllyPerformsActionSecond : BattlePhase.AllyTurn;

                        AttackTimer = 0;
                        ActiveEnemyPokemon.PokemonInstance.AnimationState = AttackAnimationState.Ready;
                        AttackState = AttackState.Undecided;
                    }
                }
                else
                {
                    _textPanel.BattleText.FirstLine = "But it failed!";

                    _textPanel.TextPromptArrow.WaitingForTextToAppear(gameTime, 100);

                    if (_textPanel.TextPromptArrow.State == TextArrowState.Clicked)
                    {

                        CurrentPhase = CurrentPhase == BattlePhase.EnemyPerformsActionFirst ? BattlePhase.AllyPerformsActionSecond : BattlePhase.AllyTurn;
                        AttackTimer = 0;
                        AttackState = AttackState.Undecided;
                    }
                }
            }
        }
Пример #43
0
    private void ProcessActionResult(Queue<BattleActionResult> resultQueue, BattlePhase nextPhase, Action callback = null)
    {
        foreach (var result in resultQueue)
        {
            this.ApplyActionResult(result);
        }

        Action onComplete = () =>{            
            if (callback != null)
            {
                callback();
            }
            this.ChangePhase(nextPhase);
        };

        if (this.onProcessActionResult != null)
        {
            this.ChangePhase(BattlePhase.Animation);
            this.onProcessActionResult(resultQueue, onComplete);
        }
        else
        {
            onComplete();
        }
    }
Пример #44
0
        /// <summary>
        /// Starts the battle and handles the update logic for that part
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of the gametime</param>
        public void StartBattle(GameTime gameTime)
        {
            //Moves trainers into position
            if (AlliedTrainer.Position.X > 50 && EnemyTrainer.Position.X < 200 && !_withDrawingStarted)
            {
                EnemyTrainer.Position = new Vector2(EnemyTrainer.Position.X + 2, EnemyTrainer.Position.Y);
                AlliedTrainer.Position = new Vector2(AlliedTrainer.Position.X - 2, AlliedTrainer.Position.Y);
            }

            //Tests if the trainers are in position for the battleText to appear
            if (EnemyTrainer.Position.X >= 50 && EnemyTrainer.Position.X >= 150 && !_withDrawingStarted)
            {
                _textPanel.BattleText.FirstLine = EnemyTrainer.Name + " wants to fight!";

                _trainersInPosition = true;
                _textPanel.TextPromptArrow.WaitingForTextToAppear(gameTime);

                if (_textPanel.TextPromptArrow.State == TextArrowState.Clicked)
                {
                    _trainerEnemyWithdrawing = true;
                    _trainersInPosition = false;
                }
            }

            //EnemyTrainer enemy starts it's withdrawal
            if (_trainerEnemyWithdrawing)
            {
                _withDrawingStarted = true;
                EnemyTrainer.Position = new Vector2(EnemyTrainer.Position.X +2, EnemyTrainer.Position.Y);

                if (EnemyTrainer.Position.X >= 250)
                    _textPanel.BattleText.FirstLine = EnemyTrainer.Name + " sent out " +
                                                        ActiveEnemyPokemon.PokemonInstance.Archetype.Name + "!";

                if (EnemyTrainer.Position.X >= 400)
                {
                    EnemyTrainer.Position = new Vector2(EnemyTrainer.Position.X - 2, EnemyTrainer.Position.Y);

                    _textPanel.TextPromptArrow.WaitingForTextToAppear(gameTime);

                    if (_textPanel.TextPromptArrow.State == TextArrowState.Clicked)
                    {
                        _textPanel.BattleText.FirstLine = "";
                        Timer = 0;
                        _trainerEnemyWithdrawing = false;
                        _trainerHeroWithdrawing = true;
                    }
                }
            }

            //EnemyTrainer hero starts it's withdrawal
            if (_trainerHeroWithdrawing)
            {
                Timer += gameTime.ElapsedGameTime.Milliseconds;
                if (Timer >= 100)
                    AlliedTrainer.Position = new Vector2(AlliedTrainer.Position.X - 2, AlliedTrainer.Position.Y);

                if (Math.Abs(AlliedTrainer.Position.X - 30) < 1)
                    _textPanel.BattleText.FirstLine = "Go, " + ActiveAlliedPokemon.PokemonInstance.Archetype.Name + "!";
            }

            //Changes the battlephase after you have thrown out a pokemon
            if (Math.Abs(AlliedTrainer.Position.X + 300) < 1)
            {
                EnemyTrainer.Visible = false;
                AlliedTrainer.Visible = false;
                CurrentPhase = BattlePhase.AllyTurn;
                Timer = 0;
            }

            //Draws the hero and the basic control-panel background
            EnemyTrainer.Visible = true;

            //Both trainers are in position to withdraw and throw out a pokeball
            if (_trainersInPosition)
            {
                _pokeballsAlly.Visible = true;

                if (EnemyTrainer.Position.X < 250)
                    _pokeballsEnemy.Visible = true;
            }

            //The enemy withdraws to throw out a pokemon
            if (EnemyTrainer.Position.X >= 160)
                _pokeballsEnemy.Visible = false;

            //The enemy withdraws to throw out a pokemon
            if (EnemyTrainer.Position.X >= 300)
            {
                if (_enemyPokemonPanel.Visible == false)
                {
                    AudioController.RequestTrack("deployPokeBall").Play();
                    // AudioController.RequestTrack("name").Play();

                }

                ActiveEnemyPokemon.Visible = true;
                _enemyPokemonPanel.Visible = true;

                if (_enemyPokemonPanel.Pokemon.PokemonInstance != ActiveEnemyPokemon.PokemonInstance)
                    _enemyPokemonPanel.SetPokemon(ActiveEnemyPokemon.PokemonInstance);
            }

            if (AlliedTrainer.Position.X <= 40)
                _pokeballsAlly.Visible = false;

            if (AlliedTrainer.Position.X <= -100)
            {
                if (ActiveAlliedPokemon.Visible == false)
                {
                    AudioController.RequestTrack("deployPokeBall").Play();

                    AudioController.RequestTrack(ActiveAlliedPokemon.PokemonInstance.Archetype.Name).Play();
                }

                ActiveAlliedPokemon.Visible = true;
                _allyPokemonPanel.Visible = true;

                if (_allyPokemonPanel.Pokemon.PokemonInstance != ActiveAlliedPokemon.PokemonInstance)
                    _allyPokemonPanel.SetPokemon(ActiveAlliedPokemon.PokemonInstance);
            }
        }
Пример #45
0
        public void ChoosingAttack(GameTime gameTime)
        {
            _textPanel.BattleText.FirstLine = "";
            _textPanel.BattleText.SecondLine = "";

            _attackMenu.SetPokemon(ActiveAlliedPokemon.PokemonInstance);
            _attackMenu.Visible = true;
            _attackChoiceArrow.Visible = true;

            if (InputHandler.ActionKeyPressed(ActionKey.Back, PlayerIndex.One))
            {
                // Return to action menu
                CurrentPlayerTurnPhase = PlayerTurnPhase.ChoosingAction;
                _attackMenu.Visible = false;
                _attackChoiceArrow.Visible = false;
            }
            else if (InputHandler.ActionKeyPressed(ActionKey.ConfirmAndInteract, PlayerIndex.One))
            {
                bool validMoveChosen = false;

                switch (_attackChoiceArrow.AttackChoiceArrowPosition)
                {
                    case AttackChoiceArrowPosition.Move1:
                        if (ActiveAlliedPokemon.PokemonInstance.Moves[0].RemainingPP > 0)
                        {
                            PlayerChosenAttack = AttackChoiceArrowPosition.Move1;
                            validMoveChosen = true;
                        }
                        break;
                    case AttackChoiceArrowPosition.Move2:
                        if (ActiveAlliedPokemon.PokemonInstance.Moves[1].RemainingPP > 0)
                        {
                            PlayerChosenAttack = AttackChoiceArrowPosition.Move2;
                            validMoveChosen = true;
                        }
                        break;
                    case AttackChoiceArrowPosition.Move3:
                        if (ActiveAlliedPokemon.PokemonInstance.Moves[2].RemainingPP > 0)
                        {
                            PlayerChosenAttack = AttackChoiceArrowPosition.Move3;
                            validMoveChosen = true;
                        }
                        break;
                    case AttackChoiceArrowPosition.Move4:
                        if (ActiveAlliedPokemon.PokemonInstance.Moves[3].RemainingPP > 0)
                        {
                            PlayerChosenAttack = AttackChoiceArrowPosition.Move4;
                            validMoveChosen = true;
                        }
                        break;
                }

                if (validMoveChosen)
                {
                    CurrentPhase = BattlePhase.EnemyTurn;
                    CurrentPlayerTurnPhase = PlayerTurnPhase.ChoosingAction;
                    PreviousPlayerAttack = PlayerChosenAttack;

                    _attackMenu.Visible = false;
                    _attackChoiceArrow.Visible = false;
                }
            }
        }
Пример #46
0
        public void AddNotification(BattlePhase Phase, string Data)
        {
            if (notifications.Count(x => x.Key == Phase) > 0)
                return;

            notifications.Add(Phase, Data);
        }
Пример #47
0
        public Battle(Game1 game, Trainer alliedTrainer, Trainer enemyTrainer, bool trainerBattle)
            : base(game)
        {
            Camera = new Camera(game.ScreenRectangle) {Zoom = 4f};
            Camera.LockToCenter(game.ScreenRectangle);

            _trainerBattle = trainerBattle;
            CurrentPhase = BattlePhase.Starting;

            AlliedTrainer = alliedTrainer;
            AlliedTrainer.PrepareForCombat(RenderingPosition.Ally);

            EnemyTrainer = enemyTrainer;
            EnemyTrainer.PrepareForCombat(RenderingPosition.Enemy);

            foreach (var pokemon in EnemyTrainer.PokemonSet.Where(pokemon => pokemon.CurrentHealth > 0))
            {
                ActiveEnemyPokemon = new PokemonWrapper(game, pokemon);
                break;
            }

            foreach (var pokemon in AlliedTrainer.PokemonSet.Where(pokemon => pokemon.CurrentHealth > 0))
            {
                ActiveAlliedPokemon = new PokemonWrapper(game, pokemon);
                break;
            }

            ActiveAlliedPokemon.PokemonInstance.PrepareForCombat(RenderingPosition.Ally);
            ActiveEnemyPokemon.PokemonInstance.PrepareForCombat(RenderingPosition.Enemy);

            // Initiate state
            BattleConclusion = BattleConclusion.Undecided;
            EndStage = EndStage.DisplayResult;
            CurrentPlayerTurnPhase = PlayerTurnPhase.ChoosingAction;
            RewardState = RewardState.ExperienceToBeAwarded;

            LoadContent();
        }
Пример #48
0
        public KeyValuePair<BattlePhase, string> RetrieveFirstNotification(BattlePhase Phase)
        {
            var scope = notifications.Where(x => x.Key == Phase);
            if (scope.Count() == 0)
                return new KeyValuePair<BattlePhase, string>(BattlePhase.Draw, "ERROR");

            var notification = notifications.OrderBy(x => x.Key).First();
            notifications.Remove(notification.Key);
            return notification;
        }
Пример #49
0
 public void GameOver()
 {
     m_phase = BattlePhase.END;
     m_win = false;
 }
Пример #50
0
    public void Correct()
    {
        if(m_coroutine != null)
            StopCoroutine(m_coroutine);

        m_gestureState = GestureState.START;

        m_playerMgr.RemoveBB();

        m_HUDService.HUDControl.ShowHPBars(true);
        m_HUDService.ShowQuestTime(true);

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

        ++gaugeCount;
        if(gaugeCount > m_fullgaugeCount)
            gaugeCount = m_fullgaugeCount;

        if(m_phase == BattlePhase.SPECIAL)
        {
            m_phase = BattlePhase.ATTACK;
            gaugeCount = 0;
            ResetGauge();
        }
        else
        {
            m_HUDService.HUDControl.SetSpecialGaugeAmt((float)gaugeCount/m_fullgaugeCount);
        }
    }
Пример #51
0
        private void PlayerRunning(GameTime gameTime)
        {
            _textPanel.BattleText.FirstLine = "Got away safely.";
            _textPanel.BattleText.SecondLine = "";

            _textPanel.TextPromptArrow.WaitingForTextToAppear(gameTime);

            if (_textPanel.TextPromptArrow.State == TextArrowState.Clicked)
            {
                CurrentPhase = BattlePhase.Ending;
                BattleConclusion = BattleConclusion.PlayerRan;
            }
        }
Пример #52
0
 public void SetBattle(BattlePhase battle)
 {
     Battle = battle;
 }
Пример #53
0
        public override void Update(GameTime gameTime)
        {
            // Conclude battle if any active pokemon reaches 0 HP
            if (BattleConclusion == BattleConclusion.Undecided &&
                (ActiveAlliedPokemon.PokemonInstance.CurrentHealth == 0
                 || ActiveEnemyPokemon.PokemonInstance.CurrentHealth == 0))
            {
               CurrentPhase = BattlePhase.ChangePokemon;
            }

            switch (CurrentPhase)
            {
                case BattlePhase.Starting:
                    StartBattle(gameTime);
                    break;
                case BattlePhase.AllyTurn:
                    AllyTurn(gameTime);
                    break;
                case BattlePhase.EnemyTurn:
                    EnemyTurn(gameTime);
                    break;
                case BattlePhase.DetermineFirstToPerformAction:
                    DetermineFirstToPerformAction();
                    break;
                case BattlePhase.AllyPerformsActionFirst:
                case BattlePhase.AllyPerformsActionSecond:
                    AllyPerformsAttack(gameTime);
                    break;
                case BattlePhase.EnemyPerformsActionFirst:
                case BattlePhase.EnemyPerformsActionSecond:
                    EnemyPerformsAttack(gameTime);
                    break;
                case BattlePhase.PlayerRunning:
                    PlayerRunning(gameTime);
                    break;
                case BattlePhase.ChangePokemon:
                    ChangePokemon(gameTime);
                    break;
                case BattlePhase.Ending:
                    Ending(gameTime);
                    break;
            }

            // Update all UI components
            foreach (var component in DrawableComponents.Where(component => component.Visible))
            {
                component.Update(gameTime);
            }
        }