示例#1
0
    public void ChangeEquippedWeapon(WeaponDefinitions.WeaponType weapon, ActionPhase actionPhase)
    {
        // print("ChangeEquippedWeapon triggered");
        if (phase == PhaseHandler.Phase.Decision && !player.IsAiPlayer)
        {
            selectedWeapon = weapon;
            print($"Changing Weapon to {selectedWeapon}");
            // just spawn a dummy weapon, such that it serves as feedback but does not reveal the actual selection
            actionPhase.ChangeLeftHandWeapon("Weapons/SA_Item_Fish");
        }

        else
        {
            print("Changing Weapon is currently not allowed");
            playerMinifigController.PlaySpecialAnimation(MinifigControllerGroupW.SpecialAnimation.IdleImpatient);
        }
    }
示例#2
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;
                    }
                }
            }
        }
    }