示例#1
0
 public bool enoughMP(Magics magic)
 {
     if (this.MP >= (int)magic)
     {
         return(true);
     }
     return(false);
 }
示例#2
0
 public Stoune(double x, double y, double width, double height, WarUnit thrower, int range,
               int TakeLife, int timeOut, SpriteType spriteType, Magics magicType, Vector2 dir, double speed
               )
     : base(x, y, width, height, thrower, range,
            TakeLife, timeOut, spriteType, magicType)
 {
     this.Direction = dir;
     this.Speed     = speed;
 }
示例#3
0
        public virtual Reaction reactToWeapon(Magics typeOfMagic)
        {
            switch (typeOfMagic)
            {
            case Magics.TakeLife: return(Reaction.ReceiveDemage); break;

            case Magics.GiveLife: return(Reaction.ReceiveLife); break;

            default: return(Reaction.Passive);
            }
        }
示例#4
0
    /// <summary>
    /// Initializes chess with the custom fen.
    /// </summary>
    public void InitializeChess(string FEN)
    {
        Magics.Init();  //Initialize magics ;)
        Zobrist.Init(); //Initiliaze zobrist
        MvvLva.Init();
        //Initialize chess
        board  = new Board(FEN);
        Moves  = new SMove[256];
        search = new AI(board);

        OnTurnSwitched(64, 64); //Call it on start
    }
示例#5
0
        public override void Die()
        {
            base.Die();

            if (Player?.Node == null)
            {
                return;
            }

            List <MapObject> targets = Player.GetTargets(CurrentMap, CurrentLocation, 2);

            foreach (MapObject target in targets)
            {
                Player.ActionList.Add(new DelayedAction(
                                          SEnvir.Now.AddMilliseconds(800),
                                          ActionType.DelayedMagicDamage,
                                          Magics.ToList(),
                                          target,
                                          Functions.InRange(target.CurrentLocation, CurrentLocation, 1),
                                          DarkStoneStats,
                                          0));
            }

            Effect effect = Effect.Puppet;

            if (DarkStoneStats.GetAffinityValue(Element.Fire) > 0)
            {
                effect = Effect.PuppetFire;
            }
            else if (DarkStoneStats.GetAffinityValue(Element.Ice) > 0)
            {
                effect = Effect.PuppetIce;
            }
            else if (DarkStoneStats.GetAffinityValue(Element.Lightning) > 0)
            {
                effect = Effect.PuppetLightning;
            }
            else if (DarkStoneStats.GetAffinityValue(Element.Wind) > 0)
            {
                effect = Effect.PuppetWind;
            }

            Broadcast(new S.ObjectEffect {
                Effect = effect, ObjectID = ObjectID
            });

            DeadTime = SEnvir.Now.AddSeconds(2);
        }
示例#6
0
 public Magic(double x, double y, double width, double height, WarUnit thrower, int range,
              int takeLife, int timeOut, SpriteType spriteType, Magics magicType
              )
     : base(x, y, width, height)
 {
     this.MagicThrower   = thrower;
     this.Range          = range;
     this.CurrentTimeout = 0;
     this.TimeOut        = timeOut;
     this.HasTimeout     = false;
     this.SpriteType     = spriteType;
     this.X        -= this.Width / 2 - 20;
     this.Y        -= this.Height / 2 - 20;
     this.MagicType = magicType;
     this.TakeLife  = takeLife;
 }
示例#7
0
 public OrderedDictionary <byte, byte> CloneMagic() => Magics.Clone();
