Example #1
0
    private void initMapNpc()
    {
        foreach (KeyValuePair <string, MapNpc> kp in npcCollection)
        {
            MapNpc  npc    = kp.Value;
            DataRow npcCfg = EditorTool.getNpc(npc.id);
            try
            {
                kp.Value.modelId = npcCfg["modelId"].ToString();
                kp.Value.modelId = "n_fujiaertongnv";
            }
            catch
            {
                kp.Value.modelId = npcCfg["modelId"].ToString();
            }

            Vector2 pos = PathUtilEdit.logicCenter2Real(npc.x, npc.y);


            float h1 = EditorData.terrainMan.GetHeight(pos.x, pos.y);
            if (kp.Value.id == 101001001)
            {
                Debug.Log("x:" + pos.x + ",y:" + pos.y + ",int x:" + npc.x + "," + npc.y + ",orig:" + PathUtilEdit.origin_x + "," + PathUtilEdit.origin_z);
            }
            Vector3 npcPos = new Vector3(pos.x, h1, pos.y);
            npcHelper.LoadNpc(kp.Value, npcPos);
            // mapNpcMgr.ShowSkillFx((GameObject.Find(RoleCtrl) as RoleCtrl), "n_fujiaertongnv");
            //mapNpcMgr.ShowSkillFx(null, kp.Value.modelId, npcPos);
        }
    }
Example #2
0
        private void onRemoveNpc()
        {
            string npcId     = input_npcId.text;
            MapNpc targetNpc = null;

            foreach (KeyValuePair <string, MapNpc> kp in EditMapManager.Instance.npcCollection)
            {
                if (kp.Value.id == int.Parse(npcId))
                {
                    targetNpc = kp.Value;
                    break;
                }
            }
            if (targetNpc == null)
            {
                Debug.Log("************未找到该NPC********************");
            }
            else
            {
                //GameObject bossLayer = GameObject.Find("bossLayer");
                //Transform oTrans = bossLayer.transform.Find(targetNpc.modelId);
                //GameObject o = oTrans.gameObject;
                GameObject o = GameObject.Find(targetNpc.modelId);
                GameObject.Destroy(o);
                EditMapManager.Instance.editMapNpc(targetNpc, EditMapManager.OPERATE_DELETE);
            }
        }
Example #3
0
    public static List <MapNpc> readDatas(DataReader reader)
    {
        int len = reader.ReadInt32();

        int[]    ID      = reader.ReadInt32Array(len);
        int[]    mapID   = reader.ReadInt32Array(len);
        Vec3[]   NPCPos  = Vec3.createArray(reader, len);
        float[]  posTo   = reader.ReadFloatArray(len);
        string[] modelID = reader.ReadStringArray(len);

        List <MapNpc> list = new List <MapNpc>();

        MapNpc temp;

        for (int i = 0; i < len; i++)
        {
            temp = new MapNpc();
            list.Add(temp);
            temp.ID      = ID[i];
            temp.mapID   = mapID[i];
            temp.NPCPos  = NPCPos[i];
            temp.posTo   = posTo[i];
            temp.modelID = modelID[i];
        }
        return(list);
    }
Example #4
0
    public void AddNpc(DataRow data, MapNpc node)
    {
        //int id = int.Parse(data["id"].ToString());
        //MapNpc node = new MapNpc(id);
        node.type = int.Parse(data["type"].ToString());
        if (node.type == 1)
        {
            node.ai = 1;
        }
        else
        {
            node.ai = 4;
        }
        node.npcName = data["name"].ToString();
        node.modelId = data["modelId"].ToString();
        editMapNpc(node, OPERATE_ADD);
        Vector3    npcPos = new Vector3(0, 0, 0);
        GameObject obj    = npcHelper.LoadNpc(node, npcPos);

        EditorTool.CenterObj(obj);
        if (EditorData.terrainMan != null)
        {
            Vector3 pos = obj.transform.localPosition;
            pos.y = EditorData.terrainMan.GetHeight(pos.x, pos.z);
            obj.transform.localPosition = pos;
            IntPoint pt = PathUtilEdit.Real2Logic(pos);
            node.x = pt.x;
            node.y = pt.y;

            //EditorTool.LookObj(obj);
        }
    }
