Exemplo n.º 1
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();
    }
Exemplo n.º 2
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();
    }
Exemplo n.º 3
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
            GameDataHandler.CheckFolder();
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }

        GameDataHandler.LoadGemCount(out goldCount, out topazCount, out rubyCount, out sapphireCount, out diamondCount);
        var allcard = GameDataHandler.LoadCards();

        if (allcard != null)
        {
            AllCards = allcard;
        }
        //AllCards = GameDataHandler.LoadCards();
        stage_count = GameDataHandler.LoadStageCount();
        mapName     = "Stage" + stage_count;
        // GameDataHandler.SaveCards(AllCards);
    }
Exemplo n.º 4
0
    public void AddGold(int gold)
    {
        goldCount += gold;

        GameDataHandler.SaveGemCount(goldCount, topazCount, rubyCount, sapphireCount, diamondCount);
        MainUIMnager.Instance.SetText();
    }
Exemplo n.º 5
0
 public void OnStageClear()
 {
     stage_count++;
     GameDataHandler.SaveStageCount(stage_count);
     isFirstStart = true;
     mapName      = "Stage" + stage_count;
 }
Exemplo n.º 6
0
 void Update()
 {
     if (save && spot != null)
     {
         GameDataHandler.SaveMap(spot, map_name);
         save = false;
     }
 }
Exemplo n.º 7
0
    void Awake()
    {
        upParticle = Resources.Load("Upgrade Particle System") as GameObject;
        int cardCount = GameManager.instance.AllCards.Count;

        for (int i = 0; i < cardCount; i++)
        {
            CardSet cardSet = GameManager.instance.AllCards[i];
            if (cardSet.upgradeLevel > 4)
            {
                continue;
            }

            CardPicker picker = Instantiate(pickerPrefab);
            picker.transform.SetParent(layoutGroup.transform);

            picker.SetOption(cardSet.showCard, (cardPicker) =>
            {
                WindowUI win = Instantiate(MainUIMnager.Instance.window);
                win.GetComponent <ChooseWindowUI>().SetWindow("카드 강화", "계속 하시겠습니까?\n\n" + string.Format("{0} -> {1}", cardSet.upgradeLevel, cardSet.upgradeLevel + 1), "네", "아니요", () =>
                {
                    int cost = cardSet.showCard.card.upgradeCostPerLevel;
                    if (cardSet.showCard.card.upgradeCostPerLevel <= GameManager.instance.goldCount && cardSet.showCard.card.upgradeGemPerLevel <= GameManager.instance.GetGem(cardSet.showCard.card.type))
                    {
                        GameManager.instance.AddGold(-cost);
                        GameManager.instance.AddGem(cardSet.showCard.card.type, -cardSet.showCard.card.upgradeGemPerLevel);

                        cardSet.upgradeLevel++;

                        GameObject temp = Instantiate(upParticle, cardPicker.transform.position, Quaternion.identity);
                        Destroy(temp, 3.0f);

                        GameDataHandler.SaveCards(GameManager.instance.AllCards);

                        Destroy(win.gameObject);
                        if (cardSet.upgradeLevel > 4)
                        {
                            Destroy(picker.gameObject);
                        }
                    }
                    else
                    {
                        Destroy(win.gameObject);
                        win = Instantiate(MainUIMnager.Instance.window);
                        win.GetComponent <ChooseWindowUI>().SetWindow("강화 실패", "재료가 부족합니다.", "확인", "취소", () =>
                        {
                        }, () => Destroy(win.gameObject));
                    }
                }, () => Destroy(win.gameObject));
            });
        }

        Canvas cam = transform.GetChild(0).GetComponent <Canvas>();

        cam.worldCamera = Camera.main;
    }
Exemplo n.º 8
0
        public GameDataHandler GetHandler(ushort id)
        {
            GameDataHandler handler = null;

            if (_gameHandlers.ContainsKey(id))
            {
                try {
                    _gameHandlers.TryGetValue(id, out handler);
                }catch { handler = null; }
            }
            return(handler);
        }
