Exemple #1
0
        public override object Update(SpellDef input, SpellDef spell, CharacterEntity ent, object state)
        {
            var selfState = (TargetPointCastState)state;

            if (selfState == null)
            {
                selfState = new TargetPointCastState();
            }
            var targetWorldPos = EnvironmentAPI.Input.GlobalMousePos;

            selfState.T = new HierarchyTransform(targetWorldPos, 0, null);
            if (Input.Def.IsActive(selfState.TriggerWasActive))
            {
                //Logger.LogError($"{input.____GetDebugShortName()} {spell.____GetDebugShortName()}");
                ent.ActionEngine.DoInput(input, new SpellCast()
                {
                    Def = spell, TargetPoint = targetWorldPos, OwnerObject = ent.Id
                });
                selfState.TriggerWasActive = true;
            }
            if (!Input.Def.IsActive(selfState.TriggerWasActive))
            {
                selfState.TriggerWasActive = false;
            }
            return(selfState);
        }
Exemple #2
0
 public Meteor(SpellDef def, DungeonObject owner, Vector2 position)
     : base(def, owner, owner.Position)
 {
     Position            = new Vector2((int)position.X / 16 * 16, (int)position.Y / 16 * 16);
     State               = Active;
     StateCompleteAction = () => State = Hit;
 }
Exemple #3
0
 public Spell(SpellDef def, DungeonObject owner, Vector2 position) : base(def, position, "spells", state: Cast)
 {
     SpellDef = def;
     Position = new((int)Position.X / 16 * 16, (int)Position.Y / 16 * 16);
     game     = DungeonGame.Instance;
     player   = DungeonPlayer.Instance;
     Owner    = owner;
 }
Exemple #4
0
 public Lightning(SpellDef def, DungeonObject owner, Vector2 position) : base(def, owner, position)
 {
     Position            = new Vector2((int)position.X / 16 * 16, (int)position.Y / 16 * 16);
     State               = Active;
     StateCompleteAction = () =>
     {
         State = Hit;
         StateCompleteAction = () => State = Dead;
     };
 }
Exemple #5
0
 public Flame(SpellDef def, DungeonObject owner, Vector2 position) : base(def, owner, position)
 {
     Position            = new Vector2((int)position.X / 16 * 16, (int)position.Y / 16 * 16);
     State               = Cast;
     StateCompleteAction = () =>
     {
         State = Active;
         StateCompleteAction    = null;
         CurrentlyBlockingInput = false;
     };
 }
        public SpellDef GetSpell(SpellDef baseSpell)
        {
            int      maxValue    = -1;
            SpellDef maxOverride = null;

            foreach (var overrideLayer in _overrides)
            {
                if (overrideLayer.Value.Index > maxValue && overrideLayer.Value.Overrides.TryGetValue(baseSpell, out var overrideSpell))
                {
                    maxValue    = overrideLayer.Value.Index;
                    maxOverride = overrideSpell;
                }
            }
            return(maxOverride);
        }
Exemple #7
0
    public Fireball(SpellDef def, Vector2 start, Vector2 end)
        : base(def, start)
    {
        var(x1, y1) = Position;
        var(x2, y2) = end;

        var xDiff = x2 - x1;
        var yDiff = y2 - y1;

        Rotation = MathF.Atan2(yDiff, xDiff);

        StateCompleteAction = () => State = Active;

        FlightPath = Position.CastRay(end, true, true, true, true).GetEnumerator();
    }
Exemple #8
0
    public Fireball(SpellDef def, DungeonObject owner, Vector2 end)
        : base(def, owner, owner.Position)
    {
        Position = new Vector2((int)owner.Position.X / 16 * 16, (int)owner.Position.Y / 16 * 16);
        end      = new((int)end.X / 16 * 16, (int)end.Y / 16 * 16);

        var(x1, y1) = Position;
        var(x2, y2) = end;

        float xDiff = x2 - x1;
        float yDiff = y2 - y1;

        Rotation = MathF.Atan2(yDiff, xDiff);

        StateCompleteAction = () => State = Active;

        FlightPath = Position.CastRay(end, true, true, true, true).GetEnumerator();
    }
Exemple #9
0
 public abstract object Update(SpellDef input, SpellDef spell, CharacterEntity ent, object state);
Exemple #10
0
 public Spell(SpellDef def, Vector2 position) : base(def, position, "spells", state: Cast)
 {
     SpellDef = def;
 }