Exemple #1
0
    private void ActivePlayer()
    {
        if (!isReset)
        {
            return;
        }
        if (InputController.GetInstance().TargetObj == this.gameObject && InputController.GetInstance().IsInputing)
        {
            if (generateGravity != null)
            {
                generateGravity.SetIsGravity = true;
                generateGravity.SetIsKinematic(false);
                isReset = false;
                isDie   = false;
            }
            if (particleController != null)
            {
                particleController.Play();
            }

            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(3));
            }

            if (particleDoTW)
            {
                particleDoTW.gameObject.SetActive(false);
            }
        }
    }
Exemple #2
0
    private void Start()
    {
        Debug.Log($"There are {GameDataController.GetNotesCount()} data(s)");
        // Make notes if available
        if (GameDataController.GetNotesCount() > 0)
        {
            foreach (NoteData noteData in GameDataController.SaveData.noteDatas)
            {
                // Duplicate notes holder
                GameObject notesDuplicate = Instantiate(notesHolder.gameObject, canvasWorld.transform, true);
                // Name the object
                notesDuplicate.name = noteData.id;

                // Get NotesHolder component
                NotesHolder   notesHolderDuplicate = notesDuplicate.GetComponent <NotesHolder>();
                RectTransform notesRectTransform   = notesDuplicate.GetComponent <RectTransform>();

                notesDuplicate.SetActive(true);

                // Get notes
                GameDataController.GetNotes(noteData,
                                            notesDuplicate.name,
                                            notesHolderDuplicate.TitleText,
                                            notesHolderDuplicate.BodyText,
                                            notesRectTransform);
            }
        }
    }
    private void Awake()
    {
        _baseTransform = transform.Find("Base");

        if (spriteRenderer != null)
        {
            _tintMaterial = spriteRenderer.material;
        }


        if (_shieldCollier != null && GetShield() > 0)
        {
            _shieldCollier.enabled = true;
        }

        if (_collider != null)
        {
            _collider.enabled = GetShield() <= 0;
        }

        _healthLevel = GameDataController.GetPlayerHealthLevel();
        _shieldArmor = GameDataController.GetPlayerShieldArmor();
        SetHealthLevel(_healthLevel);
        SetEquippedShieldArmor(_shieldArmor);
    }
    /// <summary>
    /// 初始化
    /// </summary>
    public virtual void Init()
    {
        Time.timeScale = 1;
        gameState      = GameState.Play;
        GameDataController.GetInstance();

        Application.targetFrameRate = 60;

        if (gameData != null)
        {
            DiamantController[] diamants = FindObjectsOfType <DiamantController>();
            for (int i = 0; i < diamants.Length; i++)
            {
                if (diamants[i])
                {
                    diamants[i].SetGameData = gameData;
                    diamants[i].Init();
                }
            }
        }

        if (gameAwakeEvent != null)
        {
            gameAwakeEvent?.Invoke(0);
        }
    }
Exemple #5
0
 /// <summary>
 /// On End Drag note, set alpha of background image to normal
 /// </summary>
 /// <param name="eventData"></param>
 public void OnEndDrag(PointerEventData eventData)
 {
     backgroundColor.a     = 1f;
     backgroundImage.color = backgroundColor;
     GameDataController.UpdateNotes(this, rectTransform.anchoredPosition);
     isDragging = false;
 }
    public void UpdatedBGMMusic(AudioClip _clip)
    {
        if (MusicMgr.GetInstance() != null)
        {
            if (MusicMgr.GetInstance().GetBGMusic != null)
            {
                if (MusicMgr.GetInstance().GetBGMusic.clip != _clip)
                {
                    MusicMgr.GetInstance().PlayBGMMusicTransition(_clip, transitionTime);
                }
            }
            else
            {
                switch (target)
                {
                case DayAndNight.Day:
                default:
                    if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
                    {
                        MusicMgr.GetInstance().LoadPlayBGMusic(GameDataController.GetInstance().musicData.GetBGMClip(0));
                    }
                    break;

                case DayAndNight.Night:
                    if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
                    {
                        MusicMgr.GetInstance().LoadPlayBGMusic(GameDataController.GetInstance().musicData.GetBGMClip(1));
                    }
                    break;
                }
            }
        }
    }
