Beispiel #1
0
 void Retaliation()
 {
     // NOTE that switching to retaliation state is ENOUGH to trigger retaliation choice, as the RetaliationButtonsScript takes care of everything.
     preEnemyPhase = TurnManager.Instance.CurrentPhase;
     GameState     = GameStates.RetaliationState;
     TurnManager.Instance.CurrentPhase = TurnPhases.Enemy;
 }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        currentTurn      = 1;
        currentTurnPhase = TurnPhases.MOVE;

        UpdateTurnUI();
    }
        /// <summary>
        /// Handles the transitions from one phase to another
        /// as the Active player takes his/her turn
        /// </summary>
        void PhaseTransition()
        {
            switch (currentPhase)
            {
            case TurnPhases.First:
                currentPhase = TurnPhases.Second;
                curPhase     = currentPhase;
                break;

            case TurnPhases.Second:
                currentPhase = TurnPhases.Combat;
                curPhase     = currentPhase;
                break;

            case TurnPhases.Combat:
                currentPhase = TurnPhases.End;
                curPhase     = currentPhase;
                break;

            case TurnPhases.End:
                currentPhase = TurnPhases.First;
                curPhase     = currentPhase;
                PlayerCycle();
                break;
            }
        }
Beispiel #4
0
    private void Start()
    {
        npcs = gameObject.GetComponent <NPCsManager>();

        turnPhase = TurnPhases.defNPC;
        StartCoroutine(GameCycle());
    }
Beispiel #5
0
 private void OnOpponentHealthClicked()
 {
     if (TurnPhases.IsCurrentPhase(TurnPhase.Main))
     {
         // DealDamageToOpponent(DamageDisplay.Damage);
         //DamageDisplay.SetDamageDisplayed(0);
     }
 }
Beispiel #6
0
 void Awake()
 {
     //EventManager.OnTurnPhaseBegin += OnTurnPhaseBegin;
     EventManager.Phases.BeginningOfTurn_OnEnter += AtBeginningOfTurn;
     EventManager.Phases.EndOfTurn_OnEnter       += AtEndOfTurn;
     TurnPhases        = gameObject.AddComponent <TurnPhases>();
     CollectionManager = new CollectionManager(this);
 }
Beispiel #7
0
 public void MovementPhase()
 {
     CurrentPhase = TurnPhases.Movement;
     MouseManager.Instance.Deselect();
     if (GameStateManager.Instance.IsCurrentPlayerAI())
     {
         Debug.Log("Movement phase beggins.");
     }
 }
Beispiel #8
0
 public void ShootingPhase()
 {
     CurrentPhase = TurnPhases.Shooting;
     MouseManager.Instance.Deselect();
     if (GameStateManager.Instance.IsCurrentPlayerAI())
     {
         Debug.Log("Shooting phase beggins.");
     }
 }
Beispiel #9
0
 public void AttackPhase()
 {
     CurrentPhase = TurnPhases.Attack;
     MouseManager.Instance.Deselect();
     if (GameStateManager.Instance.IsCurrentPlayerAI())
     {
         Debug.Log("Attack phase beggins.");
     }
 }
Beispiel #10
0
        public IActionResult TurnPhase(TurnPhases phase, Guid playerId, Guid gameId)
        {
            try
            {
                switch (phase)
                {
                case TurnPhases.AttackPhase:
                    var game = GamesSingleton.GetInstance().games.Where(g => g.id == gameId).FirstOrDefault();



                    if (game.gameType == GameTypes.AutoAttack)
                    {
                        if (game.player1.id == playerId)
                        {
                            var enemyid = game.player2.id;
                            var player  = game.player1;
                            var enemy   = game.player2;
                            strategy.decideStrategy(game, player, enemy);
                        }
                        else if (game.player2.id == playerId)
                        {
                            var enemyid = game.player1.id;
                            var player  = game.player2;
                            var enemy   = game.player1;
                            strategy.decideStrategy(game, player, enemy);
                        }
                        _turnLogic.UpdateView(game);
                    }
                    else
                    {
                        _turnLogic.Attack(gameId, playerId);
                    }

                    break;

                case TurnPhases.SecondPhase:
                    _turnLogic.Second(gameId, playerId);
                    break;

                case TurnPhases.EndTurn:
                    drawcardcontroller.DrawCard(gameId, playerId, 1);
                    _turnLogic.EndTurn(gameId, playerId);
                    break;

                default:
                    throw new NotImplementedException();
                }

                return(Ok());
            }
            catch
            {
                return(BadRequest());
            }
        }
