Пример #1
0
    public static MapVO Parse(string datastr)
    {
        //var data = new XmlElement();
        var data = XElement.Parse(datastr, LoadOptions.None);
        //Logger.Log("=======================================" + data.ToString());
        var app = new MapVO();
        app.id = data.Attribute("id").Value;
        app.x = int.Parse(data.Attribute("x").Value);
        app.y = int.Parse(data.Attribute("y").Value);
        app.w = int.Parse(data.Attribute("w").Value);
        app.h = int.Parse(data.Attribute("h").Value);
        app.xx = int.Parse(data.Attribute("xx").Value);
        app.yy = int.Parse(data.Attribute("yy").Value);
        app.ww = int.Parse(data.Attribute("ww").Value);
        app.hh = int.Parse(data.Attribute("hh").Value);

        string str = data.Attribute("points").Value;
        string[] ps = str.Split(',');
        if (ps.Length > 1)
        {
            int count = ps.Length / 2;
            app.points = new Vector2[count];
            for (int i = 0; i < ps.Length; i += 2)
            {
                app.points[i / 2] = new Vector2(float.Parse(ps[i]), float.Parse(ps[i + 1]));
            }
        }
            
        return app;
    }
    IEnumerator GenerateGrid()
    {
        Debug.Log("GenerateGrid Begin!!!!");
        Vector3 rayPoint = Vector3.zero;
        int     index = 0;
        int     x, z;
        bool    bPassable;

        for (x = 0; x < cols; x++)
        {
            for (z = 0; z < rows; z++)
            {
                rayPoint  = MapVO.GetWorldPos(x, z);
                bPassable = RaycatMap(rayPoint);
                textureGrid.SetPixel(x, z, bPassable ? Color.white : Color.black);
                aStarUtils.GetNode(x, z).walkable = bPassable;
                index++;
                if (index % 50 == 0)
                {
                    yield return(1);
                }
            }
        }
        textureGrid.Apply();
        gridPlane.material.mainTexture = textureGrid;
        bRayEnd = true;
        Debug.Log("GenerateGrid End!!!!");
        yield return(bRayEnd);
    }
    void UpdatePath()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            RaycastHit raycastHit = new RaycastHit();
            if (Physics.Raycast(ray, out raycastHit))
            {
                if (raycastHit.collider.gameObject.tag == "GridPlane")
                {
                    Vector2 pointItem = MapVO.GetNodeXY(raycastHit.point);
                    this.FindPath((int)pointItem.x, (int)pointItem.y);
                }
            }
        }
    }
Пример #4
0
 private List<RaidStageInfo> GetStages(MapVO themap)
 {
     Raids = MissionModelLocator.Instance.GetCurrentRaids();
     int raidtemplateid = MissionModelLocator.Instance.CurrRaidType*100 + int.Parse(themap.id);
     for (int i = 0; i < Raids.Count; i++)
     {
         if (Raids[i].TemplateId == raidtemplateid)
         {
             return Raids[i].StateInfo;
         }
     }
     return null;
 }
Пример #5
0
    private void ShowStage(MapVO themap, bool playeffect = true)
    {
        var table = StageItemsContainer.GetComponent<KxVListRender>();
        var stages = GetStages(themap);
        List<RaidStageInfo> temp;
        if (stages != null)
        {
//            if (MissionModelLocator.Instance.CurrRaidType == RaidType.RaidNormal)
//            {
                temp = new List<RaidStageInfo>(stages.OrderByDescending(stageinfo => stageinfo.TemplateId));
//            }
//            else
//            {
//                temp = new List<RaidStageInfo>(stages.OrderBy(stageinfo => stageinfo.TemplateId));
//            }
            
        }
        else
        {
            temp = new List<RaidStageInfo>();
        }
        table.Init(temp, "Prefabs/Component/StageItem", 540, 490, 540, 140, OnStageItemClicktHandler, playeffect);

        var tt = TexSelectMap.GetComponent<UITexture>();
        tt.mainTexture = (Texture2D)Resources.Load("Textures/Mission/" + themap.id + "b", typeof(Texture2D));
        tt.width = themap.ww;
        tt.height = themap.hh;
        TexSelectMap.transform.localPosition = new Vector3(themap.xx, themap.yy, 0);
        TexSelectMap.SetActive(true);
        if (IsShowStage && CurrRaidMap.id == themap.id)
        {
            
            //table.ResetCollider();
            return;
        }
//        else
//        {
//            table.Init(temp, "Prefabs/Component/StageItem", 540, 490, 540, 140, OnStageItemClicktHandler);
//        }
        CurrRaidMap = themap;
        StartCoroutine(PlayShowStage());
    }