Ejemplo n.º 1
0
    // Token: 0x06002A1E RID: 10782 RVA: 0x00467A10 File Offset: 0x00465C10
    private PanelObject AddContentObj(int btnID, GameObject item, Vector2 pos, float height, GameObject content)
    {
        RectTransform component = item.GetComponent <RectTransform>();

        if (component != null)
        {
            GameObject gameObject = UnityEngine.Object.Instantiate(item) as GameObject;
            if (gameObject != null)
            {
                RectTransform   component2 = gameObject.GetComponent <RectTransform>();
                ScrollPanelItem component3 = gameObject.GetComponent <ScrollPanelItem>();
                if (component2 != null && component3 != null)
                {
                    component3.m_BtnID1         = btnID;
                    component3.m_Handler        = this;
                    component2.anchoredPosition = pos;
                    component2.anchorMax        = new Vector2(0f, 1f);
                    component2.anchorMin        = new Vector2(0f, 1f);
                    component2.pivot            = new Vector2(0f, 1f);
                    component2.sizeDelta        = new Vector2(component.sizeDelta.x, component.sizeDelta.y);
                    PanelObject panelObject = new PanelObject();
                    panelObject.gameObject    = gameObject;
                    panelObject.rectTransform = component2;
                    gameObject.transform.SetParent(content.transform, false);
                    return(panelObject);
                }
            }
        }
        return(null);
    }
Ejemplo n.º 2
0
 // Token: 0x06002A13 RID: 10771 RVA: 0x0046721C File Offset: 0x0046541C
 public void ButtonOnClick(ScrollPanelItem sender)
 {
     if (this.m_handler != null)
     {
         this.m_handler.ButtonOnClick(sender.gameObject, sender.m_BtnID1, this.m_ScrollPanelID);
     }
 }
Ejemplo n.º 3
0
    void Update()
    {
        if (currentBuilding != null && hasPlaced)
        {
            //if there is a selected building and it is placed then show it in white to mark it as selected
            currentBuilding.GetComponent <PlacableBuilding>().MarkWhite();
        }
        //show remov button if there is any building selected
        ShowRemoveButton();

        //if there is a building selected which is not yet placed
        if (currentBuilding != null && !hasPlaced)
        {
            //update placeposition and moveposition by casting a ray from camera to touchposition and hitting floormask and ceiling mask respectively
            placePosition = GetPointerPositionOnMask(floorMask);
            movePosition  = GetPointerPositionOnMask(ceilingMask);

            //round of the positions, so as to give effect of incremental block movement (0.12 is added to adjust for ceiling mask height)
            placePosition = new Vector3(Mathf.Round(placePosition.x + 0.12f), Mathf.Round(placePosition.y), Mathf.Round(placePosition.z + 0.12f));
            movePosition  = new Vector3(Mathf.Round(movePosition.x) + 0.12f, Mathf.Round(movePosition.y), Mathf.Round(movePosition.z) + 0.12f);

            //mark current building as red, if a legal position is found, then it will be marked as green and if placed then marked as grey
            currentBuilding.GetComponent <PlacableBuilding>().MarkRed();
            currentBuilding.position            = movePosition;
            currentBuildingBoundingBox.position = placePosition;
            if (IsPlacablePosition())
            {
                currentBuilding.GetComponent <PlacableBuilding>().MarkGreen();

                //when mouse button up or touch up event is found
                if (Input.GetMouseButtonUp(0))
                {
                    PlaceBuilding();
                }
            }
            else
            {
                //if not a legal position then return the building to its old position or in the scroll panel
                if (Input.GetMouseButtonUp(0))
                {
                    if (currentBuilding.GetComponent <PlacableBuilding>().alreadyOnScreen)
                    {
                        placePosition = currentBuilding.GetComponent <PlacableBuilding>().lastPosition;
                        PlaceBuilding();
                    }
                    else
                    {
                        RemoveBuilding(currentBuilding.gameObject);
                    }
                }
            }
        }
        //if no building is selected or it is already placed
        else
        {
            //if not zooming in or out
            if (Input.touchCount < 2)
            {
                //if mouse clicked or screen touched
                if (Input.GetMouseButtonDown(0))
                {
                    //cast a ray from camera to mouseposition, if hits a building, select that building for replacement
                    Ray        camRay = mainCamera.ScreenPointToRay(Input.mousePosition);
                    RaycastHit maskHit;
                    if (Physics.Raycast(camRay, out maskHit, camRayLength, buildingMask))
                    {
                        //if ray hits building
                        if (maskHit.collider.transform.parent == null)
                        {
                            currentBuilding = maskHit.collider.transform;
                        }
                        else
                        {
                            //if ray hits a child object
                            currentBuilding = maskHit.collider.transform.parent;
                        }
                        hasPlaced = false;
                        //create a bounding box to check for legal positions
                        currentBuildingBoundingBox = Instantiate(currentBuilding.GetComponent <PlacableBuilding>().buildingBoundingBox).transform;
                        //remove this building from building managers list
                        BuildingManager.GetInstance().RemoveFromBuildingList(currentBuilding.gameObject);
                    }
                }
            }
        }

        //if touch ends or mouse button up is detected then there is no selected control panel item
        if (Input.GetMouseButtonUp(0))
        {
            currentSelectedPanelItem = null;
        }

        //if there are no current buildings or it has been placed and there is no scroll panel item selected then camera can be moved
        if ((currentBuilding == null || hasPlaced) && currentSelectedPanelItem == null)
        {
            Camera.main.GetComponent <CameraControls>().moveCamera = true;
        }
        else
        {
            Camera.main.GetComponent <CameraControls>().moveCamera = false;
        }
    }
