public static void CreateDiceModificationsButton(GenericAction actionEffect, Vector3 position)
    {
        GameObject prefab    = (GameObject)Resources.Load("Prefabs/GenericButton", typeof(GameObject));
        GameObject newButton = MonoBehaviour.Instantiate(prefab, GameObject.Find("UI").transform.Find("CombatDiceResultsPanel").Find("DiceModificationsPanel"));

        newButton.GetComponent <RectTransform>().localPosition = position;

        newButton.name = "Button" + actionEffect.DiceModificationName;
        newButton.transform.GetComponentInChildren <Text>().text = actionEffect.DiceModificationName;

        newButton.GetComponent <Button>().onClick.AddListener(
            delegate {
            if (DiceModificationsManager.IsLocked)
            {
                return;
            }
            DiceModificationsManager.IsLocked = true;

            GameCommand command = DiceModificationsManager.GenerateDiceModificationCommand(actionEffect.DiceModificationName);
            GameMode.CurrentGameMode.ExecuteCommand(command);
        }
            );
        Tooltips.AddTooltip(newButton, actionEffect.ImageUrl);

        newButton.GetComponent <Button>().interactable = true;
        newButton.SetActive(ShowOnlyForHuman());
    }
Exemple #2
0
    private static void CreateDiceModificationsButton(ActionsList.GenericAction actionEffect, Vector3 position)
    {
        GameObject prefab    = (GameObject)Resources.Load("Prefabs/GenericButton", typeof(GameObject));
        GameObject newButton = MonoBehaviour.Instantiate(prefab, GameObject.Find("UI/CombatDiceResultsPanel").transform.Find("DiceModificationsPanel"));

        newButton.name = "Button" + actionEffect.EffectName;
        newButton.transform.GetComponentInChildren <Text>().text = actionEffect.EffectName;
        newButton.GetComponent <RectTransform>().position        = position;
        newButton.GetComponent <Button>().onClick.AddListener(delegate
        {
            Tooltips.EndTooltip();
            newButton.GetComponent <Button>().interactable = false;
            if (!actionEffect.IsOpposite)
            {
                Selection.ActiveShip = (AttackStep == CombatStep.Attack) ? Attacker : Defender;
                Selection.ActiveShip.AddAlreadyExecutedActionEffect(actionEffect);
            }
            else
            {
                Selection.ActiveShip = (AttackStep == CombatStep.Attack) ? Defender : Attacker;
                Selection.ActiveShip.AddAlreadyExecutedOppositeActionEffect(actionEffect);
            }
            actionEffect.ActionEffect(delegate { });
        });
        Tooltips.AddTooltip(newButton, actionEffect.ImageUrl);
        newButton.GetComponent <Button>().interactable = true;
        newButton.SetActive(true);
    }
Exemple #3
0
    public static void UpdateTokensIndicator(GenericShip thisShip, System.Type type)
    {
        List <GameObject> keys = new List <GameObject>();

        foreach (Transform icon in thisShip.InfoPanel.transform.Find("ShipInfo/TokensBar").transform)
        {
            keys.Add(icon.gameObject);
        }
        foreach (GameObject icon in keys)
        {
            icon.gameObject.SetActive(false);
            MonoBehaviour.Destroy(icon);
        }

        int columnCounter = 0;
        int rowCounter    = 0;

        foreach (var token in GetTokensSorted(thisShip))
        {
            GameObject prefab      = (GameObject)Resources.Load("Prefabs/TokenPanel", typeof(GameObject));
            GameObject tokenPanel  = MonoBehaviour.Instantiate(prefab, thisShip.InfoPanel.transform.Find("ShipInfo").Find("TokensBar"));
            Sprite     tokenSprite = Resources.Load <Sprite>("Sprites/Tokens/" + token.ImageName);
            if (tokenSprite == null)
            {
                Console.Write("Token's image was not found: " + token.ImageName, LogTypes.Errors, true, "red");
            }
            tokenPanel.GetComponentInChildren <Image>().sprite      = tokenSprite;
            tokenPanel.GetComponent <RectTransform>().localPosition = Vector3.zero;
            tokenPanel.name = token.Name;

            Tooltips.AddTooltip(tokenPanel, token.Tooltip);

            if (token.GetType().BaseType == typeof(GenericTargetLockToken))
            {
                Text tokenText = tokenPanel.transform.Find("Image/Letter").GetComponent <Text>();
                tokenText.text  = (token as GenericTargetLockToken).Letter.ToString();
                tokenText.color = (token is BlueTargetLockToken) ? new Color(0, 0.6f, 1) : Color.red;
            }

            tokenPanel.SetActive(true);
            tokenPanel.GetComponent <RectTransform>().localPosition = new Vector3(columnCounter * 37, tokenPanel.GetComponent <RectTransform>().localPosition.y + -37 * rowCounter, tokenPanel.GetComponent <RectTransform>().localPosition.z);
            columnCounter++;
            if (columnCounter == 8)
            {
                rowCounter++;
                columnCounter = 0;
            }
        }

        OrganizeRosters();
    }
Exemple #4
0
    public static void SubscribeUpgradesPanel(Ship.GenericShip newShip, GameObject newPanel)
    {
        int index = 1;

        foreach (var upgrade in newShip.InstalledUpgrades)
        {
            GameObject upgradeNamePanel = newPanel.transform.Find("ShipInfo/UpgradesBar/Upgrade" + index).gameObject;

            SubscribeActions(upgradeNamePanel);
            Tooltips.AddTooltip(upgradeNamePanel, upgrade.Value.ImageUrl);

            index++;
        }
    }
Exemple #5
0
    public static void SubscribeUpgradesPanel(GenericShip newShip, GameObject newPanel)
    {
        int index = 1;

        foreach (var upgrade in newShip.UpgradeBar.GetUpgradesAll())
        {
            GameObject upgradeNamePanel = newPanel.transform.Find("ShipInfo/UpgradesBar/Upgrade" + index).gameObject;

            SubscribeSelectionByInfoPanel(upgradeNamePanel);
            Tooltips.AddTooltip(upgradeNamePanel, upgrade.ImageUrl);

            index++;
        }
    }
