예제 #1
0
        private void UpdateContent()
        {
            ObservableCollection <CrewType> crewTypes = new ObservableCollection <CrewType>();

            foreach (var ct in AppData.CrewTypes)
            {
                crewTypes.Add(ct);
            }
            lvCrewTypes.ItemsSource = crewTypes;
            if (AppData.Crew.CrewTypeId > 0)
            {
                lvCrewTypes.SelectedItem = crewTypes.FirstOrDefault(x => x.Id == AppData.Crew.CrewTypeId);
            }
            if (lvCrewTypes.SelectedItem == null)
            {
                lvCrewTypes.SelectedItem = crewTypes[0];
            }

            btnAccept.Clicked += (sender, e) =>
            {
                if (lvCrewTypes.SelectedItem == null)
                {
                    return;
                }
                SelectedCrewType = lvCrewTypes.SelectedItem as CrewType;
                Device.BeginInvokeOnMainThread(() => PopupNavigation.Instance.RemovePageAsync(this));
            };
        }
예제 #2
0
        public static async Task <string> GetCrewTypes()
        {
            var res = await ExecuteCommand(ApiCommand.GetCrewTypes, new string[] { });

            if (!res.BoolResult)
            {
                return(res.ErrorMessage);
            }

            try
            {
                AppData.CrewTypes = new List <CrewType>();
                if ((res.CrewTypes?.Count ?? 0) > 0 && (res.CrewTypes[0]?.Count ?? 0) > 0)
                {
                    foreach (var apiCrewType in res.CrewTypes[0])
                    {
                        var crewType = new CrewType
                        {
                            Id   = apiCrewType.crewTypeID,
                            Name = apiCrewType.crewTypeName
                        };
                        AppData.CrewTypes.Add(crewType);
                    }
                }
                return(null);
            }
            catch (Exception e)
            {
                return(MSG_ERROR_INCORRECT_RESPONSE);
            }
        }
예제 #3
0
 public static SalaryConfig FromModConfig(CrewType type)
 {
     if (type == CrewType.AerospaceWing)
     {
         return(FromModConfig(Mod.Config.HiringHall.AerospaceWings));
     }
     else if (type == CrewType.MechTechCrew)
     {
         return(FromModConfig(Mod.Config.HiringHall.MechTechCrews));
     }
     else if (type == CrewType.MechWarrior)
     {
         return(FromModConfig(Mod.Config.HiringHall.MechWarriors));
     }
     else if (type == CrewType.MedTechCrew)
     {
         return(FromModConfig(Mod.Config.HiringHall.MedTechCrews));
     }
     else if (type == CrewType.VehicleCrew)
     {
         return(FromModConfig(Mod.Config.HiringHall.VehicleCrews));
     }
     else
     {
         return(FromModConfig(Mod.Config.HiringHall.MechWarriors));
     }
 }
예제 #4
0
    public Crew GetFreeCrew(CrewType type)
    {
        Crew crew = (Crew)_poolByType[(int)type].GetFreeResource();

        crew.transform.localPosition = Vector3.zero;

        return(crew);
    }
예제 #5
0
        public void TransformCrew(CrewType sourceType, CrewType targetType)
        {
            // first use a commander die
            Crew.First(c => c.Type == CrewType.Commander && c.State == CrewState.Available).State = CrewState.Returning;
            Crew.First(c => c.Type == sourceType && c.State == CrewState.Available).Type          = targetType;
            string message = $"You used a commander to transform one {sourceType.ToString()} crew member to {targetType.ToString()}. ";

            _eventManager.Trigger("AppendMessage", new DefaultEvent(message));
        }
예제 #6
0
    protected override void Refresh()
    {
        CrewInfo info = CrewLibrary.instance.GetRandomInfo();

        _crewType  = info.model.type;
        _crewName  = info.name;
        _crewPrice = info.GetRandomPrice();
        _crewIcon  = info.icon;
        _flagRenderer.material.SetTexture("Texture2D_D003A093", info.flagIcon);
    }
