Inheritance: MonoBehaviour
Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.Space))
        {
            CustomData customData = new CustomData();
            customData.Add("velocity", this.gameObject.GetComponent <Rigidbody>().velocity.ToString());

            RedMetricsManager.get().sendEvent(TrackingEvent.JUMP,
                                              this.gameObject.transform.position,
                                              customData,
                                              Application.loadedLevelName);

            giveImpulsion();
        }

        if (this.gameObject.transform.localPosition.y < -2.0f)
        {
            CustomData customData = new CustomData();
            customData.Add("velocity", this.gameObject.GetComponent <Rigidbody>().velocity.ToString());

            RedMetricsManager.get().sendEvent(TrackingEvent.BOUNCE,
                                              this.gameObject.transform.position,
                                              customData,
                                              Application.loadedLevelName);
            giveImpulsion();
        }
    }
Esempio n. 2
0
    private void testGet(System.Action <WWW> callback)
    {
        //logMessage("RedMetricsManager::testGet");
        string url = redMetricsURL + redMetricsPlayer;

        StartCoroutine(RedMetricsManager.GET(url, callback));
    }
Esempio n. 3
0
    void Victory()
    {
        EndTime      = Time.time;
        TimeToFinish = EndTime - StartTime;

        //Redmetrics
        if (GameObject.FindGameObjectWithTag("Redmetrics") != null)
        {
            CustomData _customData = new CustomData();
            _customData.Add("Level Finished", "Level " + Application.loadedLevel + " finished, " +
                            "Time Taken to finish : " + (int)TimeToFinish + " seconds, " +
                            "Number of trials : " + NumberOfTries);

            RedMetricsManager.get().sendEvent(TrackingEvent.LEVELFINISHED, _customData);
        }
        //

        _UI.SetActive(false);
        foreach (Transform child in _ParticulSystem.transform)
        {
            child.GetComponent <ParticleSystem>().Play();
        }
        CurrentCase.transform.DOLocalMoveY(10, AscnesionTime);
        StartCoroutine("KatyPerry");
    }
Esempio n. 4
0
    public override AddingResult askAddDevice(Device device, bool reportToRedMetrics = false)
    {
        Logger.Log("Inventory::askAddDevice", Logger.Level.TRACE);
        AddingResult addingResult = canAddDevice(device);

        if (addingResult == AddingResult.SUCCESS)
        {
            Logger.Log("Inventory::askAddDevice: AddingResult.SUCCESS, will add device=" + device, Logger.Level.INFO);
            addDevice(device);

            if (reportToRedMetrics)
            {
                RedMetricsManager.get().sendEvent(TrackingEvent.CRAFT, new CustomData(CustomDataTag.DEVICE, device.getInternalName()));
            }

            //uncomment to save user-created devices
            //TODO FIXME uncommenting this entails bugs on loading devices from _saveFilePath
            //DeviceSaver dSaver = new DeviceSaver();
            //dSaver.saveDevicesToFile(_devices, _saveFilePathWrite);
        }
        else
        {
            Logger.Log("Inventory::askAddDevice: " + addingResult + ", didn't add device=" + device, Logger.Level.INFO);
        }
        return(addingResult);
    }
    protected override void OnPress(bool isPressed)
    {
        if (isPressed)
        {
            Logger.Log("InventoriedDisplayedDevice::OnPress() " + getDebugInfos(), Logger.Level.INFO);
            if (_device == null)
            {
                Logger.Log("InventoriedDisplayedDevice::OnPress _device==null", Logger.Level.WARN);
                return;
            }

            DeviceContainer.AddingResult addingResult = _devicesDisplayer.askAddEquipedDevice(_device);
            Logger.Log("InventoriedDisplayedDevice::OnPress() added device result=" + addingResult + ", " + getDebugInfos(), Logger.Level.DEBUG);
            if (DeviceContainer.AddingResult.FAILURE_SAME_NAME == addingResult ||
                DeviceContainer.AddingResult.FAILURE_SAME_DEVICE == addingResult)
            {
                if (_devicesDisplayer.askRemoveEquipedDevice(_device))
                {
                    RedMetricsManager.get().sendEvent(TrackingEvent.UNEQUIP, new CustomData(CustomDataTag.DEVICE, _device.getInternalName()));
                }
            }
            else
            {
                RedMetricsManager.get().sendEvent(TrackingEvent.EQUIP, new CustomData(CustomDataTag.DEVICE, _device.getInternalName()));
            }

            //pointer Animation

            if (gameObject.transform.FindChild("tutorialArrow(Clone)"))
            {
                ArrowAnimation.Delete("InventoryDevicesSlotsPanel");
                GUITransitioner.get().arrowManager.isInventoryAnimPlaying = false;
            }
        }
    }
