Ejemplo n.º 1
0
    public void showActiveShipsCard(LoadedShip ship)
    {
        Transform shipCardPrefab = Resources.Load <Transform>(PREFAB_FOLDER_NAME);
        Sprite    shipSprite     = Resources.Load <Sprite>(IMAGE_FOLDER_NAME + "/" + ship.getShip().ShipName.Replace("/", ""));

        Transform shipCard = (Transform)GameObject.Instantiate(
            shipCardPrefab,
            new Vector3(100, 100, 0),
            Quaternion.identity
            );

        shipCard.transform.SetParent(TargetCanvas.transform, false);
        shipCard.transform.Find("Ship Name").gameObject.GetComponent <UnityEngine.UI.Text>().text         = ship.getShip().ShipName.ToString();
        shipCard.transform.Find("Ship Image").gameObject.GetComponent <Image>().sprite                    = shipSprite;
        shipCard.transform.Find("Attack Power Text").gameObject.GetComponent <UnityEngine.UI.Text>().text = ship.getShip().Weapon.ToString();
        shipCard.transform.Find("Agility Text").gameObject.GetComponent <UnityEngine.UI.Text>().text      = ship.getShip().Agility.ToString();
        shipCard.transform.Find("Hull Text").gameObject.GetComponent <UnityEngine.UI.Text>().text         = ship.getShip().Hull.ToString();
        shipCard.transform.Find("Shield Text").gameObject.GetComponent <UnityEngine.UI.Text>().text       = ship.getShip().Shield.ToString();
    }
Ejemplo n.º 2
0
    public void mockPlayerSquadrons()
    {
        Ships  ships  = XMLLoader.getShips("rebel_ships.xml");
        Pilots pilots = XMLLoader.getPilots("t65xw_pilots.xml");

        LoadedShip ship1 = new LoadedShip();

        ship1.setShip(ships.Ship[0]);
        ship1.setPilot(pilots.Pilot[0]);
        //Adding event actions to be registered for event handling.
        //TODO Is the input parameter correct/enough??????
        ship1.addEventAction(new EventActionWedgeAntilles(ship1));

        LoadedShip ship2 = new LoadedShip();

        ship2.setShip(ships.Ship[0]);
        ship2.setPilot(pilots.Pilot[1]);
        ship2.getPilot().Level = ship1.getPilot().Level;

        //List<LoadedShip> squadron1 = new List<LoadedShip>();

        /*foreach (LoadedShip ship in LocalDataWrapper.getPlayer().getSquadron())
         * {
         *  squadron1.Add(ship);
         *
         *  //Registering event actions...
         *  foreach (CustomEventBase eventAction in ship.getEventActions())
         *  {
         *      EventActionRegister.registerEventAction(eventAction);
         *  }
         * }*/

        LocalDataWrapper.getPlayer().setChosenSide("Rebels");
        LocalDataWrapper.getPlayer().setPLayerID(1);
        LocalDataWrapper.getPlayer().setAI(false);

        if (LocalDataWrapper.getPlayer().getSquadron() == null || LocalDataWrapper.getPlayer().getSquadron().Count == 0)
        {
            LocalDataWrapper.getPlayer().setSelectedEmptyShip(ship1.getShip());
            LocalDataWrapper.getPlayer().addPilotToSquadron(ship1.getPilot());

            LocalDataWrapper.getPlayer().setSelectedEmptyShip(ship2.getShip());
            LocalDataWrapper.getPlayer().addPilotToSquadron(ship2.getPilot());

            //LocalDataWrapper.getPlayer().setSquadron(squadron1);
        }

        //AI PLAYER!!
        Player player2 = new Player();

        player2.setChosenSide("Empire");
        player2.setPlayerName("AI Player");
        player2.setPLayerID(2);

        Ships  ships2  = XMLLoader.getShips("imperial_ships.xml");
        Pilots pilots2 = XMLLoader.getPilots("tief_pilots.xml");

        LoadedShip ship3 = new LoadedShip();

        ship3.setShip(ships2.Ship[0]);
        ship3.setPilot(pilots2.Pilot[0]);
        player2.setSelectedEmptyShip(ship3.getShip());
        player2.addPilotToSquadron(ship3.getPilot());

        LoadedShip ship4 = new LoadedShip();

        ship4.setShip(ships2.Ship[0]);
        ship4.setPilot(pilots2.Pilot[1]);
        player2.setSelectedEmptyShip(ship4.getShip());
        player2.addPilotToSquadron(ship4.getPilot());

        LoadedShip ship5 = new LoadedShip();

        ship5.setShip(ships2.Ship[0]);
        ship5.setPilot(pilots2.Pilot[2]);
        player2.setSelectedEmptyShip(ship5.getShip());
        player2.addPilotToSquadron(ship5.getPilot());

        LoadedShip ship6 = new LoadedShip();

        ship6.setShip(ships2.Ship[0]);
        ship6.setPilot(pilots2.Pilot[0]);
        player2.setSelectedEmptyShip(ship6.getShip());
        player2.addPilotToSquadron(ship6.getPilot());

        LoadedShip ship7 = new LoadedShip();

        ship7.setShip(ships2.Ship[0]);
        ship7.setPilot(pilots2.Pilot[0]);
        player2.setSelectedEmptyShip(ship7.getShip());
        player2.addPilotToSquadron(ship7.getPilot());

        LoadedShip ship8 = new LoadedShip();

        ship8.setShip(ships2.Ship[0]);
        ship8.setPilot(pilots2.Pilot[0]);
        player2.setSelectedEmptyShip(ship8.getShip());
        player2.addPilotToSquadron(ship8.getPilot());

        player2.setAI(true);

        MatchDatas.addPlayer(LocalDataWrapper.getPlayer());
        MatchDatas.addPlayer(player2);
    }