Exemple #6
0
    public static void UpdateTokensIndicator(Ship.GenericShip thisShip, System.Type type)
    {
        List <GameObject> keys = new List <GameObject>();

        foreach (Transform icon in thisShip.InfoPanel.transform.Find("ShipInfo/TokensBar").transform)
        {
            keys.Add(icon.gameObject);
        }
        foreach (GameObject icon in keys)
        {
            icon.gameObject.SetActive(false);
            MonoBehaviour.Destroy(icon);
        }

        float offset = 0;
        float row    = 0;

        foreach (var token in thisShip.GetAssignedTokens())
        {
            for (int i = 0; i < token.Count; i++)
            {
                GameObject tokenPanel = MonoBehaviour.Instantiate(Game.PrefabsList.PanelToken, thisShip.InfoPanel.transform.Find("ShipInfo").Find("TokensBar"));
                tokenPanel.GetComponent <RectTransform>().localPosition = Vector3.zero;
                tokenPanel.name = token.Name;
                Tooltips.AddTooltip(tokenPanel, token.Tooltip);
                tokenPanel.transform.Find(token.Name).gameObject.SetActive(true);

                if (token.GetType().BaseType == typeof(Tokens.GenericTargetLockToken))
                {
                    tokenPanel.transform.Find(token.Name).Find("Letter").GetComponent <Text>().text = (token as Tokens.GenericTargetLockToken).Letter.ToString();
                }

                tokenPanel.SetActive(true);
                tokenPanel.GetComponent <RectTransform>().localPosition = new Vector3(offset, tokenPanel.GetComponent <RectTransform>().localPosition.y + 35 * row, tokenPanel.GetComponent <RectTransform>().localPosition.z);
                if (i > (row * 5) + 3)
                {
                    row++;
                    offset = 0;
                }
                else
                {
                    offset += 32 + 3;
                }
            }
        }

        OrganizeRosters();
    }
Exemple #7
0
    private static void CreateDiceModificationsButton(GenericAction actionEffect, Vector3 position)
    {
        GameObject prefab    = (GameObject)Resources.Load("Prefabs/GenericButton", typeof(GameObject));
        GameObject newButton = MonoBehaviour.Instantiate(prefab, GameObject.Find("UI/CombatDiceResultsPanel").transform.Find("DiceModificationsPanel"));

        newButton.name = "Button" + actionEffect.DiceModificationName;
        newButton.transform.GetComponentInChildren <Text>().text = actionEffect.DiceModificationName;
        newButton.GetComponent <RectTransform>().position        = position;
        newButton.GetComponent <Button>().onClick.AddListener(
            delegate { GameMode.CurrentGameMode.UseDiceModification(actionEffect.DiceModificationName); }
            );
        Tooltips.AddTooltip(newButton, actionEffect.ImageUrl);
        newButton.GetComponent <Button>().interactable = true;

        newButton.SetActive(Selection.ActiveShip.Owner.GetType() == typeof(Players.HumanPlayer));
    }
Exemple #8
0
        public override void Initialize()
        {
            if (decisions.Count != 0)
            {
                decisionPanel.transform.Find("InformationPanel").GetComponentInChildren <Text>().text = InfoText;

                int i = 0;
                foreach (var item in decisions)
                {
                    GameObject prefab        = (GameObject)Resources.Load("Prefabs/DecisionButton", typeof(GameObject));
                    GameObject buttonsHolder = decisionPanel.transform.Find("DecisionsPanel").gameObject;
                    GameObject button        = MonoBehaviour.Instantiate(prefab, buttonsHolder.transform);
                    button.transform.localPosition = new Vector3((i % 2 == 0) ? 5 : 200, -buttonHeight * (i / 2), 0);
                    button.name = "Button" + i;

                    button.GetComponentInChildren <Text>().text = item.Key;

                    if (tooltips.ContainsKey(item.Key))
                    {
                        Tooltips.AddTooltip(button, tooltips[item.Key]);
                    }

                    EventTrigger       trigger = button.AddComponent <EventTrigger>();
                    EventTrigger.Entry entry   = new EventTrigger.Entry();
                    entry.eventID = EventTriggerType.PointerClick;
                    entry.callback.AddListener(
                        (data) => { GameModes.GameMode.CurrentGameMode.TakeDecision(item, button); }
                        );
                    trigger.triggers.Add(entry);

                    i++;
                }
                decisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3(decisionPanel.GetComponent <RectTransform>().sizeDelta.x, defaultWindowHeight + ((i + 1) / 2) * buttonHeight);

                if (DecisionOwner == null)
                {
                    DecisionOwner = Roster.GetPlayer(Phases.CurrentPhasePlayer);
                }

                if (ShowSkipButton)
                {
                    UI.ShowSkipButton();
                }

                DecisionOwner.TakeDecision();
            }
        }
Exemple #9
0
    public static void UpdateTokensIndicator(GenericShip thisShip, System.Type type)
    {
        List <GameObject> keys = new List <GameObject>();

        foreach (Transform icon in thisShip.InfoPanel.transform.Find("ShipInfo/TokensBar").transform)
        {
            keys.Add(icon.gameObject);
        }
        foreach (GameObject icon in keys)
        {
            icon.gameObject.SetActive(false);
            MonoBehaviour.Destroy(icon);
        }

        int columnCounter = 0;
        int rowCounter    = 0;

        foreach (var token in thisShip.GetAssignedTokens())
        {
            for (int i = 0; i < token.Count; i++)
            {
                GameObject prefab     = (GameObject)Resources.Load("Prefabs/PanelToken", typeof(GameObject));
                GameObject tokenPanel = MonoBehaviour.Instantiate(prefab, thisShip.InfoPanel.transform.Find("ShipInfo").Find("TokensBar"));
                tokenPanel.GetComponent <RectTransform>().localPosition = Vector3.zero;
                tokenPanel.name = token.Name;
                Tooltips.AddTooltip(tokenPanel, token.Tooltip);
                tokenPanel.transform.Find(token.Name).gameObject.SetActive(true);

                if (token.GetType().BaseType == typeof(Tokens.GenericTargetLockToken))
                {
                    tokenPanel.transform.Find(token.Name).Find("Letter").GetComponent <Text>().text = (token as Tokens.GenericTargetLockToken).Letter.ToString();
                }

                tokenPanel.SetActive(true);
                tokenPanel.GetComponent <RectTransform>().localPosition = new Vector3(columnCounter * 37, tokenPanel.GetComponent <RectTransform>().localPosition.y + -37 * rowCounter, tokenPanel.GetComponent <RectTransform>().localPosition.z);
                columnCounter++;
                if (columnCounter == 8)
                {
                    rowCounter++;
                    columnCounter = 0;
                }
            }
        }

        OrganizeRosters();
    }
