Beispiel #1
0
 public void InitEdit(int _iX, int _iY, int _iItemId, ParkMain.EDIT_MODE _eEditMode)
 {
     m_bEditting = true;
     Init(_iX, _iY, _iItemId, _eEditMode);
     m_eStep = STEP.EDITTING;
     return;
 }
Beispiel #2
0
    public void Init(int _iX, int _iY, int _iItemId, ParkMain.EDIT_MODE _eEditMode = ParkMain.EDIT_MODE.NORMAL)
    {
        m_eStep    = STEP.INIT;
        m_eStepPre = STEP.MAX;


        if (_eEditMode == ParkMain.EDIT_MODE.MOVE)
        {
        }
        else
        {
            m_iconRootList.Clear();
        }

        m_dataItem.x = _iX;
        m_dataItem.y = _iY;

        change_sprite(m_sprItem, _iItemId);
        DataItemMaster master = GameMain.dbItemMaster.Select(_iItemId);

        m_dataItem.width    = master.size;
        m_dataItem.height   = master.size;
        m_dataItem.item_id  = _iItemId;
        m_dataItem.category = master.category;

        m_dataItemMaster = master;

        SetPos(_iX, _iY);

        return;
    }
Beispiel #3
0
    override protected void initialize()
    {
        bool          bBuyAble      = true;
        CtrlFieldItem moveFieldItem = null;

        if (m_parkMain.m_eEditMode == ParkMain.EDIT_MODE.NORMAL)
        {
            // 道路のみ特殊処理
            // 道のみシリアルがあるものから利用
            // あとあとを見越して、同じitem_idがあれば反応できるようにしておく
            if (GameMain.Instance.m_iSettingItemId == Define.ITEM_ID_ROAD)
            {
                List <DataItem> same_list = GameMain.dbItem.Select(string.Format(" item_id = {0} and status = {1} ", GameMain.Instance.m_iSettingItemId, (int)Define.Item.Status.NONE));
                if (0 < same_list.Count)
                {
                    GameMain.Instance.m_iSettingItemSerial = same_list [0].item_serial;
                }
                else
                {
                    GameMain.Instance.m_iSettingItemSerial = 0;
                }
            }
        }
        else if (m_parkMain.m_eEditMode == ParkMain.EDIT_MODE.MOVE)
        {
            // そのまま使う
            // 自分を一度消す
            int iRemoveIndex = 0;
            foreach (CtrlFieldItem item in GameMain.ParkRoot.m_fieldItemList)
            {
                if (item.m_dataItem.item_serial == GameMain.Instance.m_iSettingItemSerial)
                {
                    //item.Remove ();
                    moveFieldItem = item;
                    GameMain.Instance.m_iSettingItemId = moveFieldItem.m_dataItem.item_id;                              // 別にここでやる必要はない
                    GameMain.ParkRoot.m_fieldItemList.RemoveAt(iRemoveIndex);
                    break;
                }
                iRemoveIndex += 1;
            }

            DataItem dataItem = GameMain.dbItem.Select(GameMain.Instance.m_iSettingItemSerial);
            // 消す予定のところに新しい土地を設置する
            for (int x = dataItem.x; x < dataItem.x + dataItem.width; x++)
            {
                for (int y = dataItem.y; y < dataItem.y + dataItem.height; y++)
                {
                    GameObject obj = PrefabManager.Instance.MakeObject("prefab/PrefFieldItem", GameMain.ParkRoot.gameObject);
                    obj.name = "fielditem_" + x.ToString() + "_" + y.ToString();
                    CtrlFieldItem script = obj.GetComponent <CtrlFieldItem> ();
                    script.Init(x, y, 0);
                    GameMain.ParkRoot.m_fieldItemList.Add(script);
                }
            }
        }
        else
        {
        }

        //Debug.LogError (GameMain.Instance.m_iSettingItemSerial);
        if (m_parkMain.m_pageHeader == null)
        {
            m_parkMain.m_pageHeader = m_parkMain.makeHeader("header_item", "Setting1");
        }

        m_editItemMaster = GameMain.dbItemMaster.Select(GameMain.Instance.m_iSettingItemId);
        m_DontSetGridList.Clear();

        Release(m_goBuyType);
        if (GameMain.Instance.m_iSettingItemId == Define.ITEM_ID_ROAD && GameMain.Instance.m_iSettingItemSerial == 0 && GameMain.Instance.PreSettingItemId == Define.ITEM_ID_ROAD)
        {
            m_goBuyType = PrefabManager.Instance.MakeObject("prefab/PrefBuyType", gameObject);
            m_goBuyType.transform.localPosition = new Vector3(190.0f, 268.0f, 0.0f);
            BuyItemButton buy_type   = m_goBuyType.GetComponent <BuyItemButton> ();
            string        strBuyType = "[FF0000]購入[-]";
            if (0 < GameMain.Instance.m_iSettingItemSerial)
            {
                strBuyType = "保管庫";
            }
            buy_type.SetText(strBuyType);
            buy_type.SetText(string.Format("{0}G", m_editItemMaster.need_coin));
        }

        if (m_YesNoButtonManager == null)
        {
            GameObject goButtonManager = PrefabManager.Instance.MakeObject("prefab/PrefYesNoButton", gameObject);
            goButtonManager.transform.localPosition = new Vector3(0.0f, -400.0f, 0.0f);
            m_YesNoButtonManager = goButtonManager.GetComponent <ButtonManager> ();
            m_YesNoButtonManager.ButtonInit();
            m_YesNoButtonManager.TriggerClearAll();
        }
        CtrlYesNoButton yes_no_button = m_YesNoButtonManager.gameObject.GetComponent <CtrlYesNoButton> ();

        m_eStep    = STEP.IDLE;
        m_eStepPre = STEP.MAX;

        GameMain.Instance.m_bStartSetting = false;
        // ゾンビアイコンを00の位置に表示する
        m_iEditItemX = 3;
        m_iEditItemY = 3;

        GameMain.GetGrid(new Vector2(Screen.width / 2, Screen.height / 2), out m_iEditItemX, out m_iEditItemY);

        ParkMain.EDIT_MODE eEditMode = ParkMain.EDIT_MODE.NORMAL;
        Debug.Log(m_parkMain.m_eEditMode);
        if (m_parkMain.m_eEditMode == ParkMain.EDIT_MODE.NORMAL)
        {
            GameObject prefab = PrefabManager.Instance.PrefabLoadInstance("prefab/PrefFieldItem");
            GameObject obj    = PrefabManager.Instance.MakeObject(prefab, m_parkMain.goParkRoot);
            m_editItem = obj.GetComponent <CtrlFieldItem> ();
        }
        else if (m_parkMain.m_eEditMode == ParkMain.EDIT_MODE.MOVE)
        {
            eEditMode  = ParkMain.EDIT_MODE.MOVE;
            m_editItem = moveFieldItem;            //GameMain.ParkRoot.GetFieldItem (GameMain.Instance.m_iSettingItemSerial);

            m_iEditItemX = m_editItem.m_dataItem.x;
            m_iEditItemY = m_editItem.m_dataItem.y;
            Debug.Log(m_editItem.m_dataItem.item_id);
        }
        m_editItem.InitEdit(m_iEditItemX, m_iEditItemY, GameMain.Instance.m_iSettingItemId, eEditMode);
        //Debug.LogError( string.Format( "x:{0} y:{1}" , m_iEditItemX , m_iEditItemY ));


        // お金が足りる
        // 実際には道路しかひっかからないはず
        if (m_editItemMaster.need_coin <= DataManager.user.m_iGold)
        {
            bBuyAble = true;
            ;            //OK
        }
        else
        {
            bBuyAble = false;
        }

        if (bBuyAble == false && 0 == GameMain.Instance.m_iSettingItemSerial)
        {
            yes_no_button.EnableButtonYes(false);
        }

        string strWhere = " status != 0 ";

        if (m_parkMain.m_eEditMode == ParkMain.EDIT_MODE.MOVE)
        {
            strWhere = string.Format(" status != {0} and item_serial != {1} ", (int)Define.Item.Status.NONE, GameMain.Instance.m_iSettingItemSerial);
        }
        DataManager.Instance.m_ItemDataList = GameMain.dbItem.Select(strWhere);
        Grid.SetUsingGrid(ref m_DontSetGridList, DataManager.Instance.m_ItemDataList);
        foreach (Grid dont in m_DontSetGridList)
        {
            //Debug.Log (string.Format ("x={0} y={1} ", dont.x, dont.y));
        }
        bool bAbleSet = Grid.AbleSettingItem(m_editItemMaster, m_iEditItemX, m_iEditItemY, m_DontSetGridList);

        m_editItem.SetEditAble(bAbleSet);

        return;
    }