Exemple #1
0
		private void HandleItemDespawn(Block block)
		{
            List<Item> toDeleteDropList = new List<Item>();
            dropProxy.IterateDrops((Item item) => 
            {
                Vector2 itemPos = Maze.Instance.GetMazePosition(item.WorldPosition);
				if (block.Contains((int)itemPos.x, (int)itemPos.y))
				{
					toDeleteDropList.Add(item);
				}
			});

			int blockKey = Block.GetBlockKey(block.Col, block.Row);
			dropProxy.InitRecordList(blockKey);

			for (int i = 0; i < toDeleteDropList.Count; ++i)
			{
                Item drop = toDeleteDropList[i];
				dropProxy.HideItem(drop.Uid);
                Item.Recycle(drop);
			}
		}
		//When a block despawns, remove all monsters on it from the monsterDic, and store them in the recordDic
		private void HandleBlockDespawn(Block block)
		{
			List<Monster> toDeleteMonsterList = new List<Monster>();
			monsterProxy.IterateMonstersInBlocks((Monster monster) => 
	         {
				Vector2 monsterPos = Maze.Instance.GetMazePosition(monster.WorldPosition);
				if (block.Contains((int)monsterPos.x, (int)monsterPos.y))
				{
					toDeleteMonsterList.Add(monster);
				}
			});

			int blockKey = Block.GetBlockKey(block.Col, block.Row);
			monsterProxy.InitRecordBlockList(blockKey);

			for (int i = 0; i < toDeleteMonsterList.Count; ++i)
			{
				Monster monster = toDeleteMonsterList[i];
				battleProxy.RemoveMonster(monster.Uid);

				if (monster.Info.IsAlive)
				{
					monsterProxy.HideMonsterInBlock(monster.Uid);
				}
				else
				{
					monsterProxy.RemoveMonsterInBlock(monster.Uid);
				}
				Monster.Recycle(monster);
			}
		}
Exemple #3
0
		private void HandleNPCDespawn(Block block)
		{
			List<NPC> npcList = npcProxy.GetAllNPCs();
			float blockSize = MazeDataManager.Instance.CurrentMazeData.BlockSize;
			int count = npcList.Count;
			for (int i = 0; i < count; ++i)
			{
				NPC npc = npcList[i];
				int col, row;
				MazeUtil.GetMazePosition(npc.WorldPosition, blockSize, out col, out row);
				if (block.Contains(col, row))
				{
					npcProxy.RemoveNPC(npc.Uid);
					
					NPC.Recycle(npc);
				}
			}
		}
		private void HandleBlockDespawn(Block block)
		{
            List<Exploration> toDeleteList = new List<Exploration>();
            explorationProxy.IterateInBlocks((Exploration expl) => 
                {
                    Vector2 pos = Maze.Instance.GetMazePosition(expl.WorldPosition);
                    if (block.Contains((int)pos.x, (int)pos.y))
                    {
                        toDeleteList.Add(expl);
                    }
                });

            for (int i = 0; i < toDeleteList.Count; ++i)
            {
                Exploration expl = toDeleteList[i];
                explorationProxy.RemoveInBlock(expl.Uid);
                Exploration.Recycle(expl);
            }
		}