Beispiel #11
0
    public void DealDamageToOpponent()
    {
        if (MegaManager.CurrentPlayer.Damage != this)
        {
            return;
        }

        if (TurnPhases.IsCurrentPhase(TurnPhase.Main))
        {
            EventManager.DealDamageToPlayer(DamageInPool, MegaManager.CurrentOpponent);
            EmptyPool();
        }
    }
Beispiel #12
0
    public void ChangeTurn()
    {
        if (currentTurn == 1)
        {
            currentTurn += 1;
        }
        else
        {
            currentTurn -= 1;
        }

        currentTurnPhase = TurnPhases.MOVE;
    }
Beispiel #13
0
    // Use this for initialization
    void Start()
    {
        customers = new Customer[5];
        user1Deck = ShuffleDeck(CreateDeck());
        user2Deck = ShuffleDeck(CreateDeck());

        turnPhase = TurnPhases.DRAW_PHASE;
        user1Turn = true;
        for (int i = 0; i < customers.Length; ++i)
        {
            customers [i] = new Customer();
        }
        ModifyCustomer(0, true, Random.Range(1, 6) << 1);
    }
Beispiel #14
0
 // Update is called once per frame
 void Update()
 {
     if (user1Turn)
     {
         if (turnPhase == TurnPhases.DRAW_PHASE)
         {
             turnPhase = TurnPhases.FLAME_SELECT_PHASE;
             Debug.Log("Robas una carta");
         }
     }
     else
     {
     }
 }
Beispiel #15
0
 public void SetNewTurn(bool isRealGame)
 {
     if (NewTurnEvent != null)
     {
         NewTurnEvent();
     }
     text1.isOff = false;
     text2.isOff = false;
     SwitchPlayerHavingTurn();
     CurrentPhase = TurnPhases.Movement;
     if (GameStateManager.Instance.IsCurrentPlayerAI())
     {
         Debug.Log("New AI turn.");
     }
     if (isRealGame)
     {
         turnSource.Play();
         TurnCount++;
         if (TurnCount > 16)
         {
             PopupTextController.AddPopupText("Time is up!", PopupTypes.Stats);
         }
         else if (TurnCount == 16)
         {
             PopupTextController.AddPopupText("Final Turn!", PopupTypes.Damage);
             Log.SpawnLog("The last turn of the game has begun!");
             Log.SpawnLog("Movement phase begins.");
         }
         else if (TurnCount >= 11)
         {
             PopupTextController.AddPopupText("Remaining turns: " + (16 - TurnCount).ToString() + "!", PopupTypes.Damage);
             Log.SpawnLog("New turn. Remaining turns: " + (16 - TurnCount).ToString() + ".");
             Log.SpawnLog("Movement phase begins.");
         }
         else if (TurnCount > 1)
         {
             PopupTextController.AddPopupText("New Turn!", PopupTypes.Info);
             Log.SpawnLog("New turn.");
             Log.SpawnLog("Movement phase begins.");
         }
         else
         {
             PopupTextController.AddPopupText("Press Escape to see Victory Conditions!", PopupTypes.Info);
             Log.SpawnLog("Prepare for the Battle! Press Escape to see Victory Conditions!");
             Log.SpawnLog("Movement phase begins.");
         }
     }
     StartCoroutine(SetColour());
 }
    /////////////////////// DRAMA REGION
    #region DRAMA REGION

    // starts random drama,
    public void StartDrama()
    {
        // drama and outcome generation (accessed through ui)
        CurrentDrama = Drama.CreateRandomOne(worldState.GetRooms());
        Debug.Log(CurrentDrama);

        if (CurrentDrama.Room.numberOfCrew == 0)
        {
            AutomaticResolution();
            return;
        }

        // only sets phase after all drama stuff has been made
        panelHandler.ShowChoicePanel();
        CurrentPhase = TurnPhases.DRAMA;
    }
