Esempio n. 1
0
 new void Update()
 {
     base.Update();
     phase         = PhaseHandler.phase;
     decisionPhase = transform.Find("LegoPaperScissors").GetComponent <DecisionPhase>();
     actionPhase   = transform.Find("LegoPaperScissors").GetComponent <ActionPhase>();
     // print($"player is {transform.name}, decision phase is from {decisionPhase.transform.parent.name}");
 }
Esempio n. 2
0
    void Awake()
    {
        animator = gameObject.GetComponent <Animator>();
        dP       = GameObject.FindWithTag("CombatControl").GetComponent <DecisionPhase>();

        cMRightSprite              = dP.cMRightSprite;
        cMRightSpriteAnim          = dP.cMRightSpriteAnim;
        cMRightCharacterName       = dP.cMRightCharacterName;
        cMRightCharacterHealthText = dP.cMRightCharacterHealthText;
    }
 void Awake()
 {
     dP = GameObject.FindWithTag("CombatControl").GetComponent <DecisionPhase>();
 }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        // TODO array with phases (interface phase), set index to active phase index, if(update active phase) increment index modulo

        CalculateTeamHp();
        if (HasGameFinished())
        {
            print("game is over now");
            phase = Phase.End;
            // TODO assign ranks
        }

        else
        {
            passedGameSeconds += Time.deltaTime;

            if (phase == Phase.Decision)
            {
                passedDecisionPhaseSeconds = passedDecisionPhaseSeconds += Time.deltaTime;
                timeLeft = maxDecisionPhaseSeconds - passedDecisionPhaseSeconds;

                if (passedDecisionPhaseSeconds >= maxDecisionPhaseSeconds)
                {
                    print("its action phase now");
                    phase = Phase.Action;
                }
            }

            if (phase == Phase.Action)
            {
                passedDecisionPhaseSeconds = 0f;
                isActionPhaseFinished      = activePlayerIndex >= players.Count;

                if (isActionPhaseFinished)
                {
                    print("its decision phase now");
                    phase                      = Phase.Decision;
                    roundCount                += 1;
                    activePlayerIndex          = 0;
                    equippingPlayerIndex       = 0;
                    arePlayerActionsOver       = Enumerable.Repeat(false, players.Count).ToList();
                    havePlayersEquippedWeapons = Enumerable.Repeat(false, players.Count).ToList();
                }
                else
                {
                    // equip new weapon for each player, one time for each ActionPhase
                    foreach (PlayerProperties player in players)
                    {
                        if (equippingPlayerIndex < havePlayersEquippedWeapons.Count && !havePlayersEquippedWeapons[equippingPlayerIndex])
                        {
                            ActionPhase   actionPhase   = player.GetComponent <ActionPhase>();
                            DecisionPhase decisionPhase = player.GetComponent <DecisionPhase>();

                            actionPhase.ChangeLeftHandWeapon(player.rowPosition, player.weapon);
                            havePlayersEquippedWeapons[equippingPlayerIndex] = true;
                            equippingPlayerIndex++;
                        }
                    }

                    // each player attacks sequentially
                    // end if the last active player is finished
                    ActionPhase activePlayerActionPhase = players[activePlayerIndex].GetComponent <ActionPhase>();

                    if (!arePlayerActionsOver[activePlayerIndex])
                    {
                        activePlayerActionPhase.DoAction();
                        arePlayerActionsOver[activePlayerIndex] = true;
                    }
                }
            }
        }
    }