예제 #7
0
        public static async Task <string> SetCrewType(CrewType crewType)
        {
            var res = await ExecuteCommand(ApiCommand.SetCrewType, new string[] { crewType.Id.ToString() });

            if (!res.BoolResult)
            {
                return(res.ErrorMessage);
            }
            return(null);
        }
 //0= sailor  1= warrior  2= slave  3= passenger 4= navigator 5= auger
 //A sailor is the base class--no benefits/detriments
 //	--navigators provide maps to different settlements and decrease negative random events
 //	--warriors make sure encounters with pirates or other raiding activities go better in your favor
 //	--slaves have zero clout--few benefits--but they never leave the ship unless they die
 public CrewMember(int ID, string name, int originCity, int clout, CrewType typeOfCrew, string backgroundInfo, bool isKillable, bool isPartOfMainQuest)
 {
     this.ID                = ID;
     this.name              = name;
     this.originCity        = originCity;
     this.clout             = clout;
     this.typeOfCrew        = typeOfCrew;
     this.backgroundInfo    = backgroundInfo;
     this.isKillable        = isKillable;
     this.isPartOfMainQuest = isPartOfMainQuest;
 }
예제 #9
0
    /// <summary>
    /// Gets the next task waiting to be completed which corresponds to the same job as the specified CrewType. 
    /// The tasks are ordered by their specified priority, and will be removed from the tasks list after returning.
    /// If no tasks are waiting to be completed with the given CrewType, null will be return.
    /// </summary>
    /// <returns>The task.</returns>
    /// <param name="type">The CrewType of the task to be fetched.</param>
    public Task GetTask(CrewType type)
    {
        for(int i = 0; i < tasks.Count; i++)
        {
            print("Getting tasks: " + i);
            Task task = tasks[i];
            if(task.crewTypes.Contains(CrewType.Anyone) || task.crewTypes.Contains(type))
            {
                print("Return task");
                tasks.RemoveAt(i);
                return task;
            }
        }

        return null;
    }