Beispiel #17
0
    private IEnumerator GameCycle()  // игровой цикл: транше стреляют -> игрок строит -> юниты двигаются -> юниты спаунятся
    {
        bool repeat = false;

        do
        {
            switch (turnPhase)
            {
            case TurnPhases.defNPC:
                // стрельба траншей

                yield return(StartCoroutine(npcs.ActAll(def: true)));

                turnPhase = TurnPhases.defPlayer;
                repeat    = true;
                break;

            case TurnPhases.defPlayer:

                // игрок строит
                nextTurnButton.interactable = true;     // отключение кнопки лежит в самой кнопке

                turnPhase = TurnPhases.attackNPC;
                repeat    = false;   // ждать нажатия кнопки
                break;

            case TurnPhases.attackNPC:
                // движение юнитов

                yield return(StartCoroutine(npcs.ActAll(def: false)));

                turnPhase = TurnPhases.attackSpawn;
                repeat    = true;
                break;

            case TurnPhases.attackSpawn:

                // спаун юнитов TODO
                turnPhase = TurnPhases.defNPC;
                repeat    = true;
                break;

            default:
                break;
            }
        } while (repeat);
    }
Beispiel #18
0
    public override void OnMouseHold(Vector3 mousePos, Camera cam)
    {
        if (!_draggingCard && (!TurnPhases.IsCurrentPhase(TurnPhase.Main) || !MegaManager.CollectionManager.CheckIfCanAfford(Card.ManaCost)))
        {
            return;
        }

        ZoomOut();
        _draggingCard = true;
        RaycastHit hit;

        Debug.DrawRay(cam.transform.position, cam.ScreenToWorldPoint(mousePos + Vector3.forward * 1000000));
        if (Physics.Raycast(cam.ScreenPointToRay(mousePos), out hit, Mathf.Infinity, Card.MegaMan.TableLayerMask))
        {
            Transform.position = hit.point + Vector3.back * 1;
        }
        //Vector3 mousePlusDepth = mousePos + Vector3.forward * Vector3.Distance(cam.transform.position, originalHandPosition);
    }
Beispiel #19
0
        /// <summary>
        /// Do the next turn
        /// </summary>
        internal void NextTurn()
        {
            switch (CurrentPhase)
            {
            case TurnPhases.Player:
                Player.DoTurn();
                CurrentPhase = TurnPhases.Enemy;

                // Want to plan enemy actors before enemy turn
                foreach (var actor in VisibleActors)
                {
                    if (actor != Player && !actor.Stunned)
                    {
                        (actor as Enemy).WhatYouWannaDo();
                    }
                }

                // If no enemies in sight, do their phase and go
                // straight back to the player one
                if (NoVisible())
                {
                    NextTurn();
                }
                break;

            case TurnPhases.Enemy:
                // Player can spend momentum to dodge or parry
                Player.DoTurn();

                foreach (var actor in VisibleActors)
                {
                    if (actor != Player)
                    {
                        actor.DoTurn();
                    }
                }
                CurrentPhase = TurnPhases.Player;
                break;
            }

            // Remove dead actors
            Hearse();
        }
Beispiel #20
0
    private void Start()
    {
        photonView = GetComponent <PhotonView>();
        if (Instance == null)
        {
            Instance = this;
        }
        turnSource        = gameObject.AddComponent <AudioSource>();
        turnSource.clip   = Resources.Load <AudioClip>("NewTurnSound");
        turnSource.volume = 0.02f;
        CurrentPhase      = TurnPhases.None;
        TurnCount         = -1;

        if (GameStateManager.Instance.MatchType == MatchTypes.Online && Player.Players[1].Type == PlayerType.Local)
        {
            // we are in an online game, AND we are not a host (precisely: second (red) player is the local player) so we should set CurrentPlayer stuff to 1 ;)
            PlayerHavingTurn = 1;
        }
    }
 // initializes the game
 public void Init()
 {
     CurrentPhase = TurnPhases.INTRO;
     panelHandler.ShowIntroPanel();
 }