Esempio n. 6
0
    public void toggleSound()
    {
        isSoundOn = !isSoundOn;
        string soundValue = isSoundOn?CustomDataValue.ON.ToString():CustomDataValue.OFF.ToString();

        RedMetricsManager.get().sendEvent(TrackingEvent.CONFIGURE, new CustomData(CustomDataTag.SOUND, soundValue));

        if (baseVolume < 0)
        {
            if (0 == AudioListener.volume)
            {
                baseVolume = 1f;
            }
            else
            {
                baseVolume = AudioListener.volume;
            }
        }
        AudioListener.volume = isSoundOn?baseVolume:0f;

        SoundOptionMainMenuItem lmmi;

        foreach (MainMenuItem item in _items)
        {
            lmmi = item as SoundOptionMainMenuItem;
            if (null != lmmi)
            {
                lmmi.updateSelection();
            }
        }
    }
    void Start()
    {
        CustomData customData = new CustomData();

        customData.Add("Level_Name", Application.loadedLevelName);

        RedMetricsManager.get().sendEvent(TrackingEvent.START, customData);
    }
Esempio n. 8
0
 void antiDuplicateInitialization()
 {
     RedMetricsManager.get();
     if (this != _instance)
     {
         Destroy(this.gameObject);
     }
 }
Esempio n. 9
0
 //switches the logging mode from test to normal and conversely
 //returns true if switched to normal
 public bool switchMetricsGameVersion()
 {
     //TODO
     //RedMetricsManager.get ().sendEvent(TrackingEvent.SWITCHFROMGAMEVERSION, RedMetricsManager.get().generateCustomDataForGuidInit());
     setMetricsDestination(isTestGUID());
     RedMetricsManager.get().sendEvent(TrackingEvent.SWITCHTOGAMEVERSION, RedMetricsManager.get().generateCustomDataForGuidInit());
     return(!isTestGUID());
 }
 void antiDuplicateInitialization()
 {
     RedMetricsManager.get();
     //logMessage("RedMetricsManager::antiDuplicateInitialization with hashcode="+this.GetHashCode()+" and _instance.hashcode="+_instance.GetHashCode(), MessageLevel.ERROR);
     if (this != _instance)
     {
         //logMessage("RedMetricsManager::antiDuplicateInitialization self-destruction");
         Destroy(this.gameObject);
     }
 }
    public override void click()
    {
        Logger.Log("the game will " + itemName + "...");

        CustomDataValue modeValue = GameConfiguration.GameMode.ADVENTURE == MemoryManager.get().configuration.getMode() ? CustomDataValue.SANDBOX : CustomDataValue.ADVENTURE;

        RedMetricsManager.get().sendEvent(TrackingEvent.SELECTMENU, new CustomData(CustomDataTag.OPTION, modeValue.ToString()));

        GameStateController.get().goToOtherGameMode();
    }
Esempio n. 12
0
    ////////////////////////////////////////
    /// helpers for standalone
    ///

    private void sendDataStandalone(string urlSuffix, string pDataString, System.Action <WWW> callback)
    {
        //logMessage("RedMetricsManager::sendDataStandalone");
        string url = redMetricsURL + urlSuffix;
        Dictionary <string, string> headers = new Dictionary <string, string> ();

        headers.Add("Content-Type", "application/json");
        byte[] pData = System.Text.Encoding.ASCII.GetBytes(pDataString.ToCharArray());
        //logMessage(MessageLevel.DEFAULT, "RedMetricsManager::sendDataStandalone StartCoroutine POST with data={0} ...", pDataString);
        StartCoroutine(RedMetricsManager.POST(url, pData, headers, callback));
    }