Exemplo n.º 9
0
    void Awake()
    {
        if (gameDataHandler == null)
        {
            Debug.LogWarning("GameDataHandler object is null; set through FindByObjectOfType<>.");
            gameDataHandler = FindObjectOfType <GameDataHandler>();
        }

        // Fix: loading of data occurs on Start (in the GameDataHandler script) so this occurs first and doesn't use the loaded value from the JSON file
        // This simply uses whatever is set in the inspector
        GameData gameData = gameDataHandler.gameData;

        CountdownValue += (CountdownValue * gameData.Clock);
    }
Exemplo n.º 10
0
    private void Start()
    {
        mytools     = GetComponent <GameDataHandler>();
        statObjJump = GameObject.Find("PlayerStatsJumpHeightPtsValue");
        statObjHit  = GameObject.Find("PlayerStatsHitForcePtsValue");
        statObjMove = GameObject.Find("PlayerStatsMoveSpeedPtsValue");
        statObjGrav = GameObject.Find("PlayerStatsCoinGravityPtsValue");

        //mytools.settings.PlayerStatsJumpHeightPts = 2;
        //mytools.settings.PlayerStatsHitForcePts = 2;
        //mytools.settings.PlayerStatsMoveSpeedPts = 2;
        //mytools.settings.PlayerStatsCoinGravityPts = 2;
        //mytools.settings.PlayerStatsTimeControlPts = 2;
    }
Exemplo n.º 11
0
    void AutoReset(Scene scene, LoadSceneMode mode)
    {
        GameDataHandler.SaveGemCount(goldCount, topazCount, rubyCount, sapphireCount, diamondCount);

        switch (scene.name)
        {
        case "Title":
            isFirstStart = true;
            GameDataHandler.LoadGemCount(out goldCount, out topazCount, out rubyCount, out sapphireCount, out diamondCount);
            MainUIMnager.Instance.SetText();
            stage_count = GameDataHandler.LoadStageCount();
            mapName     = "Stage" + stage_count;
            break;
        }
    }
Exemplo n.º 12
0
    public void SetOption(int goldCount, int topazCount, int rubyCount, int sapphireCount, int diamondCount)
    {
        GoldText.text     = goldCount.ToString();
        TopazText.text    = topazCount.ToString();
        RubyText.text     = rubyCount.ToString();
        SapphireText.text = sapphireCount.ToString();
        DiamondText.text  = diamondCount.ToString();

        GameManager.instance.goldCount     += goldCount;
        GameManager.instance.topazCount    += topazCount;
        GameManager.instance.rubyCount     += rubyCount;
        GameManager.instance.sapphireCount += sapphireCount;
        GameManager.instance.diamondCount  += diamondCount;

        if (cardLayout == null)
        {
            Debug.LogError("cardLayout이 없어 보상창에 추가카드를 표시할 수 없습니다.");
            return;
        }

        if (cardPrefabList.Count == 0)
        {
            Debug.LogError("추가로 제공할 카드가 없습니다.");
            return;
        }

        // 일단은 추가카드 선택은 랜덤으로 해뒀음 나중에 수정할 예정
        for (int i = 0; i < 3; i++)
        {
            int randomIndex = Random.Range(0, cardPrefabList.Count);

            ShowCard   additionalCard = cardPrefabList[randomIndex];
            CardPicker picker         = Instantiate(cardPicker);

            picker.SetOption(additionalCard, (cardpicker) => {
                if (!this.isSelected)
                {
                    GameManager.instance.AllCards.Add(new CardSet(additionalCard, 0));
                    cardpicker.image.sprite = null;
                    this.isSelected         = true;
                    GameDataHandler.SaveCards(GameManager.instance.AllCards);
                }
            });

            picker.transform.SetParent(cardLayout.transform);
        }
    }
Exemplo n.º 13
0
    private void Awake()
    {
        m_Rigidbody2D = GetComponent <Rigidbody2D>();

        if (OnLandEvent == null)
        {
            OnLandEvent = new UnityEvent();
        }


        GameObject Coin = GameObject.Find("Coin");

        if (Coin != null)
        {
            mytools = Coin.GetComponent <GameDataHandler>();
        }
    }
