public void OnPointerClick(PointerEventData eventData) { string squadronName = gameObject.transform.Find("Name").gameObject.GetComponent <UnityEngine.UI.Text>().text; SquadPersistenceUtil.loadSquadron(squadronName); LocalDataWrapper.getPlayer().toggleLoadingSquadrons(); }
public static Ships loadShipsForChosenSide() { string chosenSide = LocalDataWrapper.getPlayer().getChosenSide(); /*********************************TODO remove when testing is done!!*/ if (chosenSide == null || chosenSide.Equals("")) { chosenSide = "Rebels"; } /*********************************TODO remove when testing is done!!*/ Ships ships = new Ships(); switch (chosenSide) { case "Rebels": ships = XMLLoader.getShips("rebel_ships.xml"); break; case "Empire": ships = XMLLoader.getShips("imperial_ships.xml"); break; } return(ships); }
public void OnPointerClick(PointerEventData eventData) { LocalDataWrapper.getPlayer().addUpgradeToShip(ship, upgrade, slotId); LocalDataWrapper.getPlayer().setChosenLoadedShip(null); LocalDataWrapper.getPlayer().setChosenSlotId(0); LocalDataWrapper.getPlayer().setChosenUpgraType(""); }
public void changePlayerPointsToSpend(InputField gameObj) { string squadPoints = gameObj.text; int points = System.Convert.ToInt32(squadPoints); LocalDataWrapper.getPlayer().setPointsToSpend(points); }
private void showShips() { SquadBuilderUtil.resetScrollView(shipsScroll); int shipIndex = 0; foreach (Ship ship in ships.Ship) { if (ship.Size.Equals(LocalDataWrapper.getPlayer().getChosenSize())) { Transform shipPanelPrefab = Resources.Load <Transform>(SquadBuilderConstants.PREFABS_FOLDER_NAME + "/" + SquadBuilderConstants.SHIP_NAME_PANEL); RectTransform rt = (RectTransform)shipPanelPrefab; float shipPanelHeight = rt.rect.height; Transform shipPanel = (Transform)GameObject.Instantiate( shipPanelPrefab, new Vector3(SquadBuilderConstants.SHIP_PANEL_X_OFFSET, (shipIndex * shipPanelHeight * -1) + SquadBuilderConstants.SHIP_PANEL_Y_OFFSET, SquadBuilderConstants.SHIP_PANEL_Z_OFFSET), Quaternion.identity ); shipPanel.transform.SetParent(shipsScroll.transform, false); shipPanel.transform.Find("ShipName").gameObject.GetComponent <UnityEngine.UI.Text>().text = ship.ShipName.ToLower(); SquadBuilderShipPanelEvents shipPanelUIEvent = shipPanel.transform.GetComponent <SquadBuilderShipPanelEvents>(); shipPanelUIEvent.setShip(ship); shipIndex++; } } }
void Start() { Player player = new Player(); // TODO set player parameters (like name, squadpoints, etc..) from config? LocalDataWrapper.setPlayer(player); }
void Update() { showCurrentSquadPoints(); togglePlayButton(); if (!prevChosenSize.Equals(LocalDataWrapper.getPlayer().getChosenSize())) { updateWholeView(); prevChosenSize = LocalDataWrapper.getPlayer().getChosenSize(); } if (!prevChosenShip.Equals(LocalDataWrapper.getPlayer().getSelectedEmptyShip().ShipId)) { updateViewOnShipSelection(); } if (!prevChosenPilot.Equals(LocalDataWrapper.getPlayer().getSelectedPilot().Name)) { updateViewOnPilotSelection(); } if (LocalDataWrapper.getPlayer().getSquadron() != null && (prevSquadronSize != LocalDataWrapper.getPlayer().getSquadron().Count || prevSquadronCost != LocalDataWrapper.getPlayer().getCumulatedSquadPoints())) { updateViewOnSquadronChange(); SaveButton.SetActive(true); } if ((LocalDataWrapper.getPlayer().getSquadron().Count == 0 || LocalDataWrapper.getPlayer().getSquadron() == null) && SaveButton.activeSelf) { SaveButton.SetActive(false); } if (!LocalDataWrapper.getPlayer().getChosenUpgradeType().Equals("") && LocalDataWrapper.getPlayer().getChosenSlotId() != 0 && LocalDataWrapper.getPlayer().getChosenLoadedShip() != null) { if (!UpgradesPopup.activeSelf) { showUpgradesPopup(); } } else { if (UpgradesPopup.activeSelf) { closeUpgradesPopup(); } } if (LocalDataWrapper.getPlayer().isLoadingSquadrons() && !fileExplorer.activeSelf) { showFileExplorer(); } else if (!LocalDataWrapper.getPlayer().isLoadingSquadrons() && fileExplorer.activeSelf) { SquadBuilderUtil.hideFileExplorer(fileExplorer); } }
public void OnPointerClick(PointerEventData eventData) { Debug.Log("Setting upgradeslot player data - slot: " + this.slotId + ", type: " + this.upgradeType + ", ship: " + this.ship.getShip().ShipName); //When these 3 values are set, the upgrade selector popup will show the available options LocalDataWrapper.getPlayer().setChosenLoadedShip(this.ship); LocalDataWrapper.getPlayer().setChosenUpgraType(this.upgradeType); LocalDataWrapper.getPlayer().setChosenSlotId(this.slotId); }
public void OnPointerClick(PointerEventData eventData) { try { LocalDataWrapper.getPlayer().addPilotToSquadron(LocalDataWrapper.getPlayer().getSelectedPilot()); } catch (System.ApplicationException e) { SystemMessageService.showErrorMsg(e.Message, GameObject.Find("SystemMessagePanel"), 2, null); } }
public void OnPointerClick(PointerEventData eventData) { try { LocalDataWrapper.getPlayer().removePilotFromSquadron(this.pilot, this.pilotId); } catch (System.ApplicationException e) { SystemMessageService.showErrorMsg(e.Message, GameObject.Find("SystemMessagePanel"), 2, null); } }
// DUPLICATED FRAGMENT!!! public static bool isPlayersOwnShip() { foreach (LoadedShip ship in LocalDataWrapper.getPlayer().getSquadron()) { if (ship.getPilotId() == MatchDatas.getActiveShip().GetComponent <ShipProperties>().getLoadedShip().getPilotId()) { return(true); } } return(false); }
public void mockLocalPlayer() { Player player = new Player(); if (LocalDataWrapper.getPlayer() != null) { player = LocalDataWrapper.getPlayer(); } player.setPlayerName("Human Player"); LocalDataWrapper.setPlayer(player); }
public static void saveSquadron(string squadronName) { if (squadronName == null || squadronName.Equals("")) { squadronName = DEFAULT_SQUADRON_NAME; } BinaryFormatter binaryFormatter = new BinaryFormatter(); using (FileStream fileStream = File.Open(Path.Combine(Application.streamingAssetsPath, SAVED_DATA_FOLDER + LocalDataWrapper.getPlayer().getChosenSide() + "/" + squadronName + SAVED_DATA_EXTENSION), FileMode.OpenOrCreate)) { binaryFormatter.Serialize(fileStream, LocalDataWrapper.getPlayer().getSquadron()); } }
public static void loadSquadron(string squadronName) { if (squadronName == null || squadronName.Equals("")) { throw new System.ApplicationException("Cannot load squadron without a valid name! Parameter was null or empty string!!!"); } BinaryFormatter binaryFormatter = new BinaryFormatter(); using (FileStream fileStream = File.Open(Path.Combine(Application.streamingAssetsPath, SAVED_DATA_FOLDER + LocalDataWrapper.getPlayer().getChosenSide() + "/" + squadronName + SAVED_DATA_EXTENSION), FileMode.Open)) { List <LoadedShip> squadron = (List <LoadedShip>)binaryFormatter.Deserialize(fileStream); LocalDataWrapper.getPlayer().setSquadron(squadron); } }
private void togglePlayButton() { if (LocalDataWrapper.getPlayer().getCumulatedSquadPoints() > 0) { if (!PlayButton.activeSelf) { PlayButton.SetActive(true); } } else { if (PlayButton.activeSelf) { PlayButton.SetActive(false); } } }
private void showChosenSideIcon() { string chosenSide = LocalDataWrapper.getPlayer().getChosenSide(); Sprite sideIcon = null; switch (chosenSide) { case SquadBuilderConstants.FACTION_REBELS: sideIcon = Resources.Load <Sprite>(SquadBuilderConstants.IMAGE_FOLDER_NAME + "/" + SquadBuilderConstants.REBEL_ICON_IMAGE); break; case SquadBuilderConstants.FACTION_EMPIRE: sideIcon = Resources.Load <Sprite>(SquadBuilderConstants.IMAGE_FOLDER_NAME + "/" + SquadBuilderConstants.EMPIRE_ICON_IMAGE); break; } factionIconHolder.GetComponent <Image>().sprite = sideIcon; }
private void showPilotDataPreview() { SquadBuilderUtil.resetImagesInGameObject(pilotDataPreview, "PilotDataUpgradeSlots"); Pilot pilotToShow = LocalDataWrapper.getPlayer().getSelectedPilot(); if (pilotToShow != null) { string pilotName = pilotToShow.Unique ? "*" + pilotToShow.Name.ToLower() : pilotToShow.Name.ToLower(); pilotDataPreview.transform.Find("PilotLevel/Text").gameObject.GetComponent <UnityEngine.UI.Text>().text = pilotToShow.Level.ToString(); pilotDataPreview.transform.Find("PilotCost/Text").gameObject.GetComponent <UnityEngine.UI.Text>().text = pilotToShow.Cost.ToString(); pilotDataPreview.transform.Find("PilotDataPilotName/Text").gameObject.GetComponent <UnityEngine.UI.Text>().text = pilotName; pilotDataPreview.transform.Find("PilotDataPilotDescription/Text").gameObject.GetComponent <UnityEngine.UI.Text>().text = pilotToShow.Text; int upgradeIndex = 0; foreach (UpgradeSlot upgrade in pilotToShow.UpgradeSlots.UpgradeSlot) { Sprite sprite = Resources.Load <Sprite>(SquadBuilderConstants.IMAGE_FOLDER_NAME + "/" + upgrade.Type); Transform upgradeImageHolderPrefab = Resources.Load <Transform>(SquadBuilderConstants.PREFABS_FOLDER_NAME + "/" + SquadBuilderConstants.UPGRADE_IMAGE_HOLDER); RectTransform rt = (RectTransform)upgradeImageHolderPrefab; float upgradeImageHolderWidth = rt.rect.width; Transform upgradeImageHolder = (Transform)GameObject.Instantiate( upgradeImageHolderPrefab, new Vector3((upgradeIndex * upgradeImageHolderWidth) + SquadBuilderConstants.UPGRADE_IMAGE_X_OFFSET, SquadBuilderConstants.UPGRADE_IMAGE_Y_OFFSET, SquadBuilderConstants.UPGRADE_IMAGE_Z_OFFSET), Quaternion.identity ); Transform upgradesBar = pilotDataPreview.transform.Find("PilotDataUpgradeSlots"); Image upgradeImage = upgradeImageHolder.gameObject.GetComponent <Image>(); upgradeImageHolder.transform.SetParent(upgradesBar, false); upgradeImage.sprite = sprite; upgradeImage.color = new Color(upgradeImage.color.r, upgradeImage.color.g, upgradeImage.color.b, 1.0f); upgradeIndex++; } } }
public static Upgrades loadUpgrades(string side, string size) { Upgrades tempUpgrades = XMLLoader.getUpgrades(); Upgrades upgrades = new Upgrades(); upgrades.Upgrade = new System.Collections.Generic.List <UpgradesXMLCSharp.Upgrade>(); foreach (UpgradesXMLCSharp.Upgrade upgrade in tempUpgrades.Upgrade) { bool available = true; if (upgrade.SideRestriction != null && !upgrade.SideRestriction.Equals("")) { if (!upgrade.SideRestriction.Equals(LocalDataWrapper.getPlayer().getChosenSide())) { available = false; } } if (available) { if (upgrade.SizeRestriction != null && !upgrade.SizeRestriction.Equals("")) { if (!upgrade.SizeRestriction.Equals(LocalDataWrapper.getPlayer().getChosenSize())) { available = false; } } } if (available) { upgrades.Upgrade.Add(upgrade); } } return(upgrades); }
public IEnumerator RollAttackDice(System.Action <Player> callBack) { // TODO change the first param to be dynamic! DiceRollerBase.showDiceArea(1, true); Rigidbody[] GOS = FindObjectsOfType(typeof(Rigidbody)) as Rigidbody[]; bool allSleeping = false; while (!allSleeping) { allSleeping = true; foreach (Rigidbody GO in GOS) { if (!GO.IsSleeping()) { allSleeping = false; yield return(null); break; } } } DiceRollerBase.getDiceResults(GOS); Player result = null; if (LocalDataWrapper.getPlayer().getLastDiceResults()[0] == DiceRollerBase.DICE_RESULT_HIT_OR_EVADE || LocalDataWrapper.getPlayer().getLastDiceResults()[0] == DiceRollerBase.DICE_RESULT_CRIT) { result = MatchDatas.getPlayers()[0]; } else { result = MatchDatas.getPlayers()[1]; } callBack(result); }
private void updateViewOnShipSelection() { if (LocalDataWrapper.getPlayer().getSelectedEmptyShip() == null) { Ship defaultShip = null; foreach (Ship ship in ships.Ship) { if (ship.Size.Equals(LocalDataWrapper.getPlayer().getChosenSize())) { defaultShip = ship; break; } } LocalDataWrapper.getPlayer().setSelectedEmptyShip(defaultShip); } showPilots(); showShipDataPreview(); prevChosenShip = LocalDataWrapper.getPlayer().getSelectedEmptyShip().ShipId; prevChosenPilot = ""; }
void Start() { /*********************************TODO remove when testing is done!!*/ LocalDataWrapper.setPlayer(new Player()); if (LocalDataWrapper.getPlayer().getChosenSide() == null || LocalDataWrapper.getPlayer().getChosenSide().Equals("")) { LocalDataWrapper.getPlayer().setChosenSide(SquadBuilderConstants.FACTION_REBELS); } if (LocalDataWrapper.getPlayer().getChosenSize() == null || LocalDataWrapper.getPlayer().getChosenSize().Equals("")) { LocalDataWrapper.getPlayer().setChosenSize("small"); } /*********************************TODO remove when testing is done!!*/ this.ships = SquadBuilderUtil.loadShipsForChosenSide(); this.pilots = SquadBuilderUtil.loadPilotsForEachShip(this.ships); this.upgrades = SquadBuilderUtil.loadUpgrades(LocalDataWrapper.getPlayer().getChosenSide(), LocalDataWrapper.getPlayer().getChosenSize()); showChosenSideIcon(); showCurrentSquadPoints(); }
private void showPilots() { SquadBuilderUtil.resetScrollView(pilotsScroll); int pilotIndex = 0; foreach (PilotsXMLCSharp.Pilot pilot in pilots.Pilot) { if (pilot.ShipId.Equals(LocalDataWrapper.getPlayer().getSelectedEmptyShip().ShipId)) { //By default, load the first pilot as it would be selected... if (pilotIndex == 0) { LocalDataWrapper.getPlayer().setSelectedPilot(pilot); } Transform pilotPanelPrefab = Resources.Load <Transform>(SquadBuilderConstants.PREFABS_FOLDER_NAME + "/" + SquadBuilderConstants.PILOT_NAME_PANEL); RectTransform rt = (RectTransform)pilotPanelPrefab; float pilotPanelHeight = rt.rect.height; Transform pilotPanel = (Transform)GameObject.Instantiate( pilotPanelPrefab, new Vector3(SquadBuilderConstants.PILOT_PANEL_X_OFFSET, (pilotIndex * pilotPanelHeight * -1) + SquadBuilderConstants.PILOT_PANEL_Y_OFFSET, SquadBuilderConstants.PILOT_PANEL_Z_OFFSET), Quaternion.identity ); pilotPanel.transform.SetParent(pilotsScroll.transform, false); pilotPanel.transform.Find("PilotName").gameObject.GetComponent <UnityEngine.UI.Text>().text = pilot.Name.ToLower(); SquadBuilderPilotPanelEvents pilotPanelUIEvent = pilotPanel.transform.GetComponent <SquadBuilderPilotPanelEvents>(); pilotPanelUIEvent.setShip(pilot); pilotIndex++; } } }
public static void displayInitiativeChoser(Player player) { int playerIndex = 0; if (LocalDataWrapper.getPlayer().getPlayerName().Equals(player.getPlayerName())) { foreach (Player currentPlayer in MatchDatas.getPlayers()) { Transform InitiativeButtonPrefab = Resources.Load <Transform>(MatchHandlerConstants.PREFABS_FOLDER + MatchHandlerConstants.INITIATIVE_BUTTON_PREFAB_NAME); Transform InitiativeButton = (Transform)GameObject.Instantiate( InitiativeButtonPrefab, new Vector3(InitiativeButtonPrefab.position.x, InitiativeButtonPrefab.position.y - playerIndex * 85, InitiativeButtonPrefab.position.z), Quaternion.identity ); InitiativeButton.GetComponentInChildren <Text>().text = currentPlayer.getPlayerName(); InitiativeButton.transform.SetParent(initiativePanel.transform, false); playerIndex++; } initiativePanel.SetActive(true); } }
public static List <string> getSquadronNames() { List <string> names = new List <string>(); DirectoryInfo dir = new DirectoryInfo(Path.Combine(Application.streamingAssetsPath, "Saves/" + LocalDataWrapper.getPlayer().getChosenSide() + "/")); FileInfo[] info = dir.GetFiles("*.dat"); foreach (FileInfo f in info) { names.Add(f.Name.Split('.')[0]); } return(names); }
public void OnPointerClick(PointerEventData eventData) { LocalDataWrapper.getPlayer().setSelectedPilot(pilot); }
public void OnPointerClick(PointerEventData eventData) { LocalDataWrapper.getPlayer().setSelectedEmptyShip(ship); }
public void OnPointerClick(PointerEventData eventData) { LocalDataWrapper.getPlayer().toggleLoadingSquadrons(); }
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); }
public void OnPointerClick(PointerEventData eventData) { LocalDataWrapper.getPlayer().setChosenSize(size); LocalDataWrapper.getPlayer().setSelectedShip(null); }
public void OnPointerClick(PointerEventData eventData) { //TODO Check, if side can be chosen (if (squadTotal == 0){...}) LocalDataWrapper.getPlayer().setChosenSide(faction); SceneManager.LoadScene("SquadronBuilder", LoadSceneMode.Single); }