public ImGuiRenderer(GraphicsDevice device, Game game, ImmediateEffect effect) { this.GraphicsDevice = device; this.Game = game; this.Effect = effect; var context = ImGui.CreateContext(); ImGui.SetCurrentContext(context); this.LoadedTextures = new Dictionary <IntPtr, Texture2D>(); this.RasterizerState = new RasterizerState() { CullMode = CullMode.None, DepthBias = 0, FillMode = FillMode.Solid, MultiSampleAntiAlias = false, ScissorTestEnable = true, SlopeScaleDepthBias = 0 }; var io = ImGui.GetIO(); io.ConfigFlags |= ImGuiConfigFlags.DockingEnable; this.SetupInput(); this.RebuildFontAtlas(); }
//every tick countsdown the duration, at 0 removes the effect, at period applies Effects public override void TickEffect(CharacterTargetInfo targetInfo) { duration--; targetInfo.logMessage += name + " ticked, " + duration + " ticks remaining"; //check if effects should be applied ,if so apply each effect if (duration % period == 0) { targetInfo.logMessage += ", applying effects"; foreach (ImmediateEffect eff in effects) { eff.ApplyEffect(ref targetInfo); } timesApplied++; } Debug.Log(targetInfo.logMessage); if (duration <= 0) { targetInfo.logMessage = name + " removed"; targetInfo.target.RemoveEffect(this); if (reverseOnRemove) //if it should be reversed on removal, if the sub effects have a non-Zero powBonus, this may not fully reverse the effect { for (int i = 0; i < timesApplied; i++) //for each time applied { foreach (ImmediateEffect eff in effects) //for each effect { //apply the reverse of the effect ImmediateEffect efTemp = new ImmediateEffect(name + " Remover", eff.GetAttribute(), eff.GetPower(), CharacterAttributes.Zero, 0f, !eff.GetIsDamage()); efTemp.ApplyEffect(ref targetInfo); } } } Debug.Log(targetInfo.logMessage); } }
//Constructor for a Single Effect Ability public Ability(string name, ImmediateEffect eff, CharacterAttributes atk, CharacterAttributes tar, int range, int num = 2, int sides = 10, int baseDif = 11, bool lineOfSight = true, bool affectedByCover = true) { this.name = name; effects.Add(eff); attackAttribute = atk; targetAttribute = tar; numDice = num; diceSides = sides; baseDifficulty = baseDif; this.range = range; requiresLineOfSight = lineOfSight; this.affectedByCover = affectedByCover; }
// Start is called before the first frame update void Start() { int[] att = { 9, 9, 9, 9, 9, 9, 4, 100, 6 }; //tests Immediate Effects AbilitySets[] abil = { AbilitySets.GOSPEL_Rifle }; Character c = new Character("Test Character 1", att, abil); Character c2 = new Character("Test Character 2", att, abil); ImmediateEffect e = new ImmediateEffect("TestImmediateEffect-20", CharacterAttributes.Health, 20, CharacterAttributes.Perception); Ability a = new Ability("TestAbilityImmediate", e, CharacterAttributes.Perception, CharacterAttributes.Defense, 5); c.UseAbility(a, 0, new CharacterTargetInfo(c, c2)); //tests Removable Effects RemovableEffect e1 = new RemovableEffect("TestRemovableEffect-40", CharacterAttributes.Health, 40, CharacterAttributes.Perception); Ability a2 = new Ability("TestAbilityRemovable", e1, CharacterAttributes.Perception, CharacterAttributes.Defense, 5); c.UseAbility(a2, 0, new CharacterTargetInfo(c, c2)); //e1.RemoveEffect(new CharacterTargetInfo(c2, c2)); //tests Temporary Effects TemporaryEffect e2 = new TemporaryEffect("TestTemporaryEffect-60", CharacterAttributes.Health, 60, CharacterAttributes.Perception, 2); Ability a3 = new Ability("TestAbilityTemporary", e2, CharacterAttributes.Perception, CharacterAttributes.Defense, 5); c.UseAbility(a3, 0, new CharacterTargetInfo(c, c2)); c2.TickCharacter(); c2.TickCharacter(); //tests Periodic Temporary Effects ImmediateEffect[] eff = { e }; PeriodicTemporaryEffect e3 = new PeriodicTemporaryEffect("TestPeriodicEffect-20", CharacterAttributes.Health, 20, 2, 1, eff, true); Ability a4 = new Ability("TestAbilityPeriodic", e3, CharacterAttributes.Perception, CharacterAttributes.Defense, 5); c.UseAbility(a4, 0, new CharacterTargetInfo(c, c2)); c2.TickCharacter(); c2.TickCharacter(); c2.TickCharacter(); }