Esempio n. 13
0
    void managePickUp(Collider col)
    {
        PickableItem item = col.GetComponent <PickableItem>();

        if (null != item)
        {
            Logger.Log("Hero::managePickUp collided with DNA! bit=" + item.getDNABit(), Logger.Level.INFO);
            item.pickUp();
            RedMetricsManager.get().sendEvent(TrackingEvent.PICKUP, new CustomData(CustomDataTag.DNABIT, item.getDNABit().getInternalName()));
        }
    }
Esempio n. 14
0
    public void goToOtherGameMode()
    {
        Logger.Log("GameStateController::goToOtherGameMode", Logger.Level.INFO);
        GameConfiguration.GameMap destination =
            (MemoryManager.get().configuration.gameMap == GameConfiguration.GameMap.ADVENTURE1) ?
            GameConfiguration.GameMap.SANDBOX2 :
            GameConfiguration.GameMap.ADVENTURE1;

        setAndSaveLevelName(destination, "goToOtherGameMode");
        RedMetricsManager.get().sendEvent(TrackingEvent.SWITCH, new CustomData(CustomDataTag.GAMELEVEL, destination.ToString()));
        internalRestart();
    }
Esempio n. 15
0
    public void LevelFinished()
    {
        Player.IsStuck = true;

        Scene activeScene = SceneManager.GetActiveScene();
        int   nbScene     = activeScene.buildIndex - 2; // TODO watch if we modify the build order

        if (LevelManager.UnlockedLevels == nbScene)
        {
            Debug.Log("CurrentScene:" + nbScene);

            int nbScene1 = nbScene + 1;
            LevelManager.SaveData(nbScene1);
        }

        // Invoke to return to main menu
        if (SceneManager.GetActiveScene().buildIndex == 8)
        {
            Invoke("ReturnToMenu", 12);
        }
        else
        {
            Invoke("ReturnToMenu", 6);
        }


        // Handles the movie playing
        int          nbMovie     = nbScene++;
        MovieTexture _movTexture = Resources.Load <MovieTexture>("Movies/Carte_" + nbMovie) as MovieTexture;

        if (SceneManager.GetActiveScene().buildIndex == 8) // END LEVEL
        {
            _movTexture = Resources.Load <MovieTexture>("Movies/ANIMATION FIN") as MovieTexture;
        }

        GameObject.Find("MoviePlayer").GetComponent <MeshRenderer>().enabled          = true;
        GameObject.Find("MoviePlayer").GetComponent <Renderer>().material.mainTexture = _movTexture;

        ((MovieTexture)GameObject.Find("MoviePlayer").GetComponent <Renderer>().material.mainTexture).Play();
        _movTexture.Play();



        // Not necessary since we are not keeping any object between scenes. But if so, we should do this.
        nbDeathInLevel = 0;

        CustomData customData = new CustomData();

        customData.Add("NUMBER_OF_DEATH", nbDeathInLevel.ToString());
        customData.Add("LEVEL_NAME", activeScene.name);
        RedMetricsManager.get().sendEvent(TrackingEvent.DEATH_AVERAGE, customData);
    }
Esempio n. 16
0
    public static void changeLanguageTo(Language lang)
    {
        RedMetricsManager.get().sendEvent(TrackingEvent.CONFIGURE, new CustomData(CustomDataTag.LANGUAGE, lang.ToString()));

        Localization.instance.currentLanguage = lang.ToString();

        MemoryManager.get().configuration.language = lang;

        foreach (UILocalize localize in GameObject.FindObjectsOfType <UILocalize>())
        {
            localize.Localize();
        }
    }
 public static RedMetricsManager get()
 {
     if (_instance == null) {
         _instance = GameObject.Find (gameObjectName).GetComponent<RedMetricsManager> ();
         if (null != _instance) {
             //RedMetricsManager object is not destroyed when game restarts
             DontDestroyOnLoad (_instance.gameObject);
             _instance.initializeIfNecessary ();
         } else {
             logMessage ("RedMetricsManager::get couldn't find game object", MessageLevel.ERROR);
         }
     }
     return _instance;
 }
