Exemple #1
0
    /// <summary>
    /// 处理 读取的方块
    /// </summary>
    public void HandleForLoadBlock()
    {
        GameDataManager gameDataManager = GameDataHandler.Instance.manager;
        //获取数据中的chunk
        UserDataBean userData = gameDataManager.GetUserData();

        ChunkSaveBean chunkSaveData = gameDataManager.GetChunkSaveData(userData.userId, WorldCreateHandler.Instance.manager.worldType, chunkData.positionForWorld);

        //如果没有世界数据 则创建一个
        if (chunkSaveData == null)
        {
            chunkSaveData           = new ChunkSaveBean();
            chunkSaveData.workdType = (int)WorldCreateHandler.Instance.manager.worldType;
            chunkSaveData.userId    = userData.userId;
            chunkSaveData.position  = chunkData.positionForWorld;
        }
        chunkSaveData.InitData();
        Dictionary <int, BlockBean> dicBlockData = chunkSaveData.dicBlockData;

        foreach (var itemData in dicBlockData)
        {
            BlockBean  blockData     = itemData.Value;
            Vector3Int positionBlock = blockData.localPosition;

            //添加方块 如果已经有该方块 则先删除,优先使用存档的方块
            //chunkData.GetBlockForLocal(positionBlock, out Block block, out DirectionEnum direction);

            Block block = BlockHandler.Instance.manager.GetRegisterBlock(blockData.blockId);
            chunkData.SetBlockForLocal(positionBlock, block, blockData.direction);
        }
        SetChunkSaveData(chunkSaveData);
    }
Exemple #2
0
    /// <summary>
    /// 检测是否能合成
    /// </summary>
    public bool CheckSynthesis()
    {
        //获取合成材料
        List <ItemsSynthesisMaterialsBean> listMaterials = GetSynthesisMaterials();
        UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();

        for (int i = 0; i < listMaterials.Count; i++)
        {
            ItemsSynthesisMaterialsBean itemMaterials = listMaterials[i];
            bool hasMaterial = false;
            for (int f = 0; f < itemMaterials.itemIds.Length; f++)
            {
                long itemsId = itemMaterials.itemIds[f];
                //有其中一种素材
                bool hasEnoughItem = userData.HasEnoughItem(itemsId, itemMaterials.itemNumber);
                if (hasEnoughItem)
                {
                    hasMaterial = true;
                    break;
                }
            }
            if (hasMaterial == false)
            {
                return(false);
            }
        }
        return(true);
    }
 public override void Launch()
 {
     base.Launch();
     IconHandler.Instance.InitData();
     //打开主UI
     UIHandler.Instance.OpenUIAndCloseOther <UILoading>(UIEnum.Loading);
     //加载资源
     GameHandler.Instance.LoadGameResources(() =>
     {
         UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();
         userData.userPosition.GetWorldPosition(out WorldTypeEnum worldType, out Vector3 worldPosition);
         //如果是测试数据
         if (userData.userId.Equals("Test"))
         {
             worldType = testWorldType;
         }
         testWorldType = worldType;
         //设置游戏状态
         GameHandler.Instance.manager.SetGameState(GameStateEnum.Init);
         //设置种子
         WorldCreateHandler.Instance.manager.SetWorldSeed(userData.seed);
         //开关角色控制
         GameControlHandler.Instance.SetPlayerControlEnabled(false);
         //设置世界类型
         WorldCreateHandler.Instance.SetWorldType(worldType);
         //设置远景模糊
         VolumeHandler.Instance.SetDepthOfField(worldType);
         //刷新周围区块
         GameConfigBean gameConfig = GameDataHandler.Instance.manager.GetGameConfig();
         WorldCreateHandler.Instance.CreateChunkRangeForCenterPosition(Vector3Int.zero, gameConfig.worldRefreshRange, true, CompleteForUpdateChunk);
     });
 }
    /// <summary>
    /// 设置是否有道具
    /// </summary>
    public void SetCanHasItems(long[] listItemsId, long itemsNumber)
    {
        UserDataBean userData      = GameDataHandler.Instance.manager.GetUserData();
        bool         hasEnoughItem = false;

        for (int i = 0; i < listItemsId.Length; i++)
        {
            long itemsId = listItemsId[i];
            if (userData.HasEnoughItem(itemsId, itemsNumber))
            {
                hasEnoughItem = true;
                break;
            }
        }
        if (hasEnoughItem)
        {
            ui_TVNumber.color = Color.green;
            ui_Icon.material.SetFloat("_EffectAmount", 0);
        }
        else
        {
            ui_TVNumber.color = Color.white;
            ui_Icon.material.SetFloat("_EffectAmount", 1);
        }
    }
 public void GetUserDataSuccess(UserDataBean userData)
 {
     if (userData != null)
     {
         this.userData = userData;
     }
 }
