Beispiel #1
0
        public IntVector2 AddShipToFreePosition(Ship ship)
        {
            Ships.Add(ship);
            var coordinates = PlayerArena.AddShipToFreePosition(ship);

            return(coordinates);
        }
Beispiel #2
0
        public void Update(RawMasterInfo rpInfo)
        {
            Ships.UpdateRawData(rpInfo.Ships, r => new ShipInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));
            ShipTypes.UpdateRawData(rpInfo.ShipTypes, r => new ShipTypeInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));

            Equipment.UpdateRawData(rpInfo.Equipment, r => new EquipmentInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));
            EquipmentTypes.UpdateRawData(rpInfo.EquipmentTypes, r => new EquipmentTypeInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));

            Items.UpdateRawData(rpInfo.Items, r => new ItemInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));

            MapAreas.UpdateRawData(rpInfo.MapAreas, r => new MapAreaInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));
            Maps.UpdateRawData(rpInfo.Maps, r => new MapMasterInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));

            Expeditions.UpdateRawData(rpInfo.Expeditions, r => new ExpeditionInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));

            EventMapCount = (from rArea in MapAreas.Values
                             where rArea.IsEventArea
                             join rMap in Maps.Values on rArea.ID equals rMap.AreaID
                             select rMap).Count();

            if (r_InitializationLock != null)
            {
                r_InitializationLock.Set();
                r_InitializationLock.Dispose();
                r_InitializationLock = null;
            }
        }
Beispiel #3
0
        public Shot TakeShot(char column, int row)
        {
            var selectedPoint = this.board.coordinates.Where(x => x.Column == column && x.Row == row).FirstOrDefault();

            if (selectedPoint.ShipIdentifier > 0 & selectedPoint.Occupied != Status.Hit)
            {
                var selectedShip = Ships.Where(x => x.Id == selectedPoint.ShipIdentifier).FirstOrDefault();

                if (selectedShip.Width > selectedShip.Hits)
                {
                    selectedShip.Hits++;
                }

                if (selectedShip.IsSunk)
                {
                    RaiseEvent($"{selectedShip.Name} has been sunk.!");
                }
                if (Ships.Where(x => x.IsSunk == false).Count() == 0)
                {
                    RaiseEvent($"Player 1 Wins. !");
                }
            }

            selectedPoint.Occupied = Status.Hit;

            return(Ships.Where(x => x.IsSunk == false).Count() == 0 ? Shot.Wins :
                   Ships.Where(x => x.Id == selectedPoint.ShipIdentifier && x.IsSunk == true).Any() ? Shot.Sinks : selectedPoint.ShipIdentifier > 0 ? Shot.Hit : Shot.Miss);
        }
Beispiel #4
0
    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);
    }
Beispiel #5
0
        private void cleanUpGalaxy()
        {
            foreach (Ship ship in Ships)
            {
                ship.Inventory.ClearInventory();
                ship.Nodes.Clear();
            }
            Ships.Clear();

            foreach (Faction faction in Factions)
            {
                faction.OwnedFactories.Clear();
                faction.OwnedMarkets.Clear();
                faction.OwnedShips.Clear();
                faction.OwnedStations.Clear();
            }

            factions.Clear();

            foreach (StarSystem system in Systems)
            {
                system.Planetoids.Clear();
            }

            Systems.Clear();
        }
Beispiel #6
0
        public ShotResult ProcessShot(Coordinates coords, Label response)
        {
            var tile = Board.Tiles.At(coords.Row, coords.Column);

            if (!tile.Occupied)
            {
                response.Text = $"{Name} says: Miss!";
                response.Refresh();
                tile.ShotResult = ShotResult.Miss;
                return(ShotResult.Miss);
            }
            var ship = Ships.First(x => x.TileOccupation == tile.TileOccupation);

            ship.Hits++;
            tile.ShotResult = ShotResult.Hit;
            response.Text   = $"{Name} says: Hit!";

            if (ship.IsDestoyed)
            {
                response.Text = $"{Name} says: You sunk my {ship.Name}!";
            }

            response.Refresh();
            return(ShotResult.Hit);
        }