Exemple #10
0
    private static void CreateDiceModificationsButton(ActionsList.GenericAction actionEffect, Vector3 position)
    {
        GameObject newButton = MonoBehaviour.Instantiate(Game.PrefabsList.GenericButton, Game.PrefabsList.DiceResultsMenu.transform);

        newButton.name = "Button" + actionEffect.EffectName;
        newButton.transform.GetComponentInChildren <Text>().text = actionEffect.EffectName;
        newButton.GetComponent <RectTransform>().position        = position;
        newButton.GetComponent <Button>().onClick.AddListener(delegate
        {
            Tooltips.EndTooltip();
            newButton.GetComponent <Button>().interactable = false;
            Selection.ThisShip.AddAlreadyExecutedActionEffect(actionEffect);
            actionEffect.ActionEffect();
        });
        Tooltips.AddTooltip(newButton, actionEffect.ImageUrl);
        newButton.GetComponent <Button>().interactable = true;
        newButton.SetActive(true);
    }
Exemple #11
0
    private static void ShowActionsButtons(List <ActionsList.GenericAction> actionList)
    {
        HideActionsButtons();

        float   offset          = 0;
        Vector3 defaultPosition = new Vector3(5, -5, 0);

        foreach (var action in actionList)
        {
            GameObject newButton = MonoBehaviour.Instantiate(Game.PrefabsList.GenericButton, Game.PrefabsList.PanelActions.transform.Find("ActionButtons").transform);
            newButton.name = "Button" + action.Name;
            newButton.transform.GetComponentInChildren <Text>().text = action.Name;
            newButton.GetComponent <RectTransform>().localPosition   = defaultPosition + new Vector3(0, -offset, 0);
            offset += 40;
            newButton.GetComponent <Button>().onClick.AddListener(delegate {
                Tooltips.EndTooltip();
                CloseActionsPanel();
                Selection.ThisShip.AddAlreadyExecutedAction(action);
                action.ActionTake();
            });
            Tooltips.AddTooltip(newButton, action.ImageUrl);
            newButton.GetComponent <Button>().interactable = true;
            newButton.SetActive(true);
        }

        Selection.ActiveShip = Selection.ThisShip;

        if (actionList.Count != 0)
        {
            Game.PrefabsList.PanelActions.GetComponent <RectTransform>().sizeDelta = new Vector2(Game.PrefabsList.PanelActions.GetComponent <RectTransform>().sizeDelta.x, offset + 80);
            Game.PrefabsList.PanelActions.SetActive(true);
        }
        else
        {
            Messages.ShowErrorToHuman("Cannot perform any actions");
            Phases.Next();
        }
    }
Exemple #12
0
 //Tooltips
 private static void AddPilotTooltip(GameObject panel)
 {
     Tooltips.AddTooltip(panel, GetPilotTooltipImage);
 }
Exemple #13
0
    public static GameObject CreateRosterInfo(Ship.GenericShip newShip)
    {
        GameObject newPanel = MonoBehaviour.Instantiate(Game.PrefabsList.RosterPanel, Game.PrefabsList.RostersHolder.transform.Find("TeamPlayer" + newShip.Owner.Id).Find("RosterHolder").transform);

        //Generic info
        newPanel.transform.Find("ShipInfo/ShipPilotSkillText").GetComponent <Text>().text = newShip.PilotSkill.ToString();

        newPanel.transform.Find("ShipInfo/ShipId").GetComponent <Text>().text  = newShip.ShipId.ToString();
        newPanel.transform.Find("ShipIdText/Text").GetComponent <Text>().text  = newShip.ShipId.ToString();
        newPanel.transform.Find("ShipIdText/Text").GetComponent <Text>().color = (newShip.Owner.PlayerNo == PlayerNo.Player1) ? Color.green : Color.red;
        newPanel.transform.Find("ShipIdText").localPosition = new Vector3((newShip.Owner.PlayerNo == PlayerNo.Player1) ? 205 : -50, 0, 0);
        newPanel.transform.Find("ShipIdText").gameObject.SetActive(true);

        GameObject pilotNameGO = newPanel.transform.Find("ShipInfo/ShipPilotNameText").gameObject;

        pilotNameGO.GetComponent <Text>().text = newShip.PilotName;
        Tooltips.AddTooltip(pilotNameGO, newShip.ImageUrl);
        SubscribeActions(pilotNameGO);

        GameObject shipTypeGO = newPanel.transform.Find("ShipInfo/ShipTypeText").gameObject;

        shipTypeGO.GetComponent <Text>().text = newShip.Type;
        Tooltips.AddTooltip(shipTypeGO, newShip.ManeuversImageUrl);
        SubscribeActions(shipTypeGO);

        newPanel.transform.Find("ShipInfo/ShipFirepowerText").GetComponent <Text>().text = newShip.Firepower.ToString();
        newPanel.transform.Find("ShipInfo/ShipAgilityText").GetComponent <Text>().text   = newShip.Agility.ToString();
        newPanel.transform.Find("ShipInfo/ShipHullText").GetComponent <Text>().text      = newShip.MaxHull.ToString();
        newPanel.transform.Find("ShipInfo/ShipShieldsText").GetComponent <Text>().text   = newShip.MaxShields.ToString();

        //Mark
        newPanel.transform.Find("Mark").localPosition = new Vector3((newShip.Owner.PlayerNo == PlayerNo.Player1) ? 198 : -8, 0, 0);

        //Hull and shields
        float panelWidth           = 200 - 10;
        float hullAndShield        = newShip.MaxHull + newShip.MaxShields;
        float panelWidthNoDividers = panelWidth - (1 * (hullAndShield - 1));
        float damageIndicatorWidth = panelWidthNoDividers / hullAndShield;

        GameObject damageIndicatorBar = newPanel.transform.Find("ShipInfo/DamageBarPanel").gameObject;
        GameObject damageIndicator    = damageIndicatorBar.transform.Find("DamageIndicator").gameObject;

        damageIndicator.GetComponent <RectTransform>().sizeDelta = new Vector2(damageIndicatorWidth, 10);
        for (int i = 0; i < hullAndShield; i++)
        {
            GameObject newDamageIndicator = MonoBehaviour.Instantiate(damageIndicator, damageIndicatorBar.transform);
            newDamageIndicator.transform.position = damageIndicator.transform.position + new Vector3(i * (damageIndicatorWidth + 1), 0, 0);
            if (i < newShip.Hull)
            {
                newDamageIndicator.GetComponent <Image>().color = Color.yellow;
                newDamageIndicator.name = "DamageIndicator.Hull." + (i + 1).ToString();
            }
            else
            {
                newDamageIndicator.GetComponent <Image>().color = new Color(0, 202, 255);
                newDamageIndicator.name = "DamageIndicator.Shield." + (i - newShip.Hull + 1).ToString();
            }
            newDamageIndicator.SetActive(true);
        }
        MonoBehaviour.Destroy(damageIndicator);

        //Finish
        newPanel.transform.Find("ShipInfo").tag = "ShipId:" + newShip.ShipId.ToString();

        AddToRoster(newShip, newPanel);

        newPanel.transform.Find("ShipInfo").gameObject.SetActive(true);

        return(newPanel);
    }
