Exemplo n.º 1
0
 /// <summary>
 /// 重新设置地图
 /// </summary>
 private void ResetMap()
 {
     if (iMapState.MapBackSprite == null)
     {
         return;
     }
     //根据场景初始化地图
     uiMapControl.InitMap(iMapState.MapBackSprite, iMapState.MaskMapSprite, iMapState.MapRectAtScene, 0.05f);
     //重回全地图的图标
     //npc与路牌
     NPCDataInfo[] npcDataInfos = npcData.GetNPCDataInfos(iGameState.SceneName);
     foreach (NPCDataInfo npcDataInfo in npcDataInfos)
     {
         UIMapIconStruct uiMapIconStruct = uiMapControl.AddIcon(npcDataInfo.NPCSprite, new Vector2(10, 10), new Vector2(npcDataInfo.NPCLocation.x, npcDataInfo.NPCLocation.z));
         object[]        innerValue      = new object[]
         {
             npcDataInfo.NPCType != EnumNPCType.Street?EnumBigMapIconCheck.Action : EnumBigMapIconCheck.Street,
             npcDataInfo
         };
         uiMapIconStruct.value = innerValue;
     }
     //任务
     //等待接取的任务
     TaskMap.RunTimeTaskInfo[] runTimeTaskInfos_Wait = iNowTaskState.GetWaitTask(iGameState.SceneName);
     foreach (TaskMap.RunTimeTaskInfo runTimeTaskInfo in runTimeTaskInfos_Wait)
     {
         NPCDataInfo npcDataInfo = npcData.GetNPCDataInfo(iGameState.SceneName, runTimeTaskInfo.TaskInfoStruct.ReceiveTaskNpcId);//接取任务的NPC
         if (npcDataInfo == null)
         {
             continue;
         }
         //需要传入一个金色的叹号
         UIMapIconStruct uiMapIconStruct = uiMapControl.AddIcon(null, new Vector2(20, 30),
                                                                new Vector2(npcDataInfo.NPCLocation.x, npcDataInfo.NPCLocation.z));
         object[] innerValue = new object[]
         {
             EnumBigMapIconCheck.Task,
             runTimeTaskInfo,
             0//0表示等待接取,1表示正在执行,2表示已经完成
         };
         uiMapIconStruct.value = innerValue;
     }
     //正在执行的任务
     TaskMap.RunTimeTaskInfo[] runTimeTaskInfos_Start = iNowTaskState.GetStartTask(iGameState.SceneName);
     foreach (TaskMap.RunTimeTaskInfo runTimeTaskInfo in runTimeTaskInfos_Start)
     {
         Vector2 targetPosition = Vector2.zero;
         if (runTimeTaskInfo.TaskInfoStruct.DeliveryTaskLocation != null && runTimeTaskInfo.TaskInfoStruct.DeliveryTaskNpcId < 0)
         {
             targetPosition = new Vector2(runTimeTaskInfo.TaskInfoStruct.DeliveryTaskLocation.ArrivedCenterPos.x, runTimeTaskInfo.TaskInfoStruct.DeliveryTaskLocation.ArrivedCenterPos.z);
         }
         else
         {
             NPCDataInfo npcDataInfo = npcData.GetNPCDataInfo(iGameState.SceneName, runTimeTaskInfo.TaskInfoStruct.DeliveryTaskNpcId);//交付任务的NPC
             if (npcDataInfo != null)
             {
                 targetPosition = new Vector2(npcDataInfo.NPCLocation.x, npcDataInfo.NPCLocation.z);
             }
         }
         //需要传入一个白色的的问号
         UIMapIconStruct uiMapIconStruct = uiMapControl.AddIcon(null, new Vector2(20, 30), targetPosition);
         object[]        innerValue      = new object[]
         {
             EnumBigMapIconCheck.Task,
             runTimeTaskInfo,
             1//0表示等待接取,1表示正在执行,2表示已经完成
         };
         uiMapIconStruct.value = innerValue;
     }
     //条件达成但是没有交付的任务
     TaskMap.RunTimeTaskInfo[] runTimeTaskInfos_End = iNowTaskState.GetStartTask(iGameState.SceneName);
     foreach (TaskMap.RunTimeTaskInfo runTimeTaskInfo in runTimeTaskInfos_End)
     {
         NPCDataInfo npcDataInfo = npcData.GetNPCDataInfo(iGameState.SceneName, runTimeTaskInfo.TaskInfoStruct.DeliveryTaskNpcId);//交付任务的NPC
         if (npcDataInfo == null)
         {
             continue;
         }
         //需要传入一个金色的问号
         UIMapIconStruct uiMapIconStruct = uiMapControl.AddIcon(null, new Vector2(20, 30),
                                                                new Vector2(npcDataInfo.NPCLocation.x, npcDataInfo.NPCLocation.z));
         object[] innerValue = new object[]
         {
             EnumBigMapIconCheck.Task,
             runTimeTaskInfo,
             2//0表示等待接取,1表示正在执行,2表示已经完成
         };
         uiMapIconStruct.value = innerValue;
     }
     //根据玩家位置设置地图中心位置
     MoveToCenter();
 }