Exemple #6
0
    /// <summary>
    /// 点击-升级
    /// </summary>
    public void OnClickForLevel()
    {
        UserDataBean          userData          = uiComponent.handler_GameData.GetUserData();
        UserModelPartDataBean userModelPartData = userModelData.GetUserPartDataById(modelPartInfo.id);

        if (userModelPartData == null)
        {
            return;
        }
        long levelMoney = modelPartInfo.GetLevelUpMoney(userModelPartData.level);
        bool isPay      = userData.PayMoney(levelMoney);

        if (isPay)
        {
            //升级
            int level = userModelPartData.LevelUp(1);
            //计算收益
            long addPrice = modelPartInfo.GetAddPrice(level);
            //增加收益
            userModelPartData.SetAddPrice(addPrice);
            //设置舰船显示进度
            uiComponent.handler_GameModel.SetPartProgress(modelPartInfo.part_name, userModelPartData.GetProgress(modelPartInfo.max_level));
        }
        else
        {
            LogUtil.Log("升级失败,没有足够的金钱");
        }
    }
Exemple #7
0
    /// <summary>
    ///  修改摄像头距离
    /// </summary>
    /// <param name="distance">距离:0为第一人称,0-1距离依次增加</param>
    public void ChangeCameraDistance(float distance)
    {
        CinemachineVirtualCamera cameraForFirst = manager.cameraForFirst;
        CinemachineFreeLook      cameraForThree = manager.cameraForThree;

        if (distance <= 0)
        {
            ChangeCameraPriority(cameraForFirst, 1);
            ChangeCameraPriority(cameraForThree, 0);
        }
        else
        {
            ChangeCameraPriority(cameraForFirst, 0);
            ChangeCameraPriority(cameraForThree, 1);
            for (int i = 0; i < cameraForThree.m_Orbits.Length; i++)
            {
                cameraForThree.m_Orbits[i].m_Height = manager.threeFreeLookOriginalOrbits[i].m_Height * distance;
                cameraForThree.m_Orbits[i].m_Radius = manager.threeFreeLookOriginalOrbits[i].m_Radius * distance;
            }
        }

        //隐藏或显示自己的头
        //if (player != null)
        //{
        //    CreatureCptCharacter creatureCpt = player.GetCharacter();
        //    creatureCpt.SetActiveHead(isShowHead);
        //}

        //保存数据
        UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();

        userData.userSetting.cameraDistance = distance;
    }
Exemple #8
0
    /// <summary>
    /// 设置状态
    /// </summary>
    public void SetItemState()
    {
        UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();
        bool         isUnlock = userData.userAchievement.CheckUnlockBookModelDetails(bookModelDetailsInfo.id);

        //判断是否解锁
        if (isUnlock)
        {
            IconHandler.Instance.manager.GetUISpriteByName("ui_border_13", (sprite) =>
            {
                ui_BG.sprite = sprite;
                ui_BG.color  = Color.green;
                ui_Icon.material.SetFloat("_EffectAmount", 0);
            });
        }
        else
        {
            IconHandler.Instance.manager.GetUISpriteByName("ui_border_14", (sprite) =>
            {
                ui_BG.sprite = sprite;
                ui_BG.color  = Color.white;
                ui_Icon.material.SetFloat("_EffectAmount", 1);
            });
        }
    }