Example #5
0
        public void Run(byte faction)
        {
            MapInstance map     = ServerManager.Instance.GenerateMapInstance(149, faction == 1 ? MapInstanceType.Act4ShipAngel : MapInstanceType.Act4ShipDemon, null);
            MapNpc      mapNpc1 = new MapNpc()
            {
                NpcVNum = 613, MapNpcId = map.GetNextNpcId(), Dialog = 434, MapId = 149, MapX = 8, MapY = 28, IsMoving = false, Position = 1, IsSitting = false
            };

            mapNpc1.Initialize(map);
            map.AddNPC(mapNpc1);
            MapNpc mapNpc2 = new MapNpc()
            {
                NpcVNum = 540, MapNpcId = map.GetNextNpcId(), Dialog = 433, MapId = 149, MapX = 31, MapY = 28, IsMoving = false, Position = 3, IsSitting = false
            };

            mapNpc2.Initialize(map);
            map.AddNPC(mapNpc2);
            while (true)
            {
                openShip();
                Thread.Sleep(60 * 1000);
                map.Broadcast(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SHIP_MINUTE"), 0));
                lockShip();
                Thread.Sleep(30 * 1000);
                map.Broadcast(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SHIP_SECONDS"), 30), 0));
                Thread.Sleep(20 * 1000);
                map.Broadcast(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SHIP_SECONDS"), 10), 0));
                Thread.Sleep(10 * 1000);
                map.Broadcast(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SHIP_SETOFF"), 0));
                List <ClientSession> sessions = map.Sessions.Where(s => s?.Character != null).ToList();
                Observable.Timer(TimeSpan.FromSeconds(0)).Subscribe(X => teleportPlayers(sessions));
            }
        }
Example #6
0
        public static bool ToMapNpc(MapNpcDTO input, MapNpc output)
        {
            if (input == null)
            {
                return(false);
            }

            output.Dialog      = input.Dialog;
            output.Effect      = input.Effect;
            output.EffectDelay = input.EffectDelay;
            output.IsDisabled  = input.IsDisabled;
            output.IsMoving    = input.IsMoving;
            output.IsSitting   = input.IsSitting;
            output.MapId       = input.MapId;
            output.MapNpcId    = input.MapNpcId;
            output.MapX        = input.MapX;
            output.MapY        = input.MapY;
            output.Name        = input.Name;
            output.NpcVNum     = input.NpcVNum;
            output.Position    = input.Position;
            output.Say         = input.Say;
            output.Delay       = input.Delay;

            return(true);
        }
        public void ShowShop(string packet)
        {
            Logger.Debug(packet, Session.SessionId);
            string[] packetsplit = packet.Split(' ');
            long     owner;
            int      mode;

            if (packetsplit.Length > 2)
            {
                if (!int.TryParse(packetsplit[2], out mode))
                {
                    return;
                }
                if (mode == 1)
                {
                    // User Shop
                    if (packetsplit.Length <= 3)
                    {
                        return;
                    }
                    if (!long.TryParse(packetsplit[3], out owner))
                    {
                        return;
                    }
                    KeyValuePair <long, MapShop> shopList = Session.CurrentMap.UserShops.FirstOrDefault(s => s.Value.OwnerId.Equals(owner));
                    LoadShopItem(owner, shopList);
                }
                else
                {
                    // Npc Shop , ignore if has drop
                    short MapNpcId = -1;
                    if (!short.TryParse(packetsplit[3], out MapNpcId))
                    {
                        return;
                    }
                    MapNpc npc = Session.CurrentMap.Npcs.FirstOrDefault(n => n.MapNpcId.Equals(MapNpcId));
                    if (npc == null)
                    {
                        return;
                    }
                    if (npc.Npc.Drops.Any(s => s.MonsterVNum != null) && npc.Npc.Race == 8 && (npc.Npc.RaceType == 7 || npc.Npc.RaceType == 5))
                    {
                        Session.SendPacket(Session.Character.GenerateDelay(5000, 4, $"#guri^400^{npc.MapNpcId}"));
                    }
                    else if (npc.Npc.VNumRequired > 0 && npc.Npc.Race == 8 && (npc.Npc.RaceType == 7 || npc.Npc.RaceType == 5))
                    {
                        Session.SendPacket(Session.Character.GenerateDelay(6000, 4, $"#guri^400^{npc.MapNpcId}"));
                    }
                    else if (npc.Npc.MaxHP == 0 && !npc.Npc.Drops.Any(s => s.MonsterVNum != null) && npc.Npc.Race == 8 && (npc.Npc.RaceType == 7 || npc.Npc.RaceType == 5))
                    {
                        // #guri^710^X^Y^MapNpcId
                        Session.SendPacket(Session.Character.GenerateDelay(5000, 1, $"#guri^710^162^85^{npc.MapNpcId}"));
                    }
                    else if (!string.IsNullOrEmpty(npc?.GetNpcDialog()))
                    {
                        Session.SendPacket(npc.GetNpcDialog());
                    }
                }
            }
        }
Example #8
0
    void showNpcAdd(int tp)
    {
        if (allNpcDict == null)
        {
            allNpcDict = new Dictionary <int, DataRow>();
            DataTable dt = EditorTool.getAllNpc();
            foreach (DataRow row in  dt.Select())
            {
                int id;
                if (int.TryParse(row["id"].ToString(), out id))
                {
                    allNpcDict[id] = row;
                }
            }
        }
        if (curNpcType != tp || npcLabels == null || allNpcData == null)
        {
            allNpcData = EditorTool.getNpcByType(tp);
            if (allNpcData != null)
            {
                npcLabels = new string[allNpcData.Length];

                for (int i = 0; i < allNpcData.Length; i++)
                {
                    npcLabels[i] = allNpcData[i]["id"].ToString() + "," + allNpcData[i]["name"].ToString();
                }
            }
        }
        if (npcLabels != null)
        {
            GUILayout.BeginHorizontal();
            selNpc = EditorGUILayout.Popup(selNpc, npcLabels);
            if (GUILayout.Button("添加"))
            {
                DataRow data = allNpcData[selNpc];
                int     id;
                if (input_id > 0)
                {
                    if (!allNpcDict.TryGetValue(input_id, out data))
                    {
                        Debug.LogError("npc id:" + input_id + ",不存在!");
                        return;
                    }
                    id = input_id;
                }
                else
                {
                    id = int.Parse(data["id"].ToString());
                }
                MapNpc node = new MapNpc(id);

                //warp.warpX = EditorGUILayout.IntField("传送门 X:", warp.warpX);

                npcHelper.AddNpc(data, node);
            }
            GUILayout.EndHorizontal();
            input_id = EditorGUILayout.IntField("输入npcId:", input_id);
        }
    }
Example #9
0
        public void GenerateInPacketIsNotCorruptedForNpc()
        {
            var mapNpcTest = new MapNpc();

            var packet = PacketFactory.Serialize(new[] { mapNpcTest.GenerateIn() });

            Assert.AreEqual("in 2 - 0 0 0 0 0 0 0 0 0 -1 1 0 -1 - 2 -1 0 0 0 0 0 0 0 0", packet);
        }
Example #10
0
        public LargeNpc(MapNpc npc)
        {
            On <SlowClockEvent>(e => { _sprite.Frame = e.FrameCount; });
            On <ShowMapMenuEvent>(OnRightClick);

            _npc              = npc ?? throw new ArgumentNullException(nameof(npc));
            _sprite           = AttachChild(new MapSprite <LargeNpcId>((LargeNpcId)_npc.ObjectNumber, DrawLayer.Underlay - 1, 0, SpriteFlags.BottomAligned));
            _sprite.Selected += (sender, e) => { e.RegisterHit(this); e.Handled = true; };
        }
Example #11
0
        public override void Import(DCFG cfg)
        {
            MapNpc data = cfg as MapNpc;

            this.ID    = data.ID;
            this.NpcID = data.NpcID;
            this.Pos   = data.Pos;
            this.Face  = data.Face;
        }
Example #12
0
        public SmallNpc(MapNpc npc)
        {
            On <SlowClockEvent>(e => { _sprite.Frame = e.FrameCount; });
            On <ShowMapMenuEvent>(OnRightClick);

            _npc              = npc ?? throw new ArgumentNullException(nameof(npc));
            _sprite           = AttachChild(new MapSprite(npc.SpriteOrGroup, DrawLayer.Underlay - 1, 0, SpriteFlags.BottomAligned));
            _sprite.Selected += (sender, e) => e.RegisterHit(this);
        }
Example #13
0
        public static void DrawNpc(RendererDestinationData destData, Map activeMap, Enums.MapID targetMapID, int npcSlot)
        {
            MapNpc npc = activeMap.MapNpcs[npcSlot];

            if (npc != null && npc.Num > 0 && npc.ScreenActive)
            {
                SpriteRenderer.DrawSprite(destData, activeMap, targetMapID, npc);
            }
        }
Example #14
0
 public void EnterWorld(MapConfig data)
 {
     for (int i = 0; i < data.MapNpcs.Count; i++)
     {
         MapNpc cfg = data.MapNpcs[i];
         DActor db  = ReadCfgActor.GetDataById(cfg.NpcID);
         if (db == null)
         {
             continue;
         }
         XCharacter c = new XCharacter();
         c.Id   = cfg.NpcID;
         c.Name = db.Name;
         c.GUID = GTGUID.NewGUID();
         c.PosX = cfg.Pos.x;
         c.PosY = cfg.Pos.y;
         c.PosZ = cfg.Pos.z;
         c.Face = cfg.Face;
         c.Type = (int)EActorType.NPC;
         c.Camp = (int)EBattleCamp.CT_PVE_NEUTRAL;
         c.CurAttrs.AddRange(GTTools.GetListFromEnumNames <int>(typeof(EAttr)));
         foreach (var current in db.Attrs)
         {
             c.CurAttrs[(int)current.Key - 1] = current.Value;
         }
         m_AllActors.Add(c.GUID, c);
     }
     for (int i = 0; i < data.MapAreaMonsters.Count; i++)
     {
         MapAreaMonster cfg = data.MapAreaMonsters[i];
         DActor         db  = ReadCfgActor.GetDataById(cfg.MonsterID);
         if (db == null)
         {
             continue;
         }
         for (int k = 0; k < cfg.Points.Count; k++)
         {
             MapPoint   p = cfg.Points[k];
             XCharacter c = new XCharacter();
             c.Id   = cfg.MonsterID;
             c.Name = db.Name;
             c.GUID = GTGUID.NewGUID();
             c.PosX = p.Pos.x;
             c.PosY = p.Pos.y;
             c.PosZ = p.Pos.z;
             c.Face = p.EulerAngles.y;
             c.Type = (int)EActorType.MONSTER;
             c.Camp = (int)EBattleCamp.CT_PVE_ENEMY;
             c.CurAttrs.AddRange(GTTools.GetListFromEnumNames <int>(typeof(EAttr)));
             foreach (var current in db.Attrs)
             {
                 c.CurAttrs[(int)current.Key - 1] = current.Value;
             }
             m_AllActors.Add(c.GUID, c);
         }
     }
 }
Example #15
0
        public override void OnNpcDeath(PacketHitList hitlist, ICharacter attacker, MapNpc npc)
        {
            var map = MapManager.RetrieveActiveMap(npc.MapID);

            if (!map.ActiveNpc.Enumerate().Where(x => x.Num > 0).Where(x => x != npc).Any())
            {
                SetCompletionTile(MapManager.RetrieveActiveMap(npc.MapID));
            }
        }
Example #16
0
        public void GenerateInPacketIsNotCorruptedForNpc()
        {
            var mapNpcTest = new MapNpc(null, new GenericDao <Database.Entities.Shop, ShopDto>(_logger),
                                        new GenericDao <Database.Entities.ShopItem, ShopItemDto>(_logger), new List <NpcMonsterDto>(), _logger);

            var packet = PacketFactory.Serialize(new[] { mapNpcTest.GenerateIn() });

            Assert.AreEqual("in 2 - 0 0 0 0 0 0 0 0 0 -1 1 0 -1 - 2 -1 0 0 0 0 0 0 0 0", packet);
        }
Example #17
0
        public override void OnNpcSpawn(IMap map, MapNpcPreset npc, MapNpc spawnedNpc, PacketHitList hitlist)
        {
            spawnedNpc.MaxHPBonus = 300;
            spawnedNpc.SpAtkBuff  = 1;
            spawnedNpc.SpDefBuff  = 1;
            spawnedNpc.HP         = spawnedNpc.MaxHP;

            Main.RefreshCharacterTraits(spawnedNpc, map, hitlist);
        }
Example #18
0
        public override DCFG Export()
        {
            MapNpc data = new MapNpc();

            data.ID    = this.ID;
            data.NpcID = this.NpcID;
            data.Pos   = this.Pos;
            data.Face  = this.Face;
            return(data);
        }
Example #19
0
    public GameObject LoadNpc(MapNpc npc, Vector3 pos)
    {
        string fxname = npc.modelId;
        Object prefab = EditorTool.LoadAssetBundle("model/" + fxname);

        if (prefab == null)
        {
            Debug.LogError("npc 资源找不到:" + fxname);
            npc.modelId = "n_fujiaertongnv";
            fxname      = npc.modelId;
            prefab      = EditorTool.LoadAssetBundle("model/" + fxname);
        }

        string subpath = "npc";

        switch (npc.type)
        {
        case 1:
            subpath = "monster";
            break;

        default:
            subpath = "npc";
            break;
        }
        Transform parentTrans = getRoot().FindChild(subpath);

        if (parentTrans == null)
        {
            GameObject subroot = new GameObject(subpath);
            subroot.transform.SetParent(getRoot());
            parentTrans = subroot.transform;
        }
        string nodeName = "npc_" + npc.uniqueId;



        GameObject npcObj  = (GameObject)GameObject.Instantiate(prefab);
        GameObject npcCont = new GameObject(nodeName);

        npcObj.transform.SetParent(npcCont.transform);
        npcObj.transform.localPosition = Vector3.zero;

        npcCont.transform.SetParent(parentTrans);
        //x y坐标
        npcCont.transform.localPosition = pos;
        //direction 是弧度 * 1000 只记了y方向的旋转
        //npcCont.transform.localRotation.eulerAngles = new Vector3(0,npc.direction / 1000 / 2 / Mathf.PI * 360,0);
        MapNpcView view = npcCont.AddComponent <MapNpcView>();

        view.data  = npc;
        npc.target = npcCont;
        return(npcCont);
    }
Example #20
0
    static MapObject BuildNpcObject(
        int tileWidth,
        int tileHeight,
        Dictionary <ushort, string> functionsByEventId,
        GetTileFunc getTileFunc,
        Dictionary <int, int> npcPathIndices,
        int npcIndex,
        MapNpc npc,
        ref int nextId)
    {
        var objProps = new List <TiledProperty>
        {
            new(Prop.Visual, npc.SpriteOrGroup.ToString()),
            new(Prop.Flags, npc.Flags.ToString()),
            new(Prop.Triggers, npc.Triggers.ToString()),
            new(Prop.Movement, npc.Movement.ToString()),
            new(Prop.Type, npc.Type.ToString()),
        };

        if (!npc.Id.IsNone)
        {
            objProps.Add(new TiledProperty(Prop.Id, npc.Id.ToString()));
        }
        if (npc.Node != null)
        {
            objProps.Add(new TiledProperty(Prop.Script, functionsByEventId[npc.Node.Id]));
        }
        if (!npc.Sound.IsNone)
        {
            objProps.Add(new TiledProperty(Prop.Sound, npc.Sound.ToString()));
        }
        if (npcPathIndices.TryGetValue(npcIndex, out var pathObjectId))
        {
            objProps.Add(TiledProperty.Object(Prop.Path, pathObjectId));
        }

        var(tileId, tileW, tileH) = getTileFunc(npc.SpriteOrGroup);
        return(new MapObject
        {
            Id = nextId++,
            Gid = tileId ?? 0,
            Name = $"NPC{npcIndex} {npc.Id}",
            Type = ObjectGroupMapping.TypeName.Npc,
            X = npc.Waypoints[0].X * tileWidth,
            Y = npc.Waypoints[0].Y * tileHeight,
            Width = tileW,
            Height = tileH,
            Properties = objProps
        });
    }
Example #21
0
        public void LoadNpcs()
        {
            var partitioner = Partitioner.Create(DaoFactory.MapNpcDao.Where(s => s.MapId == Map.MapId),
                                                 EnumerablePartitionerOptions.None);

            Parallel.ForEach(partitioner, npc =>
            {
                MapNpc mapNpc = npc.Adapt <MapNpc>();
                mapNpc.Initialize(_npcMonsters.Find(s => s.NpcMonsterVNum == mapNpc.VNum));
                mapNpc.MapInstance     = this;
                mapNpc.MapInstanceId   = MapInstanceId;
                _npcs[mapNpc.MapNpcId] = mapNpc;
            });
        }
Example #22
0
        private static MapNpcDTO update(MapNpc entity, MapNpcDTO mapNpc, OpenNosContext context)
        {
            if (entity != null)
            {
                Mapper.Mappers.MapNpcMapper.ToMapNpc(mapNpc, entity);
                context.Entry(entity).State = EntityState.Modified;
                context.SaveChanges();
            }
            if (Mapper.Mappers.MapNpcMapper.ToMapNpcDTO(entity, mapNpc))
            {
                return(mapNpc);
            }

            return(null);
        }
Example #23
0
        public override void OnNpcSpawn(IMap map, MapNpcPreset npc, MapNpc spawnedNpc, PacketHitList hitlist)
        {
            base.OnNpcSpawn(map, npc, spawnedNpc, hitlist);

            if (Data.Started)
            {
                if (!map.IsZoneOrObjectSandboxed())
                {
                    spawnedNpc.Unrecruitable = true;
                    spawnedNpc.Shiny         = Server.Enums.Coloration.Shiny;

                    PacketBuilder.AppendNpcSprite(map, hitlist, spawnedNpc.MapSlot);
                }
            }
        }
Example #24
0
    public SmallNpc(MapNpc npc)
    {
        _npc    = npc ?? throw new ArgumentNullException(nameof(npc));
        _sprite = AttachChild(new MapSprite(npc.SpriteOrGroup, DrawLayer.Underlay - 1, 0, SpriteFlags.BottomAligned)
        {
            SelectionCallback = registerHit => { registerHit(this); return(false); }
        });

        On <ShowMapMenuEvent>(OnRightClick);
        On <SlowClockEvent>(e =>
        {
            _frameCount  += e.Delta;
            _sprite.Frame = _frameCount;
        });
    }
Example #25
0
 public void editMapNpc(MapNpc node, int addOrDelete)
 {
     if (npcCollection.ContainsKey(node.uniqueId) && addOrDelete == OPERATE_ADD)
     {
         Debug.Log("这个npc(boss)已经被添加过了");
     }
     else if (npcCollection.ContainsKey(node.uniqueId) && addOrDelete == OPERATE_DELETE)
     {
         npcCollection.Remove(node.uniqueId);
     }
     else if (!npcCollection.ContainsKey(node.uniqueId) && addOrDelete == OPERATE_ADD)
     {
         npcCollection[node.uniqueId] = node;
     }
 }
Example #26
0
        private void ExecuteHandler(ClientSession session)
        {
            if (!session.HasCurrentMapInstance)
            {
                return;
            }

            if (Type == 1)
            {
                // User Shop
                KeyValuePair <long, MapShop> shopList = session.CurrentMapInstance.UserShops.FirstOrDefault(s => s.Value.OwnerId.Equals(OwnerId));
                session.LoadShopItem(OwnerId, shopList);
            }
            else
            {
                // Npc Shop , ignore if has drop
                MapNpc npc = session.CurrentMapInstance.Npcs.Find(n => n.MapNpcId.Equals((int)OwnerId));
                if (npc == null)
                {
                    return;
                }

                session.Character.OnTalk(new TalkEventArgs(npc));

                if (npc.Npc.Drops.Any(s => s.MonsterVNum != null) && npc.Npc.Race == 8 &&
                    (npc.Npc.RaceType == 7 || npc.Npc.RaceType == 5))
                {
                    session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 4, $"#guri^400^{npc.MapNpcId}"));
                }
                else if (npc.Npc.VNumRequired > 0 && npc.Npc.Race == 8 &&
                         (npc.Npc.RaceType == 7 || npc.Npc.RaceType == 5))
                {
                    session.SendPacket(UserInterfaceHelper.GenerateDelay(6000, 4, $"#guri^400^{npc.MapNpcId}"));
                }
                else if (npc.Npc.MaxHP == 0 && npc.Npc.Drops.All(s => s.MonsterVNum == null) && npc.Npc.Race == 8 &&
                         (npc.Npc.RaceType == 7 || npc.Npc.RaceType == 5))
                {
                    session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 1,
                                                                         $"#guri^710^{npc.MapX}^{npc.MapY}^{npc.MapNpcId}")); // #guri^710^DestinationX^DestinationY^MapNpcId
                }
                else if (!string.IsNullOrEmpty(npc.GetNpcDialog()))
                {
                    session.SendPacket(npc.GetNpcDialog());
                }
            }
        }