Exemple #14
0
        public override void Initialize()
        {
            if (decisions.Count != 0)
            {
                decisionPanel.transform.Find("InformationPanel").GetComponentInChildren <Text>().text = InfoText;

                switch (DecisionViewType)
                {
                case DecisionViewTypes.TextButtons:
                    decisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        395,
                        defaultWindowHeight + ((decisions.Count + 1) / 2) * buttonHeight
                        );
                    buttonsHolder.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        395,
                        defaultWindowHeight + ((decisions.Count + 1) / 2) * buttonHeight
                        );
                    break;

                case DecisionViewTypes.ImagesUpgrade:
                    decisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        Mathf.Max(395, decisions.Count * RuleSets.RuleSet.Instance.UpgradeCardSize.x + (decisions.Count + 1) * 10),
                        defaultWindowHeight + RuleSets.RuleSet.Instance.UpgradeCardSize.y + 10
                        );
                    buttonsHolder.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        decisions.Count * RuleSets.RuleSet.Instance.UpgradeCardSize.x + (decisions.Count + 1) * 10,
                        defaultWindowHeight + RuleSets.RuleSet.Instance.UpgradeCardSize.y + 10
                        );
                    break;

                case DecisionViewTypes.ImagesDamageCard:
                    decisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        Mathf.Max(395, decisions.Count * ImagesDamageCardSize.x + (decisions.Count + 1) * 10),
                        defaultWindowHeight + ImagesDamageCardSize.y + 10
                        );
                    buttonsHolder.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        decisions.Count * ImagesDamageCardSize.x + (decisions.Count + 1) * 10,
                        defaultWindowHeight + ImagesDamageCardSize.y + 10
                        );
                    break;

                default:
                    break;
                }

                buttonsHolder.transform.localPosition = new Vector2(-buttonsHolder.GetComponent <RectTransform>().sizeDelta.x / 2, -70);

                int i = 0;
                foreach (var decision in decisions)
                {
                    GameObject prefab = null;

                    switch (DecisionViewType)
                    {
                    case DecisionViewTypes.TextButtons:
                        prefab = (GameObject)Resources.Load("Prefabs/DecisionButton", typeof(GameObject));
                        break;

                    case DecisionViewTypes.ImagesUpgrade:
                    case DecisionViewTypes.ImagesDamageCard:
                        prefab = (GameObject)Resources.Load("Prefabs/SquadBuilder/SmallCardPanel", typeof(GameObject));
                        break;

                    default:
                        break;
                    }

                    GameObject     button = MonoBehaviour.Instantiate(prefab, buttonsHolder.transform);
                    SmallCardPanel script = null;

                    switch (DecisionViewType)
                    {
                    case DecisionViewTypes.TextButtons:
                        button.transform.localPosition = new Vector3((i % 2 == 0) ? 5 : 200, -buttonHeight * (i / 2), 0);

                        button.GetComponentInChildren <Text>().text  = decision.Name;
                        button.GetComponentInChildren <Text>().color = (decision.IsRed) ? Color.red : Color.white;

                        if (decision.HasTooltip)
                        {
                            Tooltips.AddTooltip(button, decision.Tooltip);
                        }

                        EventTrigger       trigger = button.AddComponent <EventTrigger>();
                        EventTrigger.Entry entry   = new EventTrigger.Entry();
                        entry.eventID = EventTriggerType.PointerClick;
                        entry.callback.AddListener(
                            (data) => { DecisionButtonWasPressed(decision, button); }
                            );
                        trigger.triggers.Add(entry);

                        break;

                    case DecisionViewTypes.ImagesUpgrade:
                        button.transform.localPosition = new Vector3(10 * (i + 1) + i * RuleSets.RuleSet.Instance.UpgradeCardSize.x, 0, 0);

                        script = button.GetComponent <SmallCardPanel>();
                        script.Initialize(
                            decision.Name,
                            decision.Tooltip,
                            delegate { GameMode.CurrentGameMode.TakeDecision(decision, button); },
                            DecisionViewTypes.ImagesUpgrade,
                            decision.Count
                            );

                        break;

                    case DecisionViewTypes.ImagesDamageCard:
                        button.transform.localPosition = new Vector3(10 * (i + 1) + i * ImagesDamageCardSize.x, 0, 0);

                        script = button.GetComponent <SmallCardPanel>();
                        script.Initialize(
                            decision.Name,
                            decision.Tooltip,
                            delegate { GameMode.CurrentGameMode.TakeDecision(decision, button); },
                            DecisionViewTypes.ImagesDamageCard,
                            decision.Count
                            );

                        break;

                    default:
                        break;
                    }

                    button.name = "Button" + i;
                    i++;
                }

                if (DecisionOwner == null)
                {
                    DecisionOwner = Roster.GetPlayer(Phases.CurrentPhasePlayer);
                }

                if (ShowSkipButton)
                {
                    UI.ShowSkipButton();
                }
                else
                {
                    UI.HideSkipButton();
                }
            }
        }
        public override void Initialize()
        {
            DecisionPanel      = GameObject.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/UI/DecisionsPanel"), GameObject.Find("UI/DecisionPanelHolder").transform);
            DecisionPanel.name = "DecisionsPanel";
            ButtonsHolder      = DecisionPanel.transform.Find("Center/DecisionsPanel").gameObject;

            if (DescriptionShort != null)
            {
                ShowDecisionDescription(DescriptionShort, DescriptionLong, ImageSource);
            }

            float defaultWindowHeight = (DescriptionLong != null) ? 190f : 70f;
            float buttonHeight        = 70f;

            if (decisions.Count != 0)
            {
                if (DescriptionLong == null)
                {
                    DecisionPanel.transform.Find("DescriptionHolder/Description").GetComponentInChildren <Text>().text = DescriptionShort;
                }

                int i             = 0;
                int rowsUsed      = 0;
                int currentColumn = 1;

                foreach (var decision in decisions)
                {
                    GameObject prefab = null;

                    switch (DecisionViewType)
                    {
                    case DecisionViewTypes.TextButtons:
                        prefab = (GameObject)Resources.Load("Prefabs/DecisionButton", typeof(GameObject));
                        break;

                    case DecisionViewTypes.ImagesUpgrade:
                    case DecisionViewTypes.ImagesDamageCard:
                        prefab = (GameObject)Resources.Load("Prefabs/SquadBuilder/SmallCardPanel", typeof(GameObject));
                        break;

                    default:
                        break;
                    }

                    GameObject     button = MonoBehaviour.Instantiate(prefab, ButtonsHolder.transform);
                    SmallCardPanel script = null;

                    switch (DecisionViewType)
                    {
                    case DecisionViewTypes.TextButtons:
                        if (!decision.IsCentered)
                        {
                            float offsetX = (currentColumn == 1) ? 7.5f : 350;

                            button.transform.localPosition = new Vector3(offsetX, -(buttonHeight + 5) * rowsUsed, 0);
                            button.GetComponent <RectTransform>().sizeDelta = new Vector2(335, 67.5f);

                            if (currentColumn == 1)
                            {
                                currentColumn++;
                            }
                            else
                            {
                                currentColumn = 1;
                                rowsUsed++;
                            }
                        }
                        else
                        {
                            button.transform.localPosition = new Vector3(182.5f, -(buttonHeight + 5) * rowsUsed, 0);
                            button.GetComponent <RectTransform>().sizeDelta = new Vector2(335, 67.5f);

                            rowsUsed++;
                            currentColumn = 1;
                        }

                        button.GetComponentInChildren <Text>().text = decision.Name;

                        switch (decision.Color)
                        {
                        case ActionColor.White:
                            button.GetComponentInChildren <Text>().color = Color.white;
                            break;

                        case ActionColor.Red:
                            button.GetComponentInChildren <Text>().color = Color.red;
                            break;

                        case ActionColor.Purple:
                            button.GetComponentInChildren <Text>().color = new Color(128, 0, 128);
                            break;

                        default:
                            break;
                        }

                        if (decision.HasTooltip)
                        {
                            Tooltips.AddTooltip(button, decision.Tooltip);
                        }

                        EventTrigger       trigger = button.AddComponent <EventTrigger>();
                        EventTrigger.Entry entry   = new EventTrigger.Entry();
                        entry.eventID = EventTriggerType.PointerClick;
                        entry.callback.AddListener(
                            (data) => { DecisionButtonWasPressed(decision, button); }
                            );
                        trigger.triggers.Add(entry);

                        break;

                    case DecisionViewTypes.ImagesUpgrade:
                        button.transform.localPosition = new Vector3(15 * (i + 1) + i * Editions.Edition.Current.UpgradeCardSize.x, 0, 0);

                        script = button.GetComponent <SmallCardPanel>();
                        script.Initialize(
                            decision.Name,
                            decision.Tooltip,
                            delegate {
                            GameCommand command = GenerateDecisionCommand(decision.Name);
                            GameMode.CurrentGameMode.ExecuteCommand(command);
                        },
                            DecisionViewTypes.ImagesUpgrade,
                            decision.Count
                            );

                        break;

                    case DecisionViewTypes.ImagesDamageCard:

                        if (currentColumn == 6)
                        {
                            currentColumn = 1;
                            rowsUsed++;
                        }

                        button.transform.localPosition = new Vector3(15 * (currentColumn) + (currentColumn - 1) * ImagesDamageCardSize.x, rowsUsed * -ImagesDamageCardSize.y - 15 * rowsUsed, 0);

                        script = button.GetComponent <SmallCardPanel>();
                        script.Initialize(
                            decision.Name,
                            decision.Tooltip,
                            delegate {
                            GameCommand command = GenerateDecisionCommand(decision.Name);
                            GameMode.CurrentGameMode.ExecuteCommand(command);
                        },
                            DecisionViewTypes.ImagesDamageCard,
                            decision.Count
                            );

                        currentColumn++;

                        break;

                    default:
                        break;
                    }

                    button.name = "Button" + i;
                    i++;
                }

                switch (DecisionViewType)
                {
                case DecisionViewTypes.TextButtons:
                    if (currentColumn == 2)
                    {
                        rowsUsed++;
                    }
                    DecisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        700f,
                        defaultWindowHeight + rowsUsed * (buttonHeight + 5)
                        );
                    ButtonsHolder.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        700f,
                        defaultWindowHeight + rowsUsed * (buttonHeight + 5)
                        );
                    break;

                case DecisionViewTypes.ImagesUpgrade:
                    DecisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        Mathf.Max(700f, decisions.Count * Editions.Edition.Current.UpgradeCardSize.x + (decisions.Count + 1) * 15),
                        defaultWindowHeight + Editions.Edition.Current.UpgradeCardSize.y + 15
                        );
                    ButtonsHolder.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        decisions.Count * Editions.Edition.Current.UpgradeCardSize.x + (decisions.Count + 1) * 15,
                        defaultWindowHeight + Editions.Edition.Current.UpgradeCardSize.y + 15
                        );
                    break;

                case DecisionViewTypes.ImagesDamageCard:
                    DecisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        Mathf.Max(700f, Mathf.Min(decisions.Count, 5) * ImagesDamageCardSize.x + (Mathf.Min(decisions.Count, 5) + 1) * 15),
                        defaultWindowHeight + ImagesDamageCardSize.y * (rowsUsed + 1) + 10 * (rowsUsed + 1)
                        );
                    ButtonsHolder.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        Mathf.Min(decisions.Count, 5) * ImagesDamageCardSize.x + (Mathf.Min(decisions.Count, 5) + 1) * 15,
                        defaultWindowHeight + ImagesDamageCardSize.y * (rowsUsed + 1) + 15 * (rowsUsed + 1)
                        );
                    break;

                default:
                    break;
                }

                ButtonsHolder.transform.localPosition = new Vector2(-ButtonsHolder.GetComponent <RectTransform>().sizeDelta.x / 2, -185);

                if (DecisionOwner == null)
                {
                    DecisionOwner = Roster.GetPlayer(Phases.CurrentPhasePlayer);
                }
                RequiredPlayer = DecisionOwner.PlayerNo;
                Roster.HighlightPlayer(RequiredPlayer);

                if (ShowSkipButton)
                {
                    UI.ShowSkipButton();
                }
                else
                {
                    UI.HideSkipButton();
                }
            }
        }