Exemple #9
0
    public void OnClickForAddSpeed()
    {
        GameDataHandler gameDataHandler = uiComponent.handler_GameData;
        GameBean        gameData        = uiComponent.handler_Game.GetGameData();
        UserDataBean    userData        = gameDataHandler.GetUserData();
        int             maxLevel        = uiComponent.handler_GameData.GetLevelMaxForSpeed();

        gameDataHandler.GetLevelLevelUpDataForSpeed(gameData.levelForSpeed, out float addSpeed, out long preSpeedGold);
        if (!gameData.HasEnoughGold(preSpeedGold))
        {
            //钱不够
            uiComponent.manager_Msg.ShowMsg(GameCommonInfo.GetUITextById(1001));
            return;
        }

        bool isLevelUp = gameData.LevelUpForPlayerSpeed(maxLevel, addSpeed);

        if (!isLevelUp)
        {
            //升级失败
            uiComponent.manager_Msg.ShowMsg(GameCommonInfo.GetUITextById(1002));
            return;
        }

        //支付金币
        gameData.PayGold(preSpeedGold);

        uiComponent.handler_Character.SetCharacterSpeed(CharacterTypeEnum.Player, gameData.GetPlayerSpeed() + userData.speed);
        uiComponent.handler_Character.RefreshCharacter(CharacterTypeEnum.Player);
        RefreshUI();
    }
Exemple #10
0
    public void OnClickForAddGoldPrice()
    {
        UserDataBean    userData        = uiComponent.handler_GameData.GetUserData();
        GameDataHandler gameDataHandler = uiComponent.handler_GameData;
        GameBean        gameData        = uiComponent.handler_Game.GetGameData();

        int maxLevel = uiComponent.handler_GameData.GetLevelMaxForGoldPrice();

        gameDataHandler.GetLevelUpDataForGoldPrice(gameData.levelForGoldPrice, out int addPrice, out long prePriceGold);
        if (!gameData.HasEnoughGold(prePriceGold))
        {
            //钱不够
            uiComponent.manager_Msg.ShowMsg(GameCommonInfo.GetUITextById(1001));
            return;
        }

        bool isLevelUp = gameData.LevelUpForGoldPrice(maxLevel, addPrice);

        if (!isLevelUp)
        {
            //升级失败
            uiComponent.manager_Msg.ShowMsg(GameCommonInfo.GetUITextById(1002));
            return;
        }

        //支付金币
        gameData.PayGold(prePriceGold);

        RefreshUI();
    }
    /// <summary>
    /// 创建角色
    /// </summary>
    /// <param name="characterData"></param>
    public void CreateCharacter(CharacterDataBean characterData)
    {
        if (!handler_Gold.GetTargetGold(transform.position))
        {
            //没有金币了也不创建角色
            return;
        }
        UserDataBean userData = handler_GameData.GetUserData();

        if (characterData.characterType == CharacterTypeEnum.Player)
        {
            //如果超过上线则不创建
            if (manager.GetPlayerCharacterNumber() >= userData.pirateNumber)
            {
                return;
            }
        }
        if (characterData.characterType == CharacterTypeEnum.Enemy)
        {
            //如果超过上线则不创建
            if (manager.GetEnemyCharacterNumber() >= numberForEnemy)
            {
                return;
            }
        }

        Vector3 startPosition = handler_Scene.GetStartPosition(characterData.characterType);

        manager.CreateCharacter(startPosition, characterData);
    }
    /// <summary>
    /// 获取玩家游玩时间
    /// </summary>
    /// <returns></returns>
    public TimeBean GetPlayTime()
    {
        UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();
        TimeBean     timeData = userData.timeForPlay;

        return(timeData);
    }
    /// <summary>
    /// 初始化数据
    /// </summary>
    public void InitData()
    {
        UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();

        listBackpack = userData.listBackpack;
        ui_ItemList.AddCellListener(OnCellForItem);
        ui_ItemList.SetCellCount(listBackpack.Length);
    }
