public bool SetEditFarmObject(FarmObject farmObject, Vector3 basePos3D) { FarmRoot instance = FarmRoot.Instance; FarmField field = instance.Field; FarmField.Field field2 = field.GetField(); this.farmObject = farmObject; this.settingMode = FarmObjectSetting.SettingMode.EDIT; FarmGrid.GridPosition gridPosition = field.Grid.GetGridPosition(basePos3D); bool flag = field.IsOutsideField(gridPosition); if (flag) { gridPosition = field.Grid.GetGridPosition(Vector3.zero); } int gridIndex = field.Grid.GetGridIndex(gridPosition); Vector3 positionGridCenter = field.Grid.GetPositionGridCenter(gridIndex, false); this.farmObject.SetPosition(field.gridHorizontal, field.gridVertical, positionGridCenter); this.farmObject.DisplayedInFront(true); int[] gridIndexs = this.farmObject.GetGridIndexs(field2, gridIndex); this.farmObject.isPlaceable = (!this.farmObject.IsInvalidGrid(field, gridIndexs) && !this.farmObject.IsPutGrid(field2, gridIndexs)); return(flag); }
public bool SetFarmObject(FarmObject farmObject, Vector3 basePos3D) { FarmField field = FarmRoot.Instance.Field; this.farmObject = farmObject; this.settingMode = FarmObjectSetting.SettingMode.BUILD; this.farmObject.SetSettingMark(field, FarmRoot.Instance.SettingMark); FarmGrid.GridPosition gridPosition = field.Grid.GetGridPosition(basePos3D); bool flag = field.IsOutsideField(gridPosition); if (flag) { gridPosition = field.Grid.GetGridPosition(Vector3.zero); } int gridIndex = field.Grid.GetGridIndex(gridPosition); Vector3 positionGridCenter = field.Grid.GetPositionGridCenter(gridIndex, false); this.farmObject.SetPosition(field.gridHorizontal, field.gridVertical, positionGridCenter); this.farmObject.DisplayedInFront(true); FarmField.Field field2 = field.GetField(); this.farmObject.SetMarkColor(field2, gridIndex); FarmRoot.Instance.Input.AddTouchDragEvent(new Func <InputControll, bool>(this.OnDrag)); return(flag); }