Beispiel #7
0
 private static int SendFleet(Celestial origin, Ships ships, Coordinate destination, Missions mission, Speeds speed, Model.Resources payload = null, bool force = false)
 {
     Helpers.WriteLog(LogType.Info, LogSender.Tbot, "Sending fleet from " + origin.Coordinate.ToString() + " to " + destination.ToString() + ". Mission: " + mission.ToString() + ". Ships: " + ships.ToString());
     UpdateSlots();
     if (slots.Free > 1 || force)
     {
         if (payload == null)
         {
             payload = new Resources {
                 Metal = 0, Crystal = 0, Deuterium = 0
             };
         }
         try
         {
             Fleet fleet = ogamedService.SendFleet(origin, ships, destination, mission, speed, payload);
             fleets = ogamedService.GetFleets();
             UpdateSlots();
             return(fleet.ID);
         }
         catch (Exception e)
         {
             Helpers.WriteLog(LogType.Error, LogSender.Defender, "Exception: " + e.Message);
             return(0);
         }
     }
     else
     {
         Helpers.WriteLog(LogType.Warning, LogSender.Tbot, "Unable to send fleet, no slots available");
         return(0);
     }
 }
        public void ShipyardSwap(JournalShipyardSwap e, string station, string system)
        {
            if (e.StoreShipId.HasValue)     // if we have an old ship ID (old records do not)
            {
                string oldship = Key(e.StoreOldShipFD, e.StoreShipId.Value);

                if (Ships.ContainsKey(oldship))
                {
                    //System.Diagnostics.Debug.WriteLine(oldship + " Swap Store at " + system + ":" + station);
                    Ships[oldship] = Ships[oldship].Store(station, system);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine(e.StoreOldShipFD + " Cant find to swap");
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine(e.StoreOldShipFD + " Cant find to swap");
            }

            string sid = Key(e.ShipFD, e.ShipId);           //swap to new ship

            //System.Diagnostics.Debug.WriteLine(sid + " Swap to at " + system);

            ShipInformation sm = EnsureShip(sid);                 // this either gets current ship or makes a new one.

            sm         = sm.SetShipDetails(e.ShipType, e.ShipFD); // shallow copy if changed
            sm         = sm.SwapTo();                             // swap into
            Ships[sid] = sm;
            currentid  = sid;
            VerifyList();
        }
        public bool AutomaticShipCoordinates2()
        {
            int shipCount = 0;

            while (true)
            {
                Ships shipType = (Ships)shipCount;
                x_coord = rnd.Next(1, boardSize + 1);
                y_coord = rnd.Next(1, boardSize + 1);
                Player2ShipCoordinates.Add(x_coord.ToString() + y_coord.ToString());
                direction  = GameBoard.directionNumberToString[rnd.Next(0, 2)];
                shipLength = shipCount;
                if (ShipLocationCheck2(x_coord, y_coord,
                                       StringToEnum(direction), shipType))
                {
                    Player2ShipCoordinates.Add(x_coord.ToString() + y_coord.ToString());
                    Player2ShipDirections.Add(StringToEnum(direction));
                    PlaceOneShip(Player2Board1);
                    shipCount++;
                    if (shipCount == 5)
                    {
                        break;
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #10
0
 public SendExpAction(Ships.Fleet fl, Missions.Expedition exp)
 {
     fleet = fl;
     //expeditionNumber = expNumber;
     Exp = exp;
     ExecuteDate = DateTime.Now;
 }
Beispiel #11
0
 public void LoadShips(IEnumerable <long> shipIds)
 {
     shipIds = shipIds.Distinct().Where(w => !Characters.Select(s => s.Id).ToList().Contains(w));
     shipIds.ToList().ForEach(f =>
                              Ships.Add(_mapper.Map <ItemSummary>(
                                            new Devpack.ESI.Models.Universe.ItemType(f))));
 }
Beispiel #12
0
 public static void registerEnemy(Ships thisP)
 {
     if (!foundEnemy.Contains(thisP))
     {
         foundEnemy.Add(thisP);
     }
 }
Beispiel #13
0
        internal string GetStatusMessage()
        {
            var message = new StringBuilder();

            if (Ships.Any(a => a.HitCount > 0))
            {
                message.AppendLine($"{Name} current status:");

                var hitShips = Ships.Where(w => w.HitCount > 0 && !w.IsSunk).ToList();
                foreach (var item in hitShips)
                {
                    var plural = item.HitCount > 1 ? "s" : string.Empty;
                    message.AppendLine($"{item.Name} : {item.HitCount} hit{plural}");
                }

                var sunkShips = Ships.Where(w => w.IsSunk).ToList();
                foreach (var item in sunkShips)
                {
                    message.AppendLine($"{item.Name} : Sunk");
                }

                message.AppendLine($"Received {GameBoard.Squares.Count(c => c.IsHit)} hit shot");
                message.AppendLine($"Received {GameBoard.Squares.Count(c => c.IsMiss)} missed shot");
            }

            return(message.ToString());
        }
Beispiel #14
0
 private FleetState CheckFleetState()
 {
     if (Ships.AsList().Count == 0)
     {
         return(FleetState.Empty);
     }
     if (Expedition != null)
     {
         return(FleetState.Expedition);
     }
     if (ships.Any(s => s.IsRepairing))
     {
         return(FleetState.Repairing);
     }
     if (Ships.Any(s => s.HP.DamageState >= ShipDamageState.HeavilyDamaged))
     {
         return(FleetState.Damaged);
     }
     if (Ships.Any(s => !s.Fuel.IsMaximum || !s.Bullet.IsMaximum))
     {
         return(FleetState.Insufficient);
     }
     if (Ships.Any(s => s.Morale < 40))
     {
         return(FleetState.Fatigued);
     }
     if (owner.CombinedFleet > 0 && (Id == 1 || Id == 2))
     {
         return(FleetState.Combined);
     }
     return(FleetState.Ready);
 }
Beispiel #15
0
        public void UpdateInventoryCategories()
        {
            Elixirs.Clear();
            Ships.Clear();
            Weapons.Clear();
            Armor.Clear();

            foreach (var gameItemQuantity in _inventory)
            {
                if (gameItemQuantity.GameObject is Weapons)
                {
                    Weapons.Add(gameItemQuantity);
                }
                if (gameItemQuantity.GameObject is Armor)
                {
                    Armor.Add(gameItemQuantity);
                }
                if (gameItemQuantity.GameObject is Ship)
                {
                    Ships.Add(gameItemQuantity);
                }
                if (gameItemQuantity.GameObject is Elixirs)
                {
                    Elixirs.Add(gameItemQuantity);
                }
            }
        }
Beispiel #16
0
        public void PlaceShip(Coordinate startCoordinate, Coordinate endCoordinate)
        {
            // Validate ship location and shape
            if (IsCoordinateOutsideBoard(startCoordinate) || IsCoordinateOutsideBoard(endCoordinate))
            {
                throw new ArgumentOutOfRangeException();
            }
            if (!_shapeValidator.IsValidShapeForShip(startCoordinate, endCoordinate))
            {
                throw new NotValidShapeForShipException();
            }
            var coords = GetShipCoordinates(startCoordinate, endCoordinate);

            // Validate if location is not empty. Not required in our simple exercise, but for a real solution
            if (!IsShipPlaceEmpty(coords))
            {
                throw new ShipPlaceIsNotEmptyException();
            }

            /* all validation passes then
             * 1 - mark all board cells as BoardCellStatus.Ship
             * 2 - and add it to the ship list */
            Array.ForEach(coords, x => _board[x.Row, x.Column] = BoardCellStatus.Ship);
            Ships.Add(new Ship(coords));
        }
Beispiel #17
0
 public void RemoveShip(ShipType type)
 {
     if (Ships.ContainsKey(type))
     {
         Ships.Remove(type);
     }
 }
Beispiel #18
0
    public void inConstruction(Ships ships, People people)
    {
        if (workInProgress)
        {
            if (remainingTimeForConstruction <= 0)
            {
                // rajouter un navire dans Ships, differencier en fonction du type
                if (this.typeOfShipConstruct == ConstantsAndEnums.shipType.type1)
                {
                    ships.NbrOfShipType1 += 1;
                }
                // else if (this.typeOfShipConstruct == ConstantsAndEnums.shipType.type2) ships.NbrOfShipType2 +=1;
                // else if (this.typeOfShipConstruct == ConstantsAndEnums.shipType.type3) ships.NbrOfShipType3 +=1;

                people.NbrOfVikings       += nbrOfVikingAssigned;
                people.NbrOfShieldMaidens += nbrOfShieldMaidenAssigned;
                people.NbrOfSlave         += nbrOfSlaveAssigned;
                nbrOfVikingAssigned        = 0;
                nbrOfShieldMaidenAssigned  = 0;
                nbrOfSlaveAssigned         = 0;
                workInProgress             = false;
            }
            else if (remainingTimeForConstruction > 0)
            {
                remainingTimeForConstruction -= 1;
            }
        }
    }
Beispiel #19
0
 internal void UpdateShips(RawShip[] rpShips)
 {
     if (Ships.UpdateRawData(rpShips, r => new Ship(r), (rpData, rpRawData) => rpData.Update(rpRawData)))
     {
         UpdateShipsCore();
     }
 }
Beispiel #20
0
        /*-------------------------------------------------------------------------------------------------------------------------
         * Called per Ai physics tick.
         *
         * holdTimer is the time that the AI has been holding the weapon, including timer modifications from gamemodes.
         * unscaledHoldTimer is the time that the AI has been holding the weapon, not including their modifications from gamemodes.
         * --------------------------------------------------------------------------------------------------------------------------*/
        public override void AiUpdate(float holdTimer, float unscaledHoldTimer)
        {
            // if the total hold time is over the usage time then drop the pickup
            if (unscaledHoldTimer > AiUsageDelay)
            {
                OnDrop();
            }

            // check if there a ship in front of the ai
            bool canSeeShip = Physics.Raycast(R.RBody.position, R.Forward, out RaycastHit hit, 15.0f, Layers.ShipToShip); // cast against the ship to ship layer, which are the bounding box colliders of each ship

            if (!canSeeShip)
            {
                return;
            }

            // figure out which ship is at the hit point. If the AI is passive towards the ship, do nothing
            ShipRefs targetShip = Ships.GetClosestShipToPoint(hit.point);

            if (R.IsPassiveTowards(targetShip))
            {
                canSeeShip = false;
            }

            if (canSeeShip)
            {
                OnUse();
            }
        }
Beispiel #21
0
    IEnumerator LoadShipAsync(string ship, int index)
    {
        ShipsJsonFactory shipFactory = new ShipsJsonFactory(this);
        string           baseUrl     = "https://api.spacexdata.com/v3/ships/";
        ShipList         shipList    = listParent.shipList;

        shipList.listItems = new List <ShipListItem>();
        shipFactory.FetchJson(baseUrl + ship);
        yield return(new WaitUntil(() => shipFactory.IsDone));

        if (!shipFactory.IsError)
        {
            Ships        shipsRoot = shipFactory.GetRootObject();
            ShipListItem item      = new ShipListItem();
            item.homePort    = shipsRoot.ship.home_port;
            item.imageUrl    = shipsRoot.ship.image;
            item.numMissions = shipsRoot.ship.missions.Length;
            item.shipName    = shipsRoot.ship.ship_name;
            item.shipType    = shipsRoot.ship.ship_type;
            shipList.listItems.Add(item);
        }
        shipList.SpawnList();
        if (index > 0 && index < coroutines.Count)
        {
            activeCoroutines.RemoveAll(value => value == coroutines[index]);
        }
    }
Beispiel #22
0
 private void ExecuteRemoveShipCommand()
 {
     if (MessageBox.Show("Deseja realmente remover esse navio?", "Remover", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
     {
         Ships.Remove(SelectedShip);
     }
 }
Beispiel #23
0
        public async Task <bool> OpenAsync()
        {
            if (Open)
            {
                return(Open);
            }

            var root = await ReadJson();

            Species = root.Members.Select(x => x.Species).Distinct().OrderBy(x => x).ToArray();

            Genders = root.Members.Select(x => x.Gender).Distinct().OrderBy(x => x).ToArray();

            foreach (var ship in Ships = root.Ships)
            {
                ship.Image = UpdateImagePaths(ship.Show, ship.Images);
            }

            foreach (var member in Members = root.Members)
            {
                member.Image = UpdateImagePaths(member.Show, member.Images);
            }

            foreach (var show in Shows = root.Shows)
            {
                UpdateImagePaths(show.Abbreviation, show.Images);
                show.Image = Ships.First(x => x.Show == show.Abbreviation)?.Images?.First();
            }

            return(Open = true);

            Image UpdateImagePaths(string show, params Image[] images)
Beispiel #24
0
        /// <summary>
        /// Find a ship with a specific name and return it
        /// </summary>
        /// <returns></returns>
        private static Ship GetShip()
        {
            //TODO: Add the option to search by GUID
            Console.WriteLine();
            Console.WriteLine("Please type the GUID of the ship to select");

            long shipGUID;
            try
            {
                shipGUID = Int64.Parse(Console.ReadLine());
            }
            catch (Exception ex)
            {
                var newEx = new InvalidCastException("The Ship GUID you tried to search was not a number. Search failed.", ex);
                throw newEx;
            }

            Console.Write("Searching... ");

            var ship = Ships.GetShip(shipGUID);
            if (ship != null)
            {
                ConsoleColorLine(string.Format("Ship Found! {0}", ship), ConsoleColor.DarkGreen);
            }
            else
            {
                ConsoleColorLine("Ship Not Found!!!", ConsoleColor.Red);
            }
            return ship;
        }
 /// <summary>
 /// Remove an enemy from the list of enemies
 /// </summary>
 /// <param name="index">index of the ship to remove</param>
 public void RemoveEnemy(int index)
 {
     Game.game.RandomBonus(Ships[index].Position);
     Ships.RemoveAt(index);
     UpdateBBox();
     Game.game.playerScore.CalculateScore();
 }
Beispiel #26
0
 private void PortHandler(port_port api)
 {
     System.Runtime.GCSettings.LargeObjectHeapCompactionMode = System.Runtime.GCLargeObjectHeapCompactionMode.CompactOnce;
     GC.Collect();
     Staff.Current.Admiral.BasicHandler(api.api_basic);
     ConditionHelper.Instance.BeginUpdate();
     Staff.Current.Shipyard.RepairDocks.ForEach(x => x.Ship?.IgnoreNextCondition());
     if (Ships == null)
     {
         Ships = new IDTable <int, Ship>(api.api_ship.Select(x => new Ship(x)));
     }
     else
     {
         Ships.UpdateAll(api.api_ship, x => x.api_id);
     }
     ConditionHelper.Instance.EndUpdate();
     Staff.Current.Admiral.ShipCount = api.api_ship.Length;
     Staff.Current.Shipyard.NDockHandler(api.api_ndock);
     DecksHandler(api.api_deck_port);
     if (Fleets.Any(x => x.MissionState == Fleet.FleetMissionState.Complete))
     {
         Logger.Loggers.MaterialLogger.ForceLog = false;
     }
     Material.MaterialHandler(api.api_material);
     CombinedFleet = (CombinedFleetType)api.api_combined_flag;
     Fleets.ForEach(x => x.CheckHomeportRepairingTime(false));
 }
Beispiel #27
0
        public void RemoveShip(Ship ship, bool removeEquip = true)
        {
            var infleet = ship.InFleet;

            if (infleet != null)
            {
                DispatcherHelper.UIDispatcher.Invoke(() =>
                {
                    infleet.Ships?.Remove(ship);
                    infleet.UpdateStatus();
                });
            }
            if (removeEquip)
            {
                foreach (var slot in ship.Slots)
                {
                    if (slot.HasItem)
                    {
                        Equipments.Remove(slot.Item);
                    }
                }
                if (ship.SlotEx.HasItem)
                {
                    Equipments.Remove(ship.SlotEx.Item);
                }
            }
            Ships.Remove(ship);
            UpdateCounts();
        }
Beispiel #28
0
        private ShipInformation EnsureShip(string id)      // ensure we have an ID of this type..
        {
            if (Ships.ContainsKey(id))
            {
                ShipInformation sm = Ships[id];
                if (sm.State == ShipInformation.ShipState.Owned)               // if owned, ok
                {
                    return(sm);
                }
                else
                {
                    Ships[Key(sm.ShipFD, newsoldid++)] = sm;              // okay, we place this information on back ID list+  all Ids of this will now refer to new entry
                }
            }

            //System.Diagnostics.Debug.WriteLine("Made new ship " + id);

            int i;

            id.Substring(id.IndexOf(":") + 1).InvariantParse(out i);
            ShipInformation smn = new ShipInformation(i);

            Ships[id] = smn;
            return(smn);
        }
        public override void PlaceShip(int size, string tag)
        {
            var loop = true;

            while (loop)
            {
                var direction = GetDirection();
                var coords    = GetShipCoordinates();
                var ship      = new Ship(coords, direction, size, tag);
                if (ship.IsHorizontal && (ship.Size + coords.Row) > 10)
                {
                    continue;
                }
                else if ((!ship.IsHorizontal) && (ship.Size + coords.Column) > 10)
                {
                    continue;
                }
                else if (IsCoordinateTaken(ship))
                {
                    continue;
                }
                else
                {
                    Ships.Add(ship);
                    foreach (var coordinate in ship.ShipCoordinates)
                    {
                        OwnBoard.Board[coordinate.Row][coordinate.Column].Symbol = tag;
                    }
                    loop = false;
                }
            }
        }
        public IHttpActionResult PutShips(int id, Ships ships)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != ships.ShipID)
            {
                return(BadRequest());
            }

            db.Entry(ships).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ShipsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #31
0
        public void AddShipToBoard(int xStartCoordinate, int yStartCoordinate, int length, ShipAlignment alignment)
        {
            try
            {
                xStartCoordinate.ValidateXStartCoordinate();
                yStartCoordinate.ValidateYStartCoordinate();
                length.ValidateLength();

                var ship = new Ship(xStartCoordinate, yStartCoordinate, length, alignment);
                Ships.Add(ship);

                Board.AddShipToBoard(ship);
            }
            catch (XCoordOutOfBoundsException exception)
            {
                Console.WriteLine(exception.Message);
            }
            catch (YCoordOutOfBoundsException exception)
            {
                Console.WriteLine(exception.Message);
            }
            catch (LengthOutOfBoundsException exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
Beispiel #32
0
 public Ship(string name, Ships ships, Sector sector, SectorPosition sectorPosition, Vector3 angle, Tile tile)
 {
     this.name = name;
     this.ships = ships;
     this.sector = sector;
     this.sectorPosition = sectorPosition;
     this.angle = angle;
     this.tilesList.Add(tile);
 }
Beispiel #33
0
 //acceleration or power/weight
 //turn rates
 //any other parts that aren't in cubes
 public Ship()
 {
     name = null;
     ships = null;
     sector = new Sector();
     sectorPosition = new SectorPosition();
     ObjectVelocity velocity = new ObjectVelocity();
     List<Tile> tiles = new List<Tile>();
 }
Beispiel #34
0
 public void Initialize(SuperPolarity game, Vector2 position, Ships shipType, int rate, int scoreThreshold)
 {
     Game = game;
     ShipType = shipType;
     ScoreThreshold = scoreThreshold;
     Rate = rate;
     Randomizer = new Random();
     Position = position;
     CurrentTime = rate;
 }
Beispiel #35
0
 public Ship(string name, Ships ships, Sector sector, SectorPosition sectorPosition, Vector3 angle, List<Tile> tileList)
 {
     this.name = name;
     this.ships = ships;
     this.sector = sector;
     this.sectorPosition = sectorPosition;
     this.angle = angle;
     foreach (Tile tile in tileList) {
         this.tilesList.Add(tile);
         tile.ship = this;
     }
 }
Beispiel #36
0
 void changer(Ships change)
 {
     ship = change;
     if (change != sprite) {
         sprite=change;
         switch (change) {
         case Ships.red:
             GetComponent <SpriteRenderer>().sprite= shipChange[0];
             break;
         case Ships.blue:
             GetComponent <SpriteRenderer>().sprite= shipChange[1];
             break;
         case Ships.yellow:
             GetComponent <SpriteRenderer>().sprite= shipChange[2];
             break;
         }
     }
 }
Beispiel #37
0
        public CrewMember(Library.Race race, Ships.Ship ship, string name)
        {
            // Store details
            Race = race;
            Name = name;
            this.ship = ship;

            // Load spritesheets
            tsRed = Root.Singleton.Material(race.TilesheetRed, true);
            tsYellow = Root.Singleton.Material(race.TilesheetYellow, true);
            tsGreen = Root.Singleton.Material(race.TilesheetGreen, true);
            tsSelected = Root.Singleton.Material(race.TilesheetSelected, true);

            // Calculate tile size
            tileW = (int)(tsGreen.Size.X / race.TilesX);
            tileH = (int)(tsGreen.Size.Y / race.TilesY);

            // Create sprite
            sprGraphic = new Sprite();
            sprGraphic.Scale = new Vector2f(1.0f, 1.0f);

            // Default drawmode
            Mode = DrawMode.Yellow;
        }
Beispiel #38
0
	void removeFromFleet(Ships ship){
		FleetShips.Remove (ship);
		ship.assignedFleet = null;
	}
Beispiel #39
0
        static async void Server()
        {
            Out.WriteLine("Started pararell task.", "Azure.Boot");
            checkUpdates();

            Out.WriteLine("Checking for app.ini...", "Azure.Boot");
            
            if (!System.IO.File.Exists("app.ini"))
            {
                Out.WriteLine("Error #1 loading app.ini: File not exists", "Azure.Boot", ConsoleColor.Red);
                Console.ReadKey();
                Environment.Exit(0);
            }
            Settings = await ReadSettings(System.IO.File.ReadAllText("app.ini"));
            if (!Settings.ContainsKey("server") || !Settings.ContainsKey("mport") || !Settings.ContainsKey("username") || !Settings.ContainsKey("password") || !Settings.ContainsKey("dbName") || !Settings.ContainsKey("port") || !Settings.ContainsKey("flushPackets"))
            {
                Out.WriteLine("Error #3 loading app.ini: Configuration file is invalid", "Azure.Boot", ConsoleColor.Red);
                Console.ReadKey();
                Environment.Exit(0);
            }
            Out.WriteLine("app.ini loaded.", "Azure.Boot");
            Console.WriteLine();

            try
            {
                Out.WriteLine("Connecting to " + Settings["dbName"] + " at " + Settings["server"] + ":" + Settings["mport"] + " for user " + Settings["username"], "MySQL.Connect");
                manager = new DatabaseManager(30, 10, DatabaseType.MySQL);
                manager.setServerDetails(Settings["server"], uint.Parse(Settings["mport"]), Settings["username"], Settings["password"], Settings["dbName"]);
                manager.init();
                Out.WriteLine("Connection to database successfull.", "MySQL.Connect");
            }
            catch (Exception e)
            {
                Out.WriteLine("Error #4 connecting to MySQL: " + e.Message, "MySQL.Connect", ConsoleColor.Red);
                Console.ReadKey();
                Environment.Exit(0);
            }

            Console.WriteLine();
            Users = new Dictionary<uint, game.User>();
            Out.WriteLine("Initializing game maps ...", "Server.Game.Maps");
            Maps = new Dictionary<ushort, serverGame.Map>();
            using (IQueryAdapter dbClient = manager.getQueryreactor())
            {
                NPCS = new Dictionary<ushort, Ships>();
                var data = (System.Data.DataTable)dbClient.query("SELECT * FROM ships");
                foreach (System.Data.DataRow Row in data.Rows)
                {
                    Ships alien = new Ships();
                    alien.Id = Convert.ToUInt16(Row["Id"]);
                    alien.Name = Row["Name"].ToString();
                    alien.HP = Convert.ToUInt32(Row["HP"]);
                    alien.Shield = Convert.ToUInt32(Row["Shield"]);
                    alien.Damage = Convert.ToUInt32(Row["Damage"]);
                    alien.Speed = Convert.ToUInt16(Row["Speed"]);
                    alien.isNeutral = ToBool(Row["isNeutral"].ToString());
                    alien.shieldAbsorb = Convert.ToUInt16(Row["shieldAbsorb"]);
                    alien.LaserId = Convert.ToUInt16(Row["LaserId"]);
                    NPCS.Add(alien.Id, alien);

                    var data2 = (System.Data.DataTable)dbClient.query("SELECT * FROM ships_designs WHERE ShipId = " + alien.Id + "");
                    if (data2.Rows.Count > 0)
                    {
                        foreach (System.Data.DataRow _Row in data2.Rows)
                        {
                            Ships ship = new Ships();
                            ship.Id = Convert.ToUInt16(_Row["Id"]);
                            ship.Name = _Row["Name"].ToString();
                            ship.HP = Convert.ToUInt32(Row["HP"]);
                            ship.Shield = Convert.ToUInt32(Row["Shield"]);
                            ship.Damage = Convert.ToUInt32(Row["Damage"]);
                            ship.Speed = Convert.ToUInt16(Row["Speed"]);
                            ship.isNeutral = ToBool(Row["isNeutral"].ToString());
                            ship.shieldAbsorb = Convert.ToUInt16(Row["shieldAbsorb"]);
                            ship.LaserId = Convert.ToUInt16(Row["LaserId"]);
                            NPCS.Add(ship.Id, ship);
                        }
                    }
                }

                data = (System.Data.DataTable)dbClient.query("SELECT * FROM maps");
                foreach (System.Data.DataRow Row in data.Rows)
                {
                    Maps.Add(Convert.ToUInt16(Row["id"]), new serverGame.Map(Convert.ToUInt16(Row["id"]), Row["Name"].ToString(), Row["Portals"].ToString(), Row["NPCS"].ToString(), Program.ToBool(Row["isStarterMap"].ToString()), Convert.ToUInt16(Row["factionId"])));
                }
            }
            Out.WriteLine("Loaded " + Maps.Count + " maps.", "Server.Game.Maps");
            Out.WriteLine("Loaded " + NPCS.Count + " ships.", "Server.Game.Ships");
            Console.WriteLine();

            Out.WriteLine("Starting up asynchronous sockets server for game connections for port " + Settings["port"], "Server.AsyncSocketListener");
            Core.AsynchronousSocketListener.SetPort(Convert.ToInt32(Settings["port"]));
            Task.Factory.StartNew(Core.AsynchronousSocketListener.StartListening);
            Out.WriteLine("Asynchronous sockets server for game connections running on port " + Settings["port"], "Server.AsyncSocketListener");
            Out.WriteLine("DarkOrbit Emulator ready. Status: idle", "Azure.Boot");
            Console.WriteLine();
            Console.Beep();
        }
Beispiel #40
0
 public void SetRoom(Ships.Room room)
 {
     SetTile(room.GetTiles().First());
 }
Beispiel #41
0
        public void SetTile(Ships.Room.Tile tile)
        {
            // Check for first set
            if (this.tile == null)
            {
                this.tile = tile;
                return;
            }

            // TODO: Move from one room to another
        }