Exemplo n.º 14
0
    public void RefreshUI()
    {
        GameBean        gameData        = uiComponent.handler_Game.GetGameData();
        GameDataHandler gameDataHandler = uiComponent.handler_GameData;

        gameDataHandler.GetLevelLevelUpDataForSpeed(gameData.levelForSpeed, out float addSpeed, out long preSpeedGold);
        SetTextForAttribute(ui_TvSpeedLevel, ui_TvSpeedMoney, gameData.levelForSpeed, gameDataHandler.GetLevelMaxForSpeed(), preSpeedGold);
        SetButtonStatusForAttribute(ui_BtSpeedAdd, preSpeedGold);

        gameDataHandler.GetLevelLevelUpDataForNumber(gameData.levelForPirateNumber, out int addNumber, out long preNumberGold);
        SetTextForAttribute(ui_TvNumberLevel, ui_TvNumberMoney, gameData.levelForPirateNumber, gameDataHandler.GetLevelMaxForNumber(), preNumberGold);
        SetButtonStatusForAttribute(ui_BtNumberAdd, preNumberGold);

        gameDataHandler.GetLevelUpDataForGoldPrice(gameData.levelForGoldPrice, out int addPrice, out long prePriceGold);
        SetTextForAttribute(ui_TvGoldPriceLevel, ui_TvGoldPriceMoney, gameData.levelForGoldPrice, gameDataHandler.GetLevelMaxForGoldPrice(), prePriceGold);
        SetButtonStatusForAttribute(ui_BtGoldPriceAdd, prePriceGold);
    }
Exemplo n.º 15
0
    void Awake()
    {
        string mapName = GameManager.instance.mapName;

        if (GameManager.instance.isFirstStart)
        {
            // traveler.nowSpot = MapDataHandler.CreateMap("Test");
            // MapDataHandler.SaveMapJson(traveler.nowSpot, "Test");
            Spot.nowSpot = GameDataHandler.LoadMap(mapName);
            GameManager.instance.isFirstStart = false;
            Spot.SetParent();
        }
        else
        {
            Spot firstSpot = GameDataHandler.LoadMap(mapName);
            GameDataHandler.LoadProgress(firstSpot, mapName);
            Spot.nowSpot = Spot.GetProgressSpot();
            Spot.SetParent();
        }
    }
Exemplo n.º 16
0
 public override void Handle(User sender, InPacket packetReader)
 {
     if (sender.Authenticated && sender.Room != null)
     {
         // [0] = ROOM SLOT
         // [1] = ROOM ID
         byte roomSlot = packetReader.ReadByte(0);
         if (roomSlot < sender.Room.MaximumPlayers)
         {
             ushort roomId = packetReader.ReadUshort(1);
             if (roomId == sender.Room.ID)
             {
                 byte   unknown = packetReader.ReadByte(2); // Seems to be 2 or 0?
                 ushort subType = packetReader.ReadUshort(3);
                 // HANDLE PACKET IN A SEPERATED CLASS //
                 GameDataHandler handler = NetworkTable.Instance.GetHandler(subType);
                 if (handler != null)
                 {
                     try
                     {
                         handler.Process(sender, packetReader);
                     }
                     catch { /* error? */ }
                 }
                 else
                 {
                     Log.Instance.WriteLine("UNKNOWN SUBPACKET :: " + packetReader);
                 }
             }
             else
             {
                 sender.Disconnect(); // Wrong room targeted - Cheating?
             }
         }
         else
         {
             sender.Disconnect(); // Room slot over maximum players - Cheating?
         }
     }
 }