Exemple #7
0
    public void LoadGame()
    {
        PlayerData data = GameDataController.LoadData();

        health    = data.health;
        maxHealth = data.maxHealth;
        currency  = data.currency;

        Vector3 playerPosition;

        playerPosition.x = data.playerPosition[0];
        playerPosition.y = data.playerPosition[1];
        playerPosition.z = data.playerPosition[2];

        Vector3 dronePosition;

        dronePosition.x = data.dronePosition[0];
        dronePosition.y = data.dronePosition[1];
        dronePosition.z = data.dronePosition[2];

        Vector2 checkpointPosition;

        checkpointPosition.x = data.lastCheckpointPos[0];
        checkpointPosition.y = data.lastCheckpointPos[1];
        lastCheckpointPos    = checkpointPosition;

        lastCheckpointLevelIndex = data.lastCheckpointLevelIndex;

        currentScene = data.currentScene;
    }
Exemple #8
0
    // We make sure this object do not vanishes in loadscenes
    // If our protected static instance variable isn't ready we destroy this one and return the existing one.
    void Awake()
    {
        if (_instance == null)
        {
            DontDestroyOnLoad(gameObject);
            _instance = this;
        }
        else if (_instance != this)
        {
            Destroy(gameObject);
        }

        _sceneLoader = transform.GetComponent <SceneLoader>();

        _dataController = new GameDataController();
        _dataController.Load(_stageNames);
        _stages = Stages.BuildStages(_stageNames, _dataController.GetDataInfo());

        SetupSoundAndMusicManager();

        _device = new DeviceController();

        // if tablet use "fastest" quality (Index 0);
        if (_device.isTablet())
        {
            QualitySettings.SetQualityLevel(0);
        }
    }
    public override void ShowUI()
    {
        //RemoveListener();
        if (!gameObject.activeSelf)
        {
            gameObject.SetActive(true);
        }

        oriRaidus = raidus;
        dir       = (raidus - targetRaidus) >= 0 ? 1 : -1;

        isForward = dir == 1 ? false : true;

        if (isForward)
        {
            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(1), false, 0.3f, true);
            }
        }
        else
        {
            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(2), false, 0.3f, true);
            }
        }

        tempTime = 0;

        cicle = new Vector4(center.x, center.y, raidus);
        AddListener();
    }
Exemple #10
0
    /// <summary>
    /// Save added note
    /// </summary>
    public void SaveAddedNote()
    {
        if (!string.IsNullOrWhiteSpace(inputTitle.text) &&
            !string.IsNullOrWhiteSpace(inputBody.text))
        {
            Debug.Log("Title: " + inputTitle.text);
            Debug.Log("Body: " + inputBody.text);

            // Duplicate notes holder
            GameObject notesDuplicate = Instantiate(notesHolder.gameObject, canvasWorld.transform, true);
            // Name the object
            notesDuplicate.name = $"Note {noteNumber}";
            AddNoteNumber(); // Add number to make name unique

            // Get NotesHolder component
            NotesHolder   notesHolderDuplicate = notesDuplicate.GetComponent <NotesHolder>();
            RectTransform notesRectTransform   = notesDuplicate.GetComponent <RectTransform>();

            notesDuplicate.SetActive(true);

            // Set note's text
            notesHolderDuplicate.TitleText.text = inputTitle.text;
            notesHolderDuplicate.BodyText.text  = inputBody.text;

            // Save to JSON
            GameDataController.SetNotes(notesDuplicate.name,
                                        notesHolderDuplicate.TitleText,
                                        notesHolderDuplicate.BodyText,
                                        notesRectTransform);
        }
    }
    public SaveableScene prepareNextScene(string sceneName, List <IRestorableGameObject> transferToNextScene, bool loadScene = true)
    {
        SaveableScene result = getScene(sceneName);

        FirstTimeSceneLoaded = !loadScene;
        ///check if the scene is loaded already
        if (result == null)
        {
            ///if the scene was not loaded, check if it is even existing as a file in the game folder
            if (sceneExists(sceneName))
            {
                ///if the scene exists in a file load it
                result = GameDataController.LoadSaveable <SaveableScene>(FolderSystem.getSceneSavePath(GameName, sceneName));
                /////create new Scene list. Since its marked as "NonSerialized" its null after loading
                //AllScenes = new List<SaveableScene>();
                addScene(result);
            }
            else
            {
                ///if the scene doesnt exist in file, create a new scene
                result = addNewScene(sceneName);
                ///since the scene was not existing already, "KeepExistingObjects"
                ///is set to true, as the scene objects
                ///should not be deleted when first entering a scene
                FirstTimeSceneLoaded = true;
            }
        }
        CurrentScene = result;
        CurrentScene.initiateLoadedScene();

        CurrentScene.TransferedObjectTree = transferToNextScene;
        return(result);
    }
