Exemplo n.º 1
0
 public MovePart(TargettingType target, MoveDirection direction, int distance, Vector2Int center, bool forced = false, int chance = 100) : base(target, chance)
 {
     this.direction = direction;
     amount         = distance;
     this.forced    = forced;
     this.center    = center;
 }
Exemplo n.º 2
0
        public static SpellTargetInfoView Deserialize(System.IO.StreamReader input)
        {
            SpellTargetInfoView _obj = new SpellTargetInfoView();
            // Type
            TargettingType _obj_Type = (TargettingType)Int32.Parse(input.ReadLine());

            _obj.Type = (TargettingType)_obj_Type;
            // Range
            float _obj_Range = Single.Parse(input.ReadLine());

            _obj.Range = (float)_obj_Range;
            // Duration
            float _obj_Duration = Single.Parse(input.ReadLine());

            _obj.Duration = (float)_obj_Duration;
            // AoeRadius
            float _obj_AoeRadius = Single.Parse(input.ReadLine());

            _obj.AoeRadius = (float)_obj_AoeRadius;
            // DieOnCollision
            bool _obj_DieOnCollision = Int32.Parse(input.ReadLine()) == 0 ? false : true;

            _obj.DieOnCollision = (bool)_obj_DieOnCollision;
            // AllowedTargetTypes
            EntityTypeRelative _obj_AllowedTargetTypes = (EntityTypeRelative)Int32.Parse(input.ReadLine());

            _obj.AllowedTargetTypes = (EntityTypeRelative)_obj_AllowedTargetTypes;
            return(_obj);
        }
Exemplo n.º 3
0
    public override ITargettingDescription Generate()
    {
        ExceptTargetDescription desc = new ExceptTargetDescription(targetType, alignment);

        TargettingType exceptTargetting = TargettingType.TARGET;

        switch (desc.GetPlayerAlignment())
        {
        case Alignment.POSITIVE:
            exceptTargetting = TargettingType.TARGET_ALLY;
            break;

        case Alignment.NEGATIVE:
            exceptTargetting = TargettingType.TARGET_ENEMY;
            break;
        }

        IProceduralTargettingGenerator targetGen = ProceduralUtils.GetProceduralGenerator(exceptTargetting);

        targetGen.SetupParameters(targetType, random, model, minAllocatedBudget, maxAllocatedBudget);
        desc.targetDescription = targetGen.Generate();
        if (desc.targetDescription is IQualifiableTargettingDescription qualifiableDesc)
        {
            qualifiableDesc.qualifier = desc.qualifier;
        }
        return(desc);
    }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new damage part with the corresponding damage values
 /// </summary>
 /// <param name="modifiedByValue">If this is affected by a numerical value (EX. healing based on healing recieved), how much is it affectd</param>
 public HealingPart(TargettingType target, int heal, int flatHeal, int maxHPHeal, int chance = 100, float modifiedByValue = 0) : base(target, chance)
 {
     healing              = heal;
     flatHealing          = flatHeal;
     maxHpPercent         = maxHPHeal;
     this.modifiedByValue = modifiedByValue;
 }
        public override void NowPrimaried(object request)
        {
            TargettingKeystrokeRequest targettingRequest = (TargettingKeystrokeRequest)request;
            m_targetablePoints = targettingRequest.TargetablePoints;
            m_selectionDelegate = targettingRequest.SelectionDelegate;

            if (m_selectionDelegate == null)
                throw new ArgumentNullException("Selection delegate for targetting must not be null");
            
            m_alternateSelectionKey = targettingRequest.AlternateSelectionKey;

            m_targettingType = targettingRequest.TargettingType;

            SelectionPoint = SetTargettingInitialSpot(m_engine);

            EnablePlayerTargeting enableRequest = new EnablePlayerTargeting(true, m_targetablePoints);
            if (targettingRequest.HaloDelegate != null)
                enableRequest.HaloDelegate = x => targettingRequest.HaloDelegate(x);

            m_gameInstance.SendPaintersRequest(enableRequest);
            m_gameInstance.SendPaintersRequest(new EnableMapCursor(true, SelectionPoint));

            // If we have no targetable points, just exit now
            if (m_targetablePoints.Count == 0)
                Escape();

            m_gameInstance.UpdatePainters();
        }