Exemplo n.º 17
0
    public void OnClickForAddNumber()
    {
        GameBean        gameData        = uiComponent.handler_Game.GetGameData();
        GameDataHandler gameDataHandler = uiComponent.handler_GameData;
        UserDataBean    userData        = gameDataHandler.GetUserData();

        int maxLevel = uiComponent.handler_GameData.GetLevelMaxForNumber();

        gameDataHandler.GetLevelLevelUpDataForNumber(gameData.levelForPirateNumber, out int addNumber, out long preNumberGold);

        if (!gameData.HasEnoughGold(preNumberGold))
        {
            //钱不够
            uiComponent.manager_Msg.ShowMsg(GameCommonInfo.GetUITextById(1001));
            return;
        }
        bool isLevelUp = gameData.LevelUpForPlayerPirateNumber(maxLevel, addNumber);

        if (!isLevelUp)
        {
            //升级失败
            uiComponent.manager_Msg.ShowMsg(GameCommonInfo.GetUITextById(1002));
            return;
        }
        //支付金币
        gameData.PayGold(preNumberGold);
        //生成海盗
        for (int i = 0; i < addNumber; i++)
        {
            CharacterDataBean playerCharacterData = new CharacterDataBean(CharacterTypeEnum.Player)
            {
                life      = userData.life + gameData.playerForLife,
                maxLife   = userData.life + gameData.playerForLife,
                moveSpeed = userData.speed + gameData.GetPlayerSpeed()
            };
            uiComponent.handler_Character.CreateCharacter(playerCharacterData);
        }
        RefreshUI();
    }
Exemplo n.º 18
0
    // Use this for initialization
    void Awake()
    {
        _gameSceneTool   = GameObject.Find("Game_Controller").GetComponent <GameSceneTool>();
        _gameDataHandler = GameDataHandler.Instance;
        _cursor          = GameObject.Find("Cursor").GetComponent <CursorController>();
        _isOnline        = false;

        if (_gameDataHandler.PlayerNum == 0)
        {
            _isBlack = true;
            _gameDataHandler.PlayerNum++;
        }
        else if (_gameDataHandler.PlayerNum == 1)
        {
            _isBlack = false;
            _gameDataHandler.PlayerNum++;
        }
        else
        {
            throw new MaxPlayerException();
        }
        Debug.Log("Player awaked, _isBlack = " + _isBlack);
    }
Exemplo n.º 19
0
    void Start()
    {
        sql  = SQLHandler.sqlHandler;
        json = JSONHandler.jsonHandler;

        string JSONData = json.LoadFile(Application.persistentDataPath + "/game.json");

        if (JSONData != null)
        {
            gameData = JsonUtility.FromJson <GameDataHandler>(JSONData);
        }
        else
        {
            gameData = new GameDataHandler();
        }

        // load all levels

        // while (levels.Read()) {
        //     Debug.Log(levels[1].ToString());
        // }

        normalTimeScale = Time.timeScale;
    }
Exemplo n.º 20
0
    public void AddGem(Type.TYPE type, int add)
    {
        switch (type)
        {
        case Type.TYPE.DIAMOND:
            diamondCount += add;
            break;

        case Type.TYPE.RUBY:
            rubyCount += add;
            break;

        case Type.TYPE.SAPPHIRE:
            sapphireCount += add;
            break;

        case Type.TYPE.TOPAZ:
            topazCount += add;
            break;
        }

        GameDataHandler.SaveGemCount(goldCount, topazCount, rubyCount, sapphireCount, diamondCount);
        MainUIMnager.Instance.SetText();
    }
Exemplo n.º 21
0
 void Awake()
 {
     rb2D    = GetComponent <Rigidbody2D>();
     mytools = GetComponent <GameDataHandler>();
 }
Exemplo n.º 22
0
 public void SaveProgress()
 {
     GameDataHandler.SaveProgress(Spot.GetFirstSpot(), mapName);
 }
Exemplo n.º 23
0
 public void LoadTitleDie()
 {
     SceneLoader.LoadSceneWithFadeStatic("Title");
     GameDataHandler.SaveStageCount(0);
     Debug.Log("asdf");
 }
Exemplo n.º 24
0
 public void AddSelfToGameMoveList()
 {
     GameDataHandler.AddMove(this);
 }