Ejemplo n.º 1
0
        /// <summary>
        /// This section checks if the force pool allows for the casting of the spell.
        /// </summary>
        /// <param name="verbAbility"></param>
        /// <param name="reason">Why did we fail?</param>
        /// <returns></returns>
        public override bool CanCastPowerCheck(Verb_UseAbility verbAbility, out string reason)
        {
            reason = "";
            ForceAbilityDef forceDef = (ForceAbilityDef)verbAbility.useAbilityProps.abilityDef;

            if (forceDef != null)
            {
                if (forceDef.requiresAlignment)
                {
                    if (forceDef.requiredAlignmentType != ForceAlignmentType.Gray &&
                        forceDef.requiredAlignmentType != this.ForceAlignmentType)
                    {
                        reason = "WrongAlignment";
                        return(false);
                    }
                }
                if (ForcePool != null)
                {
                    if (forceDef.forcePoolCost > 0 &&
                        forceDef.forcePoolCost > ForcePool.CurLevel)
                    {
                        reason = "DrainedForcePool";
                        return(false);
                    }
                }
            }
            return(true);
        }
        public override void PostAbilityAttempt(Pawn caster, AbilityDef ability)
        {
            ForceAbilityDef forceDef = ability as ForceAbilityDef;

            if (forceDef != null)
            {
                if (forceDef.changedAlignmentType != ForceAlignmentType.None)
                {
                    //Log.Message("Alignment: " + AlignmentValue.ToStringPercent());
                    //Log.Message("Alignment Change: " + forceDef.changedAlignmentRate.ToStringPercent());
                    AlignmentValue += forceDef.changedAlignmentRate;
                    //Log.Message("New Alignment: " + AlignmentValue.ToStringPercent());
                    UpdateAlignment();
                }

                if (ForcePool != null)
                {
                    float poolCost = 0f;
                    //Log.Message("PC" + forceDef.forcePoolCost.ToString());
                    poolCost = forceDef.forcePoolCost - (forceDef.forcePoolCost * (0.15f * (float)ForceSkillLevel("PJ_ForcePool")));
                    //Log.Message("PC" + poolCost.ToString());
                    ForcePool.UseForcePower(poolCost);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This section checks what force abilities were used, and thus their effect on the Jedi's force powers.
        /// </summary>
        public override void PostCastAbilityEffects(Verb_UseAbility verbAbility)
        {
            ForceAbilityDef forceDef = (ForceAbilityDef)verbAbility.useAbilityProps.abilityDef;

            if (forceDef != null)
            {
                if (ForcePool != null)
                {
                    float value = ForcePool.CurLevel - forceDef.forcePoolCost;
                    ForcePool.CurLevel = Mathf.Clamp(value, 0.01f, 0.99f);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Shows the required alignment (optional),
        /// alignment change (optional),
        /// and the force pool usage
        /// </summary>
        /// <param name="verb"></param>
        /// <returns></returns>
        public override string PostAbilityVerbDesc(Verb_UseAbility verb)
        {
            string          result   = "";
            StringBuilder   postDesc = new StringBuilder();
            ForceAbilityDef forceDef = (ForceAbilityDef)verb.useAbilityProps.abilityDef;

            if (forceDef != null)
            {
                string alignDesc  = "";
                string changeDesc = "";
                string pointsDesc = "";
                if (forceDef.requiresAlignment)
                {
                    alignDesc = "ForceAbilityDescAlign".Translate(new object[]
                    {
                        forceDef.requiredAlignmentType.ToString(),
                    });
                }
                if (forceDef.changesAlignment)
                {
                    changeDesc = "ForceAbilityDescChange".Translate(new object[]
                    {
                        forceDef.changedAlignmentType.ToString(),
                        forceDef.changedAlignmentRate.ToString("p1")
                    });
                }
                pointsDesc = "ForceAbilityDescPoints".Translate(new object[]
                {
                    forceDef.forcePoolCost.ToString("p1")
                });
                if (alignDesc != "")
                {
                    postDesc.AppendLine(alignDesc);
                }
                if (changeDesc != "")
                {
                    postDesc.AppendLine(changeDesc);
                }
                if (pointsDesc != "")
                {
                    postDesc.AppendLine(pointsDesc);
                }
                result = postDesc.ToString();
            }
            return(result);
        }
        /// <summary>
        /// Shows the required alignment (optional),
        /// alignment change (optional),
        /// and the force pool usage
        /// </summary>
        /// <param name="verb"></param>
        /// <returns></returns>
        public override string PostAbilityVerbCompDesc(VerbProperties_Ability verbDef)
        {
            string          result   = "";
            StringBuilder   postDesc = new StringBuilder();
            ForceAbilityDef forceDef = (ForceAbilityDef)verbDef.abilityDef;

            if (forceDef != null)
            {
                string alignDesc  = "";
                string changeDesc = "";
                string pointsDesc = "";
                if (forceDef.changedAlignmentType != ForceAlignmentType.None)
                {
                    alignDesc = "ForceAbilityDescAlign".Translate(new object[]
                    {
                        forceDef.requiredAlignmentType.ToString(),
                    });
                }
                if (forceDef.changedAlignmentType != ForceAlignmentType.None)
                {
                    changeDesc = "ForceAbilityDescChange".Translate(new object[]
                    {
                        forceDef.changedAlignmentType.ToString(),
                        forceDef.changedAlignmentRate.ToString("p1")
                    });
                }
                if (ForceSkillLevel("PJ_ForcePool") > 0)
                {
                    float poolCost = 0f;
                    //Log.Message("PC" + forceDef.forcePoolCost.ToString());
                    poolCost   = forceDef.forcePoolCost - (forceDef.forcePoolCost * (0.15f * (float)ForceSkillLevel("PJ_ForcePool")));
                    pointsDesc = "ForceAbilityDescOriginPoints".Translate(new object[]
                    {
                        forceDef.forcePoolCost.ToString("p1")
                    })

                                 + "\n" +

                                 "ForceAbilityDescNewPoints".Translate(new object[]
                    {
                        poolCost.ToString("p1")
                    })
                    ;
                }
                else
                {
                    pointsDesc = "ForceAbilityDescPoints".Translate(new object[]
                    {
                        forceDef.forcePoolCost.ToString("p1")
                    });
                }
                if (alignDesc != "")
                {
                    postDesc.AppendLine(alignDesc);
                }
                if (changeDesc != "")
                {
                    postDesc.AppendLine(changeDesc);
                }
                if (pointsDesc != "")
                {
                    postDesc.AppendLine(pointsDesc);
                }
                result = postDesc.ToString();
            }
            return(result);
        }
        public static void PowersGUIHandler(Rect inRect, CompForceUser compForce, List <ForcePower> forcePowers, Texture2D pointTexture)
        {
            float buttonYOffset = inRect.y;

            foreach (ForcePower power in forcePowers)
            {
                Rect buttonRect = new Rect(inRect.x, buttonYOffset, ForceButtonSize, ForceButtonSize);
                TooltipHandler.TipRegion(buttonRect, () => power.abilityDef.label + "\n\n" + power.abilityDef.description + "\n\n" + "PJ_CheckStarsForMoreInfo".Translate(), 398462);
                if (compForce.ForceData.AbilityPoints == 0 || power.level >= 3)
                {
                    Widgets.DrawTextureFitted(buttonRect, power.Icon, 1.0f);
                }
                else if (Widgets.ButtonImage(buttonRect, power.Icon) && (compForce.AbilityUser.Faction == Faction.OfPlayer))
                {
                    ForceAbilityDef powerDef = power.nextLevelAbilityDef as ForceAbilityDef;
                    if (powerDef.requiredAlignmentType != ForceAlignmentType.None &&
                        powerDef.requiredAlignmentType != compForce.ForceAlignmentType)
                    {
                        Messages.Message("PJ_NextLevelAlignmentMismatch".Translate(new object[]
                        {
                            powerDef.requiredAlignmentType.ToString(),
                            compForce.ForceAlignmentType.ToString()
                        }), MessageTypeDefOf.RejectInput);
                        return;
                    }
                    if (compForce.LightsidePoints < powerDef.lightsideTreePointsRequired)
                    {
                        Messages.Message("PJ_LightsidePointsRequired".Translate(new object[]
                        {
                            powerDef.lightsideTreePointsRequired
                        }), MessageTypeDefOf.RejectInput);
                        return;
                    }
                    if (compForce.DarksidePoints < powerDef.darksideTreePointsRequired)
                    {
                        Messages.Message("PJ_DarksidePointsRequired".Translate(new object[]
                        {
                            powerDef.darksideTreePointsRequired
                        }), MessageTypeDefOf.RejectInput);
                        return;
                    }
                    if (compForce.ForceData.AbilityPoints < powerDef.abilityPoints)
                    {
                        Messages.Message("PJ_NotEnoughAbilityPoints".Translate(new object[]
                        {
                            compForce.ForceData.AbilityPoints,
                            powerDef.abilityPoints
                        }), MessageTypeDefOf.RejectInput);
                        return;
                    }
                    if (compForce.AbilityUser.story != null && (compForce.AbilityUser.WorkTagIsDisabled(WorkTags.Violent) && power.abilityDef.MainVerb.isViolent))
                    {
                        Messages.Message("IsIncapableOfViolenceLower".Translate(new object[]
                        {
                            compForce.parent.LabelShort
                        }), MessageTypeDefOf.RejectInput);
                        return;
                    }
                    compForce.LevelUpPower(power);
                    compForce.ForceData.AbilityPoints -= powerDef.abilityPoints;
                }
                for (int i = 0; i < 3; i++)
                {
                    float drawXOffset = ForceButtonSize + 1f;
                    if (i != 0)
                    {
                        drawXOffset += (ForceButtonPointSize * i);
                    }

                    float drawYOffset = buttonYOffset + (ForceButtonSize / 3f);
                    Rect  powerRegion = new Rect(inRect.x + drawXOffset, drawYOffset, ForceButtonPointSize, ForceButtonPointSize);

                    if (power.level > i)
                    {
                        Widgets.DrawTextureFitted(powerRegion, pointTexture, 1.0f);
                    }
                    else
                    {
                        Widgets.DrawTextureFitted(powerRegion, TexButton.PJTex_ForcePointDim, 1.0f);
                    }
                    ForceAbilityDef powerDef = power.GetAbilityDef(i) as ForceAbilityDef;
                    if (powerDef != null)
                    {
                        TooltipHandler.TipRegion(powerRegion, () => powerDef.GetDescription() + "\n" + compForce.PostAbilityVerbCompDesc(powerDef.MainVerb) + "\n" + powerDef.GetPointDesc(), 398462);
                    }
                }
                buttonYOffset += ForceButtonSize + 1;
            }
        }