예제 #10
0
        private static CrewDetails ReadRoninTags(PilotDef roninDef)
        {
            //CrewDetails crewDetails = new CrewDetails(); BAD, SERIALIZATION ONLY!
            Mod.Log.Debug?.Write($"Building CrewDetails for Ronin: {roninDef.Description.Name}_{roninDef.GUID}");

            CrewType     type = CrewType.MechWarrior;
            FactionValue favored = null, hated = null;
            int          skill = 0, size = 0;
            SalaryConfig salaryCfg = new SalaryConfig();
            bool         isFounder = false;

            foreach (string tag in roninDef.PilotTags)
            {
                // Check types
                if (tag.Equals(ModTags.Tag_CrewType_Aerospace, StringComparison.InvariantCultureIgnoreCase))
                {
                    Mod.Log.Debug?.Write($" -- found type == Aerospace");
                    type = CrewType.AerospaceWing;
                }
                if (tag.Equals(ModTags.Tag_CrewType_MechTech, StringComparison.InvariantCultureIgnoreCase))
                {
                    Mod.Log.Debug?.Write($" -- found type == MechTech");
                    type = CrewType.MechTechCrew;
                }
                if (tag.Equals(ModTags.Tag_CrewType_MedTech, StringComparison.InvariantCultureIgnoreCase))
                {
                    Mod.Log.Debug?.Write($" -- found type == MedTech");
                    type = CrewType.MedTechCrew;
                }
                if (tag.Equals(ModTags.Tag_CU_Vehicle_Crew, StringComparison.InvariantCultureIgnoreCase))
                {
                    Mod.Log.Debug?.Write($" -- found type == Vehicle");
                    type = CrewType.VehicleCrew;
                }

                // Check factions
                if (tag.StartsWith(ModTags.Tag_Prefix_Ronin_Faction_Favored, StringComparison.InvariantCultureIgnoreCase))
                {
                    string factionDefId = tag.Substring(ModTags.Tag_Prefix_Ronin_Faction_Favored.Length);
                    Mod.Log.Debug?.Write($" -- found favored faction defId: {factionDefId}");

                    foreach (FactionValue factionVal in Mod.Config.Attitude.FavoredFactionCandidates)
                    {
                        if (factionVal.FactionDefID.Equals(factionDefId, StringComparison.InvariantCultureIgnoreCase))
                        {
                            favored = factionVal;
                        }
                    }

                    if (favored == null)
                    {
                        Mod.Log.Warn?.Write($"Could not map favored factionDefId: {factionDefId} to a configured faction! Skipping!");
                    }
                }

                if (tag.StartsWith(ModTags.Tag_Prefix_Ronin_Faction_Hated, StringComparison.InvariantCultureIgnoreCase))
                {
                    string factionDefId = tag.Substring(ModTags.Tag_Prefix_Ronin_Faction_Hated.Length);
                    Mod.Log.Debug?.Write($" -- found hated faction defId: {factionDefId}");

                    foreach (FactionValue factionVal in Mod.Config.Attitude.HatedFactionCandidates)
                    {
                        if (factionVal.FactionDefID.Equals(factionDefId, StringComparison.InvariantCultureIgnoreCase))
                        {
                            hated = factionVal;
                        }
                    }

                    if (hated == null)
                    {
                        Mod.Log.Warn?.Write($"Could not map hated factionDefId: {factionDefId} to a configured faction! Skipping!");
                    }
                }

                // Check size and skill tags
                if (tag.StartsWith(ModTags.Tag_Prefix_Ronin_Support_Size, StringComparison.InvariantCultureIgnoreCase))
                {
                    string tagS = tag.Substring(ModTags.Tag_Prefix_Ronin_Support_Size.Length);
                    try
                    {
                        size = Int32.Parse(tagS, CultureInfo.InvariantCulture);
                        Mod.Log.Debug?.Write($" -- found size: {size}");
                    }
                    catch (Exception e)
                    {
                        Mod.Log.Warn?.Write(e, $"Failed to read size: {tagS} as an integer value, skipping!");
                    }
                }
                if (tag.StartsWith(ModTags.Tag_Prefix_Ronin_Support_Skill, StringComparison.InvariantCultureIgnoreCase))
                {
                    string tagS = tag.Substring(ModTags.Tag_Prefix_Ronin_Support_Skill.Length);
                    try
                    {
                        skill = Int32.Parse(tagS, CultureInfo.InvariantCulture);
                        Mod.Log.Debug?.Write($" -- found skill: {skill}");
                    }
                    catch (Exception e)
                    {
                        Mod.Log.Warn?.Write(e, $"Failed to read skill: {tagS} as an integer value, skipping!");
                    }
                }

                // Check salary & bonus values
                if (tag.StartsWith(ModTags.Tag_Prefix_Ronin_Salary_Multi, StringComparison.InvariantCultureIgnoreCase))
                {
                    string tagS = tag.Substring(ModTags.Tag_Prefix_Ronin_Salary_Multi.Length);
                    try
                    {
                        salaryCfg.Multi = Int32.Parse(tagS, CultureInfo.InvariantCulture);
                        Mod.Log.Debug?.Write($" -- found salaryMulti: {salaryCfg.Multi}");
                    }
                    catch (Exception e)
                    {
                        Mod.Log.Warn?.Write(e, $"Failed to read salaryMulti: {tagS} as an integer value, skipping!");
                    }
                }

                if (tag.StartsWith(ModTags.Tag_Prefix_Ronin_Salary_Exp, StringComparison.InvariantCultureIgnoreCase))
                {
                    string tagS = tag.Substring(ModTags.Tag_Prefix_Ronin_Salary_Exp.Length);
                    try
                    {
                        salaryCfg.Exponent = float.Parse(tagS, CultureInfo.InvariantCulture);
                        Mod.Log.Debug?.Write($" -- found salaryExp: {salaryCfg.Exponent}");
                    }
                    catch (Exception e)
                    {
                        Mod.Log.Warn?.Write(e, $"Failed to read salaryExp: {tagS} as an integer value, skipping!");
                    }
                }

                if (tag.StartsWith(ModTags.Tag_Prefix_Ronin_Salary_Variance, StringComparison.InvariantCultureIgnoreCase))
                {
                    string tagS = tag.Substring(ModTags.Tag_Prefix_Ronin_Salary_Variance.Length);
                    try
                    {
                        salaryCfg.Variance = float.Parse(tagS, CultureInfo.InvariantCulture);
                        Mod.Log.Debug?.Write($" -- found salaryVariance: {salaryCfg.Variance}");
                    }
                    catch (Exception e)
                    {
                        Mod.Log.Warn?.Write(e, $"Failed to read salaryVariance: {tagS} as an integer value, skipping!");
                    }
                }

                if (tag.StartsWith(ModTags.Tag_Prefix_Ronin_Bonus_Variance, StringComparison.InvariantCultureIgnoreCase))
                {
                    string tagS = tag.Substring(ModTags.Tag_Prefix_Ronin_Bonus_Variance.Length);
                    try
                    {
                        salaryCfg.BonusVariance = float.Parse(tagS, CultureInfo.InvariantCulture);
                        Mod.Log.Debug?.Write($" -- found bonusVariance: {salaryCfg.BonusVariance}");
                    }
                    catch (Exception e)
                    {
                        Mod.Log.Warn?.Write(e, $"Failed to read bonusVariance: {tagS} as an integer value, skipping!");
                    }
                }

                // Check founder
                if (tag.Equals(ModTags.Tag_Founder, StringComparison.InvariantCultureIgnoreCase))
                {
                    Mod.Log.Debug?.Write($" -- found founder tag");
                    isFounder = true;
                }
            }

            // Normalize size and skill to index values
            CrewDetails details = new CrewDetails(roninDef, type, favored, hated, size - 1, skill - 1, isFounder,
                                                  salaryCfg.IsDefault() ? null : salaryCfg);

            return(details);
        }