Exemple #16
0
    public static GameObject CreateRosterInfo(GenericShip newShip)
    {
        GameObject prefab = (GameObject)Resources.Load("Prefabs/RosterPanel", typeof(GameObject));

        int playerPanelNum = (Network.IsNetworkGame && !Network.IsServer) ? AnotherPlayer(newShip.Owner.Id) : newShip.Owner.Id;

        GameObject newPanel = MonoBehaviour.Instantiate(prefab, GameObject.Find("UI/RostersHolder").transform.Find("TeamPlayer" + playerPanelNum).Find("RosterHolder").transform);

        //Generic info
        newPanel.transform.Find("ShipInfo/ShipPilotSkillText").GetComponent <Text>().text = newShip.PilotSkill.ToString();

        newPanel.transform.Find("ShipInfo/ShipFirepowerText").GetComponent <Text>().text = newShip.Firepower.ToString();
        newPanel.transform.Find("ShipInfo/ShipAgilityText").GetComponent <Text>().text   = newShip.Agility.ToString();
        newPanel.transform.Find("ShipInfo/ShipHullText").GetComponent <Text>().text      = newShip.MaxHull.ToString();
        newPanel.transform.Find("ShipInfo/ShipShieldsText").GetComponent <Text>().text   = newShip.MaxShields.ToString();

        // ALT ShipId text
        PlayerNo rosterPanelOwner = (Network.IsNetworkGame && !Network.IsServer) ? AnotherPlayer(newShip.Owner.PlayerNo) : newShip.Owner.PlayerNo;

        newPanel.transform.Find("ShipInfo/ShipId").GetComponent <Text>().text  = newShip.ShipId.ToString();
        newPanel.transform.Find("ShipIdText/Text").GetComponent <Text>().text  = newShip.ShipId.ToString();
        newPanel.transform.Find("ShipIdText/Text").GetComponent <Text>().color = (newShip.Owner.PlayerNo == PlayerNo.Player1) ? Color.green : Color.red;
        newPanel.transform.Find("ShipIdText").localPosition = new Vector3((rosterPanelOwner == PlayerNo.Player1) ? SHIP_PANEL_WIDTH + 5 : -50, 0, 0);
        newPanel.transform.Find("ShipIdText").gameObject.SetActive(true);

        //Tooltips
        GameObject pilotNameGO = newPanel.transform.Find("ShipInfo/ShipPilotNameText").gameObject;

        pilotNameGO.GetComponent <Text>().text = newShip.PilotName;
        Tooltips.AddTooltip(pilotNameGO, newShip.ImageUrl);
        SubscribeSelectionByInfoPanel(pilotNameGO);

        GameObject shipTypeGO = newPanel.transform.Find("ShipInfo/ShipTypeText").gameObject;

        shipTypeGO.GetComponent <Text>().text = newShip.Type;
        Tooltips.AddTooltip(shipTypeGO, newShip.ManeuversImageUrl);
        SubscribeSelectionByInfoPanel(shipTypeGO);

        //Mark
        newPanel.transform.Find("Mark").localPosition = new Vector3((rosterPanelOwner == PlayerNo.Player1) ? SHIP_PANEL_WIDTH - 2 : -8, 0, 0);
        SubscribeMarkByHover(newPanel);

        //Hull and shields
        float panelWidth           = SHIP_PANEL_WIDTH - 10;
        float hullAndShield        = newShip.MaxHull + newShip.MaxShields;
        float panelWidthNoDividers = panelWidth - (1 * (hullAndShield - 1));
        float damageIndicatorWidth = panelWidthNoDividers / hullAndShield;

        GameObject damageIndicatorBar = newPanel.transform.Find("ShipInfo/DamageBarPanel").gameObject;
        GameObject damageIndicator    = damageIndicatorBar.transform.Find("DamageIndicator").gameObject;

        damageIndicator.GetComponent <RectTransform>().sizeDelta = new Vector2(damageIndicatorWidth, 10);
        for (int i = 0; i < hullAndShield; i++)
        {
            GameObject newDamageIndicator = MonoBehaviour.Instantiate(damageIndicator, damageIndicatorBar.transform);
            newDamageIndicator.transform.position = damageIndicator.transform.position + new Vector3(i * (damageIndicatorWidth + 1), 0, 0);
            if (i < newShip.MaxHull)
            {
                newDamageIndicator.GetComponent <Image>().color = Color.yellow;
                newDamageIndicator.name = "DamageIndicator.Hull." + (i + 1).ToString();
            }
            else
            {
                newDamageIndicator.GetComponent <Image>().color = new Color(0, 202, 255);
                newDamageIndicator.name = "DamageIndicator.Shield." + (i - newShip.MaxHull + 1).ToString();
            }
            newDamageIndicator.SetActive(true);
        }
        MonoBehaviour.Destroy(damageIndicator);

        //Assigned Maneuver Dial
        GameObject maneuverDial = newPanel.transform.Find("AssignedManeuverDial").gameObject;

        SubscribeShowManeuverByHover(maneuverDial);
        maneuverDial.transform.localPosition = (rosterPanelOwner == PlayerNo.Player1) ? new Vector3(320, -5, 0) : new Vector3(-120, -5, 0);

        //Tags
        newPanel.transform.Find("ShipInfo").tag = "ShipId:" + newShip.ShipId.ToString();
        maneuverDial.transform.Find("Holder").gameObject.tag = "ShipId:" + newShip.ShipId.ToString();

        //Finish
        AddToRoster(newShip, newPanel);
        newPanel.transform.Find("ShipInfo").gameObject.SetActive(true);

        return(newPanel);
    }