Exemple #14
0
    /// <summary>
    /// 初始化位置
    /// </summary>
    public void InitPosition()
    {
        int          maxHeight = WorldCreateHandler.Instance.manager.GetMaxHeightForWorldPosition(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.z));
        UserDataBean userData  = GameDataHandler.Instance.manager.GetUserData();

        userData.userPosition.GetWorldPosition(out WorldTypeEnum worldType, out Vector3 position);
        SetPosition(new Vector3(position.x, maxHeight + 2, position.z));
    }
    /// <summary>
    /// 单个数据回调
    /// </summary>
    /// <param name="itemCell"></param>
    public void OnCellForItem(ScrollGridCell itemCell)
    {
        UserDataBean        userData          = GameDataHandler.Instance.manager.GetUserData();
        UIViewItemContainer viewItemContainer = itemCell.GetComponent <UIViewItemContainer>();
        ItemsBean           itemsData         = userData.GetItemsFromBackpack(itemCell.index);

        viewItemContainer.SetData(UIViewItemContainer.ContainerType.Backpack, itemsData, itemCell.index);
    }
    /// <summary>
    /// 点击-开始合成
    /// </summary>
    public void OnClickForStartSynthesis()
    {
        //当前选中的合成道具
        ItemsSynthesisBean itemsSynthesis = listSynthesisData[indexSelect];
        //检测当前道具是否能合成
        bool canSynthesis = itemsSynthesis.CheckSynthesis();

        if (!canSynthesis)
        {
            //素材不足 无法合成
            UIHandler.Instance.ToastHint <ToastView>(TextHandler.Instance.GetTextById(30002));
            return;
        }
        //首先消耗素材
        BaseUIComponent currentUI = UIHandler.Instance.GetOpenUI();
        //获取素材
        List <ItemsSynthesisMaterialsBean> listMaterials = itemsSynthesis.GetSynthesisMaterials();

        UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();

        //扣除素材
        for (int i = 0; i < listMaterials.Count; i++)
        {
            ItemsSynthesisMaterialsBean itemMaterials = listMaterials[i];
            for (int f = 0; f < itemMaterials.itemIds.Length; f++)
            {
                //只要扣除其中一项素材就行
                long itemMaterialId = itemMaterials.itemIds[f];
                if (userData.HasEnoughItem(itemMaterialId, itemMaterials.itemNumber))
                {
                    userData.RemoveItem(itemMaterialId, itemMaterials.itemNumber);
                    break;
                }
                else
                {
                    continue;
                }
            }
        }
        //添加道具
        itemsSynthesis.GetSynthesisResult(out long itemsId, out int itemNum);
        int moreNum = userData.AddItems(itemsId, itemNum, null);

        //如果还有多余的道具 则丢出来
        if (moreNum > 0)
        {
            Player player = GameHandler.Instance.manager.player;
            ItemsHandler.Instance.CreateItemCptDrop(itemsId, moreNum, null, player.transform.position + Vector3.up, ItemDropStateEnum.DropNoPick);
        }

        UIViewBackpackList backpackUI = currentUI.GetComponentInChildren <UIViewBackpackList>();

        backpackUI.RefreshUI();
        UIViewShortcuts shortcutsUI = currentUI.GetComponentInChildren <UIViewShortcuts>();

        shortcutsUI.RefreshUI();
        RefreshUI();
    }
    /// <summary>
    /// 设置角色控制开关
    /// </summary>
    /// <param name="enabled"></param>
    public void SetPlayerControlEnabled(bool enabled)
    {
        UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();

        CameraHandler.Instance.ChangeCameraDistance(userData.userSetting.cameraDistance);

        manager.controlForPlayer?.EnabledControl(enabled);
        manager.controlForCamera?.EnabledControl(enabled);
    }