Ejemplo n.º 4
0
        // Token: 0x0600297A RID: 10618 RVA: 0x004598A0 File Offset: 0x00457AA0
        public virtual void OnEndDrag(PointerEventData eventData)
        {
            if (eventData.button != PointerEventData.InputButton.Left)
            {
                return;
            }
            float num  = Vector2.Distance(this.startPos, eventData.position);
            float num2 = Screen.dpi / 2.54f;

            if (num < num2 * 0.15f)
            {
                uButtonScale uButtonScale = eventData.pointerPressRaycast.gameObject.GetComponent(typeof(uButtonScale)) as uButtonScale;
                if (uButtonScale != null)
                {
                    uButtonScale.OnPointerClick(eventData);
                }
                else
                {
                    IPointerClickHandler pointerClickHandler = eventData.pointerPressRaycast.gameObject.GetComponent(typeof(IPointerClickHandler)) as IPointerClickHandler;
                    if (pointerClickHandler != null)
                    {
                        pointerClickHandler.OnPointerClick(eventData);
                    }
                    else
                    {
                        byte      b         = 3;
                        Transform transform = eventData.pointerPressRaycast.gameObject.transform;
                        while (b > 0 && transform.parent)
                        {
                            ScrollPanelItem component = transform.parent.GetComponent <ScrollPanelItem>();
                            if (component)
                            {
                                pointerClickHandler = (transform.parent.GetComponent(typeof(IPointerClickHandler)) as IPointerClickHandler);
                                if (pointerClickHandler != null)
                                {
                                    pointerClickHandler.OnPointerClick(eventData);
                                }
                                break;
                            }
                            b        -= 1;
                            transform = transform.parent;
                        }
                    }
                }
                this.startPos = Vector2.zero;
            }
            if (this.m_bInitViewState && (this.ViewState == ListViewState.LVS_PULL_REFRESH || this.ViewState == ListViewState.LVS_PULL_REFRESH_UP))
            {
                this.SwitchViewState(ListViewState.LVS_NORMAL);
            }
            if (this.bPageMove)
            {
                float num3 = Time.realtimeSinceStartup - this._time2;
                float num4 = eventData.position.x - this._pos2.x;
                float num5 = num4 / num3;
                if (GUIManager.Instance.IsArabic)
                {
                    if (this.NowPageIndex > 0 && (num5 < -500f || (double)(this.m_Content.anchoredPosition.x - this.m_ContentStartPosition.x) >= (double)this.PageWidth * 0.5))
                    {
                        this.setCurrentIndex(this.NowPageIndex - 1, false);
                    }
                    else if (this.NowPageIndex < this.PageQuantity - 1 && (num5 > 500f || (double)(-(double)(this.m_Content.anchoredPosition.x - this.m_ContentStartPosition.x)) >= (double)this.PageWidth * 0.5))
                    {
                        this.setCurrentIndex(this.NowPageIndex + 1, false);
                    }
                    else
                    {
                        this.setCurrentIndex(this.NowPageIndex, false);
                    }
                }
                else if (this.NowPageIndex > 0 && (num5 > 500f || (double)(this.m_Content.anchoredPosition.x - this.m_ContentStartPosition.x) >= (double)this.PageWidth * 0.5))
                {
                    this.setCurrentIndex(this.NowPageIndex - 1, false);
                }
                else if (this.NowPageIndex < this.PageQuantity - 1 && (num5 < -500f || (double)(-(double)(this.m_Content.anchoredPosition.x - this.m_ContentStartPosition.x)) >= (double)this.PageWidth * 0.5))
                {
                    this.setCurrentIndex(this.NowPageIndex + 1, false);
                }
                else
                {
                    this.setCurrentIndex(this.NowPageIndex, false);
                }
            }
            this.m_Dragging = false;
        }
