Ejemplo n.º 1
0
 public AttackTargetingContext(List <AttackTargetContext> targetContexts, PieceAttackPattern pattern, Layers targetedLayer, Layers blockLayer)
 {
     this.targetContexts = targetContexts;
     this.pattern        = pattern;
     this.targetedLayer  = targetedLayer;
     this.blockLayer     = blockLayer;
 }
Ejemplo n.º 2
0
        public static IEnumerable <AttackTargetContext> DiscardUnreachable(
            IEnumerable <AttackTargetContext> contexts, PieceAttackPattern pattern)
        {
            // we assume they are sorted
            // weaponEvent.targets.Sort((a, b) => a.piece.index - b.piece.index);

            bool[] blockedArray = new bool[contexts.Max(t => t.pieceIndex) + 1];

            foreach (var target in contexts)
            {
                int i     = target.pieceIndex;
                var piece = pattern.pieces[i];

                // we prevent reach if we are a block
                blockedArray[i] = target.attackness.HasFlag(Attackness.IS_BLOCK);

                if (piece.reach.reachesAll || piece.reach.indices.All(j => blockedArray[j] == false))
                {
                    yield return(target);
                }
            }
        }