Ejemplo n.º 3
0
    public void showPilotCard(GameObject target)
    {
        LoadedShip ship = MatchDatas.getPlayers()[MatchDatas.getActivePlayerIndex()].getSelectedhip();
        string     side = "";
        Image      image;
        Sprite     sprite;

        foreach (Player player in MatchDatas.getPlayers())
        {
            foreach (LoadedShip ls in player.getSquadron())
            {
                if (ls.getShip().ShipId == ship.getShip().ShipId&& ls.getPilot().Name.Equals(ship.getPilot().Name))
                {
                    side = player.getChosenSide();
                    break;
                }

                if (!side.Equals(""))
                {
                    break;
                }
            }
        }

        target.transform.Find("PilotName").gameObject.GetComponent <UnityEngine.UI.Text>().text                = ship.getPilot().Name.ToLower();
        target.transform.Find("ShipType").gameObject.GetComponent <UnityEngine.UI.Text>().text                 = ship.getShip().ShipName.ToLower();
        target.transform.Find("Description").gameObject.GetComponent <UnityEngine.UI.Text>().text              = ship.getPilot().Text.ToLower();
        target.transform.Find("BaseCostHolder/BaseCost").gameObject.GetComponent <UnityEngine.UI.Text>().text  = ship.getPilot().Cost.ToString();
        target.transform.Find("ShieldValueHolder/Value").gameObject.GetComponent <UnityEngine.UI.Text>().text  = ship.getShip().Shield.ToString();
        target.transform.Find("HullValueHolder/Value").gameObject.GetComponent <UnityEngine.UI.Text>().text    = ship.getShip().Hull.ToString();
        target.transform.Find("AgilityValueHolder/Value").gameObject.GetComponent <UnityEngine.UI.Text>().text = ship.getShip().Agility.ToString();
        target.transform.Find("PowerValueHolder/Value").gameObject.GetComponent <UnityEngine.UI.Text>().text   = ship.getShip().Weapon.ToString();
        target.transform.Find("PilotLevelHolder/Value").gameObject.GetComponent <UnityEngine.UI.Text>().text   = ship.getPilot().Level.ToString();

        int actionIndex = 0;


        // TODO use prefabs instead???
        foreach (string action in ship.getShip().Actions.Action)
        {
            image  = null;
            sprite = Resources.Load <Sprite>(SquadBuilderConstants.IMAGE_FOLDER_NAME + "/" + action.Replace(" ", "-"));

            Transform     actionIconPrefab = Resources.Load <Transform>(SquadBuilderConstants.PREFABS_FOLDER_NAME + "/" + SquadBuilderConstants.ACTION_ICON);
            RectTransform rt = (RectTransform)actionIconPrefab;
            float         actionIconWidth = rt.rect.width;

            Transform actionIcon = (Transform)GameObject.Instantiate(
                actionIconPrefab,
                new Vector3((actionIndex * actionIconWidth) + SquadBuilderConstants.UPGRADE_IMAGE_X_OFFSET, SquadBuilderConstants.UPGRADE_IMAGE_Y_OFFSET, SquadBuilderConstants.UPGRADE_IMAGE_Z_OFFSET),
                Quaternion.identity
                );

            Transform actionsBar      = target.transform.Find("ActionIcons");
            Image     actionIconImage = actionIcon.gameObject.GetComponent <Image>();

            actionIcon.transform.SetParent(actionsBar, false);
            actionIconImage.sprite = sprite;
            actionIconImage.color  = new Color(actionIconImage.color.r, actionIconImage.color.g, actionIconImage.color.b, 1.0f);

            /*if (ship.getNumOfActions() > 0 && ship.isBeforeAction() && !actionHasBeenUsed(ship, action))
             * {
             *  addActionToSelector(target, action, actionIndex);
             * }*/

            actionIndex++;
        }

        sprite = Resources.Load <Sprite>(SquadBuilderConstants.IMAGE_FOLDER_NAME + "/" + side + "_pilot_card");
        target.transform.Find("CardImage").gameObject.GetComponent <Image>().sprite = sprite;
        image       = target.transform.Find("CardImage").gameObject.GetComponent <Image>();
        image.color = new Color(image.color.r, image.color.g, image.color.b, 1.0f);

        sprite = Resources.Load <Sprite>(SquadBuilderConstants.IMAGE_FOLDER_NAME + "/" + ship.getShip().ShipId);
        target.transform.Find("CardImage/ShipImage").gameObject.GetComponent <Image>().sprite = sprite;
        image       = target.transform.Find("CardImage/ShipImage").gameObject.GetComponent <Image>();
        image.color = new Color(image.color.r, image.color.g, image.color.b, 1.0f);

        target.transform.Find("ShipDataManeuvers").gameObject.SetActive(false);

        target.SetActive(true);
    }