Exemple #18
0
    /// <summary>
    /// 互动
    /// </summary>
    public override void Interactive(GameObject user, Vector3Int worldPosition, BlockDirectionEnum direction)
    {
        //暂时解除控制
        ControlForPlayer controlForPlayer = GameControlHandler.Instance.manager.controlForPlayer;
        ControlForCamera controlForCamera = GameControlHandler.Instance.manager.controlForCamera;

        controlForPlayer.EnabledControl(false);
        controlForCamera.EnabledControl(false);

        CameraHandler.Instance.SetCameraAxis(-70, 0);
        //获取链接数据
        WorldCreateHandler.Instance.manager.GetBlockForWorldPosition(worldPosition, out Block targetBlock, out BlockDirectionEnum targetDirection, out Chunk targetChunk);
        BlockBean    blockData     = targetChunk.GetBlockData(worldPosition - targetChunk.chunkData.positionForWorld);
        BlockMetaBed blockMetaData = GetLinkBaseBlockData <BlockMetaBed>(blockData.meta);

        //获取身体的旋转角度
        float angleY = direction == BlockDirectionEnum.UpForward
            ? 0 : direction == BlockDirectionEnum.UpBack
            ? 180 : direction == BlockDirectionEnum.UpLeft
            ? 90 : direction == BlockDirectionEnum.UpRight
            ? -90 : 0;
        //获取身体偏移位置
        float moveX = direction == BlockDirectionEnum.UpLeft
            ? 0.5f : direction == BlockDirectionEnum.UpRight
            ? -0.5f : 0;
        float moveZ = direction == BlockDirectionEnum.UpForward
            ? 0.5f : direction == BlockDirectionEnum.UpBack
            ? -0.5f : 0;

        Player player = GameHandler.Instance.manager.player;

        player.transform.position    = blockMetaData.GetBasePosition() + new Vector3(0.5f, 0.5f, 0.5f);
        player.transform.eulerAngles = new Vector3(0, 180, 0);
        player.character.transform.localEulerAngles = new Vector3(-90, angleY, 0);
        player.character.transform.localPosition    = new Vector3(moveX, 0, moveZ);
        //设置时间
        GameTimeHandler.Instance.SetGameTime(6, 0);

        Action callBackForFinish = () =>
        {
            //恢复控制
            controlForPlayer.EnabledControl(true);
            controlForCamera.EnabledControl(true);
            player.character.transform.localEulerAngles = new Vector3(0, 0, 0);
            player.character.transform.localPosition    = new Vector3(0, 0, 0);
        };

        GameTimeHandler.Instance.WaitExecuteSeconds(3, callBackForFinish);

        //保存位置
        UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();

        userData.userPosition.SetWorldType(WorldCreateHandler.Instance.manager.worldType);
        userData.userPosition.SetPosition(player.transform.position);
        GameDataHandler.Instance.manager.SaveUserData(userData);
    }
Exemple #19
0
    /// <summary>
    /// 获取游戏数据
    /// </summary>
    /// <returns></returns>
    public UserDataBean GetUserDataData(string userId)
    {
        UserDataBean data = serviceUserData.QueryDataByUserId(userId);

        if (data == null)
        {
            data = new UserDataBean();
        }
        return(data);
    }
    public void ChangeGameStatus(GameStatusEnum gameStatus)
    {
        GetGameData().gameStatus = gameStatus;
        switch (gameStatus)
        {
        case GameStatusEnum.GamePre:
            //扫描地形
            //AstarPath.active.ScanAsync();
            //初始化数据
            handler_GameData.GetPlayerInitData(out float playerSpeed, out int playerLife);
            GameBean gameData = new GameBean(playerSpeed, playerLife);
            SetGameData(gameData);
            manager_UI.RefreshAllUI();
            //打开UI
            manager_UI.OpenUIAndCloseOther <UIGameStart>(UIEnum.GameStart);
            //创建金币
            GameLevelBean gameLevelData = GetGameLevelData();
            handler_Gold.CreateGold(gameLevelData.gold_pile, gameLevelData.gold_number, gameLevelData.gold_id);
            break;

        case GameStatusEnum.GameIng:
            //开启角色创建
            UserDataBean      userData            = handler_GameData.GetUserData();
            CharacterDataBean playerCharacterData = new CharacterDataBean(CharacterTypeEnum.Player)
            {
                life      = userData.life + GetGameData().playerForLife,
                maxLife   = userData.life + GetGameData().playerForLife,
                moveSpeed = userData.speed + GetGameData().GetPlayerSpeed()
            };
            CharacterDataBean enemyCharacterData = new CharacterDataBean(CharacterTypeEnum.Enemy)
            {
                life      = GetGameLevelData().enemy_life,
                maxLife   = GetGameLevelData().enemy_life,
                moveSpeed = GetGameLevelData().enemy_speed
            };
            StartCoroutine(handler_Character.InitCreateCharacter(playerCharacterData, enemyCharacterData, GetGameLevelData().enemy_number));
            //创建船
            Action enemyShipCallBack = () =>
            {
                //开启敌舰自动攻击
                handler_Ship.OpenShipFireAutoForEnemy();
            };
            handler_Ship.CreateShip(CharacterTypeEnum.Player, 1, null);
            handler_Ship.CreateShip(CharacterTypeEnum.Enemy, GetGameLevelData().enemy_ship_id, enemyShipCallBack);
            //开启经验计算
            StartCoroutine(CoroutineForLevelProgress());
            break;

        case GameStatusEnum.GameEnd:
            //打开UI
            manager_UI.OpenUIAndCloseOther <UIGameEnd>(UIEnum.GameEnd);
            CleanGameData();
            break;
        }
    }