示例#8
0
        private static void AddMovesFromSquare(MagicMoveTableBuilder builder, int srcFile, int srcRank)
        {
            ulong        mask        = 0;
            List <ulong> occupancies = new List <ulong>();
            List <ulong> moves       = new List <ulong>();

            // populate mask
            // Note: mask rays don't extend to the edge of the map; this is because if a ray reaches all the way to the edge of the board, that square's occupancy doesn't affect move generation.

            // up/left
            for (int i = 1;; i++)
            {
                int dstFile = srcFile - i;
                int dstRank = srcRank + i;
                if (!InsideOuterRing(dstFile, dstRank))
                {
                    break;
                }

                mask |= Position.ValueFromFileRank(dstFile, dstRank);
            }

            // up/right
            for (int i = 1; ; i++)
            {
                int dstFile = srcFile + i;
                int dstRank = srcRank + i;
                if (!InsideOuterRing(dstFile, dstRank))
                {
                    break;
                }

                mask |= Position.ValueFromFileRank(dstFile, dstRank);
            }

            // down/left
            for (int i = 1; ; i++)
            {
                int dstFile = srcFile - i;
                int dstRank = srcRank - i;
                if (!InsideOuterRing(dstFile, dstRank))
                {
                    break;
                }

                mask |= Position.ValueFromFileRank(dstFile, dstRank);
            }

            // down/right
            for (int i = 1; ; i++)
            {
                int dstFile = srcFile + i;
                int dstRank = srcRank - i;
                if (!InsideOuterRing(dstFile, dstRank))
                {
                    break;
                }

                mask |= Position.ValueFromFileRank(dstFile, dstRank);
            }

            int maskBits         = Bits.PopCount(mask);
            int maskPermutations = 1 << maskBits;

            for (int permutation = 0; permutation < maskPermutations; permutation++)
            {
                ulong occupancy     = Bits.ParallelBitDeposit((ulong)permutation, mask);
                ulong singularMoves = 0;

                // Note: rays do now reach all the way to the edge of the board; we do want to generate moves that would reach the end of the board.

                // up/left
                for (int i = 1; ; i++)
                {
                    int dstFile = srcFile - i;
                    int dstRank = srcRank + i;
                    if (!Position.FileRankOnBoard(dstFile, dstRank))
                    {
                        break;
                    }

                    ulong move = Position.ValueFromFileRank(dstFile, dstRank);
                    singularMoves |= move;
                    if ((occupancy & move) > 0)
                    {
                        break;
                    }
                }

                // up/right
                for (int i = 1; ; i++)
                {
                    int dstFile = srcFile + i;
                    int dstRank = srcRank + i;
                    if (!Position.FileRankOnBoard(dstFile, dstRank))
                    {
                        break;
                    }

                    ulong move = Position.ValueFromFileRank(dstFile, dstRank);
                    singularMoves |= move;
                    if ((occupancy & move) > 0)
                    {
                        break;
                    }
                }

                // down/left
                for (int i = 1; ; i++)
                {
                    int dstFile = srcFile - i;
                    int dstRank = srcRank - i;
                    if (!Position.FileRankOnBoard(dstFile, dstRank))
                    {
                        break;
                    }

                    ulong move = Position.ValueFromFileRank(dstFile, dstRank);
                    singularMoves |= move;
                    if ((occupancy & move) > 0)
                    {
                        break;
                    }
                }

                // down/right
                for (int i = 1; ; i++)
                {
                    int dstFile = srcFile + i;
                    int dstRank = srcRank - i;
                    if (!Position.FileRankOnBoard(dstFile, dstRank))
                    {
                        break;
                    }

                    ulong move = Position.ValueFromFileRank(dstFile, dstRank);
                    singularMoves |= move;
                    if ((occupancy & move) > 0)
                    {
                        break;
                    }
                }

                occupancies.Add(occupancy);
                moves.Add(singularMoves);
            }

            var ix   = Position.IxFromFileRank(srcFile, srcRank);
            var info = new MagicMoveTable.Info
            {
                Magic = Magics.GetOrDefault(ix),
                Mask  = mask,
                MaskedOccupancyKeys = occupancies.ToArray(),
                MovesValues         = moves.ToArray(),
            };

            builder.Add(ix, info);
        }
示例#9
0
        public override void Load(BinaryReader reader, int version, int customVersion)
        {
            Index  = reader.ReadInt32();
            Name   = reader.ReadString();
            Level  = reader.ReadUInt16();
            Class  = (MirClass)reader.ReadByte();
            Gender = (MirGender)reader.ReadByte();
            Hair   = reader.ReadByte();

            CreationDate = DateTime.FromBinary(reader.ReadInt64());

            Deleted    = reader.ReadBoolean();
            DeleteDate = DateTime.FromBinary(reader.ReadInt64());

            HP = reader.ReadInt32();
            MP = reader.ReadInt32();

            Experience = reader.ReadInt64();

            int count = reader.ReadInt32();

            Array.Resize(ref Inventory, count);

            for (int i = 0; i < count; i++)
            {
                if (!reader.ReadBoolean())
                {
                    continue;
                }
                UserItem item = new UserItem(reader, version, customVersion);
                if (Envir.BindItem(item) && i < Inventory.Length)
                {
                    Inventory[i] = item;
                }
            }

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                if (!reader.ReadBoolean())
                {
                    continue;
                }
                UserItem item = new UserItem(reader, version, customVersion);
                if (Envir.BindItem(item) && i < Equipment.Length)
                {
                    Equipment[i] = item;
                }
            }

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                UserMagic magic = new UserMagic(reader, version, customVersion);
                if (magic.Info == null)
                {
                    continue;
                }

                magic.CastTime = int.MinValue;
                Magics.Add(magic);
            }

            if (version > 99)
            {
                AutoPot       = reader.ReadBoolean();
                Grade         = reader.ReadByte();
                HPItemIndex   = reader.ReadInt32();
                MPItemIndex   = reader.ReadInt32();
                AutoHPPercent = reader.ReadByte();
                AutoMPPercent = reader.ReadByte();
            }

            if (version > 101)
            {
                SealCount = reader.ReadUInt16();
            }
        }
示例#10
0
 public FireBall(double x, double y, double width, double height, WarUnit thrower, int range,
                 int TakeLife, int timeOut, SpriteType spriteType, Magics magicType
                 ) : base(x, y, width, height, thrower, range,
                          TakeLife, timeOut, spriteType, magicType)
 {
 }