コード例 #1
0
ファイル: NPC.cs プロジェクト: Fallenoath/EndlessClient
		public NPC(NPCData serverNPCData, NPCRecord localNPCData)
		{
			Index = serverNPCData.Index;
			X = serverNPCData.X;
			Y = serverNPCData.Y;
			Direction = serverNPCData.Direction;
			Data = localNPCData;
		}
コード例 #2
0
ファイル: NPC.cs プロジェクト: weedindeed/EndlessClient
		public NPC(NPCData data)
			: base(EOGame.Instance)
		{
			ApplyData(data);
			bool success = true;
			npcSheet = new EONPCSpriteSheet(((EOGame)Game).GFXManager, this);
			int tries = 0;
			do
			{
				try
				{
					//attempt to get standing frame 1. It will have non-black pixels if it exists.
					Frame = NPCFrame.StandingFrame1;
					Texture2D tmp = npcSheet.GetNPCTexture();
					Color[] tmpData = new Color[tmp.Width*tmp.Height];
					tmp.GetData(tmpData);
					hasStandFrame1 = tmpData.Any(_c => _c.R != 0 || _c.G != 0 || _c.B != 0);

					//get the first non-transparent pixel to determine offsets for name labels and damage counters
					Frame = NPCFrame.Standing;
					tmp = npcSheet.GetNPCTexture();
					tmpData = new Color[tmp.Width*tmp.Height];
					tmp.GetData(tmpData);
					int i = 0;
					while (i < tmpData.Length && tmpData[i].A == 0) i++;
					TopPixel = i == tmpData.Length - 1 ? 0 : i/tmp.Height;

				} //this block throws errors sometimes..no idea why. Keep looping until it works.
				catch (InvalidOperationException)
				{
					success = false;
					tries++;
				}
			} while (!success && tries < 3);

			if(tries >= 3)
				throw new InvalidOperationException("Something weird happened initializing this NPC.");

			m_chatBubble = new EOChatBubble(this);
			m_damageCounter = new DamageCounter(this);
			_mouseoverName = new XNALabel(new Rectangle(1, 1, 1, 1), Constants.FontSize08pt75)
			{
				Visible = false,
				Text = Data.Name,
				ForeColor = Color.White,
				AutoSize = false,
				DrawOrder = (int) ControlDrawLayer.BaseLayer + 3
			};
			_mouseoverName.DrawLocation = new Vector2(
				DrawArea.X + (DrawArea.Width - _mouseoverName.ActualWidth)/2f,
				DrawArea.Y + TopPixel - _mouseoverName.ActualHeight - 4);
			_mouseoverName.ResizeBasedOnText();
		}
コード例 #3
0
ファイル: Refresh.cs プロジェクト: Vulttwin/EndlessClient
        private void _handleRefreshReply(Packet pkt)
        {
            if (OnWarpAgree == null)
                return;

            byte numOtherChars = pkt.GetChar();
            if (pkt.GetByte() != 255)
                return;

            List<CharacterData> otherChars = new List<CharacterData>(numOtherChars);
            for (int i = 0; i < numOtherChars; ++i)
            {
                CharacterData data = new CharacterData(pkt);
                otherChars.Add(data);
                if (pkt.GetByte() != 255)
                    return;
            }

            List<NPCData> otherNPCs = new List<NPCData>();
            while (pkt.PeekByte() != 255)
            {
                NPCData newGuy = new NPCData(pkt);
                otherNPCs.Add(newGuy);
            }
            pkt.GetByte();

            List<MapItem> mapItems = new List<MapItem>();
            while (pkt.ReadPos < pkt.Length)
            {
                mapItems.Add(new MapItem
                {
                    uid = pkt.GetShort(),
                    id = pkt.GetShort(),
                    x = pkt.GetChar(),
                    y = pkt.GetChar(),
                    amount = pkt.GetThree(),
                    //turn off drop protection for items coming into view - server will validate
                    time = DateTime.Now.AddSeconds(-5),
                    npcDrop = false,
                    playerID = -1
                });
            }

            OnWarpAgree(-1, WarpAnimation.None, otherChars, otherNPCs, mapItems);
        }
コード例 #4
0
ファイル: NPC.cs プロジェクト: Vulttwin/EndlessClient
        public NPC(NPCData data)
            : base(EOGame.Instance)
        {
            ApplyData(data);
            bool success = true;
            npcSheet = new EONPCSpriteSheet(this);
            int tries = 0;
            do
            {
                try
                {
                    //attempt to get standing frame 1. It will have non-black pixels if it exists.
                    Frame = NPCFrame.StandingFrame1;
                    Texture2D tmp = npcSheet.GetNPCTexture();
                    Color[] tmpData = new Color[tmp.Width*tmp.Height];
                    tmp.GetData(tmpData);
                    hasStandFrame1 = tmpData.Any(_c => _c.R != 0 || _c.G != 0 || _c.B != 0);

                    //get the first non-transparent pixel to determine offsets for name labels and damage counters
                    Frame = NPCFrame.Standing;
                    tmp = npcSheet.GetNPCTexture();
                    tmpData = new Color[tmp.Width*tmp.Height];
                    tmp.GetData(tmpData);
                    int i = 0;
                    while (i < tmpData.Length && tmpData[i].A == 0) i++;
                    TopPixel = i == tmpData.Length - 1 ? 0 : i/tmp.Height;

                } //this block throws errors sometimes..no idea why. Keep looping until it works.
                catch (InvalidOperationException)
                {
                    success = false;
                    tries++;
                }
            } while (!success && tries < 3);

            if(tries >= 3)
                throw new InvalidOperationException("Something weird happened initializing this NPC.");

            m_chatBubble = new EOChatBubble(this);
            m_damageCounter = new DamageCounter(this, GetType());
        }