Exemple #21
0
    public override void OnEnable()
    {
        base.OnEnable();
        if (objRender != null)
        {
            objRender.ShowObj(true);
        }
        //设置角色数据
        UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();

        showCharacter.SetCharacterData(userData.characterData);
    }
Exemple #22
0
 /// <summary>
 /// 获取游戏数据
 /// </summary>
 /// <returns></returns>
 public UserDataBean GetUserData()
 {
     if (userData == null)
     {
         //如果没有数据 则使用测试数据
         userData = new UserDataBean();
         userData.timeForGame.hour = 6;
         userData.userId           = "Test";
         userData.seed             = 132349;
     }
     return(userData);
 }
    /// <summary>
    /// 获取数据
    /// </summary>
    /// <param name="action"></param>
    /// <returns></returns>
    public UserDataBean GetUserDataData(string usreId, Action <UserDataBean> action)
    {
        UserDataBean data = GetModel().GetUserDataData(usreId);

        if (data == null)
        {
            GetView().GetUserDataFail("没有数据", null);
            return(null);
        }
        GetView().GetUserDataSuccess(data, action);
        return(data);
    }
    /// <summary>
    /// 处理-瞄准使用道具的目标
    /// </summary>
    public void HandlerForUseItemSightTarget()
    {
        if (!isActiveAndEnabled)
        {
            return;
        }
        //获取道具栏上的物品
        UserDataBean userData  = GameDataHandler.Instance.manager.GetUserData();
        ItemsBean    itemsData = userData.GetItemsFromShortcut();

        ItemsHandler.Instance.UseItemForSightTarget(itemsData);
    }