Exemplo n.º 6
0
 public AddTriggerPart(TargettingType target, TriggeredEffect effect, int maxTimesThisBattle = -1, int turnCooldown = -1, int maxActiveTurns = -1, int chance = 100) : base(target, chance)
 {
     this.effect             = effect;
     this.maxTimesThisBattle = maxTimesThisBattle;
     this.turnCooldown       = turnCooldown;
     this.maxActiveTurns     = maxActiveTurns;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Creates a new damage part with the corresponding damage values
 /// </summary>
 /// <param name="modifiedByValue">If this is affected by a numerical value (EX. dealing damage based on damage taken), how much is it affectd</param>
 public DamagePart(TargettingType target, DamageType damageType, int damage, int flatDamage, int maxHpDamage, int remainingHpDamage, int chance = 100, float modifiedByValue = 0) : base(target, chance)
 {
     this.damageType      = damageType;
     this.damage          = damage;
     this.flatDamage      = flatDamage;
     maxHpPercent         = maxHpDamage;
     missingHpPercent     = remainingHpDamage;
     this.modifiedByValue = modifiedByValue;
 }
Exemplo n.º 8
0
 static public IProceduralTargettingGenerator GetProceduralGenerator(TargettingType type)
 {
     if (proceduralTargettingGenerators.ContainsKey(type))
     {
         return(proceduralTargettingGenerators[type]);
     }
     Assert.IsTrue(false);
     return(null);
 }
Exemplo n.º 9
0
 public BattleItemBase(TargettingType targetType, bool outOfBattleUse, List <SkillPartBase> effects, int maxStack, int sellPrice, string flavorText = "") : base(maxStack, sellPrice, flavorText)
 {
     this.targetType   = targetType;
     usableOutOfBattle = outOfBattleUse;
     if (effects != null)
     {
         foreach (SkillPartBase part in effects)
         {
             partList.Add(part);
         }
     }
 }
Exemplo n.º 10
0
 public Skill(string name, TargettingType target, int cost, int targetRange, int xAOE, int yAOE, int unlockCost, int unlockLvl, string flavorText = "")
 {
     this.name       = name;
     targetType      = target;
     aEtherCost      = cost;
     targettingRange = targetRange;
     xRange          = xAOE;
     yRange          = yAOE;
     this.unlockCost = unlockCost;
     unlockLevel     = unlockLvl;
     this.flavorText = flavorText;
 }
        public TargettingModeKeyboardHandler(TargettingType targettingType, IGameEngine engine, Map map, List<EffectivePoint> targetablePoints)
        {
            m_targetablePoints = targetablePoints;

            m_targettingType = targettingType;
            
            map.InTargettingMode = true;
            map.TargetPoint = SetTargettingInitialSpot(engine);
            if (m_targetablePoints != null)
                map.TargetablePoints = m_targetablePoints;

            m_lastTargetted = null;
        }
Exemplo n.º 12
0
    static private void RegisterProceduralGenerator(TargettingType type, IProceduralTargettingGenerator generator)
    {
        Assert.IsFalse(proceduralTargettingGenerators.ContainsKey(type));
        Assert.AreEqual(type, generator.GetTargettingType());
        proceduralTargettingGenerators[type] = generator;

        double minCost = generator.GetMinCost();
        int    i;

        for (i = 0; i < targettingMinCosts.Count; i++)
        {
            if (minCost <= targettingMinCosts[i].Item1)
            {
                break;
            }
        }
        targettingMinCosts.Insert(i, new Tuple <double, TargettingType>(minCost, type));
        targettingByAlignment[generator.GetDescriptionType().GetAlignment()].Add(type);
    }
Exemplo n.º 13
0
        public static SpellCastTargetInfoView Deserialize(System.IO.StreamReader input)
        {
            SpellCastTargetInfoView _obj = new SpellCastTargetInfoView();
            // Type
            TargettingType _obj_Type = (TargettingType)Int32.Parse(input.ReadLine());

            _obj.Type = (TargettingType)_obj_Type;
            // TargetPosition
            Vector2 _obj_TargetPosition = Vector2.Deserialize(input);

            _obj.TargetPosition = (Vector2)_obj_TargetPosition;
            // TargetDirection
            Vector2 _obj_TargetDirection = Vector2.Deserialize(input);

            _obj.TargetDirection = (Vector2)_obj_TargetDirection;
            // TargetId
            int _obj_TargetId = Int32.Parse(input.ReadLine());

            _obj.TargetId = (int)_obj_TargetId;
            return(_obj);
        }
Exemplo n.º 14
0
 public TargettingInfo(TargettingType type, Action <int> onTargetSelected)
 {
     Type             = type;
     OnTargetSelected = onTargetSelected;
 }
Exemplo n.º 15
0
 void EnableTargetting(TargettingType type, Action <int> action)
 {
     TargetInfo = new TargettingInfo(type, action);
     CombatView.EnableTargetting(type);
 }
Exemplo n.º 16
0
 public void EnableTargetting(TargettingType type)
 {
     Enabled = true;
     Type    = type;
     SetDefaultTarget();
 }
Exemplo n.º 17
0
 public SkillPartBase(TargettingType targetType, int chanceToProc)
 {
     this.targetType   = targetType;
     this.chanceToProc = chanceToProc;
 }
Exemplo n.º 18
0
 protected IQualifiableTargettingDescription(TargetType target, TargettingType targetting, Alignment alignment) : base(target, targetting)
 {
     playerAlignment = alignment;
 }
Exemplo n.º 19
0
        /// <summary>
        /// Gets a target from the player. false showed an escape. otherwise target is the target selected.
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        private bool GetTargetFromPlayer(Point start, out Point target, TargettingType type, int range, double spreadAngle, char confirmChar, CreatureFOV currentFOV)
        {
            //Turn targetting mode on the screen
            Screen.Instance.TargettingModeOn();
            Screen.Instance.Target = start;
            Screen.Instance.TargetType = type;
            Screen.Instance.TargetRange = range;
            Screen.Instance.TargetPermissiveAngle = spreadAngle;

            if ((range == -1 && currentFOV.CheckTileFOV(start.x, start.y))
                || Utility.TestRangeFOVForWeapon(Game.Dungeon.Player, start, range, currentFOV))
            {
                Screen.Instance.SetTargetInRange = true;
                SquareContents sqC = SetViewPanelToTargetAtSquare(start);
            }
            else
            {
                Screen.Instance.SetTargetInRange = false;
            }

            Game.MessageQueue.AddMessage("Find a target. " + confirmChar + " to confirm. ESC to exit.");
            Screen.Instance.Update();

            bool keepLooping = true;
            bool validFire = false;

            target = start;

            do
            {
                //Get direction from the user or 'z' to fire
                KeyPress userKey = Keyboard.WaitForKeyPress(true);

                Point direction = new Point();
                KeyModifier mod = KeyModifier.Arrow;
                bool validDirection = false;

                if (GetDirectionFromKeypress(userKey, out direction, out mod))
                {
                    //Valid direction
                    validDirection = true;
                }
                else
                {
                    //Look for firing
                    if (userKey.KeyCode == KeyCode.TCODK_CHAR)
                    {
                        char keyCode = (char)userKey.Character;
                        if(keyCode == confirmChar) {

                                validFire = true;
                                keepLooping = false;
                        }
                    }

                    if (userKey.KeyCode == KeyCode.TCODK_ESCAPE)
                    {
                        keepLooping = false;
                    }
                }

                //If direction, update the location and redraw

                if (validDirection)
                {
                    Point newPoint = new Point(target.x + direction.x, target.y + direction.y);

                    int level = Game.Dungeon.Player.LocationLevel;

                    if (newPoint.x < 0 || newPoint.x >= Game.Dungeon.Levels[level].width || newPoint.y < 0 || newPoint.y >= Game.Dungeon.Levels[level].height)
                        continue;

                    //Otherwise OK
                    target = newPoint;

                    if ((range == -1 && currentFOV.CheckTileFOV(newPoint.x, newPoint.y))
                        || Utility.TestRangeFOVForWeapon(Game.Dungeon.Player, newPoint, range, currentFOV))
                    {
                        Screen.Instance.SetTargetInRange = true;
                        SquareContents sqC = SetViewPanelToTargetAtSquare(target);
                    }
                    else
                        Screen.Instance.SetTargetInRange = false;

                    //Update screen
                    Screen.Instance.Target = newPoint;
                    Game.MessageQueue.AddMessage("Find a target. " + confirmChar + " to confirm. ESC to exit.");
                    Screen.Instance.Update();

                }
            } while (keepLooping);

            //Turn targetting mode off
            Screen.Instance.TargettingModeOff();
            Screen.Instance.Update();

            return validFire;
        }
Exemplo n.º 20
0
 public TargetingInfo(TargettingType targetingType, int range)
 {
     Type = targetingType;
     Range = range;
 }
Exemplo n.º 21
0
        /// <summary>
        /// Let the user target something
        /// </summary>
        /// <returns></returns>
        private bool TargetAttack(out Point target, int range, TargettingType targetType, double spreadAngle, char confirmChar, CreatureFOV currentFOV)
        {
            Player player = Game.Dungeon.Player;

            //Start on the nearest creature
            Creature closeCreature = Game.Dungeon.FindClosestHostileCreatureInFOV(player);

            if (closeCreature == null)
            {
                var allCreatures = Game.Dungeon.FindClosestCreaturesInPlayerFOV();
                if (allCreatures.Any())
                    closeCreature = allCreatures.First();
            }

            //If no nearby creatures, start on the player
            if (closeCreature == null)
                closeCreature = Game.Dungeon.Player;

            Point startPoint;

            if (Utility.TestRange(Game.Dungeon.Player, closeCreature, range) || range == -1)
            {
                startPoint = new Point(closeCreature.LocationMap.x, closeCreature.LocationMap.y);
            }
            else
            {
                startPoint = new Point(player.LocationMap.x, player.LocationMap.y);
            }
            /*
            //Get the FOV from Dungeon (this also updates the map creature FOV state)
            TCODFov currentFOV = Game.Dungeon.CalculateCreatureFOV(player);

            Point startPoint;

            //Is that creature in FOV
            if (currentFOV.CheckTileFOV(closeCreature.LocationMap.x, closeCreature.LocationMap.y))
            {
                //If so, target
                startPoint = new Point(closeCreature.LocationMap.x, closeCreature.LocationMap.y);
            }
            else
            {
                //If not, target the PC
                startPoint = new Point(player.LocationMap.x, player.LocationMap.y);
            }
            */
            //Get the desired target from the player

            return GetTargetFromPlayer(startPoint, out target, targetType, range, spreadAngle, confirmChar, currentFOV);
        }
Exemplo n.º 22
0
 public StatChangePart(TargettingType target, Stats affectedStat, int flatChange, float multiplier, int duration, int chance = 100) : base(target, chance)
 {
     statMod = new StatMod(affectedStat, flatChange, multiplier, duration);
 }
Exemplo n.º 23
0
 public ConnectedChancePart(TargettingType target, List <ConnectedChanceEffect> effects, int chanceOutOf, int chance = 100) : base(target, chance)
 {
     this.effects     = effects;
     this.chanceOutOf = chanceOutOf;
 }
Exemplo n.º 24
0
 public StatusEffectPart(TargettingType target, string status, bool removeIt, int chance = 100) : base(target, chance)
 {
     this.status = status;
     remove      = removeIt;
 }
Exemplo n.º 25
0
 public TargetingInfo(TargettingType targetingType)
     : this(targetingType, -1)
 {
 }
Exemplo n.º 26
0
    static private bool GenerateCardEffect(System.Random random, IHistogram model, CreatureModelIndex creatureModels, CardEffectDescription effectDesc, EffectType effect, double minBudget, double maxBudget, bool positive)
    {
        IProceduralEffectGenerator effectGen = ProceduralUtils.GetProceduralGenerator(effect);

        effectGen.SetupParameters(random, model, creatureModels, minBudget, maxBudget);
        effectDesc.effectType = effectGen.Generate();

        // Adjust budgets
        minBudget /= effectDesc.effectType.PowerLevel();
        maxBudget /= effectDesc.effectType.PowerLevel();
        if (minBudget > maxBudget)
        {
            double temp = minBudget;
            minBudget = maxBudget;
            maxBudget = temp;
        }
        // Always allow for default targetting (multiplier 1.0x)
        if (maxBudget < 1.0)
        {
            maxBudget = 1.0;
        }

        TargetType                 targetType          = TargetType.CREATURES;
        SortedSet <TargetType>     validTargets        = CardEnums.GetValidFlags <TargetType>(effect);
        SortedSet <TargettingType> allowableTargetting = new SortedSet <TargettingType>();
        SortedSet <QualifierType>  allowableQualifiers = new SortedSet <QualifierType>();

        while (validTargets.Count > 0 && allowableTargetting.Count == 0)
        {
            targetType = ProceduralUtils.GetRandomValue(random, model, validTargets);
            validTargets.Remove(targetType);

            switch (effectDesc.effectType.GetAlignment())
            {
            case Alignment.POSITIVE:
                if (positive)
                {
                    allowableTargetting = ProceduralUtils.GetTargettingByAlignment(Alignment.POSITIVE);

                    allowableQualifiers = ProceduralUtils.GetQualifiersByAlignment(Alignment.NEUTRAL);
                    allowableQualifiers.UnionWith(ProceduralUtils.GetQualifiersByAlignment(Alignment.POSITIVE));
                    allowableQualifiers.IntersectWith(CardEnums.GetValidFlags <QualifierType>(targetType));
                    if (allowableQualifiers.Count > 0)
                    {
                        allowableTargetting.UnionWith(ProceduralUtils.GetTargettingByAlignment(Alignment.NEUTRAL));
                    }
                }
                else
                {
                    allowableTargetting = ProceduralUtils.GetTargettingByAlignment(Alignment.NEGATIVE);

                    allowableQualifiers = ProceduralUtils.GetQualifiersByAlignment(Alignment.NEGATIVE);
                    allowableQualifiers.IntersectWith(CardEnums.GetValidFlags <QualifierType>(targetType));
                    if (allowableQualifiers.Count > 0)
                    {
                        allowableTargetting.UnionWith(ProceduralUtils.GetTargettingByAlignment(Alignment.NEUTRAL));
                    }
                }
                break;

            case Alignment.NEGATIVE:
                if (positive)
                {
                    allowableTargetting = ProceduralUtils.GetTargettingByAlignment(Alignment.NEGATIVE);

                    allowableQualifiers = ProceduralUtils.GetQualifiersByAlignment(Alignment.NEUTRAL);
                    allowableQualifiers.UnionWith(ProceduralUtils.GetQualifiersByAlignment(Alignment.NEGATIVE));
                    allowableQualifiers.IntersectWith(CardEnums.GetValidFlags <QualifierType>(targetType));
                    if (allowableQualifiers.Count > 0)
                    {
                        allowableTargetting.UnionWith(ProceduralUtils.GetTargettingByAlignment(Alignment.NEUTRAL));
                    }
                }
                else
                {
                    allowableTargetting = ProceduralUtils.GetTargettingByAlignment(Alignment.POSITIVE);
                    allowableQualifiers = ProceduralUtils.GetQualifiersByAlignment(Alignment.POSITIVE);
                    allowableQualifiers.IntersectWith(CardEnums.GetValidFlags <QualifierType>(targetType));
                    if (allowableQualifiers.Count > 0)
                    {
                        allowableTargetting.UnionWith(ProceduralUtils.GetTargettingByAlignment(Alignment.NEUTRAL));
                    }
                }
                break;

            default:
                if (positive)
                {
                    allowableTargetting = new SortedSet <TargettingType>((TargettingType[])Enum.GetValues(typeof(TargettingType)));
                    allowableQualifiers = new SortedSet <QualifierType>((QualifierType[])Enum.GetValues(typeof(QualifierType)));
                    allowableQualifiers.IntersectWith(CardEnums.GetValidFlags <QualifierType>(targetType));
                }
                else
                {
                    allowableTargetting = new SortedSet <TargettingType>();
                }
                break;
            }

            allowableTargetting.IntersectWith(CardEnums.GetValidFlags <TargettingType>(targetType));
            allowableTargetting.IntersectWith(CardEnums.GetValidFlags <TargettingType>(effectDesc.triggerCondition));

            // Special case
            // Up to can never be a downside because you can choose 0 targets
            if (!positive)
            {
                allowableTargetting.Remove(TargettingType.UP_TO_TARGET);
                allowableTargetting.Remove(TargettingType.UP_TO_TARGET_ALLY);
                allowableTargetting.Remove(TargettingType.UP_TO_TARGET_ENEMY);
            }
        }

        // Could not find any valid targetting to achieve the desired alignment
        if (allowableTargetting.Count == 0)
        {
            SortedSet <TargetType> targets = CardEnums.GetValidFlags <TargetType>(effect);

            Debug.Log("Wasn't able to generate targets for effect <" + effect.ToString() + ">");
            return(false);
        }


        // Attempt to narrow down the targetting pool
        SortedSet <TargettingType> targettingWithinBudget = new SortedSet <TargettingType>(allowableTargetting.Intersect(ProceduralUtils.GetTargettingWithinBudget(maxBudget)));

        if (targettingWithinBudget.Count > 0)
        {
            allowableTargetting = targettingWithinBudget;
        }
        else
        {
            Debug.Log("Unable to narrow down targetting types for <" + effect.ToString() + ", " + targetType.ToString() + "> for budget " + maxBudget);
        }

        TargettingType targettingType = ProceduralUtils.GetRandomValue(random, model, allowableTargetting);
        IProceduralTargettingGenerator targettingGen = ProceduralUtils.GetProceduralGenerator(targettingType);

        targettingGen.SetupParameters(targetType, random, model, minBudget, maxBudget);
        effectDesc.targettingType = targettingGen.Generate();

        // Adjust budgets
        minBudget /= effectDesc.targettingType.PowerLevel();
        maxBudget /= effectDesc.targettingType.PowerLevel();
        if (minBudget > maxBudget)
        {
            double temp = minBudget;
            minBudget = maxBudget;
            maxBudget = temp;
        }


        if (effectDesc.targettingType is IQualifiableTargettingDescription qualifiable)
        {
            // Generate a possible qualifier

            // Attempt to narrow down the qualifier pool
            SortedSet <QualifierType> qualifiersWithinBudget = new SortedSet <QualifierType>(allowableQualifiers.Intersect(ProceduralUtils.GetQualifiersWithinBudget(maxBudget)));
            if (targettingWithinBudget.Count > 0)
            {
                allowableQualifiers = qualifiersWithinBudget;
            }
            else
            {
                Debug.Log("Unable to narrow down qualifier types for <" + effect.ToString() + ", " + targetType.ToString() + "> for budget " + maxBudget);
            }

            QualifierType qualifier = ProceduralUtils.GetRandomValue(random, model, allowableQualifiers);
            if (qualifier != QualifierType.NONE)
            {
                IProceduralQualifierGenerator qualifierGen = ProceduralUtils.GetProceduralGenerator(qualifier);
                qualifierGen.SetupParameters(random, model, minBudget, maxBudget);
                qualifiable.qualifier = qualifierGen.Generate();
            }
        }

        return(true);
    }
Exemplo n.º 27
0
 public TargettingKeystrokeHandler()
 {
     m_targettingType = TargettingType.None;
     m_lastTargetted = null;
 }
 public TargettingModeKeyboardHandler(TargettingType targettingType, IGameEngine engine, Map map, OnTargetSelect selectionAction, List<EffectivePoint> targetablePoints)
     : this(targettingType, engine, map, targetablePoints)
 {
     m_action = selectionAction;
 }
Exemplo n.º 29
0
 public void EnableTargetting(TargettingType type) => TargetView.EnableTargetting(type);
Exemplo n.º 30
0
 protected ITargettingDescription(TargetType target, TargettingType targetting)
 {
     targetType     = target;
     targettingType = targetting;
 }
Exemplo n.º 31
0
 public UniqueEffectPart(TargettingType target, UniqueEffects effect, int chance = 100) : base(target, chance)
 {
     this.effect = effect;
 }
Exemplo n.º 32
0
 private bool TargetAttack(out Point target, TargettingType targetType, double spreadAngle, char confirmChar, CreatureFOV currentFOV)
 {
     return TargetAttack(out target, -1, targetType, spreadAngle, confirmChar, currentFOV);
 }