Exemplo n.º 1
0
        //创建怪物
        public void CreateMonster(GameStruct.GeneratorInfo info)
        {
            GameStruct.MonsterInfo minfo = ConfigManager.Instance().GetMonsterInfo(info.monsterid);
            if (minfo == null)
            {
                Log.Instance().WriteLog("无法找到怪物id:" + info.monsterid.ToString());
                return;
            }
            MonsterObject obj;
            Random        rd = new Random();

            for (int i = 0; i < info.amount; i++)
            {
                short cx    = 0;
                short cy    = 0;
                byte  index = 0;
                while (true)
                {
                    cx = (short)rd.Next((int)info.bound_x, (int)(info.bound_x + info.bound_cx));
                    cy = (short)rd.Next((int)info.bound_y, (int)(info.bound_y + info.bound_cy));
                    if (CanMove(cx, cy))
                    {
                        break;
                    }
                    index++;
                    if (index >= 100)
                    {
                        cx = cy = 0;
                        break;
                    }
                }
                if (cx == 0 && cy == 0)
                {
                    Log.Instance().WriteLog("创建怪物失败,无法找到落脚点" + this.GetMapInfo().name + "怪物名称:" + minfo.name + "地图id:" +
                                            info.mapid.ToString() + " x:" + info.bound_x.ToString() + " y:" + info.bound_y.ToString());
                    return;
                }
                obj = new MonsterObject(minfo.id, minfo.ai, cx, cy, true);
                if (info.dir == DIR.MAX_DIRSIZE)
                {
                    obj.SetDir(GameStruct.DIR.Random_Dir());
                }
                else
                {
                    obj.SetDir(info.dir);
                }
                obj.SetRebirthTime(info.time);


                AddObject(obj);
            }
        }
Exemplo n.º 2
0
        public void SendInfo(PlayerObject play = null)
        {
            //  byte[] data2 = {  100, 0, 1, 4, 210, 193, 183, 227, 0, 0, 0 };
            GameStruct.MonsterInfo info = ConfigManager.Instance().GetMonsterInfo(id);
            if (info == null)
            {
                Log.Instance().WriteLog("获取黑暗骑士信息失败!!!" + id.ToString());
                return;
            }
            GameBase.Network.PacketOut outpack = null;
            if (play == null)
            {
                outpack = new GameBase.Network.PacketOut();
            }
            else
            {
                outpack = new GameBase.Network.PacketOut(play.GetGamePackKeyEx());
            }
            outpack.WriteUInt16(81);
            outpack.WriteUInt16(2069);
            outpack.WriteUInt32(GetTypeId());
            outpack.WriteUInt32(play.GetTypeId());
            byte[] data = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            outpack.WriteBuff(data);
            outpack.WriteUInt32(info.lookface);
            outpack.WriteInt16(GetCurrentX());
            outpack.WriteInt16(GetCurrentY());
            outpack.WriteInt16(0); //未知
            outpack.WriteUInt16(info.level);
            outpack.WriteUInt32(info.id);
            outpack.WriteInt32(0);
            outpack.WriteInt32(info.life);
            outpack.WriteInt16(GetDir());
            byte[] data1 = { 100, 0, 1, 4, 210, 193, 183, 227, 0, 0, 0 };
            outpack.WriteBuff(data1);

            if (play != null)
            {
                play.SendData(outpack.Flush());
            }
            else
            {
                //广播
                data = outpack.Flush();
                this.BrocatBuffer(data);
            }
        }
Exemplo n.º 3
0
        public EudemonObject(RoleData_Eudemon info,PlayerObject _play)
        {
            type = OBJECTTYPE.EUDEMON;
            mInfo = info;
            play = _play;
            mPlayObject = new Dictionary<uint, PlayerObject>();
            typeid = info.GetTypeID();
            mMonsterInfo = EudemonObject.GetMonsterInfo(play, info.itemid);
            mbIsCombo = false;
            mAttackSpeed = new GameBase.Core.TimeOut();
            mAttackSpeed.SetInterval(GameBase.Config.Define.ROLE_ATTACK_SPEED);
            mAttackSpeed.Update();

            mMagicAttackSpeed = new List<GameBase.Core.TimeOut>();
            this.SetRiding(false);
            this.SetState(EUDEMONSTATE.NROMAL);
        }
Exemplo n.º 4
0
        //怪物复活
        //init 是否是第一次初始化的怪物
        public void Alive(bool init = true)
        {
            mInfo = ConfigManager.Instance().GetMonsterInfo(id);
            Name = mInfo.name;
            attr.life =attr.life_max = mInfo.life;
            if (!init)
            {
                this.SetPoint(mInitPoint.x, mInitPoint.y);
            }
            SetLastWalkTime(System.Environment.TickCount);
            LastDieTime = System.Environment.TickCount;

            SetWalkTime(IRandom.Random(1000, 60 * 1000));

            if (!init)
            {
                Walk(DIR.MAX_DIRSIZE);
            }
        }
Exemplo n.º 5
0
        //怪物复活
        //init 是否是第一次初始化的怪物
        public void Alive(bool init = true)
        {
            mInfo     = ConfigManager.Instance().GetMonsterInfo(id);
            Name      = mInfo.name;
            attr.life = attr.life_max = mInfo.life;
            if (!init)
            {
                this.SetPoint(mInitPoint.x, mInitPoint.y);
            }
            SetLastWalkTime(System.Environment.TickCount);
            LastDieTime = System.Environment.TickCount;

            SetWalkTime(IRandom.Random(1000, 60 * 1000));


            if (!init)
            {
                Walk(DIR.MAX_DIRSIZE);
            }
        }
Exemplo n.º 6
0
 public void SetMosterInfo(GameStruct.MonsterInfo info)
 {
     mMonsterInfo = info;
 }