Example #1
0
 public void PrepareByParametersNew(Action selectTargetAction, Func <GenericShip, bool> filterTargets, Func <GenericShip, int> getAiPriority, PlayerNo subphaseOwnerPlayerNo, bool showSkipButton = true)
 {
     FilterTargets  = filterTargets;
     GetAiPriority  = getAiPriority;
     finishAction   = selectTargetAction;
     RequiredPlayer = subphaseOwnerPlayerNo;
     if (showSkipButton)
     {
         UI.ShowSkipButton();
     }
 }
Example #2
0
        private static bool ValidateMinShipsCount(PlayerNo playerNo)
        {
            bool result = true;

            if (GetSquadList(playerNo).GetShips().Count < Edition.Current.MinShipsCount)
            {
                result = false;
                Messages.ShowError("Minimum number of pilots is required: " + Edition.Current.MinShipsCount);
            }
            return(result);
        }
Example #3
0
 public static void TryAddShip(PlayerNo playerNo)
 {
     if (GetShipsCount(playerNo) < 8)
     {
         AddShip(playerNo);
     }
     else
     {
         Messages.ShowError("You cannot have more than 8 ships");
     }
 }
Example #4
0
    public static GenericPlayer GetThisPlayer()
    {
        PlayerNo playerNo = PlayerNo.Player1;

        if (Network.IsNetworkGame && !Network.IsServer)
        {
            playerNo = PlayerNo.Player2;
        }

        return(GetPlayer(playerNo));
    }
Example #5
0
        private static bool RosterIsEmpty(PlayerNo playerNo)
        {
            bool result = false;

            if (GetSquadList(playerNo).GetShips().Count == 0)
            {
                result = true;
                Messages.ShowError("At least one pilot must be present");
            }
            return(result);
        }
Example #6
0
    // CHECK ALL SHIPS IN ROSTER

    public static bool AllManuversAreAssigned(PlayerNo playerNo)
    {
        var results =
            from n in AllShips
            where n.Value.Owner.PlayerNo == playerNo
            where n.Value.AssignedManeuver == null && !RulesList.IonizationRule.IsIonized(n.Value)
            select n;

        //if (results.Count() > 0) Game.UI.ShowError("Not all ship are assigned their maneuvers");
        return(results.Count() == 0);
    }
Example #7
0
        private static bool ValidateMaxShipsCount(PlayerNo playerNo)
        {
            bool result = true;

            if (GetSquadList(playerNo).GetShips().Count > RuleSet.Instance.MaxShipsCount)
            {
                result = false;
                Messages.ShowError("Maximum number of pilots is required: " + RuleSet.Instance.MaxShipsCount);
            }
            return(result);
        }
Example #8
0
        public static GenericObstacle GenerateObstacle(string shortName, PlayerNo playerNo)
        {
            GenericObstacle prefab      = Instance.AllPossibleObstacles.First(n => n.ShortName == shortName);
            GenericObstacle newObstacle = (GenericObstacle)Activator.CreateInstance(
                prefab.GetType(),
                new object[] { prefab.Name, prefab.ShortName }
                );

            Instance.ChosenObstacles.Add(newObstacle);
            return(newObstacle);
        }
Example #9
0
    //Ship Panels

    private static GameObject CreateShipPanel(PlayerNo playerNo)
    {
        GameObject prefab = GetShipPanelPefab();
        Transform  parent = GetShipsPanel(playerNo);

        GameObject newPanel = MonoBehaviour.Instantiate(prefab, parent);

        newPanel.transform.localPosition = Vector3.zero;
        SubscribeControlButtons(playerNo, newPanel);

        return(newPanel);
    }
Example #10
0
    // NEW

    public static void HighlightShipsFiltered(PlayerNo playerNo, int pilotSkill = -1)
    {
        AllShipsHighlightOff();
        foreach (var ship in GetPlayer(playerNo).Ships)
        {
            if ((pilotSkill == -1) || (ship.Value.PilotSkill == pilotSkill))
            {
                ship.Value.HighlightCanBeSelectedOn();
                RosterPanelHighlightOn(ship.Value);
            }
        }
    }
Example #11
0
 // 所有するユーザを変える
 public void ReverseKoma(PlayerNo playerNo)
 {
     if (playerNo == PlayerNo.One)
     {
         Player = PlayerNo.Two;
     }
     else
     {
         Player = PlayerNo.One;
     }
     this.MyPicture = GetPicture();
 }
Example #12
0
 private static bool ValidatePlayerRoster(PlayerNo playerNo)
 {
     if (!ValidateUniqueCards(playerNo))
     {
         return(false);
     }
     if (!ValidateSquadCost(playerNo))
     {
         return(false);
     }
     return(true);
 }
