示例#1
0
文件: Romancer.cs 项目: yakoder/NRaas
        protected static bool BumpUp(SimDescription a, SimDescription b, bool prompt)
        {
            Relationship relation = Relationship.Get(a, b, true);

            if (relation == null)
            {
                return(false);
            }

            string currentState = relation.LTR.CurrentLTR;

            string nextState = null;

            if (currentState == "Stranger")
            {
                nextState = "Acquaintance";
            }
            else
            {
                nextState = ChangeRelationship.NextPositiveRomanceState(currentState);
            }

            if (nextState == null)
            {
                if (prompt)
                {
                    SimpleMessageDialog.Show("Bump to Next Level", "There is no way to go higher than these sims already are.");
                }
                return(false);
            }

            if (relation.LTR.RelationshipIsInappropriate(LTRData.Get(nextState)))
            {
                if (prompt)
                {
                    SimpleMessageDialog.Show("Bump to Next Level", "A relationship of " + nextState + " is unavailable to the selected sims.");
                }
                return(false);
            }

            if (a.Genealogy.IsBloodRelated(b.Genealogy))
            {
                if ((prompt) && (!AcceptCancelDialog.Show(a.FirstName + " " + a.LastName + " and " + b.FirstName + " " + b.LastName + " are blood related.  Proceed?")))
                {
                    return(false);
                }
            }

            if (currentState == "Romantic Interest")
            {
                if ((a.Partner != null) && (a.Partner != b))
                {
                    if ((b.Partner != null) && (b.Partner != a))
                    {
                        if ((prompt) && (!AcceptCancelDialog.Show("Both " + a.FirstName + " " + a.LastName + " and " + b.FirstName + " " + b.LastName + " already have different partners.  Proceed?")))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if ((prompt) && (!AcceptCancelDialog.Show(a.FirstName + " " + a.LastName + " already has a different partner.  Proceed?")))
                        {
                            return(false);
                        }
                    }
                }
                else if ((b.Partner != null) && (b.Partner != a))
                {
                    if ((prompt) && (!AcceptCancelDialog.Show(b.FirstName + " " + b.LastName + " already has a different partner.  Proceed?")))
                    {
                        return(false);
                    }
                }

                if (a.Partner != null)
                {
                    BumpDown(a, a.Partner, false);
                }
                if (b.Partner != null)
                {
                    BumpDown(b, b.Partner, false);
                }

                a.SetPartner(b);
            }

            relation.LTR.ForceChangeState(nextState);

            if (currentState == relation.LTR.CurrentLTR)
            {
                return(false);
            }

            StyledNotification.Show(new StyledNotification.Format("Relationship between " + a.FirstName + " " + a.LastName + " and " + b.FirstName + " " + b.LastName + " changed to " + nextState, StyledNotification.NotificationStyle.kAlert));
            return(true);
        }
示例#2
0
        public bool BumpToHigherState(Common.IStatGenerator stats, SimDescription a, SimDescription b)
        {
            Relationship relation = ManagerSim.GetRelationship(a, b);

            if (relation == null)
            {
                IncStat("BumpUp: Bad Relation");
                stats.IncStat("BumpUp: Bad Relation");
                return(false);
            }

            LongTermRelationshipTypes currentState = relation.LTR.CurrentLTR;

            LongTermRelationshipTypes nextState = ChangeRelationship.NextPositiveRomanceState(currentState, relation.IsPetToPetRelationship);

            if (nextState == LongTermRelationshipTypes.Undefined)
            {
                IncStat("BumpUp: No Next Level");
                stats.IncStat("BumpUp: No Next Level");
                return(false);
            }

            if (currentState == LongTermRelationshipTypes.RomanticInterest)
            {
                if (Flirts.IsCloselyRelated(a, b))
                {
                    IncStat("BumpUp: Related");
                    stats.IncStat("BumpUp: Related");
                    return(false);
                }

                if ((!GetValue <AllowSteadyOption, bool>(a)) || (!GetValue <AllowSteadyOption, bool>(b)))
                {
                    IncStat("BumpUp: Steady Denied");
                    stats.IncStat("BumpUp: Steady Denied");
                    return(false);
                }

                if (!DumpOtherRomances(stats, a, b))
                {
                    return(false);
                }
                if (!DumpOtherRomances(stats, b, a))
                {
                    return(false);
                }

                if ((a.Partner != b) || (b.Partner != a))
                {
                    try
                    {
                        a.SetPartner(b);

                        SetElapsedTime <DayOfLastPartnerOption>(a);
                        SetElapsedTime <DayOfLastPartnerOption>(b);

                        SetElapsedTime <DayOfLastRomanceOption>(a);
                        SetElapsedTime <DayOfLastRomanceOption>(b);
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(a, b, e);
                    }
                }
            }
            else if (currentState == LongTermRelationshipTypes.Partner)
            {
                if ((a.TeenOrBelow) || (b.TeenOrBelow))
                {
                    if ((!GetValue <AllowMarriageOption, bool>(a)) || (!GetValue <AllowMarriageOption, bool>(b)))
                    {
                        IncStat("BumpUp: Marriage Denied");
                        stats.IncStat("BumpUp: Marriage Denied");
                        return(false);
                    }
                    else if (GetValue <MarriageScenario.AllowTeenOnlyOnPregnancyOption, bool>())
                    {
                        if ((!a.IsPregnant) && (!b.IsPregnant))
                        {
                            IncStat("BumpUp: Non-Pregnant Marriage Denied");
                            stats.IncStat("BumpUp: Non-Pregnant Marriage Denied");
                            return(false);
                        }
                    }
                }

                relation.ProposerDesc = a;
            }

            float liking = relation.LTR.Liking;

            ForceChangeState(relation, nextState);

            if (liking > relation.LTR.Liking)
            {
                relation.LTR.SetLiking(liking);
            }

            if (currentState == relation.LTR.CurrentLTR)
            {
                IncStat("Invalid: " + currentState);
                stats.IncStat("Invalid: " + currentState);
                return(false);
            }

            IncStat("BumpUp: " + currentState + " to " + relation.LTR.CurrentLTR);
            stats.IncStat("BumpUp: " + currentState + " to " + relation.LTR.CurrentLTR);
            return(true);
        }