Esempio n. 18
0
 void OnPress()
 {
     if (null != device)
     {
         if (device.askRemoveDevice())
         {
             RedMetricsManager.get().sendEvent(TrackingEvent.UNEQUIP, new CustomData(CustomDataTag.DEVICE, device._device.getInternalName()));
         }
     }
     else
     {
         Logger.Log("EquipedDeviceCloseButton::OnPress null==device", Logger.Level.WARN);
     }
 }
Esempio n. 19
0
    void Update()
    {
        if (!_pause)
        {
            _lifeManager.regen(Time.deltaTime);
            _energy = _medium.getEnergy() / _maxMediumEnergy;

            if (GameStateController.isShortcutKey(_keyLife, true))
            {
                _lifeManager.addVariation(1f);
            }
            if (GameStateController.isShortcutKey(_keyEnergy, true))
            {
                setEnergy(1f);
            }

            // dammage in case of low energy
            if (_energy <= 0.05f)
            {
                _lifeManager.addVariation(-Time.deltaTime * _lowEnergyDpt);
            }


            // Life animation when life is reducing
            if (_lifeManager.getVariation() < 0)
            {
                if (lifeAnimation.isPlaying == false)
                {
                    lifeAnimation.Play();
                }
            }

            // Energy animation when energy is reducing
            if (_energy < _energyBefore)
            {
                DisplayEnergyAnimation();
            }
            _energyBefore = _energy;


            _lifeManager.applyVariation();
            if (_lifeManager.getLife() == 0f && (_isAlive))
            {
                _isAlive = false;

                RedMetricsManager.get().sendEvent(TrackingEvent.DEATH, null, getLastCheckpointName());
                StartCoroutine(RespawnCoroutine());
            }
        }
    }
Esempio n. 20
0
    void setCurrentRespawnPoint(Collider col)
    {
        if (null != col.gameObject.GetComponent <RespawnPoint>() &&
            (null == _lastCheckpoint ||
             _lastCheckpoint.name != col.gameObject.name))
        {
            _lastCheckpoint = col.gameObject;
            duplicateCell();

            //RedMetrics reporting
            //TODO put equiped devices in customData of sendEvent
            RedMetricsManager.get().sendEvent(TrackingEvent.REACH);
        }
    }
 public static RedMetricsManager get()
 {
     if (_instance == null)
     {
         _instance = GameObject.Find(gameObjectName).GetComponent <RedMetricsManager>();
         if (null != _instance)
         {
             //RedMetricsManager object is not destroyed when game restarts
             DontDestroyOnLoad(_instance.gameObject);
             _instance.initializeIfNecessary();
         }
         else
         {
             logMessage("RedMetricsManager::get couldn't find game object", MessageLevel.ERROR);
         }
     }
     return(_instance);
 }
 protected override void OnPress(bool isPressed)
 {
     if (isPressed)
     {
         Logger.Log("EquipedDisplayedDevice::OnPress() " + getDebugInfos(), Logger.Level.INFO);
         if (_device == null)
         {
             Logger.Log("EquipedDisplayedDevice::OnPress _device == null", Logger.Level.WARN);
             return;
         }
         if (_devicesDisplayer.IsEquipScreen())
         {
             if (askRemoveDevice())
             {
                 RedMetricsManager.get().sendEvent(TrackingEvent.UNEQUIP, new CustomData(CustomDataTag.DEVICE, _device.getInternalName()));
             }
         }
     }
 }
Esempio n. 23
0
    private void initializeIfNecessary(bool onlyIfEmpty = true)
    {
        Logger.Log("MemoryManager::initializeIfNecessary", Logger.Level.DEBUG);
        if (!onlyIfEmpty || 0 == _loadedLevelInfo.Count)
        {
            loadLevelData(inputFiles, _loadedLevelInfo);

            string playerGUID = configuration.playerGUID;
            Logger.Log(
                "MemoryManager::initializeIfNecessary: playerGUID=" + playerGUID
                + " & configuration.isTestGUID()=" + configuration.isTestGUID()
                + " & Application.isEditor=" + Application.isEditor
                );

            //TODO manage RedMetricsManager's globalPlayerGUID
            RedMetricsManager.get().setLocalPlayerGUID(playerGUID);
            RedMetricsManager.get().sendStartEvent();
            Logger.Log(string.Format("MemoryManager::initializeIfNecessary initial game configuration={0}, labelledGameVersionGUID={1}, playerGUID={2}"
                                     , configuration, GameConfiguration.labelledGameVersionGUID, playerGUID)
                       , Logger.Level.INFO);
        }
    }