Exemple #25
0
    protected override void UseForPlayer(Player player, ItemsBean itemData, ItemUseTypeEnum useType)
    {
        //检测玩家前方是否有方块
        if (player.playerRay.RayToChunkBlock(out RaycastHit hit, out Vector3Int targetBlockPosition))
        {
            ChunkComponent chunkForHit = hit.collider.GetComponentInParent <ChunkComponent>();
            if (chunkForHit != null)
            {
                //获取位置和方向
                player.playerRay.GetHitPositionAndDirection(hit, out Vector3Int targetPosition, out Vector3Int closePosition, out BlockDirectionEnum direction);

                Vector3Int localPosition = targetPosition - chunkForHit.chunk.chunkData.positionForWorld;
                //获取原位置方块
                Block tagetBlock = chunkForHit.chunk.chunkData.GetBlockForLocal(localPosition);

                //如果不能种地
                if (tagetBlock.blockInfo.plant_state == 0)
                {
                    return;
                }

                //种植位置
                Vector3Int upLocalPosition = localPosition + Vector3Int.up;
                //获取上方方块
                Block upBlock = chunkForHit.chunk.chunkData.GetBlockForLocal(upLocalPosition);

                //如果上方有方块 则无法种植
                if (upBlock != null && upBlock.blockType != BlockTypeEnum.None)
                {
                    return;
                }

                //种植的方块
                ItemsInfoBean itemsInfo      = GetItemsInfo(itemData.itemId);
                BlockTypeEnum plantBlockType = (BlockTypeEnum)itemsInfo.type_id;
                //初始化meta数据
                BlockMetaCrop blockCropData = new BlockMetaCrop();
                blockCropData.isStartGrow = false;
                blockCropData.growPro     = 0;
                string metaData = BlockBaseCrop.ToMetaData(blockCropData);
                //替换为种植
                chunkForHit.chunk.SetBlockForLocal(upLocalPosition, plantBlockType, BlockDirectionEnum.UpForward, metaData);

                //扣除道具
                UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();
                userData.AddItems(itemData, -1);
                //刷新UI
                UIHandler.Instance.RefreshUI();
            }
        }
    }
    /// <summary>
    /// 展示用户数据
    /// </summary>
    public void ShowUserData()
    {
        UserDataBean userData1 = GetUserDataByIndex(1);

        ui_ItemMainUserData_1.SetData(1, userData1);

        UserDataBean userData2 = GetUserDataByIndex(2);

        ui_ItemMainUserData_2.SetData(2, userData2);

        UserDataBean userData3 = GetUserDataByIndex(3);

        ui_ItemMainUserData_3.SetData(3, userData3);
    }
Exemple #27
0
    /// <summary>
    /// 设置提交状态
    /// </summary>
    public void SetSubmitState(int bookModelDetailsInfoId)
    {
        UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();

        //检测该模块是否解锁
        if (userData.userAchievement.CheckUnlockBookModelDetails(bookModelDetailsInfoId))
        {
            ui_BTComplete.ShowObj(true);
            ui_BTSumit.ShowObj(false);
        }
        else
        {
            ui_BTComplete.ShowObj(false);
            ui_BTSumit.ShowObj(true);
        }
    }
Exemple #28
0
    /// <summary>
    /// 点击解锁
    /// </summary>
    public void OnClickForUnlock()
    {
        UserDataBean userData = uiComponent.handler_GameData.GetUserData();
        bool         isPay    = userData.PayMoney(modelPartInfo.unlock_money);

        if (isPay)
        {
            //添加解锁数据
            UserModelPartDataBean userModelPartData = userModelData.AddUnLockPart(modelPartInfo.id, modelPartInfo.GetAddPrice(0));
            //设置显示部件
        }
        else
        {
            LogUtil.Log("解锁失败,没有足够的金钱");
        }
    }
 /// <summary>
 /// 通过序号获取用户数据
 /// </summary>
 private UserDataBean GetUserDataByIndex(int index)
 {
     if (listUserData == null || listUserData.Count == 0)
     {
         return(null);
     }
     for (int i = 0; i < listUserData.Count; i++)
     {
         UserDataBean userData = listUserData[i];
         if (userData.dataIndex == index)
         {
             return(userData);
         }
     }
     return(null);
 }
    /// <summary>
    /// 丢弃处理
    /// </summary>
    /// <param name="callback"></param>
    public void HandleForDrop(CallbackContext callback)
    {
        //获取道具栏上的物品
        UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();
        ItemsBean    itemData = userData.GetItemsFromShortcut();

        //丢出道具
        Player  player      = GameHandler.Instance.manager.player;
        Vector3 randomFroce = new Vector3(UnityEngine.Random.Range(-0.5f, 0.5f), UnityEngine.Random.Range(0f, 0.5f), UnityEngine.Random.Range(-0.5f, 0.5f));

        ItemsHandler.Instance.CreateItemCptDrop(itemData.itemId, 1, itemData.meta, player.transform.position + Vector3.up, ItemDropStateEnum.DropNoPick, player.transform.forward + randomFroce);

        //扣除道具
        userData.AddItems(itemData, -1);
        //刷新UI
        UIHandler.Instance.RefreshUI();
    }