Exemple #12
0
    private static void UnlockInGameContent(string productId)
    {
        var gameData = GameDataController.GetGameData();

        // Check if a consumable (coins) has been purchased by this user.
        foreach (var coin in CoinList.List.Where(coin =>
                                                 string.Equals(productId, coin.ProductId, StringComparison.Ordinal)))
        {
            gameData.UpdateCoins(coin);
            return;
        }

        // Check if a non-consumable (car) has been purchased by this user.
        foreach (var car in CarList.List.Where(car => string.Equals(productId, car.ProductId,
                                                                    StringComparison.Ordinal)))
        {
            gameData.PurchaseCar(car);
            return;
        }

        // Check if a subscription has been purchased by this user.
        foreach (var subscription in SubscriptionList.List.Where(subscription => string.Equals(productId,
                                                                                               subscription.ProductId,
                                                                                               StringComparison.Ordinal)))
        {
            gameData.UpdateSubscription(subscription);
            return;
        }


        // Pop up window
        Debug.LogError("Product ID doesn't match any of exist products.");
    }
    public void GameEnd()
    {
        Vector3 campoint = InputController.GetInstance().GetMainCam.WorldToScreenPoint(transform.parent.position);
        Vector2 center   = new Vector2(campoint.x / Screen.width, campoint.y / Screen.height);

        EventCenter.GetInstance().EventTrigger <Vector2>("GameEndVector2", center);
        EventCenter.GetInstance().EventTrigger("GameEnd");
        EventCenter.GetInstance().RemoveEventListener(EventData.playerReset, GameReset);

        if (gameData != null)
        {
            gameData.gameClearanceTime = (System.DateTime.Now - gameData.startTime).ToString();
            gameData.gameClearanceDate = System.DateTime.Now.ToString();
        }

        if (GameDataController.GetInstance() != null && GameDataController.GetInstance().sceneData != null)
        {
            string sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
            if (GameDataController.GetInstance().sceneData.GetIsLock(sceneName))
            {
                //Debug.Log("GetIsLock");
                GameDataController.GetInstance().sceneData.ChangeSceneLock(sceneName, false);
            }

            GameDataController.GetInstance().GameSave();
        }



#if UNITY_IOS || UNITY_ANDROID
        InputController.GetInstance().IphoneShake();
#endif
    }
Exemple #14
0
 public void HammerToggleClicked(int newCurrentHammerId)
 {
     UpdateCostMoneyLabels();
     currentHammerId = newCurrentHammerId;
     Debug.Log("toggle " + currentHammerId + " toggled\n name:" + hammers.hammers[currentHammerId].name);
     hammerCreator.SetHammer(hammers.hammers[currentHammerId]);
     GameDataController.setSaveInt(SaveInt.currentHammer, newCurrentHammerId);
 }
    public void Awake()
    {
        if (_instance == null)
            _instance = this;

        gameDataController = new GameDataController();
        gameDataController.LoadGameData();
    }