Exemple #17
0
    public static GameObject CreateRosterInfo(GenericShip newShip)
    {
        GameObject prefab = (GameObject)Resources.Load("Prefabs/RosterPanel", typeof(GameObject));

        int playerPanelNum = (Network.IsNetworkGame && !Network.IsServer) ? AnotherPlayer(newShip.Owner.Id) : newShip.Owner.Id;

        GameObject newPanel = MonoBehaviour.Instantiate(prefab, GameObject.Find("UI/RostersHolder").transform.Find("TeamPlayer" + playerPanelNum).Find("RosterHolder").transform);

        //Generic info
        newPanel.transform.Find("ShipInfo/ShipPilotSkillText").GetComponent <Text>().text = newShip.State.Initiative.ToString();

        newPanel.transform.Find("ShipInfo/ShipFirepowerText").GetComponent <Text>().text = newShip.State.Firepower.ToString();
        newPanel.transform.Find("ShipInfo/ShipAgilityText").GetComponent <Text>().text   = newShip.State.Agility.ToString();
        newPanel.transform.Find("ShipInfo/ShipHullText").GetComponent <Text>().text      = newShip.State.HullMax.ToString();
        newPanel.transform.Find("ShipInfo/ShipShieldsText").GetComponent <Text>().text   = newShip.State.ShieldsMax.ToString();

        // ALT ShipId text
        PlayerNo rosterPanelOwner = (Network.IsNetworkGame && !Network.IsServer) ? AnotherPlayer(newShip.Owner.PlayerNo) : newShip.Owner.PlayerNo;

        newPanel.transform.Find("ShipInfo/ShipId").GetComponent <Text>().text  = newShip.ShipId.ToString();
        newPanel.transform.Find("ShipIdText/Text").GetComponent <Text>().text  = newShip.ShipId.ToString();
        newPanel.transform.Find("ShipIdText/Text").GetComponent <Text>().color = (newShip.Owner.PlayerNo == PlayerNo.Player1) ? Color.green : Color.red;
        newPanel.transform.Find("ShipIdText").localPosition = new Vector3((rosterPanelOwner == PlayerNo.Player1) ? SHIP_PANEL_WIDTH + 5 : -50, 0, 0);
        newPanel.transform.Find("ShipIdText").gameObject.SetActive(true);

        //Tooltips
        GameObject pilotNameGO = newPanel.transform.Find("ShipInfo/ShipPilotNameText").gameObject;

        pilotNameGO.GetComponent <Text>().text = newShip.PilotInfo.PilotName;
        Tooltips.AddTooltip(pilotNameGO, newShip.ImageUrl);
        SubscribeSelectionByInfoPanel(pilotNameGO);

        GameObject shipTypeGO = newPanel.transform.Find("ShipInfo/ShipTypeText").gameObject;

        shipTypeGO.GetComponent <Text>().text = newShip.ShipInfo.ShipName;
        Tooltips.AddTooltip(shipTypeGO, newShip.ManeuversImageUrl);
        SubscribeSelectionByInfoPanel(shipTypeGO);

        //Mark
        newPanel.transform.Find("Mark").localPosition = new Vector3((rosterPanelOwner == PlayerNo.Player1) ? SHIP_PANEL_WIDTH - 2 : -8, 0, 0);
        SubscribeMarkByHover(newPanel);

        //Damage Indicators
        UpdateDamageIndicators(newShip, newPanel);

        //Assigned Maneuver Dial
        GameObject maneuverDial = newPanel.transform.Find("AssignedManeuverDial").gameObject;

        SubscribeShowManeuverByHover(maneuverDial);
        maneuverDial.transform.localPosition = (rosterPanelOwner == PlayerNo.Player1) ? new Vector3(320, -5, 0) : new Vector3(-120, -5, 0);

        //Tags
        newPanel.transform.Find("ShipInfo").tag = "ShipId:" + newShip.ShipId.ToString();
        maneuverDial.transform.Find("Holder").gameObject.tag = "ShipId:" + newShip.ShipId.ToString();

        //Finish
        AddToRoster(newShip, newPanel);
        newPanel.transform.Find("ShipInfo").gameObject.SetActive(true);

        return(newPanel);
    }