Example #13
0
    private static Type GetPlayerType(PlayerNo playerNo)
    {
        int index = GetPlayerPanel(playerNo).Find("GroupPlayer/Dropdown").GetComponent <Dropdown>().value;

        switch (index)
        {
        case 0: return(typeof(HumanPlayer));

        case 1: return(typeof(HotacAiPlayer));
        }
        return(null);
    }
        public override void Execute()
        {
            PlayerNo playerNo   = (PlayerNo)Enum.Parse(typeof(PlayerNo), GetString("player"));
            string   playerType = GetString("type");

            Console.Write($"Squad for Player {Tools.PlayerToInt(playerNo)} ({playerType}) is ready");

            SquadList playerList = Global.SquadBuilder.SquadLists[playerNo];

            playerList.SavedConfiguration = (JSONObject)GetParameter("list");
            playerList.PlayerType         = System.Type.GetType(playerType);
        }
Example #15
0
        // IMPORT / EXPORT

        public static void CreateSquadFromImportedJson(string jsonString, PlayerNo playerNo, Action callback)
        {
            JSONObject squadJson = new JSONObject(jsonString);

            //LogImportedSquad(squadJson);

            SetPlayerSquadFromImportedJson(
                squadJson,
                playerNo,
                callback
                );
        }
Example #16
0
    private static void SubscribeControlButtons(PlayerNo playerNo, GameObject panel)
    {
        panel.transform.Find("Panel/RemoveButton").GetComponent <Button>().onClick.AddListener(delegate
        {
            RemoveShip(playerNo, panel);
        });

        panel.transform.Find("Panel/CopyButton").GetComponent <Button>().onClick.AddListener(delegate
        {
            CopyShip(playerNo, panel);
        });
    }
Example #17
0
    private static int GetShipsCount(PlayerNo playerNo)
    {
        int result = 0;

        foreach (var panel in GetShipsPanel(playerNo))
        {
            result++;
        }
        result--;

        return(result);
    }
Example #18
0
 public void PrepareByParameters(Action <GenericObstacle> selectTargetAction, Func <GenericObstacle, bool> filterTargets, PlayerNo subphaseOwnerPlayerNo, bool showSkipButton, string abilityName, string description, IImageHolder imageSource = null)
 {
     SelectTargetAction = selectTargetAction;
     FilterTargets      = filterTargets;
     RequiredPlayer     = subphaseOwnerPlayerNo;
     if (showSkipButton)
     {
         UI.ShowSkipButton();
     }
     AbilityName = abilityName;
     Description = description;
     ImageSource = imageSource;
 }
Example #19
0
    public static GameCommand GenerateDeckShuffleCommand(PlayerNo playerNo, int seed)
    {
        JSONObject parameters = new JSONObject();

        parameters.AddField("player", playerNo.ToString());
        parameters.AddField("seed", seed.ToString());

        return(GameController.GenerateGameCommand(
                   GameCommandTypes.DamageDecksSync,
                   null,
                   parameters.ToString()
                   ));
    }
Example #20
0
        /// <summary>
        /// Shows "Take a decision" window for ability with various buttons
        /// </summary>
        public void AskForDecision(
            string descriptionShort,
            string descriptionLong   = null,
            IImageHolder imageHolder = null,
            Dictionary <string, EventHandler> decisions = null,
            Dictionary <string, string> tooltips        = null,
            string defaultDecision  = null,
            Action callback         = null,
            bool showSkipButton     = true,
            PlayerNo requiredPlayer = PlayerNo.PlayerNone
            )
        {
            if (callback == null)
            {
                callback = Triggers.FinishTrigger;
            }

            DecisionSubPhase pilotAbilityDecision = (DecisionSubPhase)Phases.StartTemporarySubPhaseNew(
                Name,
                typeof(AbilityDecisionSubphase),
                callback
                );

            pilotAbilityDecision.DescriptionShort = descriptionShort;
            pilotAbilityDecision.DescriptionLong  = descriptionLong;
            pilotAbilityDecision.ImageSource      = imageHolder;

            pilotAbilityDecision.RequiredPlayer = (requiredPlayer == PlayerNo.PlayerNone) ? HostShip.Owner.PlayerNo : requiredPlayer;

            foreach (var decision in decisions)
            {
                pilotAbilityDecision.AddDecision(
                    decision.Key,
                    delegate
                {
                    DecisionSubPhase.ConfirmDecisionNoCallback();
                    decision.Value.Invoke(null, null);
                }
                    );
            }

            foreach (var tooltip in tooltips)
            {
                pilotAbilityDecision.AddTooltip(tooltip.Key, tooltip.Value);
            }

            pilotAbilityDecision.DefaultDecisionName = defaultDecision;
            pilotAbilityDecision.ShowSkipButton      = showSkipButton;

            pilotAbilityDecision.Start();
        }