Example #27
0
        public static void DrawNpcBars(RendererDestinationData destData, Map map, Enums.MapID targetMapID, int npcSlot)
        {
            MapNpc npc = map.MapNpcs[npcSlot];
            int    x, y;

            if (npc != null && npc.HP > 0 && npc.Num > 0 && npc.ScreenActive)
            {
                if (npc.HP != npc.MaxHP)
                {
                    //if (Npc.NpcHelper.Npcs[npc.Num].Big) {
                    //    x = (npc.Location.X * Constants.TILE_WIDTH - 9 + npc.Offset.X) - (Globals.NewMapX * Constants.TILE_WIDTH) - Globals.NewMapXOffset;
                    //    y = (npc.Location.Y * Constants.TILE_HEIGHT + npc.Offset.Y) - (Globals.NewMapY * Constants.TILE_HEIGHT) - Globals.NewMapYOffset;

                    //    Box hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + 50, destData.Location.Y + y + 36));
                    //    destData.Draw(hpBox, Color.Black, false, true);
                    //    if (npc.MaxHP < 1) {
                    //        hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + ((npc.HP / 100) / ((npc.MaxHP + 1) / 100) * 50), destData.Location.Y + y + 36));
                    //    } else {
                    //        double
                    //        hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + ((npc.HP / 100) / (double)((double)npc.MaxHP / 100) * 50)), destData.Location.Y + y + 36));
                    //    }
                    //    destData.Draw(hpBox, Color.LightGreen, false, true);
                    //} else {
                    int npcX = npc.Location.X;
                    int npcY = npc.Location.Y;
                    Renderers.Maps.SeamlessWorldHelper.ConvertCoordinatesToBorderless(map, targetMapID, ref npcX, ref npcY);

                    x = ScreenRenderer.ToTileX(npcX) + npc.Offset.X; //(npc.X * Constants.TILE_WIDTH + sx + npc.XOffset) - (Globals.NewMapX * Constants.TILE_WIDTH) - Globals.NewMapXOffset;
                    y = ScreenRenderer.ToTileY(npcY) + npc.Offset.Y; //(npc.Y * Constants.TILE_HEIGHT + sx + npc.YOffset) - (Globals.NewMapY * Constants.TILE_HEIGHT) - Globals.NewMapYOffset;

                    Box hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + 32, destData.Location.Y + y + 36));
                    destData.Draw(hpBox, Color.Black, false, true);
                    if (npc.MaxHP < 1)
                    {
                        hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + 32, destData.Location.Y + y + 36));
                    }
                    else
                    {
                        hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x + 1, destData.Location.Y + y + 33), new Point(Convert.ToInt32(destData.Location.X + x + (Logic.MathFunctions.CalculatePercent(npc.HP, npc.MaxHP) * 0.01) * 31), destData.Location.Y + y + 35));
                    }
                    destData.Draw(hpBox, Color.LightGreen, false, true);
                    //}
                }
            }
        }