예제 #11
0
 public CrewInfo GetInfo(CrewType type)
 {
     return(_infos[(int)type]);
 }
예제 #12
0
        public CrewDetails(PilotDef pilotDef, CrewType type,
                           FactionValue favoredFaction, FactionValue hatedFaction,
                           int sizeIdx            = 0, int skillIdx = 0, bool isFounder = false,
                           SalaryConfig salaryCfg = null)
        {
            this.Type  = type;
            this.Size  = sizeIdx + 1;
            this.Skill = skillIdx + 1;

            this.Attitude = 0;

            // Calculate value and set required tags
            CrewOpts config = null;

            if (IsAerospaceCrew)
            {
                Value  = Mod.Config.HiringHall.PointsBySkillAndSize.Aerospace[skillIdx][sizeIdx];
                config = Mod.Config.HiringHall.AerospaceWings;
                pilotDef.PilotTags.Add(ModTags.Tag_CrewType_Aerospace);
            }
            else if (IsMechTechCrew)
            {
                Value  = Mod.Config.HiringHall.PointsBySkillAndSize.MechTech[skillIdx][sizeIdx];
                config = Mod.Config.HiringHall.MechTechCrews;
                pilotDef.PilotTags.Add(ModTags.Tag_CrewType_MechTech);
            }
            else if (IsMedTechCrew)
            {
                Value  = Mod.Config.HiringHall.PointsBySkillAndSize.MedTech[skillIdx][sizeIdx];
                config = Mod.Config.HiringHall.MedTechCrews;
                pilotDef.PilotTags.Add(ModTags.Tag_CrewType_MedTech);
            }
            else if (IsMechWarrior)
            {
                Value  = pilotDef.BaseGunnery + pilotDef.BasePiloting + pilotDef.BaseGuts + pilotDef.BaseTactics;
                config = Mod.Config.HiringHall.MechWarriors;
            }
            else if (IsVehicleCrew)
            {
                Value  = pilotDef.BaseGunnery + pilotDef.BasePiloting + pilotDef.BaseGuts + pilotDef.BaseTactics;
                config = Mod.Config.HiringHall.VehicleCrews;

                // Required tags
                pilotDef.PilotTags.Add(ModTags.Tag_CU_NoMech_Crew);
                pilotDef.PilotTags.Add(ModTags.Tag_CU_Vehicle_Crew);
            }

            if (salaryCfg == null)
            {
                this.SalaryConfig = SalaryConfig.FromModConfig(config);
            }
            else
            {
                this.SalaryConfig = salaryCfg;
            }


            // Calculate salary and bonus
            SalaryHelper.CalcSalary(Value, this.SalaryConfig, out int salary, out int bonus);
            this.Salary      = salary;
            this.HiringBonus = bonus;

            // Determine contract length
            if (pilotDef.IsFree && pilotDef.IsImmortal)
            {
                IsPlayer = true;
                Mod.Log.Debug?.Write("Setting expiration and contract term to 0 for player character.");
                this.ContractTerm  = 0; // Free and Immortal = player character
                this.ExpirationDay = 0;
            }
            else if (isFounder)
            {
                IsFounder = true;
                Mod.Log.Debug?.Write("Setting expiration and contract term to 0 for founding member.");
                this.ContractTerm  = 0; // Free overhead, not immortal
                this.ExpirationDay = 0;
            }
            else
            {
                IsPlayer = false;
                Mod.Log.Debug?.Write("Generating contract length, new expiration day");
                this.ContractTerm  = CrewHelper.RandomContractLength(config);
                this.ExpirationDay = ModState.SimGameState.DaysPassed + ContractTerm;
            }

            if (favoredFaction != null)
            {
                this.FavoredFactionId = (int)favoredFaction.FactionID;
            }
            if (hatedFaction != null)
            {
                this.HatedFactionId = (int)hatedFaction.FactionID;
            }

            this.NextHeadHuntingDay = ModState.SimGameState.DaysPassed;
        }
 public RemoveCrewFromMissionEvent(string threatName, CrewType crewType)
 {
     ThreatName = threatName;
     Type       = crewType;
 }
예제 #14
0
    public void AddCrew(CrewType type, bool doAnim = true)
    {
        Crew crew = CrewLibrary.instance.GetFreeCrew(type);

        _positioner.SetPosition(crew, doAnim);
    }