Beispiel #22
0
    /// <summary>
    /// Advance to the next turn phase
    /// </summary>
    /// <returns>Whether advancing to the next turn phase was successful</returns>
    public bool Advance()
    {
        TurnPhases currentPhase = GetCurrentPhase();

        FileLogger.Trace("GAME", "Advancing. Current faction: " + GetCurrentFaction().GetName() + ", phase: " + currentPhase);

        switch (currentPhase)
        {
        case TurnPhases.START:

            if (IsGameOver())
            {
                return(false);
            }

            GetCurrentFaction().CollectIncome();

            FileLogger.Trace("SUMMARY", GetCurrentFaction().GetName() + " can recruit " + GetCurrentFaction().GetTotalManpower() + " units on turn " + _data.turn + ".");
            FileLogger.Trace("SUMMARY", GetCurrentFaction().GetName() + " have " + GetCurrentFaction().GetMoneyBalance() + " gold coins.");
            FileLogger.Trace("SUMMARY", GetCurrentFaction().GetName() + " accumulated " + GetCurrentFaction().GetFavors() + " divine favors.");

            GetCurrentFaction().CompleteTraining();

            GenerateStartOfTurnEvents();

            if (!GetCurrentFaction().IsPC())
            {
                if (_currentEvents.Count > 0)
                {
                    while (_currentEvents.Count > 0)
                    {
                        ReactToAnEvent(_currentEvents[0], GetCurrentFaction().GetStrategos().ChooseAnOption(_currentEvents[0]));
                    }
                    _currentEvents.Clear();
                }
            }
            break;

        case TurnPhases.TRAINING:

            if (!GetCurrentFaction().IsPC())
            {
                // NOTE: training and movement planning are combined for NPC actions
                // since this turn's training can depend on the next turn's movement plans
                List <ArmyMovementOrder> movementOrders = GetCurrentFaction().GetStrategos().SelectMovements();
                for (int i = 0; i < movementOrders.Count; i++)
                {
                    AddArmyMovementOrder(movementOrders[i]);
                }
            }

            if (GetCurrentFaction().GetMoneyBalance() < 0)
            {
                return(false);
            }
            break;

        case TurnPhases.MOVEMENT:
            List <ArmyMovementOrder> orders = _movementOrders.GetAllOrders();
            for (int i = 0; i < orders.Count; i++)
            {
                if (!orders[i].IsCombatMove())
                {
                    orders[i].GetDestination().AddUnits(orders[i].GetUnits());
                }
            }
            _movementOrders.RemoveNonCombatMoveOrders();
            // skip combat phase if there are no combats to resolve
            if (_movementOrders.GetAllOrders().Count == 0)
            {
                FileLogger.Trace("GAME", "No Combats To Resolve - Skipping The Phase");
                _data.currentTurnPhase++;

                // but do generate end of turn events
                // which are usually created at the end of combat phase
                GenerateEndOfTurnEvents();
            }
            break;

        case TurnPhases.COMBAT:
            // do not move to the next phase if there are unresolved movement orders
            if (_movementOrders.GetAllOrders().Count > 0)
            {
                if (!GetCurrentFaction().IsPC())
                {
                    Province target = _movementOrders.GetAllOrders()[0].GetDestination();
                    SetUpCombat(target);

                    if (!target.GetOwnersFaction().IsPC())
                    {
                        FileLogger.Trace("GAME", "Resolving a NPC-to-NPC combat");
                        // the honest Game doesn't use estimates
                        // it goes through some real dice rolling!
                        _currentCombat.ResolveCombat(false);
                        ResolveCombatResults();
                        return(true);
                    }
                    else
                    {
                        if (CombatStarted != null)
                        {
                            CombatStarted(this, EventArgs.Empty);
                        }
                    }
                    return(false);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                GenerateEndOfTurnEvents();
            }
            break;
        }

        if (currentPhase == TurnPhases.END)
        {
            if (_currentEvents.Count > 0)
            {
                if (!GetCurrentFaction().IsPC())
                {
                    while (_currentEvents.Count > 0)
                    {
                        ReactToAnEvent(_currentEvents[0], GetCurrentFaction().GetStrategos().ChooseAnOption(_currentEvents[0]));
                    }
                }
                _currentEvents.Clear();
            }
            else
            {
                _data.currentTurnPhase = 0;
                MoveToTheNextMajorFaction();
            }
        }
        else
        {
            _data.currentTurnPhase++;
        }

        FileLogger.Trace("GAME", "Current faction: " + GetCurrentFaction().GetName() + ", phase: " + GetCurrentPhase());

        if (PhaseChanged != null)
        {
            PhaseChanged(this, new EventArgs());
        }
        return(true);
    }
 private TurnPhase(TurnPhases @enum)
 {
     Value = @enum;
 }
 // ends the drama, displays outcome
 void EndDrama()
 {
     CurrentPhase = TurnPhases.DRAMA_OUTCOME;
     panelHandler.ShowOutcomePanel();
 }
    /////////////////////// MOVE REGION
    #region MOVE REGION

    // starts move (triggered by button)
    public void StartMove()
    {
        panelHandler.ShowMovePanel();
        CurrentPhase = TurnPhases.MOVE;
    }