Example #28
0
        public ConcurrentDictionary <long, MapNpc> Create(MapInstance mapInstance)
        {
            var npcs        = new ConcurrentDictionary <long, MapNpc>();
            var partitioner = Partitioner.Create(_mapNpcs.Where(s => s.MapId == mapInstance.Map.MapId),
                                                 EnumerablePartitionerOptions.None);

            Parallel.ForEach(partitioner, npc =>
            {
                MapNpc mapNpc = npc.Adapt <MapNpc>();
                mapNpc.Initialize(_npcMonsters.Find(s => s.NpcMonsterVNum == mapNpc.VNum));
                mapNpc.MapInstance    = mapInstance;
                mapNpc.MapInstanceId  = mapInstance.MapInstanceId;
                mapNpc.Shop           = LoadShop(mapNpc.MapNpcId);
                npcs[mapNpc.MapNpcId] = mapNpc;
            });

            return(npcs);
        }
Example #29
0
        private void onAddNpc()
        {
            NpcConfig npcCfg = ConfigAsset.Instance.getNpcConfigs(int.Parse(input_npcId.text));

            if (npcCfg == null)
            {
                Debug.Log("该NPC不在npc表中  " + int.Parse(input_npcId.text));
                return;
            }
            else
            {
                try
                {
                    input_npcModel.text = int.Parse(npcCfg.modelId).ToString();
                    input_npcModel.text = "n_fujiaertongnv";
                }
                catch
                {
                    input_npcModel.text = npcCfg.modelId;
                }
            }
            MapNpc npcNode = new MapNpc(int.Parse(input_npcId.text));

            npcNode.ntype     = npcCfg.type;
            npcNode.x         = int.Parse(input_npcX.text);
            npcNode.y         = int.Parse(input_npcY.text);
            npcNode.ai        = int.Parse(input_npcAI.text);
            npcNode.num       = int.Parse(input_npcNum.text);
            npcNode.interval  = int.Parse(input_npcInterval.text);
            npcNode.scope     = int.Parse(input_npcScope.text);
            npcNode.chase     = int.Parse(input_npcChase.text);
            npcNode.enemyType = int.Parse(input_npcEnemyType.text);
            npcNode.level     = int.Parse(input_npcLevel.text);

            EditMapManager.Instance.editMapNpc(npcNode, EditMapManager.OPERATE_ADD);

            float   h1     = EditMapManager.Instance.terrainMan.GetHeight(int.Parse(input_npcX.text), int.Parse(input_npcY.text));
            Vector3 npcPos = new Vector3(int.Parse(input_npcX.text), h1, int.Parse(input_npcY.text));

            npcNode.modelId = input_npcModel.text;
            EditMapManager.Instance.mapNpcMgr.Preload(input_npcModel.text, npcPos, npcNode.uniqueId.ToString());
            // mapNpcMgr.ShowSkillFx((GameObject.Find(RoleCtrl) as RoleCtrl), "n_fujiaertongnv");
            EditMapManager.Instance.mapNpcMgr.ShowSkillFx(null, input_npcModel.text, npcPos);
        }
        public static void Run(byte faction)
        {
            MapInstance map     = ServerManager.GenerateMapInstance(148, faction == 1 ? MapInstanceType.Act4ShipAngel : MapInstanceType.Act4ShipDemon, new InstanceBag());
            MapNpc      mapNpc1 = new MapNpc
            {
            };

            mapNpc1.Initialize(map);
            map.AddNpc(mapNpc1);
            MapNpc mapNpc2 = new MapNpc
            {
            };

            mapNpc2.Initialize(map);
            map.AddNpc(mapNpc2);
            Observable.Interval(TimeSpan.FromMinutes(1)).Subscribe(obs =>
            {
                OpenShip();
                Observable.Timer(TimeSpan.FromMinutes(1)).Subscribe(observer =>
                {
                    map.Broadcast(
                        UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SHIP_MINUTE"), 0));
                    LockShip();
                });
                Observable.Timer(TimeSpan.FromSeconds(30)).Subscribe(observer =>
                {
                    map.Broadcast(UserInterfaceHelper.GenerateMsg(
                                      string.Format(Language.Instance.GetMessageFromKey("SHIP_SECONDS"), 30), 0));
                });
                Observable.Timer(TimeSpan.FromSeconds(50)).Subscribe(observer =>
                {
                    map.Broadcast(UserInterfaceHelper.GenerateMsg(
                                      string.Format(Language.Instance.GetMessageFromKey("SHIP_SECONDS"), 10), 0));
                });
                Observable.Timer(TimeSpan.FromMinutes(1)).Subscribe(observer =>
                {
                    map.Broadcast(
                        UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SHIP_SETOFF"), 0));
                    List <ClientSession> sessions = map.Sessions.Where(s => s?.Character != null).ToList();
                    Observable.Timer(TimeSpan.FromSeconds(0)).Subscribe(x => TeleportPlayers(sessions));
                });
            });
        }
Example #31
0
 public static TcpPacket CreateNpcAttack(MapNpc mapNpc)
 {
     return TcpPacket.CreatePacket("npcattack", mapNpc.MapID, mapNpc.MapSlot.ToString());
 }
Example #32
0
        public static TcpPacket CreateNpcVolatileStatus(MapNpc mapNpc)
        {
            TcpPacket packet = TcpPacket.CreatePacket("npcvolatilestatus", mapNpc.MapID, mapNpc.MapSlot.ToString(), mapNpc.VolatileStatus.Count.ToString());

                for (int j = 0; j < mapNpc.VolatileStatus.Count; j++) {
                    packet.AppendParameter(mapNpc.VolatileStatus[j].Emoticon);
                }

                return packet;
        }
Example #33
0
 public static TcpPacket CreateNpcSprite(MapNpc mapNpc)
 {
     return TcpPacket.CreatePacket("npcsprite", mapNpc.MapID, mapNpc.MapSlot.ToString(),
         mapNpc.Sprite.ToString(), mapNpc.Form.ToString(), ((int)mapNpc.Shiny).ToString(), ((int)mapNpc.Sex).ToString());
 }
Example #34
0
 public static TcpPacket CreateNpcSpawn(MapNpc mapNpc)
 {
     TcpPacket packet = new TcpPacket("spawnnpc");
         packet.AppendParameters(mapNpc.MapID, mapNpc.MapSlot.ToString(), mapNpc.Num.ToString(), mapNpc.Sprite.ToString(),
             mapNpc.Form.ToString(), ((int)mapNpc.Shiny).ToString(), ((int)mapNpc.Sex).ToString(),
             mapNpc.X.ToString(), mapNpc.Y.ToString(), ((int)mapNpc.Direction).ToString(), ((int)mapNpc.StatusAilment).ToString());
         if (mapNpc.Num > 0) {
             Npc npc = NpcManager.Npcs[mapNpc.Num];
             if (npc.Behavior != Enums.NpcBehavior.Friendly && npc.Behavior != Enums.NpcBehavior.Shopkeeper && npc.Behavior != Enums.NpcBehavior.Scripted) {
                 packet.AppendParameters("1");
             } else {
                 packet.AppendParameters("0");
             }
         }
         packet.FinalizePacket();
         return packet;
 }
Example #35
0
 public static TcpPacket CreateNpcHP(MapNpc mapNpc)
 {
     return TcpPacket.CreatePacket("npchp", mapNpc.MapID, mapNpc.MapSlot.ToString(), mapNpc.HP.ToString(), mapNpc.MaxHP.ToString());
 }
Example #36
0
 public static TcpPacket CreateNpcDir(MapNpc mapNpc)
 {
     return TcpPacket.CreatePacket("npcdir", mapNpc.MapID, mapNpc.MapSlot.ToString(), ((int)mapNpc.Direction).ToString());
 }
Example #37
0
 public static TcpPacket CreateNpcXY(MapNpc mapNpc)
 {
     return TcpPacket.CreatePacket("npcxy", mapNpc.MapID, mapNpc.MapSlot.ToString(), mapNpc.X.ToString(), mapNpc.Y.ToString());
 }
Example #38
0
 //public static void AppendNpcConfusion(IMap map, PacketHitList hitlist, int mapNpcNum) {
 //    MapNpc mapNpc = map.ActiveNpc[mapNpcNum];
 //    hitlist.AddPacketToOthers(mapNpc, map, CreateNpcConfusion(mapNpc), Enums.OutdateType.Condition);
 //}
 public static void AppendNpcStatusAilment(MapNpc npc, PacketHitList hitlist)
 {
     hitlist.AddPacketToOthers(npc, Maps.MapManager.RetrieveActiveMap(npc.MapID), CreateNpcStatusAilment(npc), Enums.OutdateType.Condition);
 }
Example #39
0
 //public static TcpPacket CreateNpcConfusion(MapNpc mapNpc) {
 //    
 //    return TcpPacket.CreatePacket("npcconfuse", mapNpc.MapID, mapNpc.MapSlot.ToString(), mapNpc.Confused.ToIntString());
 //}
 public static TcpPacket CreateNpcStatusAilment(MapNpc npc)
 {
     return TcpPacket.CreatePacket("npcstatus", npc.MapID, npc.MapSlot.ToString(), ((int)npc.StatusAilment).ToString());
 }
Example #40
0
 //for need-to-know sending
 public static TcpPacket CreateNpcActivation(MapNpc mapNpc, bool active)
 {
     return TcpPacket.CreatePacket("npcactive", mapNpc.MapID, mapNpc.MapSlot.ToString(), active.ToIntString());
 }