Ejemplo n.º 5
0
    // Token: 0x06001F0F RID: 7951 RVA: 0x003B9580 File Offset: 0x003B7780
    public void UpDateRowItem(GameObject item, int dataIdx, int panelObjectIdx, int panelId)
    {
        Transform[]     array     = new Transform[2];
        ScrollPanelItem component = item.transform.GetComponent <ScrollPanelItem>();

        component.m_BtnID1 = dataIdx;
        component.m_BtnID2 = panelObjectIdx;
        if (this.m_ScrollObj[panelObjectIdx].PanelItem[0].HeroBtn == null)
        {
            for (int i = 0; i < 2; i++)
            {
                array[i] = item.transform.GetChild(0).GetChild(i);
                UIButton component2 = array[i].GetComponent <UIButton>();
                component2.m_Handler = this;
                this.m_ScrollObj[panelObjectIdx].PanelItem[i].HeroBtn = array[i].GetChild(0).GetComponent <UIHIBtn>();
                UIButtonHint uibuttonHint = array[i].GetChild(0).gameObject.AddComponent <UIButtonHint>();
                uibuttonHint.m_Handler = this;
                uibuttonHint.m_eHint   = EUIButtonHint.DownUpHandler;
                this.m_ScrollObj[panelObjectIdx].PanelItem[i].EnhanceIcon          = array[i].GetChild(2).GetComponent <Image>();
                this.m_ScrollObj[panelObjectIdx].PanelItem[i].EnhanceIcon.material = this.GetEnhanceMat();
                this.m_ScrollObj[panelObjectIdx].PanelItem[i].ArmsIcons            = array[i].GetChild(1).GetComponent <Image>();
                this.m_ScrollObj[panelObjectIdx].PanelItem[i].ArmsText             = array[i].GetChild(3).GetComponent <UIText>();
                this.m_ScrollObj[panelObjectIdx].PanelItem[i].ArmsText.font        = this.TTF;
                this.m_ScrollObj[panelObjectIdx].PanelItem[i].MaxNumText           = array[i].GetChild(4).GetComponent <UIText>();
                this.m_ScrollObj[panelObjectIdx].PanelItem[i].MaxNumText.font      = this.TTF;
                this.m_ScrollObj[panelObjectIdx].PanelItem[i].MaskImage            = array[i].GetChild(5).GetComponent <Image>();
                this.m_ScrollObj[panelObjectIdx].PanelItem[i].SelectImage          = array[i].GetChild(7).GetComponent <Image>();
                this.m_ScrollObj[panelObjectIdx].PanelItem[i].FightImage           = array[i].GetChild(6).GetComponent <Image>();
                this.m_ScrollObj[panelObjectIdx].ItemTf1   = item.transform.GetChild(0).GetChild(0);
                this.m_ScrollObj[panelObjectIdx].ItemTf2   = item.transform.GetChild(0).GetChild(1);
                this.m_ScrollObj[panelObjectIdx].Line      = item.transform.GetChild(0).GetChild(2);
                this.m_ScrollObj[panelObjectIdx].FinalText = item.transform.GetChild(0).GetChild(3);
                UIText component3 = this.m_ScrollObj[panelObjectIdx].Line.GetChild(0).GetComponent <UIText>();
                component3.font = this.TTF;
            }
        }
        for (int j = 0; j < 2; j++)
        {
            array[j] = item.transform.GetChild(0).GetChild(j);
            this.m_Data[dataIdx].panelObjectIdx = panelObjectIdx;
            if (this.m_Data[dataIdx].Item[j].Type == 1)
            {
                this.m_ScrollObj[panelObjectIdx].Line.gameObject.SetActive(true);
                this.m_ScrollObj[panelObjectIdx].FinalText.gameObject.SetActive(false);
                this.m_ScrollObj[panelObjectIdx].ItemTf1.gameObject.SetActive(false);
                this.m_ScrollObj[panelObjectIdx].ItemTf2.gameObject.SetActive(false);
            }
            else
            {
                this.m_ScrollObj[panelObjectIdx].Line.gameObject.SetActive(false);
                this.m_ScrollObj[panelObjectIdx].FinalText.gameObject.SetActive(false);
                this.m_ScrollObj[panelObjectIdx].ItemTf1.gameObject.SetActive(true);
                this.m_ScrollObj[panelObjectIdx].ItemTf2.gameObject.SetActive(true);
                if (this.m_Data[dataIdx].Item[j].Enable)
                {
                    if (!array[j].gameObject.activeSelf)
                    {
                        array[j].gameObject.SetActive(true);
                    }
                    uint heroID = (uint)this.m_Data[dataIdx].Item[j].HeroID;
                    if (j == 0)
                    {
                        GameObject gameObject = item.transform.GetChild(0).GetChild(0).GetChild(8).gameObject;
                        if (heroID == (uint)this.DM.GetLeaderID())
                        {
                            gameObject.SetActive(true);
                        }
                        else
                        {
                            gameObject.SetActive(false);
                        }
                    }
                    UIButton component2 = array[j].GetComponent <UIButton>();
                    component2.m_BtnID1 = dataIdx;
                    component2.m_BtnID2 = panelObjectIdx;
                    component2.m_BtnID3 = j;
                    this.GM.ChangeHeroItemImg(this.m_ScrollObj[panelObjectIdx].PanelItem[j].HeroBtn.transform, eHeroOrItem.Hero, (ushort)heroID, this.m_Data[dataIdx].Item[j].Star, 0, (int)this.m_Data[dataIdx].Item[j].Lv);
                    this.m_ScrollObj[panelObjectIdx].PanelItem[j].EnhanceIcon.sprite = this.GetEnhanceIcon(this.m_Data[dataIdx].Item[j].Enhance);
                    this.m_ScrollObj[panelObjectIdx].PanelItem[j].ArmsIcons.sprite   = this.GetArmsIcon(this.m_Data[dataIdx].Item[j].Arms);
                    this.m_ScrollObj[panelObjectIdx].PanelItem[j].ArmsText           = array[j].GetChild(3).GetComponent <UIText>();
                    this.m_ScrollObj[panelObjectIdx].PanelItem[j].ArmsText.text      = this.GetArmsStr(this.m_Data[dataIdx].Item[j].Arms);
                    this.m_ScrollObj[panelObjectIdx].PanelItem[j].MaxNumText         = array[j].GetChild(4).GetComponent <UIText>();
                    if (this.m_ScrollObj[panelObjectIdx].PanelItem[j].MaxNumStr == null)
                    {
                        this.m_ScrollObj[panelObjectIdx].PanelItem[j].MaxNumStr = StringManager.Instance.SpawnString(30);
                    }
                    this.m_ScrollObj[panelObjectIdx].PanelItem[j].MaxNumStr.ClearString();
                    StringManager.Instance.IntToFormat((long)this.m_Data[dataIdx].Item[j].MaxNum, 1, true);
                    this.m_ScrollObj[panelObjectIdx].PanelItem[j].MaxNumStr.AppendFormat("{0}");
                    this.m_ScrollObj[panelObjectIdx].PanelItem[j].MaxNumText.text = this.m_ScrollObj[panelObjectIdx].PanelItem[j].MaxNumStr.ToString();
                    this.m_ScrollObj[panelObjectIdx].PanelItem[j].MaxNumText.SetAllDirty();
                    this.m_ScrollObj[panelObjectIdx].PanelItem[j].MaxNumText.cachedTextGenerator.Invalidate();
                    if (this.m_Data[dataIdx].Item[j].bSelect || this.m_Data[dataIdx].Item[j].bIsFight || this.m_Data[dataIdx].Item[j].bIsLords)
                    {
                        this.m_ScrollObj[panelObjectIdx].PanelItem[j].MaskImage.enabled = true;
                        if (this.m_Data[dataIdx].Item[j].bSelect && this.m_Data[dataIdx].Item[j].bIsFight)
                        {
                            this.m_ScrollObj[panelObjectIdx].PanelItem[j].SelectImage.enabled = true;
                            this.m_ScrollObj[panelObjectIdx].PanelItem[j].FightImage.enabled  = true;
                        }
                        else if (this.m_Data[dataIdx].Item[j].bSelect && !this.m_Data[dataIdx].Item[j].bIsFight && !this.m_Data[dataIdx].Item[j].bIsLords)
                        {
                            this.m_ScrollObj[panelObjectIdx].PanelItem[j].SelectImage.enabled = true;
                            this.m_ScrollObj[panelObjectIdx].PanelItem[j].FightImage.enabled  = false;
                        }
                        else if (this.m_Data[dataIdx].Item[j].bIsFight && !this.m_Data[dataIdx].Item[j].bSelect && !this.m_Data[dataIdx].Item[j].bIsLords)
                        {
                            this.m_ScrollObj[panelObjectIdx].PanelItem[j].FightImage.enabled  = true;
                            this.m_ScrollObj[panelObjectIdx].PanelItem[j].SelectImage.enabled = false;
                        }
                        else if (this.m_Data[dataIdx].Item[j].bIsLords && !this.m_Data[dataIdx].Item[j].bSelect && !this.m_Data[dataIdx].Item[j].bIsFight)
                        {
                            this.m_ScrollObj[panelObjectIdx].PanelItem[j].FightImage.enabled  = false;
                            this.m_ScrollObj[panelObjectIdx].PanelItem[j].SelectImage.enabled = false;
                        }
                        else if (this.m_Data[dataIdx].Item[j].bIsLords && this.m_Data[dataIdx].Item[j].bIsFight && !this.m_Data[dataIdx].Item[j].bSelect)
                        {
                            this.m_ScrollObj[panelObjectIdx].PanelItem[j].FightImage.enabled  = true;
                            this.m_ScrollObj[panelObjectIdx].PanelItem[j].SelectImage.enabled = false;
                        }
                    }
                    else
                    {
                        this.m_ScrollObj[panelObjectIdx].PanelItem[j].MaskImage.enabled   = false;
                        this.m_ScrollObj[panelObjectIdx].PanelItem[j].SelectImage.enabled = false;
                        this.m_ScrollObj[panelObjectIdx].PanelItem[j].FightImage.enabled  = false;
                    }
                }
                else if (array[j].gameObject.activeSelf)
                {
                    array[j].gameObject.SetActive(false);
                }
            }
        }
    }