Example #21
0
    public static void SetPlayerSquadFromImportedJson(JSONObject squadJson, PlayerNo playerNo, Action callBack)
    {
        string   factionNameXws  = squadJson["faction"].str;
        string   factionName     = XWSToFactionName(factionNameXws);
        Dropdown factionDropdown = GetPlayerPanel(playerNo).Find("GroupFaction/Dropdown").GetComponent <Dropdown>();

        factionDropdown.value = factionDropdown.options.IndexOf(factionDropdown.options.Find(n => n.text == factionName));

        CheckPlayerFactonChange(playerNo);

        RemoveAllShipsByPlayer(playerNo);

        if (squadJson.HasField("pilots"))
        {
            JSONObject pilotJsons = squadJson["pilots"];
            foreach (JSONObject pilotJson in pilotJsons.list)
            {
                SquadBuilderShip newShip = AddShip(playerNo);

                string   shipNameXws     = pilotJson["ship"].str;
                string   shipNameGeneral = AllShips.Find(n => n.ShipNameCanonical == shipNameXws).ShipName;
                Dropdown shipDropdown    = newShip.Panel.transform.Find("GroupShip/DropdownShip").GetComponent <Dropdown>();
                shipDropdown.value = shipDropdown.options.IndexOf(shipDropdown.options.Find(n => n.text == shipNameGeneral));

                string   pilotNameXws     = pilotJson["name"].str;
                string   pilotNameGeneral = AllPilots.Find(n => n.PilotNameCanonical == pilotNameXws).PilotNameWithCost;
                Dropdown pilotDropdown    = newShip.Panel.transform.Find("GroupShip/DropdownPilot").GetComponent <Dropdown>();
                pilotDropdown.value = pilotDropdown.options.IndexOf(pilotDropdown.options.Find(n => n.text == pilotNameGeneral));

                JSONObject upgradeJsons = pilotJson["upgrades"];
                foreach (string upgradeType in upgradeJsons.keys)
                {
                    JSONObject upgradeNames = upgradeJsons[upgradeType];
                    foreach (JSONObject upgradeName in upgradeNames.list)
                    {
                        InstallUpgradeIntoShipPanel(
                            newShip,
                            XwsToUpgradeType(upgradeType),
                            AllUpgrades.Find(n => n.UpgradeNameCanonical == upgradeName.str).UpgradeNameWithCost
                            );
                    }
                }
            }
        }
        else
        {
            Messages.ShowError("No pilots");
        }

        callBack();
    }
Example #22
0
    public DiceRoll(DiceKind type, int number, DiceRollCheckType checkType, PlayerNo playerNo = PlayerNo.PlayerNone)
    {
        Type = type;
        CountOfInitialRoll = number;
        CheckType          = checkType;
        PlayerNo           = playerNo;

        if (checkType != DiceRollCheckType.Virtual)
        {
            SetSpawningPoint();
        }

        GenerateDiceRoll();
    }
Example #23
0
    //Get information from panels

    private static Faction GetPlayerFaction(PlayerNo playerNo)
    {
        int index = GetPlayerPanel(playerNo).Find("GroupFaction/Dropdown").GetComponent <Dropdown>().value;

        switch (index)
        {
        case 0:
            return(Faction.Rebels);

        case 1:
            return(Faction.Empire);
        }
        return(Faction.Empire);
    }
Example #24
0
    public static int PlayerToInt(PlayerNo playerNo)
    {
        int result = 0;

        if (playerNo == PlayerNo.Player1)
        {
            result = 1;
        }
        else
        {
            result = 2;
        }
        return(result);
    }
Example #25
0
    public static void AddShip(PlayerNo playerNo)
    {
        if (GetShipsCount(playerNo) < 8)
        {
            GameObject newPanel = CreateShipPanel(playerNo);
            SetShip(newPanel, playerNo);

            OrganizeShipsList(playerNo);
        }
        else
        {
            Messages.ShowError("You cannot have more than 8 ships");
        }
    }
 public void PrepareByParameters(Action selectTargetAction, Func <GenericShip, bool> filterTargets, Func <GenericShip, int> getAiPriority, PlayerNo subphaseOwnerPlayerNo, bool showSkipButton, string abilityName, string description, string imageUrl = null)
 {
     FilterTargets  = filterTargets;
     GetAiPriority  = getAiPriority;
     finishAction   = selectTargetAction;
     RequiredPlayer = subphaseOwnerPlayerNo;
     if (showSkipButton)
     {
         UI.ShowSkipButton();
     }
     AbilityName = abilityName;
     Description = description;
     ImageUrl    = imageUrl;
 }
