Example #1
0
        public void ControlMonster(Client gc, int j)
        {
            if (this.IsControling == true)
            {
                return;
            }

            var chr = gc.Character;

            this.IsControling = true;

            Delay tmr = null;

            tmr = new Delay(1000, true, () =>
            {
                if (this.GetMapCharactersTotal() < 1)
                {
                    tmr.Cancel();
                    this.IsControling = false;
                    return;
                }

                for (int i = 0; i < j; i++)
                {
                    if (this.Monster[i].State == 3 || this.Monster[i].State == 7 || this.Monster[i].State == 9 ||
                        this.Monster[i].MoveType == 3)
                    {
                        continue;
                    }

                    int Direction = this.Monster[i].Direction;

                    Monster Monster = UpdatePosition(this.Monster[i], (int)(40 * this.Monster[i].Speed));

                    foreach (Character All in this.Characters)
                    {
                        if (this.Monster[i].State != 9 && Direction != Monster.Direction && All.MapX == this.MapX &&
                            All.MapY == this.MapY)
                        {
                            MonsterPacket.spawnMonster(All.Client, this.Monster[i], 0, 0, 0, 0);
                        }
                    }
                }
            });
            tmr.Execute();

            Delay tmr2 = null;

            tmr2 = new Delay(20000, true, () =>
            {
                if (this.GetMapCharactersTotal() < 1)
                {
                    tmr2.Cancel();
                    this.IsControling = false;
                    return;
                }

                for (int i = 0; i < j; i++)
                {
                    if (this.Monster[i].IsAlive == false)
                    {
                        this.Monster[i].HP      = MobFactory.MonsterMaxHP(this.Monster[i].Level);
                        this.Monster[i].IsAlive = true;
                        this.Monster[i].State   = (this.Monster[i].MoveType == 0 ? (byte)0 : (byte)1);
                        foreach (Character All in this.Characters)
                        {
                            if (All.MapX == this.MapX && All.MapY == this.MapY)
                            {
                                MonsterPacket.regenrMonster(All.Client, this.Monster[i]);
                                MonsterPacket.spawnMonster(All.Client, this.Monster[i], 0, 0, 0, 0);
                            }
                        }
                    }
                }
            });
            tmr2.Execute();
        }