示例#3
0
文件: Romancer.cs 项目: yakoder/NRaas
            protected override bool Run(SimDescription a, SimDescription b)
            {
                Relationship relation = Relationship.Get(a, b, true);

                if (relation == null)
                {
                    return(false);
                }

                string currentState = relation.LTR.CurrentLTR;

                List <NewLevel> allOptions = new List <NewLevel>();

                string newState = ChangeRelationship.NextNegativeRomanceState(currentState);

                while (newState != null)
                {
                    if (!relation.LTR.RelationshipIsInappropriate(LTRData.Get(newState)))
                    {
                        allOptions.Insert(0, new NewLevel(newState, false));
                    }

                    newState = ChangeRelationship.NextNegativeRomanceState(newState);
                }

                allOptions.Add(new NewLevel(currentState, true));

                if (currentState == "Stranger")
                {
                    newState = "Acquaintance";
                    allOptions.Add(new NewLevel(newState, true));
                }
                else
                {
                    newState = currentState;
                }

                newState = ChangeRelationship.NextPositiveRomanceState(newState);
                while (newState != null)
                {
                    if (!relation.LTR.RelationshipIsInappropriate(LTRData.Get(newState)))
                    {
                        allOptions.Add(new NewLevel(newState, true));
                    }

                    newState = ChangeRelationship.NextPositiveRomanceState(newState);
                }

                List <ObjectPicker.HeaderInfo> headers = new List <ObjectPicker.HeaderInfo>();

                headers.Add(new ObjectPicker.HeaderInfo("Level", "Relationship Level", 230));

                int count = 0;

                List <ObjectPicker.RowInfo> rowInfo = new List <ObjectPicker.RowInfo>();

                foreach (NewLevel level in allOptions)
                {
                    ObjectPicker.RowInfo item = new ObjectPicker.RowInfo(level, new List <ObjectPicker.ColumnInfo>());

                    count++;

                    item.ColumnInfo.Add(new ObjectPicker.TextColumn(count.ToString() + ". " + level.mState));

                    rowInfo.Add(item);
                }

                List <ObjectPicker.TabInfo> tabInfo = new List <ObjectPicker.TabInfo>();

                tabInfo.Add(new ObjectPicker.TabInfo("shop_all_r2", Localization.LocalizeString("Ui/Caption/ObjectPicker:All", new object[0]), rowInfo));

                string buttonTrue  = "Ok";
                string buttonFalse = Localization.LocalizeString("Ui/Caption/ObjectPicker:Cancel", new object[0]);

                List <ObjectPicker.RowInfo> list = ObjectPickerDialog.Show(true, ModalDialog.PauseMode.PauseSimulator, "Relationship", buttonTrue, buttonFalse, tabInfo, headers, 1, new Vector2(-1f, -1f), true);

                List <string> selection = new List <string>();

                if ((list == null) || (list.Count == 0))
                {
                    return(false);
                }

                NewLevel choice = list[0].Item as NewLevel;

                if (choice == null)
                {
                    return(false);
                }

                if (choice.mState == currentState)
                {
                    return(false);
                }

                bool bFirst = true;

                if (choice.mUp)
                {
                    while (BumpUp(a, b, bFirst))
                    {
                        if (choice.mState == relation.LTR.CurrentLTR)
                        {
                            return(true);
                        }

                        if (currentState == relation.LTR.CurrentLTR)
                        {
                            return(false);
                        }
                        currentState = relation.LTR.CurrentLTR;

                        bFirst = false;
                    }
                }
                else
                {
                    while (BumpDown(a, b, bFirst))
                    {
                        if (choice.mState == relation.LTR.CurrentLTR)
                        {
                            return(true);
                        }

                        if (currentState == relation.LTR.CurrentLTR)
                        {
                            return(false);
                        }
                        currentState = relation.LTR.CurrentLTR;

                        bFirst = false;
                    }
                }

                return(true);
            }