Example #27
0
    public static Faction GetPlayerFaction(PlayerNo playerNo)
    {
        Faction result = Faction.Rebel;

        if (playerNo == PlayerNo.Player1)
        {
            result = playerFactions[0];
        }
        if (playerNo == PlayerNo.Player2)
        {
            result = playerFactions[1];
        }
        return(result);
    }
Example #28
0
    public static PlayerNo IntToPlayer(int playerNo)
    {
        PlayerNo result = PlayerNo.Player1;

        if (playerNo == 1)
        {
            result = PlayerNo.Player1;
        }
        else
        {
            result = PlayerNo.Player2;
        }
        return(result);
    }
Example #29
0
    // INITIALIZE

    public DiceRoll(DiceKind type, int countOfInitialRoll, DiceRollCheckType checkType, PlayerNo owner = PlayerNo.PlayerNone)
    {
        Type = type;
        CountOfInitialRoll = countOfInitialRoll;
        CheckType          = checkType;
        Owner = owner;

        if (checkType != DiceRollCheckType.Virtual)
        {
            SetDiceSpawningPoint();
        }

        GenerateDiceRoll();
    }
Example #30
0
        private static string GetDefaultNameForSquad(PlayerNo playerNo)
        {
            string result = "Unknown Squadron";

            Type playerOneType = GetSquadList(PlayerNo.Player1).PlayerType;
            Type playerTwoType = GetSquadList(PlayerNo.Player2).PlayerType;

            if (playerOneType == typeof(HumanPlayer) && playerTwoType == typeof(NetworkOpponentPlayer))
            {
                if (playerNo == PlayerNo.Player1)
                {
                    return("My Squadron");
                }
            }
            else if (playerOneType == typeof(HumanPlayer) && playerTwoType == typeof(HumanPlayer))
            {
                if (playerNo == PlayerNo.Player1)
                {
                    return("Squadron of Player 1");
                }
                else
                {
                    return("Squadron of Player 2");
                }
            }
            else if (playerOneType == typeof(HumanPlayer) && playerTwoType == typeof(HotacAiPlayer))
            {
                if (playerNo == PlayerNo.Player1)
                {
                    return("My Squadron");
                }
                else
                {
                    return("Squadron of AI");
                }
            }
            else if (playerOneType == typeof(HotacAiPlayer) && playerTwoType == typeof(HotacAiPlayer))
            {
                if (playerNo == PlayerNo.Player1)
                {
                    return("Squadron of AI 1");
                }
                else
                {
                    return("Squadron of AI 2");
                }
            }

            return(result);
        }
Example #31
0
 public Bishop(PlayerNo color, int index)
     : base(color, index)
 {
 }
Example #32
0
 public Queen(PlayerNo color, int index)
     : base(color, index)
 {
 }
Example #33
0
 public King(PlayerNo color,int index)
     : base(color, index)
 {
 }
Example #34
0
 internal void ChangePlayer()
 {
     playerNo = playerNo == PlayerNo.Two ? PlayerNo.One : PlayerNo.Two;
     ClearClickedKoma();
 }
Example #35
0
 private KomaBase createKoma(KomaKind kind, PlayerNo playerNo, int index)
 {
     switch (kind)
     {
         case KomaKind.King:
             return new King(playerNo, index);
         case KomaKind.Queen:
             return new Queen(playerNo, index);
         case KomaKind.Bishop :
             return new Bishop(playerNo,index);
         case KomaKind.Knight:
             return new Knight(playerNo, index);
         case KomaKind.Pone:
             return new Pawn(playerNo, index);
         case KomaKind.Rook:
             return new Rook(playerNo,index);
         default:
             throw new ArgumentException("Unexpected Kind!!");
     }
 }
Example #36
0
 private bool existsKoma(int left, int heigth,PlayerNo player)
 {
     return this.GetAliveKoma().Where((koma) =>
     koma.Player == player
     && koma.Left == left
     && koma.Height == heigth).Count() > 0;
 }
Example #37
0
 public Pawn(PlayerNo color, int index)
     : base(color, index)
 {
 }
Example #38
0
 public ComputerPlayer(PlayerNo cpuColor)
 {
     this.cpuColor = cpuColor;
 }
Example #39
0
 public Rook(PlayerNo color, int index)
     : base(color, index)
 {
 }
Example #40
0
 public Knight(PlayerNo color, int index)
     : base(color, index)
 {
 }