Esempio n. 24
0
    public void Death()
    {
        if (Player.animator.GetBool("isAlive"))
        {
            AudioClip deathClip = Resources.Load <AudioClip>("Music/son/Death");
            GetComponentInChildren <AudioSource>().PlayOneShot(deathClip);

            nbDeathInLevel++;
            transform.localScale = new Vector3(1, 1, 1);
            transform.rotation   = Quaternion.identity;
            Player.IsStuck       = true;
            Player.animator.SetBool("isAlive", false);
            Invoke("DestroyPlayer", 0.5f);

            Vector2 _deathPos = new Vector2((int)Player.transform.position.x, (int)Player.transform.position.y);

            CustomData customData = new CustomData();
            customData.Add("POSITION", Player.transform.position.ToString());
            customData.Add("LEVEL_NAME", SceneManager.GetActiveScene().name);
            RedMetricsManager.get().sendEvent(TrackingEvent.DEATH_POSITION, customData);
        }
    }
Esempio n. 25
0
    public static void open(string urlKey, bool newTab = false)
    {
        string localizedUrl = getLocalizedUrl(urlKey);

        if (!newTab)
        {
            RedMetricsManager.get().sendEvent(TrackingEvent.GOTOURL, new CustomData(CustomDataTag.SAMETAB, localizedUrl));
            Application.OpenURL(localizedUrl);
        }
        else
        {
            RedMetricsManager.get().sendEvent(TrackingEvent.GOTOURL, new CustomData(CustomDataTag.NEWTAB, localizedUrl));
            switch (Application.platform)
            {
            case RuntimePlatform.WebGLPlayer:
            case RuntimePlatform.WindowsWebPlayer:
            case RuntimePlatform.OSXWebPlayer:
                Logger.Log("URLOpener::open Webplayer/WebGL attempting to open " + localizedUrl, Logger.Level.WEBPLAYER);
                Application.ExternalEval("window.open('" + localizedUrl + "','_blank')");
                break;

            case RuntimePlatform.WindowsPlayer:
            case RuntimePlatform.OSXPlayer:
            case RuntimePlatform.WindowsEditor:
            case RuntimePlatform.OSXEditor:
                Debug.LogError("URLOpener::open Editor/Standalone attempting to open " + localizedUrl);
                Application.OpenURL(localizedUrl);
                break;

            default:
                Debug.LogError("URLOpener::open default attempting to open " + localizedUrl);
                Application.OpenURL(localizedUrl);
                break;
            }
        }
    }
Esempio n. 26
0
 public void switchControlTypeToRightClickToMove()
 {
     RedMetricsManager.get().sendEvent(TrackingEvent.CONFIGURE, new CustomData(CustomDataTag.CONTROLS, CellControl.ControlType.RightClickToMove.ToString()));
     cellControl.switchControlTypeToRightClickToMove();
 }
Esempio n. 27
0
 public void switchControlTypeToRelativeWASD()
 {
     RedMetricsManager.get().sendEvent(TrackingEvent.CONFIGURE, new CustomData(CustomDataTag.CONTROLS, CellControl.ControlType.RelativeWASD.ToString()));
     cellControl.switchControlTypeToRelativeWASD();
 }
Esempio n. 28
0
 public static void restart()
 {
     RedMetricsManager.get().sendEvent(TrackingEvent.RESTART);
     internalRestart();
 }
Esempio n. 29
0
 public override void click()
 {
     Logger.Log("the game will language...");
     RedMetricsManager.get().sendEvent(TrackingEvent.SELECTMENU, new CustomData(CustomDataTag.OPTION, CustomDataValue.LANGUAGE.ToString()));
     MainMenuManager.get().switchTo(MainMenuManager.MainMenuScreen.LANGUAGES);
 }
Esempio n. 30
0
 public void sendCompletionEvent()
 {
     RedMetricsManager.get().sendEvent(TrackingEvent.COMPLETE);
 }
 private void goToMOOC(bool newTab)
 {
     RedMetricsManager.get().sendEvent(TrackingEvent.GOTOMOOC);
     URLOpener.open(urlKey, newTab);
 }