Esempio n. 1
0
            public int GetAttractiveness(FrozenActor fa, PlayerRelationship stance, Player firedBy)
            {
                if (stance != Against)
                {
                    return(0);
                }

                if (fa == null || !fa.IsValid || !fa.Visible)
                {
                    return(0);
                }

                if (Types.Overlaps(fa.TargetTypes))
                {
                    switch (TargetMetric)
                    {
                    case DecisionMetric.Value:
                        var valueInfo = fa.Info.TraitInfoOrDefault <ValuedInfo>();
                        return((valueInfo != null) ? valueInfo.Cost * Attractiveness : 0);

                    case DecisionMetric.Health:
                        var healthInfo = fa.Info.TraitInfoOrDefault <IHealthInfo>();
                        return((healthInfo != null) ? fa.HP * Attractiveness / healthInfo.MaxHP : 0);

                    default:
                        return(Attractiveness);
                    }
                }

                return(0);
            }
Esempio n. 2
0
 public RevealShroudEffect(WPos pos, WDist radius, Shroud.SourceType type, Player forPlayer, PlayerRelationship stances, int delay = 0, int duration = 50)
 {
     this.pos      = pos;
     player        = forPlayer;
     revealRadius  = radius;
     validStances  = stances;
     sourceType    = type;
     this.duration = duration;
     ticks         = -delay;
 }
Esempio n. 3
0
        public Response(string text, string pattern, PlayerRelationship rep, Emotion emotion, FeelingAdjust emotionAdjust = FeelingAdjust.None, FeelingAdjust repAdjust = FeelingAdjust.None)
        {
            Text    = text;
            Pattern = pattern;
            Feeling = ((int)rep * 3) + (int)emotion;

            EmotionIncrease      = 0;
            RelationshipIncrease = 0;

            switch (repAdjust)
            {
            case FeelingAdjust.HugeDetriment:
                RelationshipIncrease = -0.25F;
                break;

            case FeelingAdjust.Detriment:
                RelationshipIncrease = -0.1f;
                break;

            case FeelingAdjust.None:
                RelationshipIncrease = 0;
                break;

            case FeelingAdjust.Increase:
                RelationshipIncrease = 0.1f;
                break;

            case FeelingAdjust.HugeIncrease:
                RelationshipIncrease = 0.25F;
                break;
            }

            switch (emotionAdjust)
            {
            case FeelingAdjust.HugeDetriment:
                EmotionIncrease = -0.25F;
                break;

            case FeelingAdjust.Detriment:
                EmotionIncrease = -0.1f;
                break;

            case FeelingAdjust.None:
                EmotionIncrease = 0;
                break;

            case FeelingAdjust.Increase:
                EmotionIncrease = 0.1f;
                break;

            case FeelingAdjust.HugeIncrease:
                EmotionIncrease = 0.25F;
                break;
            }
        }
Esempio n. 4
0
            /// <summary>Evaluates a single actor according to the rules defined in this consideration</summary>
            public int GetAttractiveness(Actor a, PlayerRelationship stance, Player firedBy)
            {
                if (stance != Against)
                {
                    return(0);
                }

                if (a == null)
                {
                    return(0);
                }

                if (!a.IsTargetableBy(firedBy.PlayerActor) || !a.CanBeViewedByPlayer(firedBy))
                {
                    return(0);
                }

                if (Types.Overlaps(a.GetEnabledTargetTypes()))
                {
                    switch (TargetMetric)
                    {
                    case DecisionMetric.Value:
                        var valueInfo = a.Info.TraitInfoOrDefault <ValuedInfo>();
                        return((valueInfo != null) ? valueInfo.Cost * Attractiveness : 0);

                    case DecisionMetric.Health:
                        var health = a.TraitOrDefault <IHealth>();

                        if (health == null)
                        {
                            return(0);
                        }

                        // Cast to long to avoid overflow when multiplying by the health
                        return((int)((long)health.HP * Attractiveness / health.MaxHP));

                    default:
                        return(Attractiveness);
                    }
                }

                return(0);
            }
Esempio n. 5
0
    /* UNITY FUNCTIONS */
    #region
    void Awake()
    {
        s_CurrentAttitude     = DefaultAttitude;
        s_CurrentRelationship = DefaultRelationship;
        st_Stats         = GetComponent <StatTracker>();
        ro_Me            = GetComponent <Rigidbody>();
        ro_Player        = GameObject.FindGameObjectWithTag("Player");
        ro_MySpecialEyes = transform.FindChild("Eyes").gameObject;

        if (ro_MySpecialEyes == null)
        {
            var thing = new GameObject();
            thing.transform.position = transform.position;
            thing.transform.parent   = transform;
        }
        if (st_Stats == null)
        {
            st_Stats = new StatTracker();
            st_Stats.reinit(100, 5, 2);
        }
    }
Esempio n. 6
0
        public string TooltipForPlayerStance(PlayerRelationship stance)
        {
            if (stance == PlayerRelationship.None || !GenericVisibility.HasStance(stance))
            {
                return(Name);
            }

            if (GenericStancePrefix && !string.IsNullOrEmpty(AllyPrefix) && stance == PlayerRelationship.Ally)
            {
                return(AllyPrefix + " " + GenericName);
            }

            if (GenericStancePrefix && !string.IsNullOrEmpty(NeutralPrefix) && stance == PlayerRelationship.Neutral)
            {
                return(NeutralPrefix + " " + GenericName);
            }

            if (GenericStancePrefix && !string.IsNullOrEmpty(EnemyPrefix) && stance == PlayerRelationship.Enemy)
            {
                return(EnemyPrefix + " " + GenericName);
            }

            return(GenericName);
        }
 public static bool HasRelationship(this PlayerRelationship r, PlayerRelationship relationship)
 {
     // PERF: Enum.HasFlag is slower and requires allocations.
     return((r & relationship) == relationship);
 }
Esempio n. 8
0
 public static bool HasStance(this PlayerRelationship s, PlayerRelationship stance)
 {
     // PERF: Enum.HasFlag is slower and requires allocations.
     return((s & stance) == stance);
 }