public void CreateTargetBoard_validateBoardTypeCreated()
        {
            BoardType   target      = BoardType.TargetBoard;
            TargetBoard targetBoard = new TargetBoard();

            Assert.Equal(targetBoard.BoardType, target);
        }
示例#2
0
        // Choose Random coordinates
        private Coordinates RandomShot()
        {
            var    availableCells = TargetBoard.GetOpenRandomCells();
            Random rand           = new Random(Guid.NewGuid().GetHashCode());
            var    cellID         = rand.Next(availableCells.Count);

            return(availableCells[cellID]);
        }
示例#3
0
 public Player(string name)
 {
     Name        = name;
     TargetBoard = new TargetBoard();
     OceanBoard  = new OceanBoard();
     Fleet       = new List <Ship>()
     {
         new Battleship(),
         new Carrier(),
         new Cruiser(),
         new Destroyer(),
         new Submarine()
     };
 }
 public void CreateBoard()
 {
     OceanBoard.DrawBoard();
     TargetBoard.DrawBoard();
 }
示例#5
0
    public void GetFile()
    {
        GetJournalData();
        string[] JournalData = JournalDump.Split("\n"[0]);

        if (FileNumber > 0)
        {
            LastLineNumber = 0;
        }
        else
        {
            LastLineNumber = FirstFileLastLineNumber;
        }

        for (int j = LastLineNumber; j < JournalData.Length; j++)
        {
            Debug.Log(LastLineNumber + " " + JournalData.Length);
            //Handle extra blank line at end of file
            if (JournalData[j].Length == 0)
            {
            }
            else
            {
                if (FileNumber == 0)
                {
                    FirstFileLastLineNumber = j;
                }

                // Json Deserialise
                DataDump datadump = JsonConvert.DeserializeObject <DataDump>(JournalData[j]);

                //Start up 0 = no file read


                if (JournalLine > 0)
                {
                    //timestamp check


                    // Game load = 1 (when Commander event found)
                    if (JournalLine == 1 && FileNumber == 0)
                    {
                        if (datadump.@event == "Missions")
                        {
                            //Set to 2 when Missions event found
                            Debug.Log("Missions event found " + ActiveMissionList.Count + " Missions found");

                            try
                            {
                                if (JournalStartMissions == 0)
                                {
                                    for (int i = 0; i < datadump.Active.Length; i++)
                                    {
                                        if (datadump.Active[i].Expires > 0)
                                        {
                                            foreach (var File in ActiveMissionList)
                                            {
                                                if (File.MissionID == datadump.Active[i].MissionID)
                                                {
                                                    MatchedMission = true;
                                                    break;
                                                }
                                                else
                                                {
                                                    MatchedMission = false;
                                                }
                                            }
                                            if (MatchedMission == false)
                                            {
                                                JournalStartMissions = JournalStartMissions + 1;
                                                ActiveMissionList.Add(new MissionAdd {
                                                    MissionID = datadump.Active[i].MissionID.ToString()
                                                });
                                            }
                                        }
                                    }
                                    Debug.Log("Missions event found " + ActiveMissionList.Count + " Missions found");
                                    foreach (var mission in ActiveMissionList)
                                    {
                                        Debug.Log(mission.MissionID + " In list");
                                    }
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }

                    if (datadump.@event == "FSDJump" && FileNumber == 0)
                    {
                        FactionFound          = false;
                        FactionSystemCaptured = false;
                        GameObject SystemData;
                        SystemData = GameObject.Find("CurrentSystemDetails");


                        PlayerLocation = new Vector3(float.Parse(datadump.StarPos[0]), float.Parse(datadump.StarPos[1]), float.Parse(datadump.StarPos[2]));
                        StarSystem     = datadump.StarSystem;

                        ControllingFaction = datadump.SystemFaction;
                        Security           = datadump.SystemSecurity_Localised;
                        Economy            = datadump.SystemEconomy_Localised;
                        Government         = datadump.SystemGovernment_Localised;
                        population         = datadump.Population;

                        SystemData.GetComponent <Text>().text = StarSystem +
                                                                "\n" + Security + "\nEconomy: " + Economy;
                    }

                    if (datadump.@event == "Bounty")
                    {
                        killlist.Add(new KillList {
                            KillTime = datadump.timestamp, Faction = datadump.VictimFaction
                        });
                    }
                    if (datadump.@event == "Location" && FileNumber == 0)
                    {
                        StarSystem = datadump.StarSystem;
                    }

                    if (datadump.@event == "MissionAccepted")
                    {
                        try
                        {
                            if (datadump.name.StartsWith("Mission_Massacre"))
                            {
                                MissionType = "Kill";
                            }
                            if (datadump.name.StartsWith("Mission_Delivery") || datadump.name.Contains("HelpFinishTheOrder"))
                            {
                                MissionType = "Deliver";
                            }
                            if (datadump.name.StartsWith("Mission_Assass"))
                            {
                                MissionType = "Assassinate";
                            }
                            if (datadump.name.StartsWith("Mission_Courier"))
                            {
                                MissionType = "Deliver Data";
                            }
                            if (datadump.name.StartsWith("Mission_Disable"))
                            {
                                MissionType = "Take out";
                            }
                            if (datadump.name.StartsWith("Mission_Mining"))
                            {
                                MissionType = "Mine";
                            }
                            if (datadump.name.StartsWith("Mission_Collect"))
                            {
                                MissionType = "Source";
                            }
                            if (datadump.name.StartsWith("Mission_Hack"))
                            {
                                MissionType = "Hack";
                            }
                            if (datadump.name.StartsWith("MISSION_Salvage"))
                            {
                                MissionType = "Retrieve";
                            }
                            if (datadump.name.StartsWith("MISSION_Scan"))
                            {
                                MissionType = "Scan";
                            }
                        }
                        catch (Exception)
                        {
                        }

                        if (FileNumber == 0 && ActiveMissionList.Count > 0)
                        {
                            foreach (var File in ActiveMissionList)
                            {
                                if (File.MissionID == datadump.MissionID)
                                {
                                    MatchedMission = true;
                                    break;
                                }
                                else
                                {
                                    MatchedMission = false;
                                }
                            }

                            if (MatchedMission == false)
                            {
                                ActiveMissionList.Add(new MissionAdd {
                                    MissionID = datadump.MissionID.ToString()
                                });
                                Debug.Log("Mission number " + datadump.MissionID + "Added");
                            }
                        }
                        else if (FileNumber == 0 && ActiveMissionList.Count == 0)
                        {
                            ActiveMissionList.Add(new MissionAdd {
                                MissionID = datadump.MissionID.ToString()
                            });
                            Debug.Log("Mission number " + datadump.MissionID + "Added");
                        }


                        foreach (var mission in ActiveMissionList)
                        {
                            if (mission.MissionID == datadump.MissionID)
                            {
                                Debug.Log(mission.MissionID + " added detail");
                                mission.Reputation = datadump.Reputation;
                                mission.Influence  = datadump.Influence;
                                mission.Faction    = datadump.Faction;
                                break;
                            }
                        }
                        if (datadump.name.StartsWith("Mission_Altr"))
                        {
                            ActiveMissionList.Add(new MissionAdd {
                                MissionID = datadump.MissionID, LocalisedName = datadump.LocalisedName, Department = "Logistics "
                            });
                        }

                        //****** ASSASSINATE MISSIONS*******
                        else if (datadump.name.StartsWith("Mission_Assass"))

                        {
                            foreach (var mission in ActiveMissionList)
                            {
                                if (mission.MissionID == datadump.MissionID)
                                {
                                    mission.AcceptedTime      = datadump.timestamp;
                                    mission.LocalisedName     = datadump.LocalisedName;
                                    mission.reward            = datadump.Reward;
                                    mission.KillCountstring   = datadump.Target;
                                    mission.Target            = datadump.TargetType_Localised;
                                    mission.TargetFaction     = datadump.TargetFaction;
                                    mission.DestinationSystem = datadump.DestinationSystem;
                                    mission.Expiry            = datadump.Expiry;
                                    mission.type = MissionType;

                                    break;
                                }
                            }
                        }
                        //****** MASSACRE MISSIONS*******
                        else if (datadump.name.StartsWith("Mission_Massa"))
                        {
                            foreach (var mission in ActiveMissionList)
                            {
                                if (mission.MissionID == datadump.MissionID)
                                {
                                    mission.AcceptedTime      = datadump.timestamp;
                                    mission.LocalisedName     = datadump.LocalisedName;
                                    mission.reward            = datadump.Reward;
                                    mission.KillCountstring   = datadump.KillCount.ToString();
                                    mission.Target            = datadump.TargetType_Localised;
                                    mission.TargetFaction     = datadump.TargetFaction;
                                    mission.DestinationSystem = datadump.DestinationSystem;
                                    mission.Expiry            = datadump.Expiry;
                                    mission.type = MissionType;
                                    break;
                                }
                            }
                        }
                        else if (datadump.name.StartsWith("Mission_Courier"))

                        {
                            foreach (var mission in ActiveMissionList)

                            {
                                if (mission.MissionID == datadump.MissionID)
                                {
                                    //   FoundMissions = FoundMissions + 1;
                                    mission.AcceptedTime       = datadump.timestamp;
                                    mission.LocalisedName      = datadump.LocalisedName;
                                    mission.reward             = datadump.Reward;
                                    mission.TargetFaction      = datadump.TargetFaction;
                                    mission.DestinationSystem  = datadump.DestinationSystem;
                                    mission.DestinationStation = datadump.DestinationStation;
                                    mission.Expiry             = datadump.Expiry;
                                    mission.type = MissionType;

                                    break;
                                }
                            }
                        }
                        else if (datadump.name.StartsWith("Mission_Deliver") || datadump.name.Contains("HelpFinishTheOrder"))

                        {
                            foreach (var mission in ActiveMissionList)
                            {
                                if (mission.MissionID == datadump.MissionID)
                                {
                                    //    FoundMissions = FoundMissions + 1;
                                    mission.AcceptedTime       = datadump.timestamp;
                                    mission.LocalisedName      = datadump.LocalisedName;
                                    mission.reward             = datadump.Reward;
                                    mission.TargetFaction      = datadump.TargetFaction;
                                    mission.DestinationSystem  = datadump.DestinationSystem;
                                    mission.DestinationStation = datadump.DestinationStation;
                                    mission.Expiry             = datadump.Expiry;
                                    mission.type            = MissionType;
                                    mission.KillCountstring = datadump.Count.ToString();
                                    mission.Target          = datadump.Commodity_Localised;
                                    break;
                                }
                            }
                        }

                        else if (datadump.name.StartsWith("Mission_Disable"))

                        {
                            foreach (var mission in ActiveMissionList)
                            {
                                if (mission.MissionID == datadump.MissionID)
                                {
                                    //   FoundMissions = FoundMissions + 1;
                                    mission.AcceptedTime      = datadump.timestamp;
                                    mission.LocalisedName     = datadump.LocalisedName;
                                    mission.reward            = datadump.Reward;
                                    mission.TargetFaction     = datadump.TargetFaction;
                                    mission.Target            = datadump.Target_Localised;
                                    mission.Expiry            = datadump.Expiry;
                                    mission.type              = MissionType;
                                    mission.DestinationSystem = "Unknown";

                                    break;
                                }
                            }
                        }
                        else if (datadump.name.StartsWith("Mission_Collect"))

                        {
                            foreach (var mission in ActiveMissionList)
                            {
                                if (mission.MissionID == datadump.MissionID)
                                {
                                    //  FoundMissions = FoundMissions + 1;
                                    mission.AcceptedTime         = datadump.timestamp;
                                    mission.LocalisedName        = datadump.LocalisedName;
                                    mission.reward               = datadump.Reward;
                                    mission.TargetFaction        = datadump.TargetFaction;
                                    mission.KillCountstring      = datadump.Count.ToString();
                                    mission.TargetType_Localised = datadump.Commodity_Localised;
                                    mission.Expiry               = datadump.Expiry;
                                    mission.type   = MissionType;
                                    mission.Target = datadump.Commodity_Localised;

                                    break;
                                }
                            }
                        }

                        else if (datadump.name.StartsWith("Mission_Mining"))

                        {
                            foreach (var mission in ActiveMissionList)
                            {
                                if (mission.MissionID == datadump.MissionID)
                                {
                                    //   FoundMissions = FoundMissions + 1;
                                    mission.AcceptedTime       = datadump.timestamp;
                                    mission.LocalisedName      = datadump.LocalisedName;
                                    mission.reward             = datadump.Reward;
                                    mission.TargetFaction      = datadump.TargetFaction;
                                    mission.DestinationSystem  = datadump.DestinationSystem;
                                    mission.DestinationStation = datadump.DestinationStation;
                                    mission.Expiry             = datadump.Expiry;
                                    mission.type            = MissionType;
                                    mission.KillCountstring = datadump.Count.ToString();
                                    mission.Target          = datadump.Commodity_Localised;
                                    break;
                                }
                            }
                        }
                        else if (datadump.name.StartsWith("Mission_Hack"))

                        {
                            foreach (var mission in ActiveMissionList)
                            {
                                if (mission.MissionID == datadump.MissionID)
                                {
                                    //   FoundMissions = FoundMissions + 1;
                                    mission.AcceptedTime      = datadump.timestamp;
                                    mission.LocalisedName     = datadump.LocalisedName;
                                    mission.reward            = datadump.Reward;
                                    mission.Target            = datadump.Target_Localised;
                                    mission.Expiry            = datadump.Expiry;
                                    mission.type              = MissionType;
                                    mission.DestinationSystem = "Unknown";

                                    break;
                                }
                            }
                        }
                        else if (datadump.name.StartsWith("MISSION_Scan"))

                        {
                            foreach (var mission in ActiveMissionList)
                            {
                                if (mission.MissionID == datadump.MissionID)
                                {
                                    //   FoundMissions = FoundMissions + 1;
                                    mission.AcceptedTime      = datadump.timestamp;
                                    mission.LocalisedName     = datadump.LocalisedName;
                                    mission.reward            = datadump.Reward;
                                    mission.Target            = datadump.DestinationStation;
                                    mission.Expiry            = datadump.Expiry;
                                    mission.KillCountstring   = null;
                                    mission.type              = MissionType;
                                    mission.DestinationSystem = datadump.DestinationSystem;
                                    break;
                                }
                            }
                        }
                        else if (datadump.name.StartsWith("MISSION_Salvage"))

                        {
                            foreach (var mission in ActiveMissionList)
                            {
                                if (mission.MissionID == datadump.MissionID)
                                {
                                    //   FoundMissions = FoundMissions + 1;
                                    mission.AcceptedTime  = datadump.timestamp;
                                    mission.LocalisedName = datadump.LocalisedName;
                                    mission.reward        = datadump.Reward;
                                    mission.TargetFaction = datadump.TargetFaction;
                                    mission.KillCount     = datadump.Count;
                                    mission.Target        = datadump.Commodity_Localised;
                                    mission.Expiry        = datadump.Expiry;
                                    mission.type          = MissionType;
                                    mission.TargetFaction = datadump.TargetFaction;

                                    break;
                                }
                            }
                        }
                    }

                    if (datadump.@event == "MissionAbandoned" || datadump.@event == "MissionFailed")
                    {
                        EndedMissionList.Add(new MissionEnd {
                            MissionID = datadump.MissionID
                        });
                        Debug.Log("Mission Failed");
                    }
                    if (datadump.@event == "MissionCompleted")
                    {
                        Debug.Log("Mission Completed!");
                        EndedMissionList.Add(new MissionEnd {
                            MissionID = datadump.MissionID
                        });
                    }
                    if (datadump.@event == "MissionRedirected")
                    {
                        foreach (var mission in ActiveMissionList)
                        {
                            if (datadump.MissionID == mission.MissionID)
                            {
                                mission.DestinationStation = datadump.NewDestinationStation;
                                mission.DestinationSystem  = datadump.NewDestinationSystem;
                            }
                        }
                    }

                    if (datadump.@event == "ShipTargeted")
                    {
                        if (datadump.TargetLocked == false)
                        {
                            GameObject TargetBoard;
                            TargetBoard = GameObject.Find("CurrentTargetDetails");

                            TargetBoard.GetComponent <Text>().text = "";
                        }
                    }

                    if (datadump.TargetLocked == true && JournalLine == 2)
                    {
                        CurrentTarget = datadump.Ship_Localised;
                        TargetName    = datadump.PilotName_Localised;
                        TargetRank    = datadump.PilotRank;
                        TargetBounty  = datadump.Bounty;



                        GameObject TargetBoard;
                        TargetBoard = GameObject.Find("CurrentTargetDetails");

                        TargetBoard.GetComponent <Text>().text = "Name: " + TargetName + "\n Rank: " + TargetRank + "\n Bounty: " + TargetBounty;
                    }
                }
                else
                {
                    if (datadump.@event == "Commander" || datadump.part > 1)
                    {
                        Debug.Log("Commander found");
                        LastLineNumber = j;
                        JournalLine    = 1;
                    }
                }
            }
        }

        ScrollJournals();
    }