Exemple #18
0
        public override void Initialize()
        {
            if (decisions.Count != 0)
            {
                decisionPanel.transform.Find("InformationPanel").GetComponentInChildren <Text>().text = InfoText;

                int i             = 0;
                int rowsUsed      = 0;
                int currentColumn = 1;

                foreach (var decision in decisions)
                {
                    GameObject prefab = null;

                    switch (DecisionViewType)
                    {
                    case DecisionViewTypes.TextButtons:
                        prefab = (GameObject)Resources.Load("Prefabs/DecisionButton", typeof(GameObject));
                        break;

                    case DecisionViewTypes.ImagesUpgrade:
                    case DecisionViewTypes.ImagesDamageCard:
                        prefab = (GameObject)Resources.Load("Prefabs/SquadBuilder/SmallCardPanel", typeof(GameObject));
                        break;

                    default:
                        break;
                    }

                    GameObject     button = MonoBehaviour.Instantiate(prefab, buttonsHolder.transform);
                    SmallCardPanel script = null;

                    switch (DecisionViewType)
                    {
                    case DecisionViewTypes.TextButtons:
                        if (!decision.IsCentered)
                        {
                            float offsetX = (currentColumn == 1) ? 7.5f : 300;

                            button.transform.localPosition = new Vector3(offsetX, -buttonHeight * rowsUsed, 0);

                            if (currentColumn == 1)
                            {
                                currentColumn++;
                            }
                            else
                            {
                                currentColumn = 1;
                                rowsUsed++;
                            }
                        }
                        else
                        {
                            button.transform.localPosition = new Vector3(105 * 1.5f, -buttonHeight * rowsUsed, 0);

                            rowsUsed++;
                            currentColumn = 1;
                        }

                        button.GetComponentInChildren <Text>().text  = decision.Name;
                        button.GetComponentInChildren <Text>().color = (decision.IsRed) ? Color.red : Color.white;

                        if (decision.HasTooltip)
                        {
                            Tooltips.AddTooltip(button, decision.Tooltip);
                        }

                        EventTrigger       trigger = button.AddComponent <EventTrigger>();
                        EventTrigger.Entry entry   = new EventTrigger.Entry();
                        entry.eventID = EventTriggerType.PointerClick;
                        entry.callback.AddListener(
                            (data) => { DecisionButtonWasPressed(decision, button); }
                            );
                        trigger.triggers.Add(entry);

                        break;

                    case DecisionViewTypes.ImagesUpgrade:
                        button.transform.localPosition = new Vector3(15 * (i + 1) + i * Editions.Edition.Current.UpgradeCardSize.x, 0, 0);

                        script = button.GetComponent <SmallCardPanel>();
                        script.Initialize(
                            decision.Name,
                            decision.Tooltip,
                            delegate {
                            GameCommand command = GenerateDecisionCommand(decision.Name);
                            GameMode.CurrentGameMode.ExecuteCommand(command);
                        },
                            DecisionViewTypes.ImagesUpgrade,
                            decision.Count
                            );

                        break;

                    case DecisionViewTypes.ImagesDamageCard:
                        button.transform.localPosition = new Vector3(15 * (i + 1) + i * ImagesDamageCardSize.x, 0, 0);

                        script = button.GetComponent <SmallCardPanel>();
                        script.Initialize(
                            decision.Name,
                            decision.Tooltip,
                            delegate {
                            GameCommand command = GenerateDecisionCommand(decision.Name);
                            GameMode.CurrentGameMode.ExecuteCommand(command);
                        },
                            DecisionViewTypes.ImagesDamageCard,
                            decision.Count
                            );

                        break;

                    default:
                        break;
                    }

                    button.name = "Button" + i;
                    i++;
                }

                switch (DecisionViewType)
                {
                case DecisionViewTypes.TextButtons:
                    if (currentColumn == 2)
                    {
                        rowsUsed++;
                    }
                    decisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        395 * 1.5f,
                        defaultWindowHeight + rowsUsed * buttonHeight
                        );
                    buttonsHolder.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        395 * 1.5f,
                        defaultWindowHeight + rowsUsed * buttonHeight
                        );
                    break;

                case DecisionViewTypes.ImagesUpgrade:
                    decisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        Mathf.Max(395 * 1.5f, decisions.Count * Editions.Edition.Current.UpgradeCardSize.x + (decisions.Count + 1) * 15),
                        defaultWindowHeight + Editions.Edition.Current.UpgradeCardSize.y + 15
                        );
                    buttonsHolder.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        decisions.Count * Editions.Edition.Current.UpgradeCardSize.x + (decisions.Count + 1) * 15,
                        defaultWindowHeight + Editions.Edition.Current.UpgradeCardSize.y + 15
                        );
                    break;

                case DecisionViewTypes.ImagesDamageCard:
                    decisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        Mathf.Max(395 * 1.5f, decisions.Count * ImagesDamageCardSize.x + (decisions.Count + 1) * 15),
                        defaultWindowHeight + ImagesDamageCardSize.y + 10
                        );
                    buttonsHolder.GetComponent <RectTransform>().sizeDelta = new Vector3(
                        decisions.Count * ImagesDamageCardSize.x + (decisions.Count + 1) * 15,
                        defaultWindowHeight + ImagesDamageCardSize.y + 15
                        );
                    break;

                default:
                    break;
                }

                buttonsHolder.transform.localPosition = new Vector2(-buttonsHolder.GetComponent <RectTransform>().sizeDelta.x / 2, -105);

                if (DecisionOwner == null)
                {
                    DecisionOwner = Roster.GetPlayer(Phases.CurrentPhasePlayer);
                }

                if (ShowSkipButton)
                {
                    UI.ShowSkipButton();
                }
                else
                {
                    UI.HideSkipButton();
                }
            }
        }
Exemple #19
0
 private static void AddUpgradeTooltip(GameObject panel)
 {
     Tooltips.AddTooltip(panel, GetUpgradeTooltipImage);
 }