void CreateGroupItem(int index) { ShipGroup group = CommandMapper.GetGroup(index); GameObject gi = Instantiate(_groupItem, null); gi.transform.SetParent(_groups); gi.transform.Find("header").transform.Find("header").GetComponent <Text>().text = "[GROUP]: " + index; gi.transform.Find("header").transform.Find("header").GetComponent <GenericTooltipHandler>().Initialize( () => TooltipManager.getInstance.OpenTooltip("[<color=yellow>LEFT-CLICK</color>] to select.\n[<color=yellow>SCROLL-CLICK</color>] to focus.", Input.mousePosition), () => CommandMapper.SelectGroup(index), () => CameraManager.getInstance.JumpTo(CommandMapper.GetGroup(index).GetCenter(), true), null, () => TooltipManager.getInstance.CloseTooltip()); gi.transform.Find("header").transform.Find("remove").GetComponent <GenericTooltipHandler>().Initialize( () => TooltipManager.getInstance.OpenTooltip("Remove group.", Input.mousePosition), () => CommandMapper.RemoveGroup(index), null, null, () => TooltipManager.getInstance.CloseTooltip()); Transform list = gi.transform.Find("list"); for (int i = 0; i < group.ships.Count; i++) { CreateGroupShipItem(list, group.ships[i]); } _groupItems[index] = gi; _groupItems[index].transform.SetSiblingIndex(index); UpdateGroupsVisibility(); }
public Combatant(Vector2D position, Player owner, ShipGroup ships, DesignStats stats, double[] abilityAmmo, double[] abilityCharges) { this.Position = position; this.Owner = owner; this.Ships = ships; this.AbilityAmmo = abilityAmmo; this.AbilityCharges = abilityCharges; this.HitPoints = stats.HitPoints - ships.Damage; this.ShieldPoints = stats.ShieldPoints; }
static void OverwriteGroup(int index, ShipGroup sg) { if (_groups[index] != null) { RemoveGroup(index); } _groups[index] = sg; OnGroupCreated?.Invoke(index); }
public Combatant(Vector2D position, Fleet originalFleet, ShipGroup ships, DesignStats stats, double[] abilityAmmo, double[] abilityCharges) { this.Position = position; this.OriginalFleet = originalFleet; this.Ships = ships; this.AbilityAmmo = abilityAmmo; this.AbilityCharges = abilityCharges; this.TopArmor = stats.HitPoints - ships.Damage / ships.Quantity; this.TopShields = stats.ShieldPoints; this.RestArmor = stats.HitPoints * ships.Quantity - ships.Damage - this.TopArmor; this.RestShields = stats.ShieldPoints * (ships.Quantity - 1); }
public void LaunchGroup(ShipGroup pGroup) { foreach(GameObject shipGO in pGroup.m_liShips) { Ship_Small ship = (Ship_Small)shipGO.GetComponent("Ship_Small"); if(ship.m_eSmallShipState == SMALLSHIPSTATE.Loaded) { if(ship is Ship_Small_Interceptor) { foreach(GameObject tubeGO in m_goLaunchTubes) { LaunchTube tube = (LaunchTube)tubeGO.GetComponent("LaunchTube"); if(tube.m_goShip != null) { Ship_Small tubeShip = (Ship_Small)tube.m_goShip.GetComponent("Ship_Small"); if(tubeShip is Ship_Small_Interceptor) { if(ship.m_iID == tubeShip.m_iID) { tube.LaunchShip(); } } } } } else if(ship is Ship_Small_Scout) { foreach(GameObject deckGO in m_goFlightDecks) { FlightDeck deck = (FlightDeck)deckGO.GetComponent("FlightDeck"); if(deck.m_goShip != null) { Ship_Small deckShip = (Ship_Small)deck.m_goShip.GetComponent("Ship_Small"); if(deckShip is Ship_Small_Scout) { if(ship.m_iID == deckShip.m_iID) { deck.LaunchShip(); } } } } } } } }
private async Task InitializeShipGroups(Map map) { var mapSize = map.Room.Size; var countOfEmptyAreas = mapSize * mapSize * 0.2; var shipTypes = await _context.ShipTypes .AsNoTracking() .OrderBy(st => st.Size) .ToListAsync(); var shipGroups = new List <ShipGroup>(); foreach (var shipType in shipTypes) { var shipGroup = new ShipGroup { UserId = map.UserId, RoomId = map.RoomId, ShipTypeId = shipType.Id, ShipType = shipType, Count = 0, Limit = 0 }; shipGroups.Add(shipGroup); } var shipGroupIndex = 0; while (countOfEmptyAreas > 0) { if (shipGroupIndex >= shipGroups.Count) { shipGroupIndex = 0; } shipGroups[shipGroupIndex].Limit++; countOfEmptyAreas -= shipGroups[shipGroupIndex].ShipType.Size; shipGroupIndex++; } foreach (var shipGroup in shipGroups) { shipGroup.ShipType = null; } _context.ShipGroups.AddRange(shipGroups); await _context.SaveChangesAsync(); }
public static void CreateGroup(int index) { if (_selectedShips.Count == 0) { return; } //need to remove selected ships from any old group for (int i = 0; i < _groups.Length; i++) { if (i == index) { continue; } for (int j = 0; j < _selectedShips.Count; j++) { if (_groups[i] != null && _groups[i].Contains(_selectedShips[j])) { _groups[i].Remove(_selectedShips[j]); if (_groups[i].ships.Count == 0) { RemoveGroup(i); } else { OverwriteGroup(i, new ShipGroup(_groups[i].ships.ToList())); } } } } if (_groups[index] != null) { RemoveGroup(index); } _groups[index] = new ShipGroup(_selectedShips.ToList()); OnGroupCreated?.Invoke(index); }
public void Load() { { var temp = (ShipGroupManager)ShipGroup.Load(); if (temp != null) { ShipGroup = temp; } } { var temp = QuestProgress.Load(); if (temp != null) { if (QuestProgress != null) { QuestProgress.RemoveEvents(); } QuestProgress = temp; } } }
public override void AddSmallShips(int count) { var ships = new List <Ship>(); for (int i = 0; i < count; i++) { ships.Add(_smallShipFactory.CreateDestroyer(0, 0, true)); } var shipGroup = new ShipGroup { Limit = count, Count = count, ShipType = new ShipType { Name = "Small Destroyer", IsSubmarine = false, Size = 1 }, Ships = ships }; _shipGroups.Add(shipGroup); }
public override void AddMediumShips(int count) { var ships = new List <Ship>(); for (int i = 0; i < count; i++) { ships.Add(_mediumShipFactory.CreateSubmarine(0, 0, true)); } var shipGroup = new ShipGroup { Limit = count, Count = count, ShipType = new ShipType { Name = "Medium Submarine", IsSubmarine = true, Size = 2 }, Ships = ships }; _shipGroups.Add(shipGroup); }
public void Save() { ShipGroup.Save(); QuestProgress.Save(); }
internal ShipGroupInfo(ShipGroup shipGroup, DesignStats stats, StaticsDB statics) { this.Data = shipGroup; this.stats = stats; this.statics = statics; }
public ShipSelection(long quantity, ShipGroup ships, double population) { this.Quantity = quantity; this.Population = population; this.Ships = ships; }
/// <summary> /// News the group execution. /// </summary> /// <returns> /// If group creation was successful. /// </returns> /// <param name='pNewGroupNumber'> /// The new group ID /// </param> /// <param name='pNumberOfInterceptors'> /// Number of interceptors in new group. /// </param> /// <param name='pNumberOfScouts'> /// Number of scouts in new group. /// </param> bool NewGroupExecution(ShipGroup pNewGroup, int pNumberOfInterceptors, int pNumberOfScouts) { int assignedInterceptors = 0, assignedScouts = 0; //loop through each hanger bay in the hanger foreach(HangerBay bay in m_tHanger.m_tHangerBays) { //check if the bay contains a ship if(bay.m_goShip != null) { Ship_Small ship = (Ship_Small)bay.m_goShip.GetComponent("Ship_Small"); //check if ship state is ready if(ship.m_eSmallShipState == SMALLSHIPSTATE.DockedReady) { //check if ship is interceptor or scout if(ship is Ship_Small_Interceptor) { //check if the number of interceptors assigned is lower than the desired amount if(assignedInterceptors < pNumberOfInterceptors) { //add ship to group and increment assigned interceptors pNewGroup.AddShip(bay.m_goShip); assignedInterceptors++; } } else if(ship is Ship_Small_Scout) { //check if the number of scouts assigned is lower than the desired amount if(assignedScouts < pNumberOfScouts) { //add ship to group and increment assigned scouts pNewGroup.AddShip(bay.m_goShip); assignedScouts++; } } } } } //check if the assigned number of interceptors and scouts is equal to the desired number if(assignedInterceptors != pNumberOfInterceptors || assignedScouts != pNumberOfScouts) { //if one or other isn't equal then remove the group and return false m_liShipGroups.Remove(pNewGroup); return false; } return true; }
public void LoadGroup(ShipGroup pGroup) { //loop through each ship in group foreach(GameObject shipGO in pGroup.m_liShips) { Ship_Small groupShip = (Ship_Small)shipGO.GetComponent("Ship_Small"); //check if group ship isn't already loading/ loaded (so is docked) if(groupShip.m_eSmallShipState == SMALLSHIPSTATE.DockedReady) { //loop through each hanger bay foreach(HangerBay bay in m_tHanger.m_tHangerBays) { //check the bay is occupied if(bay.m_goShip != null) { Ship_Small bayShip = (Ship_Small)bay.m_goShip.GetComponent("Ship_Small"); //check that the group ship and bay ship are interceptors/ scouts if(groupShip is Ship_Small_Interceptor && bayShip is Ship_Small_Interceptor) { //check ship IDs match if(groupShip.m_iID == bayShip.m_iID) { //loop through each launch tube foreach(GameObject tubeGO in m_goLaunchTubes) { LaunchTube tube = (LaunchTube)tubeGO.GetComponent("LaunchTube"); //check if the tube is unloaded and not assigned a ship if(tube.m_eState == LAUNCHTUBESTATE.Unloaded && tube.m_goShip == null) { //load the tube and remove ship from bay tube.LoadShip(bay.RemoveShip()); //break the launchtube loop break; } } } } else if(groupShip is Ship_Small_Scout && bayShip is Ship_Small_Scout) { //check ship IDs match if(groupShip.m_iID == bayShip.m_iID) { //loop through each flight deck foreach(GameObject deckGO in m_goFlightDecks) { FlightDeck deck = (FlightDeck)deckGO.GetComponent("FlightDeck"); //check if the deck is unloaded and not assigned a ship if(deck.m_eState == DECKLIFTSTATE.Unloaded && deck.m_goShip == null) { //load the deck and remove ship from bay deck.LoadLift(bay.RemoveShip()); //break the deck loop break; } } } } } } } } }