Exemple #16
0
 // Check if player owns the background, and set the item activeness accordingly.
 private void ToggleBackgroundActivenessBasedOnOwnership()
 {
     foreach (var background in BackgroundList.List)
     {
         var isBackgroundOwned = GameDataController.GetGameData().CheckBackgroundOwnership(background);
         background.GarageItemGameObj.SetActive(isBackgroundOwned);
     }
 }
 // Check if player owns the car.
 private void ToggleCarActivenessBasedOnOwnership()
 {
     foreach (var car in CarList.List)
     {
         var isCarOwned = GameDataController.GetGameData().CheckCarOwnership(car);
         car.GarageItemGameObj.SetActive(isCarOwned);
     }
 }
Exemple #18
0
 private void Awake()
 {
     gameData = new GameDataBean();
     controllerForGameData    = new GameDataController(this, this);
     controllerForUserRevenue = new UserRevenueController(this, this);
     controllerForGameConfig  = new GameConfigController(this, this);
     controllerForGameConfig.GetGameConfigData();
 }
Exemple #19
0
    public static ServerResponseModel SaveGameDataOnline()
    {
        var values = new Dictionary <string, string>
        {
            ["gameData"] = JsonUtility.ToJson(GameDataController.GetGameData())
        };

        return(sendUnityWebRequest(values, SAVE_GAME_DATA_URL));
    }
Exemple #20
0
 public void OnConfirmSubscriptionPanelButtonClicked(bool isConfirmed)
 {
     confirmPanel.SetActive(false);
     if (isConfirmed)
     {
         PurchaseController.PurchaseASubscription(GameDataController.GetGameData().CurSubscriptionObj,
                                                  _subscriptionToSubscribe);
     }
 }
Exemple #21
0
    private void Start()
    {
        if (!GameDataController.IsBombAbilityEnable())
        {
            gameObject.SetActive(false);
        }

        _bombStatus = 0;
    }
 private void RefreshGasStorePage()
 {
     _currentCost       = Math.Ceiling((Gas.FullGasLevel - _gas.GasLevel) * GameDataController.GetGameData().Discount);
     gasPrice.text      = "* " + _currentCost;
     panelGasPrice.text = "Would you like to fill the gas tank with  " + _currentCost + "  coins";
     _gas.SetGasLevelHelper(_gasLevelImage, gasLevelImageObj);
     panelFillGas.SetActive(false);
     cannotAffordWarning.SetActive(false);
 }
    // Init the game.
    public void Awake()
    {
#if ONLINE
        NetworkRequestController.registerUserDevice();
#endif
        InitConstantData();
        GameDataController.LoadGameData();
        SetCanvas(playPageCanvas);
    }
Exemple #24
0
    // Apply discounts on coin text for each car sales in coin.
    private void ApplyCoinItemsDiscount()
    {
        var discount = GameDataController.GetGameData().Discount;

        foreach (var car in CarList.List.Where(car => !car.IsRealMoneyPurchase))
        {
            car.StoreItemCarGameObj.transform.Find("price/priceValue").gameObject.GetComponent <Text>().text =
                (car.Price * discount).ToString(CultureInfo.InvariantCulture);
        }
    }
Exemple #25
0
    private void SetBackgroundUsageStatus()
    {
        foreach (var background in BackgroundList.List)
        {
            background.GarageItemGameObj.transform.Find("statusText").gameObject.SetActive(false);
        }

        GameDataController.GetGameData().BackgroundInUseObj.GarageItemGameObj.transform.Find("statusText").gameObject
        .SetActive(true);
    }
    private void SetCarUsageStatus()
    {
        foreach (var carObj in CarList.List)
        {
            carObj.GarageItemGameObj.transform.Find("statusText").gameObject.SetActive(false);
        }

        GameDataController.GetGameData().CarInUseObj.GarageItemGameObj.transform.Find("statusText").gameObject
        .SetActive(true);
    }