コード例 #5
0
 private void _npcEnterMap(NPCData obj)
 {
     if (World.Instance.ActiveMapRenderer == null) return;
     World.Instance.ActiveMapRenderer.AddOtherNPC(obj);
 }
コード例 #6
0
		public void AddOtherNPC(NPCData data)
		{
			lock (_npcListLock)
			{
				NPC newNPC = new NPC(data);
				newNPC.Initialize();
				newNPC.Visible = true;
				npcList.Add(newNPC);
			}
		}
コード例 #7
0
ファイル: NPC.cs プロジェクト: Vulttwin/EndlessClient
        public void ApplyData(NPCData data)
        {
            Index = data.Index;
            X = data.X;
            Y = data.Y;
            Direction = data.Direction;

            Data = (NPCRecord)World.Instance.ENF.Data[data.ID];
            HP = Data.HP;

            _startFadeAway = false;
            _fadeAwayAlpha = 255;
        }
コード例 #8
0
ファイル: Welcome.cs プロジェクト: Vulttwin/EndlessClient
        internal WelcomeMessageData(Packet pkt)
        {
            m_news = new List <string>();
            for (int i = 0; i < 9; ++i)
            {
                m_news.Add(pkt.GetBreakString());
            }

            Weight    = pkt.GetChar();
            MaxWeight = pkt.GetChar();

            m_inventory = new List <InventoryItem>();
            while (pkt.PeekByte() != 255)
            {
                m_inventory.Add(new InventoryItem {
                    id = pkt.GetShort(), amount = pkt.GetInt()
                });
            }
            pkt.GetByte();

            m_spells = new List <CharacterSpell>();
            while (pkt.PeekByte() != 255)
            {
                m_spells.Add(new CharacterSpell {
                    id = pkt.GetShort(), level = pkt.GetShort()
                });
            }
            pkt.GetByte();

            //Get data for other characters
            int numOtherCharacters = pkt.GetChar();

            m_characters = new List <CharacterData>(numOtherCharacters);
            if (pkt.GetByte() != 255)
            {
                throw new Exception();
            }
            for (int i = 0; i < numOtherCharacters; ++i)
            {
                CharacterData newGuy = new CharacterData(pkt);
                if (pkt.GetByte() != 255)
                {
                    throw new Exception();
                }

                m_characters.Add(newGuy);
            }

            //get data for any npcs
            m_npcs = new List <NPCData>();
            while (pkt.PeekByte() != 255)
            {
                NPCData newGuy = new NPCData(pkt);
                m_npcs.Add(newGuy);
            }
            pkt.GetByte();

            //get data for items on map
            m_items = new List <MapItem>();
            while (pkt.ReadPos < pkt.Length)
            {
                m_items.Add(new MapItem
                {
                    uid    = pkt.GetShort(),
                    id     = pkt.GetShort(),
                    x      = pkt.GetChar(),
                    y      = pkt.GetChar(),
                    amount = pkt.GetThree(),
                    //turn off drop protection for items coming into view - server will validate
                    time     = DateTime.Now.AddSeconds(-5),
                    npcDrop  = false,
                    playerID = -1
                });
            }
        }
コード例 #9
0
ファイル: Welcome.cs プロジェクト: weedindeed/EndlessClient
		internal WelcomeMessageData(Packet pkt)
		{
			m_news = new List<string>();
			for (int i = 0; i < 9; ++i)
			{
				m_news.Add(pkt.GetBreakString());
			}

			Weight = pkt.GetChar();
			MaxWeight = pkt.GetChar();

			m_inventory = new List<InventoryItem>();
			while (pkt.PeekByte() != 255)
				m_inventory.Add(new InventoryItem { id = pkt.GetShort(), amount = pkt.GetInt() });
			pkt.GetByte();

			m_spells = new List<CharacterSpell>();
			while (pkt.PeekByte() != 255)
				m_spells.Add(new CharacterSpell { id = pkt.GetShort(), level = pkt.GetShort() });
			pkt.GetByte();

			//Get data for other characters
			int numOtherCharacters = pkt.GetChar();
			m_characters = new List<CharacterData>(numOtherCharacters);
			if (pkt.GetByte() != 255) throw new Exception();
			for (int i = 0; i < numOtherCharacters; ++i)
			{
				CharacterData newGuy = new CharacterData(pkt);
				if (pkt.GetByte() != 255)
					throw new Exception();

				m_characters.Add(newGuy);
			}

			//get data for any npcs
			m_npcs = new List<NPCData>();
			while (pkt.PeekByte() != 255)
			{
				NPCData newGuy = new NPCData(pkt);
				m_npcs.Add(newGuy);
			}
			pkt.GetByte();

			//get data for items on map
			m_items = new List<MapItem>();
			while (pkt.ReadPos < pkt.Length)
			{
				m_items.Add(new MapItem
				{
					uid = pkt.GetShort(),
					id = pkt.GetShort(),
					x = pkt.GetChar(),
					y = pkt.GetChar(),
					amount = pkt.GetThree(),
					//turn off drop protection for items coming into view - server will validate
					time = DateTime.Now.AddSeconds(-5),
					npcDrop = false,
					playerID = -1
				});
			}
		}
コード例 #10
0
		public void AddOtherNPC(NPCData data)
		{
			lock (_npcListLock)
			{
				var fileData = World.Instance.ENF.GetNPCRecordByID(data.ID);
				NPCRenderer newNpcRenderer = new NPCRenderer(new NPC(data, fileData));
				newNpcRenderer.Initialize();
				newNpcRenderer.Visible = true;
				_npcRenderers.Add(newNpcRenderer);
			}
		}