Exemplo n.º 2
0
    /// <summary>
    /// 重新设置地图
    /// </summary>
    private void ResetMap(Sprite mapBackSprite, Sprite maskMapSprite, Rect mapRectAtScene, string sceneName)
    {
        nowSceneName = sceneName;
        //根据场景初始化地图
        uiMapControl.InitMap(mapBackSprite, maskMapSprite, mapRectAtScene);
        //重绘全地图的图标
        uiMapIconStructList = new List <UIMapIconStruct>();
        //npc与路牌
        NPCDataInfo[] npcDataInfos = npcData.GetNPCDataInfos(sceneName);
        foreach (NPCDataInfo npcDataInfo in npcDataInfos)
        {
            UIMapIconStruct uiMapIconStruct = uiMapControl.AddIcon(npcDataInfo.NPCSprite, new Vector2(30, 30), new Vector2(npcDataInfo.NPCLocation.x, npcDataInfo.NPCLocation.z));
            object[]        innerValue      = new object[]
            {
                npcDataInfo.NPCType != EnumNPCType.Street?EnumBigMapIconCheck.Action : EnumBigMapIconCheck.Street,
                npcDataInfo
            };
            uiMapIconStruct.value = innerValue;
            uiMapIconStructList.Add(uiMapIconStruct);
        }
        //任务
        //等待接取的任务
        TaskMap.RunTimeTaskInfo[] runTimeTaskInfos_Wait = iNowTaskState.GetWaitTask(sceneName);
        foreach (TaskMap.RunTimeTaskInfo runTimeTaskInfo in runTimeTaskInfos_Wait)
        {
            NPCDataInfo npcDataInfo = npcData.GetNPCDataInfo(sceneName, runTimeTaskInfo.TaskInfoStruct.ReceiveTaskNpcId);//接取任务的NPC
            if (npcDataInfo == null)
            {
                continue;
            }
            //需要传入一个金色的叹号
            UIMapIconStruct uiMapIconStruct = uiMapControl.AddIcon(null, new Vector2(20, 30),
                                                                   new Vector2(npcDataInfo.NPCLocation.x, npcDataInfo.NPCLocation.z));
            object[] innerValue = new object[]
            {
                EnumBigMapIconCheck.Task,
                runTimeTaskInfo,
                0//0表示等待接取,1表示正在执行,2表示已经完成
            };
            uiMapIconStruct.value = innerValue;
            uiMapIconStructList.Add(uiMapIconStruct);
        }
        //正在执行的任务
        TaskMap.RunTimeTaskInfo[] runTimeTaskInfos_Start = iNowTaskState.GetStartTask(sceneName);
        foreach (TaskMap.RunTimeTaskInfo runTimeTaskInfo in runTimeTaskInfos_Start)
        {
            Vector2 targetPosition = Vector2.zero;
            if (runTimeTaskInfo.TaskInfoStruct.DeliveryTaskLocation != null && runTimeTaskInfo.TaskInfoStruct.DeliveryTaskNpcId < 0)
            {
                targetPosition = new Vector2(runTimeTaskInfo.TaskInfoStruct.DeliveryTaskLocation.ArrivedCenterPos.x, runTimeTaskInfo.TaskInfoStruct.DeliveryTaskLocation.ArrivedCenterPos.z);
            }
            else
            {
                NPCDataInfo npcDataInfo = npcData.GetNPCDataInfo(sceneName, runTimeTaskInfo.TaskInfoStruct.DeliveryTaskNpcId);//交付任务的NPC
                if (npcDataInfo != null)
                {
                    targetPosition = new Vector2(npcDataInfo.NPCLocation.x, npcDataInfo.NPCLocation.z);
                }
            }
            //需要传入一个白色的的问号
            UIMapIconStruct uiMapIconStruct = uiMapControl.AddIcon(null, new Vector2(20, 30), targetPosition);
            object[]        innerValue      = new object[]
            {
                EnumBigMapIconCheck.Task,
                runTimeTaskInfo,
                1//0表示等待接取,1表示正在执行,2表示已经完成
            };
            uiMapIconStruct.value = innerValue;
            uiMapIconStructList.Add(uiMapIconStruct);
        }
        //条件达成但是没有交付的任务
        TaskMap.RunTimeTaskInfo[] runTimeTaskInfos_End = iNowTaskState.GetStartTask(sceneName);
        foreach (TaskMap.RunTimeTaskInfo runTimeTaskInfo in runTimeTaskInfos_End)
        {
            NPCDataInfo npcDataInfo = npcData.GetNPCDataInfo(sceneName, runTimeTaskInfo.TaskInfoStruct.DeliveryTaskNpcId);//交付任务的NPC
            if (npcDataInfo == null)
            {
                continue;
            }
            //需要传入一个金色的问号
            UIMapIconStruct uiMapIconStruct = uiMapControl.AddIcon(null, new Vector2(20, 30),
                                                                   new Vector2(npcDataInfo.NPCLocation.x, npcDataInfo.NPCLocation.z));
            object[] innerValue = new object[]
            {
                EnumBigMapIconCheck.Task,
                runTimeTaskInfo,
                2//0表示等待接取,1表示正在执行,2表示已经完成
            };
            uiMapIconStruct.value = innerValue;
            uiMapIconStructList.Add(uiMapIconStruct);
        }
        //设置玩家的图标        //1_272
        Sprite          playerSprite           = SpriteManager.GetSrpite("1:1_272");
        UIMapIconStruct uiMapIconStruct_Player = uiMapControl.AddIcon(playerSprite, new Vector2(30, 40), new Vector2(iPlayerState.PlayerObj.transform.position.x, iPlayerState.PlayerObj.transform.position.z));

        uiMapIconStruct_Player.value = null;
        uiMapIconStructList.Add(uiMapIconStruct_Player);
        if (string.Equals(iGameState.SceneName, sceneName))//如果这个场景是玩家所在的场景则设置场景的中心位置为玩家的位置
        {
            //根据玩家位置设置地图中心位置
            Vector2 playerLocation = new Vector2(iPlayerState.PlayerObj.transform.position.x, iPlayerState.PlayerObj.transform.position.z);
            uiMapControl.MoveToTerrainPoint(playerLocation);
        }
        else
        {
            uiMapControl.MoveToTerrainPoint(mapRectAtScene.center);
        }
    }