示例#1
0
    protected override void InitUnitData()
    {
        if (UIBtn == null)
        {
            UIBtn             = UnitGO.transform.FindChild("StarModel/StarBtn").GetComponent <MogoUIBtn>();
            UIBtn.ClickAction = OnClickStar;
            m_BanBGOB         = UnitGO.transform.FindChild("StarModel/BanBG").gameObject;
            BelongTo          = StarBelongTo;
        }

        UnitGO.transform.parent        = UnitParent;
        UnitGO.transform.localScale    = new Vector3(1, 1, 1);
        UnitGO.transform.localPosition = new Vector3(PositionX, PositionY, 0);
        UnitGO.transform.FindChild("StarModel").localScale = new Vector3(BaseData.radius * 2, BaseData.radius * 2, -2);//两倍后才接近真实大小
        UnitGO.transform.FindChild("StarModel/StarBtn").GetComponent <BoxCollider>().size = Vector3.one;

        m_starInfoUIMgr = UIManager.I.GetUILogic <StarInfoUIMgr>();
        InitDrawings();

        StarColor = UnitGO.transform.FindChild("StarColor").GetComponent <UISprite>();
        StarColor.transform.localScale = new Vector3(BaseData.radius * 2, BaseData.radius * 2, 1);//两倍后才接近真实大小
        StarColor.gameObject.SetActive(false);

        UIBtn.m_imgNormal.spriteName  = BaseData.icon;
        UIBtn.m_imgPressed.spriteName = BaseData.icon;
        TweenRotation.Begin(UIBtn.m_imgNormal.gameObject, MogoWorld.GameTime, Quaternion.Euler(new Vector3(0, 0, Utils.CreateRandom().Next(90, 270))));
        //得到星球上建筑的位置
        BuildingPositionList = MapUtil.GetBuildingPosList(this, BaseData.count);
        //得到士兵在星球上的位置
        SoliderPositionList = MapUtil.GetBuildingPosList(this, 6, BaseData.radius * 1.5f);

        if (CallBack != null)
        {
            CallBack();
            CallBack = null;
        }
    }