Exemple #27
0
 private void ReplayButtonEvent()
 {
     if (!isButton)
     {
         EventCenter.GetInstance().EventTrigger(EventData.gameReset);
         if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
         {
             ButtonMusicEvent(GameDataController.GetInstance().musicData.GetSEClip(0), false);
         }
     }
 }
    public void GameStart()
    {
        isButton = false;

        EventCenter.GetInstance().RemoveEventListener("PartUIToMainUI", ShowUI);
        EventCenter.GetInstance().RemoveEventListener(EventData.HideHelpUI, ShowUI);

        if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
        {
            isPlayingMusic = GameDataController.GetInstance().musicData.isPlaying;
        }

        if (isPlayingMusic)
        {
            if (MusicMgr.GetInstance().GetBGMusic == null)
            {
                if (musicData)
                {
                    MusicMgr.GetInstance().LoadPlayBGMusic(musicData.GetBGMClip(0));
                }
                else
                {
                    MusicMgr.GetInstance().LoadPlayBGMusic("BGM");
                }
            }
            else if (MusicMgr.GetInstance().BGMusicIsPlaing == false)
            {
                MusicMgr.GetInstance().PlayBGMusic();
            }
        }
        else
        {
            if (MusicMgr.GetInstance().GetBGMusic == null)
            {
                if (musicData)
                {
                    MusicMgr.GetInstance().LoadBGMusic(musicData.GetBGMClip(0));
                }
                else
                {
                    MusicMgr.GetInstance().LoadBGMusic("BGM");
                }
            }
        }

        if (audioOpenImg != null && audioCloseImg != null)
        {
            audioOpenImg.gameObject.SetActive(isPlayingMusic);
            audioCloseImg.gameObject.SetActive(!isPlayingMusic);
        }

        //RemoveListener();
        AddListener();
    }
Exemple #29
0
    void Awake()
    {
        if (Instance != null)
        {
            Destroy(gameObject);
            return;
        }

        Instance = this;
        DontDestroyOnLoad(gameObject);
    }
Exemple #30
0
 private void Awake()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
     }
 }
 // set up our singleton!
 void Awake()
 {
     if(gameDataController == null)
     {
         gameDataController = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Exemple #32
0
    // Use this for initialization
    void Start()
    {
        persistantGameData = new GameDataController();
        persistantGameData.LoadGamedata(this);
        leaderboards.localDataController = persistantGameData;

        // Conditionnal - Android setup
        if (Application.platform == RuntimePlatform.Android)
        {
            cameraDefault.GetComponent<UnityStandardAssets.ImageEffects.Tonemapping>().enabled = false;
        }

        if (VR.VRDevice.isPresent && enableRift)
        {
            GameObject.Find("UIs").transform.FindChild("UI_OCULUS").gameObject.SetActive(true);
            cameraOculus.SetActive(true);
            cameraDefault.SetActive(false);
            ovrCharacter.enabled = true;
            ui.panelFade = ui.oculusPanelFade;
            //GameObject.Find("OVRPlayerController").transform.GetComponentInChildren<Rigidbody>().drag = 10.0f;
        }
        else
        {
            GameObject.Find("UIs").transform.FindChild("UI_OCULUS").gameObject.SetActive(false);
            cameraOculus.SetActive(false);
            cameraDefault.SetActive(true);
            ovrCharacter.enabled = false;
            //GameObject.Find("OVRPlayerController").transform.GetComponentInChildren<Rigidbody>().drag = 1.0f;
        }
        if (collisionGenerationTime == 0)
            collisionGenerationTime = 1.0f;
        defCurrentLevel = currentLevel;
        defMoveSpeedY = moveSpeedY;
        defMoveSpeedIncr = moveSpeedIncr;
    }