/* * どの場所に * どの種類のスタッフを配置するか * しかもお手持ちおスタッフかどうかも判断 * */ public void Initialize(DataItem _dataOffice, int _iStaffId, int _iStaffSerial) { /* * Debug.Log ("Initialize"); * Debug.Log (_dataOffice); * Debug.Log (_iStaffId); * Debug.Log (_iStaffSerial); */ m_dataOffice = _dataOffice; m_iSetStaffId = _iStaffId; m_iSetStaffSerial = _iStaffSerial; GameObject dispRoot = gameObject.transform.parent.parent.parent.parent.gameObject; //GameObject obj = PrefabManager.Instance.MakeObject ("prefab/PrefDispOffice", gameObject.transform.parent.parent.parent.parent.gameObject); GameObject obj = PrefabManager.Instance.MakeObject("prefab/PrefDispOffice", dispRoot); m_dispOffice = obj.GetComponent <CtrlDispOffice> (); m_dispOffice.Initialize(m_dataOffice.item_serial, GameMain.PanelFront); m_dispOffice.SetColor(Define.Item.Category.SHOP, new Color(0.75f, 0.75f, 0.75f)); m_dispOffice.SetColor(Define.Item.Category.NONE, new Color(0.75f, 0.75f, 0.75f)); m_iSelectingCageSerial = m_dispOffice.SelectingCageSerial; m_iSelectingCageSerialPre = m_iSelectingCageSerial; m_bIsEnd = false; m_fTimer = 0.0f; GameObject objYesNo = PrefabManager.Instance.MakeObject("prefab/PrefYesNoButton", GameMain.PanelFront); objYesNo.transform.localPosition = new Vector3(0.0f, -400.0f, 0.0f); m_buttonYesNo = objYesNo.GetComponent <CtrlYesNoButton> (); m_buttonYesNo.EnableButtonYes(false); return; }
// Update is called once per frame void Update() { //m_fTimer += Time.deltaTime; if (10.0f < m_fTimer) { m_bIsEnd = true; } if (m_buttonYesNo.IsYes()) { m_bIsEnd = true; DataStaff staff; int iStaffCost = 0; if (0 < m_iSetStaffSerial) { //GameMain.dbStaff.Update( Debug.Log(string.Format("set staff from backyard:{0}", m_iSetStaffSerial)); string strNow = TimeManager.StrNow(); Dictionary <string, string> dict = new Dictionary <string, string> (); dict.Add("office_serial", m_dataOffice.item_serial.ToString()); dict.Add("item_serial", m_dispOffice.SelectingCageSerial.ToString()); dict.Add("setting_time", "\"" + strNow + "\""); staff = GameMain.dbStaff.Update(m_iSetStaffSerial, dict); CsvStaffData staff_data = DataManager.GetStaff(m_iSetStaffId); iStaffCost = staff_data.coin; } else { staff = GameMain.dbStaff.Insert(m_iSetStaffId, m_dataOffice.item_serial, m_dispOffice.SelectingCageSerial); CsvStaffData staff_data = DataManager.GetStaff(m_iSetStaffId); if (0 < staff_data.coin) { DataManager.user.AddGold(-1 * staff_data.coin); } else if (0 < staff_data.ticket) { DataManager.user.AddTicket(-1 * staff_data.ticket); } else { ; // エラーちゃう? } iStaffCost = staff_data.cost; } CtrlFieldItem fielditem = GameMain.ParkRoot.GetFieldItem(m_dispOffice.SelectingCageSerial); GameObject objIcon = PrefabManager.Instance.MakeObject("prefab/PrefIcon", fielditem.gameObject); CtrlIconRoot iconRoot = objIcon.GetComponent <CtrlIconRoot> (); iconRoot.Initialize(staff, fielditem); fielditem.Add(iconRoot); // 仕事の確認 DataWork.WorkCheck(); GameMain.Instance.HeaderRefresh(); GameMain.ListRefresh = true; GameMain.Instance.m_iCostNokori -= iStaffCost; } else if (m_buttonYesNo.IsNo()) { m_bIsEnd = true; } else { ; // } m_iSelectingCageSerial = m_dispOffice.SelectingCageSerial; if (m_iSelectingCageSerialPre != m_iSelectingCageSerial) { if (0 < m_iSelectingCageSerialPre) { CtrlFieldItem script = GameMain.ParkRoot.GetFieldItem(m_iSelectingCageSerialPre); script.SetColor(Color.white); } if (0 < m_iSelectingCageSerial) { m_buttonYesNo.EnableButtonYes(true); CtrlFieldItem script = GameMain.ParkRoot.GetFieldItem(m_iSelectingCageSerial); script.SetColor(Color.red); m_iSelectingCageSerialPre = m_iSelectingCageSerial; } } }
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; }