Example #1
0
    public void addPilotToSquadron(Pilot pilot)
    {
        bool   canAddPilot = true;
        bool   duplicate   = false;
        string errorMsg    = "";

        foreach (LoadedShip ls in this.squadron)
        {
            if (ls.getPilot().Name.Equals(pilot.Name))
            {
                duplicate = true;
            }
        }

        if (pilot.Unique && duplicate)
        {
            canAddPilot = false;
            errorMsg    = "The selected pilot is unique and has already been added to your squadron!";
        }

        if ((getCumulatedSquadPoints() + pilot.Cost) > this.pointsToSpend)
        {
            canAddPilot = false;
            errorMsg    = "The selected pilot's cost is too high to fit into your current squadron!";
        }

        if (canAddPilot)
        {
            LoadedShip ls = new LoadedShip();
            ls.setShip(this.selectedEmptyShip);
            ls.setPilot(pilot);
            ls.setPilotId(this.currentPilotId);

            squadron.Add(ls);

            currentPilotId++;
        }
        else
        {
            throw new System.ApplicationException(errorMsg);
        }
    }
Example #2
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                GameObject target      = hit.transform.gameObject;
                LoadedShip clickedShip = new LoadedShip();

                int playerIndex = 0;

                foreach (Player player in MatchDatas.getPlayers())
                {
                    foreach (LoadedShip ship in player.getSquadron())
                    {
                        if (ship.getPilot().Equals(target.GetComponent <ShipProperties>().getLoadedShip().getPilot()))
                        {
                            clickedShip.setShip(target.GetComponent <ShipProperties>().getLoadedShip().getShip());
                            clickedShip.setPilot(target.GetComponent <ShipProperties>().getLoadedShip().getPilot());

                            MatchDatas.getPlayers()[playerIndex].setSelectedShip(clickedShip);

                            // TODO IF! this part is needed, get the player ID who clicked on the ship!!
                            if (player.getPlayerID() == 1)
                            {
                                player.setActiveShip(clickedShip);
                            }
                        }
                    }

                    playerIndex++;
                }
            }
        }
    }
Example #3
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);
    }