void buttonOnClick(int buttonIndex)
 {
     if (!buttonClicked)
     {
         current_button = buttonIndex;
         buttonClicked  = true;
         hugh_man.SelectAbility(abilityTexts[current_button].text);
         curr_phase = CombatPhase.TargetSelection;
     }
     else
     {
         if (hugh_man.target != null)
         {
             buttonClicked = false;
             hugh_man.ConfirmAbility();
             curr_phase = CombatPhase.ActionExecution;
         }
     }
 }
Exemple #2
0
    IEnumerator ApplyStatuses()
    {
        // Apply buff and debuff
        yield return(StartCoroutine(_activeFighter.ApplyStatuses()));

        // IF a debuff killed the actual fighter we go back
        // to turn intialization
        if (_activeFighter.dead)
        {
            _actualPhase = CombatPhase.TURN_INIT;
        }
        else
        {
            if (!_activeFighter.isAI)
            {
                _actualPhase = CombatPhase.WAIT_PLAYER_ACTION_CHOICE;
            }
            else
            {
                _actualPhase = CombatPhase.AI_ACTION_PHASE;
            }
        }
    }
        /// <summary>
        /// Update everything in the windows to play the attack minigames
        /// </summary>
        public void Run()
        {
            BeginDrawing();
            ClearBackground(BLACK);
            switch (stage)
            {
            //1st case "StartPhase", Preloading scene to make Timer count properly
            case CombatPhase.START:
                DrawText("Loading", 300, 200, 40, RAYWHITE);
                if (attackTimer.Check())
                {
                    //Setup enemy healthbar to display correctly
                    Vector2 vec = new Vector2(0, borderThickness + healthBar.Height);
                    healthBorder.Position = vec;
                    vec = Vector2.One * borderThickness;
                    healthBackground.Position = vec;
                    healthBar.Position        = vec;
                    healthBar.Width           = ((float)monster.creature.currentHP / (float)monster.creature.maximumHP) * healthBackground.Width;

                    if ((player.creature as Player).currentWeapon == null)
                    {
                        stage = CombatPhase.PAUSE;
                        break;
                    }

                    (player.creature as Player).currentWeapon.WeaponAttack.Start();
                    stage = CombatPhase.PLAYERATTACK;
                }
                break;

            //2nd case "PlayerAttackPhase", runs the players attack against the enemy
            case CombatPhase.PLAYERATTACK:
                PlayerAttack();
                break;

            //3rd case "PausePhase", Pause the action and give the player a chance to state when their ready
            case CombatPhase.PAUSE:
                DrawText("Press Enter to continue", 170, 50, 40, RAYWHITE);
                //Wait until the player presses Enter
                if (IsKeyPressed(KeyboardKey.KEY_ENTER))
                {
                    //Setup player Healthbar to display properly
                    Vector2 vec = new Vector2(0, screenHeight - (borderThickness * 2 + healthBar.Height));
                    healthBorder.Position = vec;
                    vec.X = borderThickness;
                    vec.Y = screenHeight - (borderThickness + healthBar.Height);
                    healthBackground.Position = vec;
                    healthBar.Position        = vec;
                    healthBar.Width           = ((float)player.creature.currentHP / (float)player.creature.maximumHP) * healthBackground.Width;

                    (monster.creature as Monster).enemyAttack.Start();
                    stage = CombatPhase.ENEMYATTACK;
                }
                break;

            //4th case "EnemyAttackPhase", runs the enemys attack against the player
            case CombatPhase.ENEMYATTACK:
                EnemyAttack();
                break;

            //5th case "EndPhase", Ends the Attack system
            case CombatPhase.END:
                EndAttack();
                break;
            }
            DrawUI(stage);
            EndDrawing();
        }
    /*
    public void SwitchCombatPhase(CombatPhase phase) {
        curCombatPhase = phase;
    }
    */
    //END CURRENT STATE, DETERMINE NEXT STATE, AND INITIALIZE IT AFTER CHOSEN
    public void ChangeCombatState(CombatPhase state, CombatPhase nextState = CombatPhase.None)
    {
        if (currentBattleState != null) {
            currentBattleState.EndState();
        }

        switch (state) {
            case CombatPhase.EnterCombat://ENTER COMBAT (bring up hex grid, place teams)
                currentBattleState = new EnterCombatState(state);
                break;
            case CombatPhase.ExitCombat://EXIT COMBAT (remove hex grid)
                currentBattleState = new ExitCombatState(state);
                break;
            case CombatPhase.TileSelection://TILE SELECTION (select agent to perform actions with)
                currentBattleState = new TileSelectionState(state);//UNDOABLE
                break;
            case CombatPhase.ActionSelection://ACTION SELECTION (enable Actions menu)
                currentBattleState = new ActionSelectionState(state);//UNDOABLE
                break;
            case CombatPhase.TargetSelection://TARGET SELECTION (select a target tile for the action)
                currentBattleState = new TargetSelectionState(state);//UNDOABLE
                break;
            case CombatPhase.ConfirmAction://ACTION CONFIRMATION (final confirmation, may change to something available to all Combat States)
                currentBattleState = new ConfirmActionState(state);//UNDOABLE
                break;
            case CombatPhase.PerformAction://PERFORM ACTION (no user control)
                currentBattleState = new PerformActionState(state);
                break;
            case CombatPhase.CheckTeam://CHECK TEAM (switch which team is going based on if all team members have gone)
                currentBattleState = new CheckTeamState(state);
                break;
            case CombatPhase.AISelection://SELECT AI AGENT
                currentBattleState = new AISelectionState(state);
                break;
            case CombatPhase.AILogic://PERFORM AI LOGIC
                currentBattleState = new AILogicState(state);
                break;
            case CombatPhase.Dialogue://HANDLE DIALOGUE UI
                currentBattleState = new DialogueState(state, nextState);
                break;

            default:
                Debug.LogError("BattleManager: Undefined state transition!");
                break;
        }

        currentBattleState.InitState();//make sure we initialize the state

        curCombatPhase = state;
    }
 public void PushPreviousCombatPhase(CombatPhase prevPhase)
 {
     prevCombatPhaseStack.Push(prevPhase);
 }
    // TODO: IMPLEMENT QUICK HEALTH LOSS SEQUENCE (health bar drain)
    void Combat()
    {
        timer += Time.deltaTime;

        // TODO: implement strike animations (single image w/ movement)
        switch (phase)
        {
        case CombatPhase.attackerLunge:
        {
            if (timer > 0.25f && timer < 0.5f)
            {
                attacker.transform.position += displacement * Time.deltaTime * GLOBAL.attackSpeed;
            }
            else if (timer >= 0.5f)
            {
                if (attackerHit)
                {
                    defender.Damage(attackerDamage);
                    Camera.main.GetComponent <AudioSource>().PlayOneShot(attacker.equipped.sfx);
                }
                else
                {
                    Camera.main.GetComponent <AudioSource>().PlayOneShot(GameDirector.Instance.sfxCancel);        // TODO: miss SFX here
                }

                displacement = -displacement;

                phase = CombatPhase.attackerRetreat;
            }
            break;
        }

        case CombatPhase.attackerRetreat:
        {
            if (timer < 0.75f)
            {
                attacker.transform.position += displacement * Time.deltaTime * GLOBAL.attackSpeed;
            }
            else if (timer < 1.25f)
            {
                attacker.snapToGridPos();
            }
            else
            {
                if (defender.CheckDead() || !retaliation)
                {
                    Finish();
                }
                else
                {
                    phase = CombatPhase.defenderLunge;
                }
            }

            break;
        }

        case CombatPhase.defenderLunge:
        {
            if (timer < 1.5f)
            {
                defender.transform.position += displacement * Time.deltaTime * GLOBAL.attackSpeed;
            }
            else
            {
                if (defenderHit)
                {
                    attacker.Damage(defenderDamage);
                    Camera.main.GetComponent <AudioSource>().PlayOneShot(defender.equipped.sfx);
                }
                else
                {
                    Camera.main.GetComponent <AudioSource>().PlayOneShot(GameDirector.Instance.sfxCancel);        // TODO: miss SFX here
                }

                displacement = -displacement;

                phase = CombatPhase.defenderRetreat;
            }


            break;
        }

        case CombatPhase.defenderRetreat:
        {
            if (timer < 1.75f)
            {
                defender.transform.position += displacement * Time.deltaTime * GLOBAL.attackSpeed;
            }
            else if (timer > 2.5f)
            {
                defender.snapToGridPos();

                attacker.CheckDead();         // process death for attacker

                Finish();
            }

            break;
        }
        }
    }
Exemple #7
0
 public MasterInstantiatingPhase(PhaseManager phaseManager, NetworkUIController networkUiController,
                                 CloudAnchorsExampleController cloudAnchors, ObstacleGenerator obstacleGenerator, CombatPhase combatPhase,
                                 bool skipGameArea) : base(phaseManager)
 {
     _networkUiController = networkUiController;
     _cloudAnchors        = cloudAnchors;
     _obstacleGenerator   = obstacleGenerator;
     _combatPhase         = combatPhase;
     _obstacleGenerator.OnFinishPlacingObstacles += FinishPlacingObstacles;
     _skipGameArea = skipGameArea;
 }
Exemple #8
0
 void ApplyPickedAction()
 {
     curAction.Apply(this);
     phase = CombatPhase.PickActorAction;
     CombatFinishedCheck();
 }
Exemple #9
0
 public NonMasterInstantiatingPhase(PhaseManager phaseManager, NetworkUIController networkUiController,
                                    CombatPhase combatPhase) : base(phaseManager)
 {
     _networkUiController = networkUiController;
     _combatPhase         = combatPhase;
 }