private void OnPress(bool isPressed) { if (isPressed) { Hero.get().kill(); } }
public void sendEvent(TrackingEvent trackingEvent, CustomData customData = null, string section = null, int[] coordinates = null, string userTime = null) { string checkedSection = section; //TODO remove dependency to Hero class if (string.IsNullOrEmpty(section) && (null != Hero.get())) { checkedSection = Hero.get().getLastCheckpointName(); } int[] checkedCoordinates = null; if (null != coordinates) { checkedCoordinates = new int[coordinates.Length]; for (int i = 0; i < coordinates.Length; i++) { checkedCoordinates [i] = coordinates [i]; } } else { if (null != Hero.get()) { Vector3 position = Hero.get().gameObject.transform.position; checkedCoordinates = new int[2] { Mathf.FloorToInt(position.x), Mathf.FloorToInt(position.z) }; } } //logMessage(MessageLevel.DEFAULT, "RedMetricsManager::sendEvent({0})", trackingEvent.ToString()); if (Application.isWebPlayer) { TrackingEventDataWithoutIDs data = new TrackingEventDataWithoutIDs(trackingEvent, customData, checkedSection, checkedCoordinates, userTime); if (isGameSessionGUIDCreated) { string json = getJsonString(data); Application.ExternalCall("rmPostEvent", json); } else { addEventToSendLater(data); //TODO: what if connection fails, or even fails permanently? Should retry connection at different intervals } } else { //TODO wait on gameSessionGUID using an IEnumerator if (defaultGameSessionGUID != gameSessionGUID) { } else { logMessage(MessageLevel.ERROR, "sendEvent default player guid: no registered player!"); } TrackingEventDataWithIDs data = new TrackingEventDataWithIDs(gameSessionGUID, gameVersionGuid, trackingEvent, customData, checkedSection, checkedCoordinates); string json = getJsonString(data); //logMessage (MessageLevel.DEFAULT, string.Format ("RedMetricsManager::sendEvent - gameSessionGUID={0}, gameVersionGuid={1}, json={2}", gameSessionGUID, gameVersionGuid, json)); sendDataStandalone(redMetricsEvent, json, value => wwwLogger(value, "sendEvent(" + trackingEvent + ")")); //TODO pass data as parameter to sendDataStandalone so that it's serialized inside } }
void Awake() { Logger.Log("Hero::Awake", Logger.Level.INFO); Hero.get(); _lifeManager = new Life(_life, _lifeRegen); }