private void OnServiceControl(IList <TaskResult> results, bool lastUpdate) { Dbg.Log($"Entering {MethodBase.GetCurrentMethod().Name}"); foreach (TaskResult result in results) { try { if (result.Status == Microsoft.EnterpriseManagement.Runtime.TaskStatus.Succeeded || result.Status == Microsoft.EnterpriseManagement.Runtime.TaskStatus.CompletedWithInfo) { using (StringReader stringReader = new StringReader(result.Output)) { using (XmlReader xmlReader = XmlReader.Create(stringReader)) { if (xmlReader.Read() && xmlReader.ReadToDescendant("QuadrupleList")) { QuadrupleListDataItem qlist = new QuadrupleListDataItem(xmlReader.ReadSubtree()); if (qlist.Data.List.Any()) { Quadruple response = qlist.Data.List[0]; if (response.I1 == "ERROR") { MessageBox.Show(response.I2, "Operation Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } //if (response.I1 == "OK") // MessageBox.Show("Service Configuration task completed successfully.", "Operation Completed", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } } } catch (Exception e) { Dbg.Log($"Exception {e.Message} in {MethodBase.GetCurrentMethod().Name}"); } } }
public virtual void TakeDamage(int amount) { damaged = true; currentHealth -= amount; Dbg.Log($"{currentHealth}"); if (IsPlayer) { float healthPointRatio = currentHealth / startingHealth; LogicEventListener.Invoke(eEventType.FOR_UI, eEventMessage.ON_HEALTH_POINT_CHANGED, (object)healthPointRatio); } // TODO: 플레이어 아닐떄에만 폭발사 if (currentHealth <= 0 && !isDead && !IsPlayer) { if (objDeadEffect != null) { Instantiate(objDeadEffect, transform.position, transform.rotation); } Death(); } }
private void Start() { scrollHeight = scroll.viewport.rect.height; scrollHeightHalf = scrollHeight / 2.0f; sortState = SortState.Empty; InstantiateUsers(); localUser = userDatas[RandomValue(allCountUsers)]; localUser.PlayerName("Player"); modifierWave = (localUser.Position - 50) / countNewUsersWave; Dbg.Log("localUser: "******"mod: " + modifierWave, Color.green); InitLines(modifierWave * countNewUsersWave - 1);//localUser.Position - 50); playerContentLinesIndex = localUser.Position - (modifierWave * countNewUsersWave - 1); middleLineDown = playerContentLinesIndex + 5; middleLineUp = playerContentLinesIndex - 5; lineDown = contentLines[middleLineDown]; lineUp = contentLines[middleLineUp]; StartCoroutine(CanvasUpd()); }
public Message ReceiveMessage(uint reqID) { string tmpFile = Path.GetTempFileName(); string src = SettingsManager.GetServerDialogURL(m_clInfo.ClientID); try { new NetEngin(Program.NetworkSettings).Download(tmpFile, src); ClientDialog clDlg = DialogEngin.ReadSrvDialog(tmpFile); Message msg = clDlg.Messages.SingleOrDefault(m => m.ReqID == reqID); return(msg); } catch (Exception ex) { Dbg.Log(ex.Message); } finally { File.Delete(tmpFile); } return(null); }
private void Awake() { Dbg.Log(this, "awake"); if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); DontDestroyOnLoad(player); DontDestroyOnLoad(canvas); commandMap = new Dictionary <string, Delegates.VoidVoid>() { { "jump", JumpCommand }, { "left", LeftCommand }, { "right", RightCommand }, { "stop", StopCommand }, { "crouch", CrouchCommand }, { "squat", CrouchCommand }, { "stand", StandupCommand }, { "get up", StandupCommand }, { "stand up", StandupCommand }, { "exit", ExitCommand }, { "win", EnjoyVictoryCommand } }; playerWalk = player.GetComponent <Walk>(); playerBody = player.GetComponent <Rigidbody2D>(); SceneManager.sceneLoaded += OnSceneLoaded; }
private void setupSocket() { while (!quitApplication) { if (socketReady == false || !theStream.CanRead) { socketReady = false; startSocket(); } else { //if (mySocket.Client.Poll(1, SelectMode.SelectRead) && !theStream.DataAvailable) //{ // Debug.Log("Detected disconnect, closing server!"); // closeSocket(); //} string serverSays = readSocket(); if (serverSays != "") { if (TypeOfConnection == TypeOfTCPConnection.Speech) { newResultString = serverSays; newResult = true; } else { string stringFromServer = removeEmptySpaces(serverSays); string[] messages = stringFromServer.Split('M'); string[] message = messages[messages.Length - 1].Split(';'); string[] userLocation = message[1].Split(','); float z = float.Parse(userLocation[2]); AutonomousGazeBehavior.Instance.UpdatePlayerPosition(new Vector3(float.Parse(userLocation[0]), float.Parse(userLocation[1]), z)); if (message[0] == "Unknown") { if (!lastMessageIsUnknown) { Dbg.Log(LogMessageType.PLAYER_GAZE_TARGET, "Unknown"); } lastMessageIsUnknown = true; } else { switch (message[0]) { case "Q1": SetGazeTarget("Q1"); break; case "Q2": SetGazeTarget("Q2"); break; case "Q3": SetGazeTarget("Q3"); break; case "Q4": SetGazeTarget("Q4"); break; case "Robot": SetGazeTarget("Robot"); break; } lastMessageIsUnknown = false; } } } } } }
public void Init(Transform pooledObjectsContainer) { Dbg.Log($"PoolController.Init; _poolsDictionary Create new Dictionary<string, LinkedList<BaseObjectScene>>()"); _deactivatedObjectsParent = pooledObjectsContainer; _poolsDictionary = new Dictionary <string, LinkedList <BaseObjectScene> >(); }
void OnTriggerExit2D(Collider2D collider) { Dbg.Log(this, "OnTriggerExit2D", collider); attractedGameObjectList.Remove(collider.gameObject); }
public AdService() { Dbg.Log("AdService is started".Color(Color.green)); MobileAds.Initialize(AppId); }
void Start() { Dbg.Log(this, "start"); storyLines = new List <string>(); Physics2D.gravity = Vector2.down * gravity; }
public Tuple <int, IndexBuffer, DynamicVertexBuffer> GetOccludersBuffers(RectF rect) { if (!isDirty_ && rect.Equals(lastRectF_)) //TODO rectf ==, TODO mark dirty when occluders change/ctor { Dbg.Log("returning cached occluders data"); goto ReturnData; //TODO } isDirty_ = false; allOccludersSegments.Clear(); //TODO use array - low/med prior //collect all occluders segments in range foreach (LightOccluder occluder in GetComponentsInRect(rect)) { allOccludersSegments.AddRange(occluder.GlobalSegments); //TODO slooooow, pass list? } int verticesNeeded = allOccludersSegments.Count * 4 + 4; //each segment is a quad in vbo, PLUS the projector (first 4) // each miss we double our buffers ;) while (verticesNeeded > vb.VertexCount) { int newVtxQty = vb.VertexCount * 2; int newIdxQty = ib.IndexCount * 2; vb = new DynamicVertexBuffer(Graphics.Device, OccluderVertexFormat.VertexDeclaration, newVtxQty, BufferUsage.WriteOnly); ib = new IndexBuffer(Graphics.Device, IndexElementSize.ThirtyTwoBits, newIdxQty, BufferUsage.WriteOnly); int[] indices = new int[newIdxQty]; for (int i = 0, v = 0; i < newIdxQty; i += 6, v += 4) { indices[i + 0] = v + 0; indices[i + 1] = v + 1; indices[i + 2] = v + 2; indices[i + 3] = v + 0; indices[i + 4] = v + 2; indices[i + 5] = v + 3; } ib.SetData(indices); // copy to gfx, create actual IBO, once per resize } List <OccluderVertexFormat> verts = new List <OccluderVertexFormat>(verticesNeeded); //add projector (first 4 verts) verts.Add(new OccluderVertexFormat(new Vector3(0, 0, 0), 0, OccluderVertexFormat.Corner0)); //TODO use vert idx for id? verts.Add(new OccluderVertexFormat(new Vector3(1, 0, 0), 0, OccluderVertexFormat.Corner1)); verts.Add(new OccluderVertexFormat(new Vector3(1, 1, 0), 0, OccluderVertexFormat.Corner2)); verts.Add(new OccluderVertexFormat(new Vector3(0, 1, 0), 0, OccluderVertexFormat.Corner3)); //add shadow casters foreach (OccluderSegment segment in allOccludersSegments) { verts.Add(new OccluderVertexFormat(segment.A.ToVector3(), shadowBias)); verts.Add(new OccluderVertexFormat(segment.B.ToVector3(), shadowBias)); verts.Add(new OccluderVertexFormat(segment.B.ToVector3(), 1)); verts.Add(new OccluderVertexFormat(segment.A.ToVector3(), 1)); Dbg.AddDebugLine(segment.A, segment.B, Color.Cyan); } vb.SetData(verts.ToArray()); // copy to gfx, once per draw call ReturnData: return(new Tuple <int, IndexBuffer, DynamicVertexBuffer>(allOccludersSegments.Count, ib, vb)); //TODO descriptive object }
// TODO : this only supports 1v1 matches public void MakeRoundRobinSchedule(int numTeams, int numRounds) { Dbg.Log("Making round robin schedule"); // TODO fix this numteam limitation Dbg.Assert((numTeams % 2) == 0); for (int t1 = 0; t1 < numTeams; t1++) { for (int t2 = t1 + 1; t2 < numTeams; t2++) { BS_Team tm1 = PT_Game.League.Teams[t1]; BS_Team tm2 = PT_Game.League.Teams[t2]; GM_IDList idList = new GM_IDList(); idList.Add(tm1.Id); idList.Add(tm2.Id); BS_MatchParams match = new BS_MatchParams(); match.TeamIds = idList; match.Day = -1; bool found = false; for (int dayNdx = 0; dayNdx < numTeams; dayNdx++) { found = false; foreach (var m in Matches) { if (m.Day == dayNdx && (m.TeamIds.Contains(tm1.Id) || m.TeamIds.Contains(tm2.Id))) { found = true; break; } } if (found == false) { match.Day = dayNdx; break; } } Dbg.Assert(match.Day != -1); Matches.Add(match); Dbg.Log(t1 + " vs " + t2 + " day: " + match.Day); } } Matches.Sort((x, y) => { return((x.Day < y.Day) ? -1 : ((x.Day > y.Day) ? 1 : 0)); }); /* * * // this generates a full set of each team playing every other team once. * int[,] matchInfo = GenerateRoundRobin(numTeams); * NumDays = matchInfo.GetLength(1); * for (int teamIndex1 = 0; teamIndex1 < matchInfo.GetLength(0); teamIndex1++) * { * for (int round = 0; round < matchInfo.GetLength(1); round++) * { * BS_Team t1 = PT_Game.League.Teams[teamIndex1]; * BS_Team t2 = PT_Game.League.Teams[matchInfo[teamIndex1, round]]; * * //TODO add support for multiple teams * GM_IDList idList = new GM_IDList(); * idList.Add(t1.Id); * idList.Add(t2.Id); * * if (Matches.Find(FindMatch(idList, round)) == null) * { * BS_MatchParams match = new BS_MatchParams(); * match.Day = round; * match.TeamIds = idList; * * Matches.Add(match); * } * } * } * * Matches.Sort((x, y) => { return (x.Day < y.Day) ? -1 : ((x.Day > y.Day) ? 1 : 0); }); */ }
public void Jump(float factor = 1) { Dbg.Log(this, "Jump"); body.velocity = new Vector2(body.velocity.x, 0); body.AddForce(Vector2.up * jumpPower * factor); }
void Start() { #if UNITY_EDITOR UnityEngine.Profiling.Profiler.BeginSample("Make Outline"); #endif // new Material. Material material = default; // Part Name. GameObject outlineGo = default; Mesh normalAveragedMesh = default; //CustomDebug.Log("Awake is executed!"); int len = mMaterialSOArray.Length; for (int i = 0; i < len; ++i, ++counter) { material = default; //CustomDebug.Log("material creation is executed!"); switch (mMaterialSOArray[i].RuntimeShaderType) { case MaterialScriptableObjectPrototype.eShaderType.EYE: // TODO: Find out which style of shader is proper for eyes. material = new Material(Shader.Find("Custom/Outline_AvgNormal")) { hideFlags = HideFlags.HideAndDontSave }; Dbg.Log($"<color=red>Eyes shader is applied! Count : {counter.ToString()}</color>", this); break; case MaterialScriptableObjectPrototype.eShaderType.HAIR: // TODO: Have to research with hair shader. material = new Material(Shader.Find("Custom/Anisotropic Hair")) { hideFlags = HideFlags.HideAndDontSave }; Dbg.Log($"<color=red>Hair shader is applied! Count : {counter.ToString()}</color>", this); break; case MaterialScriptableObjectPrototype.eShaderType.NORMAL: // TODO: Next level -> Sobel edge detected outline. material = new Material(Shader.Find("Custom/Outline_AvgNormal")) { hideFlags = HideFlags.HideAndDontSave }; Dbg.Log($"<color=red>Normal shader is applied! Count : {counter.ToString()}</color>", this); break; default: Debug.LogError($"Error", this); break; } if (mMaterialSOArray[i].RuntimeMeshType == MaterialScriptableObjectPrototype.eMeshType.STATIC_MESH) { MakeOutlineGameObjectForStaticMesh(ref material, mMaterialSOArray[i].RuntimeName, ref normalAveragedMesh, out outlineGo); ApplyShaderPropertiesForStaticMesh(ref outlineGo, ref material, i); } else if (mMaterialSOArray[i].RuntimeMeshType == MaterialScriptableObjectPrototype.eMeshType.SKINNED_MESH) { MakeOutlineGameObjectForSkinnedMesh(ref material, mMaterialSOArray[i].RuntimeName, ref normalAveragedMesh, out outlineGo); ApplyShaderPropertiesForSkinnedMesh(ref outlineGo, ref material, i); } //Destroy(outlineGo); } #if UNITY_EDITOR UnityEngine.Profiling.Profiler.EndSample(); #endif }
private void checkForSolutionOrInvalidStates(bool[] currBoardState) { WizardManager.Instance.ClearHints(); int numberOfPieces = 0; List <List <int> > listIslands = new List <List <int> >(); bool[] visitedPositions = new bool[16]; for (int height = 0; height < 4; height++) { for (int length = 0; length < 4; length++) { int currentPos = 4 * height + length; if (!visitedPositions[currentPos]) { List <int> currentIsland = new List <int>(); visitedPositions[currentPos] = true; if (currBoardState[currentPos]) { currentIsland.Add(currentPos); checkNeighbors(currentPos, currBoardState, visitedPositions, currentIsland); } if (currentIsland.Count > 0) { listIslands.Add(currentIsland); numberOfPieces += currentIsland.Count; } } } } int maxElements = numMaxConnectedLine(currBoardState); bool notConnectedRule = listIslands.Count > 1; RuleConnected.SetActive(notConnectedRule); if (notConnectedRule) { Dbg.Log(BROKEN_RULE_CONNECTED); } bool exactNumberRule = true; bool correctSolution = true; //if() //Check if the max elements in a row or collumn are greater than the maxrule and if the number of pieces is max if it has the exact number if (maxElements > MaxRule || (numberOfPieces == 6 && maxElements < MaxRule)) { RuleMax2.SetActive(MaxRule == 2); RuleMax3.SetActive(MaxRule == 3); RuleMax4.SetActive(MaxRule == 4); switch (MaxRule) { case 2: Dbg.Log(BROKEN_RULE_MAX2); break; case 3: Dbg.Log(BROKEN_RULE_MAX3); break; case 4: Dbg.Log(BROKEN_RULE_MAX4); break; } exactNumberRule = false; } else { RuleMax2.SetActive(false); RuleMax3.SetActive(false); RuleMax4.SetActive(false); } if (numberOfPieces == 6 && !notConnectedRule) { correctSolution = checkCorrectSolution(currBoardState); } else if (numberOfPieces > 0 && !notConnectedRule) { correctSolution = searchSolutionAndFillHints(currBoardState); } if (notConnectedRule || !exactNumberRule || !correctSolution) { Dbg.Log(INCORRECT_NEW_STATE); StateCorrectness.Instance.Change(false); return; } //If we survived here we know that the state is correct Dbg.Log(CORRECT_NEW_STATE); StateCorrectness.Instance?.Change(true); }
public void Start() { Dbg.Assert(IsRunning == false); IsRunning = true; Opts.SettingsView.ClientInfoChanged += SettingsView_ClientInfoChaned; //client enregistre? m_clInfo = Program.Settings.ClientInfo; if (m_clInfo == null) { if (RegisterClient()) { m_clStatus = ClientStatus_t.Enabled; m_dialogTimer.Start(); m_updateTimer.Start(); m_dialogRunning = true; var updateTask = new Task(AutoUpdater.Update, TaskCreationOptions.LongRunning); updateTask.Start(); } return; } DialogEngin.WriteHubDialog(SettingsManager.GetClientDialogFilePath(m_clInfo.ClientID), m_clInfo.ClientID, Enumerable.Empty <Message>()); //process only status part of the g file string tmpFile = Path.GetTempFileName(); Action start = () => { var netEngin = new NetEngin(Program.NetworkSettings); netEngin.Download(tmpFile, SettingsManager.GetServerDialogURL(m_clInfo.ClientID), true); }; Action onSuccess = () => { ClientDialog clDlg = DialogEngin.ReadSrvDialog(tmpFile); m_clStatus = clDlg.ClientStatus; if (m_clStatus == ClientStatus_t.Enabled) { new StartHandler(m_clInfo.ClientID, StartResp).Start(); } else if (m_clStatus == ClientStatus_t.Banned) { foreach (IDBTable tbl in Program.TablesManager.CriticalTables) { tbl.Clear(); Program.Settings.DataGeneration = 0; } System.Windows.Forms.MessageBox.Show(AppText.ERR_BANNED, AppText.APP_NAME, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); Exit(); return; } else if (m_clStatus == ClientStatus_t.Disabled) { new ResumeHandler(ResumeResp, m_clInfo.ClientID).Start(); } else { ResetRegistration(); } File.Delete(tmpFile); }; Action <Task> onErr = t => { Dbg.Log(t.Exception.InnerException.Message); //assume client enabled m_clStatus = ClientStatus_t.Enabled; new StartHandler(m_clInfo.ClientID, StartResp).Start(); }; var task = new Task(start, TaskCreationOptions.LongRunning); task.OnSuccess(onSuccess); task.OnError(onErr); task.Start(); }
void ProcessDialogTimer() { if (!m_dialogTimer.IsDisposed) { m_dialogTimer.Stop(); } Dbg.Log("Processing dialog timer..."); string srvDlgURI = SettingsManager.GetServerDialogURL(m_clInfo.ClientID); string tmpFile = Path.GetTempFileName(); LogEngin.PushFlash("Interrogation du serveur..."); try { new NetEngin(Program.NetworkSettings).Download(tmpFile, srvDlgURI, true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); LogEngin.PushFlash(ex.Message); m_dialogTimer.Start(); return; } try { ClientDialog clDlg = DialogEngin.ReadSrvDialog(tmpFile); if (m_clStatus != clDlg.ClientStatus) { switch (clDlg.ClientStatus) { case ClientStatus_t.Enabled: m_updateTimer.Start(true); break; case ClientStatus_t.Disabled: if (m_clStatus == ClientStatus_t.Enabled) { m_updateTimer.Stop(); } return; case ClientStatus_t.Banned: m_updateTimer.Stop(); foreach (IDBTable tbl in Program.TablesManager.Tables) { tbl.Clear(); } System.Windows.Forms.MessageBox.Show(AppText.ERR_BANNED, AppText.APP_NAME, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); Exit(); return; case ClientStatus_t.Reseted: ResetRegistration(); return; default: Dbg.Assert(false); break; } m_clStatus = clDlg.ClientStatus; } Dbg.Assert(m_clStatus == ClientStatus_t.Enabled); uint id = m_srvLastMsgID; var msgs = from msg in clDlg.Messages where msg.ID > id select msg; if (msgs.Any()) { m_srvLastMsgID = msgs.Max(m => m.ID); Action <Message> msgHandler; foreach (Message msg in msgs) { if (m_msgHandlersTable.TryGetValue(msg.MessageCode, out msgHandler)) { msgHandler.Invoke(msg); } } m_timeToLive = TTL_MAX; } if (m_needUpload) { string clFilePath = SettingsManager.GetClientDialogFilePath(m_clInfo.ClientID); new NetEngin(Program.NetworkSettings).Upload(SettingsManager.GetClientDialogURL(m_clInfo.ClientID), clFilePath, true); m_needUpload = false; } if (--m_timeToLive <= 0) { PostSyncMessage(); } if (!m_dialogTimer.IsDisposed) { m_dialogTimer.Start(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); if (!m_dialogTimer.IsDisposed) { m_dialogTimer.Start(); } } }
private void SetGazeTarget(string gazeTarget) { Dbg.Log(LogMessageType.PLAYER_GAZE_TARGET, gazeTarget); this.gazeTarget = gazeTarget; updateGazeTarget = true; }
public static void Log <T>(T message) { Dbg.Log(message.ToString()); }
/// <summary> /// make the AnimEvent and EventGO to be matched /// maybe not one-one match, multiple animEvent could match same EventGO /// </summary> private void _MatchEventGOAndAnimEvent() { ////////////////////////////////////////////////// // 1. for each AnimEvent, if there is not a corresponding eventGO, create it; // 2. for each eventGO, if there is not a corresponding AnimEvent, the delete the eventGO ////////////////////////////////////////////////// //if( _IsAnimEventPopupOpen() ) //{ // return; //don't execute matching if the AnimEventPopup is open //} // create a Dictionary for eventGO for (int idx = 0; idx < m_evtGoRoot.childCount; ++idx) { Transform ctr = m_evtGoRoot.GetChild(idx); m_evtGORefDict[ctr] = false; } // get the AnimEvent list AnimationEvent[] events = AnimationUtility.GetAnimationEvents(m_CurClip); // step 1 for (int idx = 0; idx < events.Length; ++idx) { AnimationEvent evt = events[idx]; string goName = evt.stringParameter; string funcName = evt.functionName; if (goName == null) { Dbg.LogWarn("CCEditor._MatchEventGOAndAnimEvent: found an event not specifying the GOName, at time: {0}", evt.time); ArrayUtility.RemoveAt(ref events, idx); --idx; } Transform oneTr = m_evtGoRoot.Find(goName); if (null == oneTr) { //create the go GameObject newEvtGO = new GameObject(goName); Misc.AddChild(m_evtGoRoot, newEvtGO); Dbg.Log("Sync AnimEvent with EventGO: create EventGO for: {0}", goName); //add component according to the funcName, the init-work should be executed by the MB's awake() or start() //CC_EvtActions newAct = newEvtGO.AddComponent("CC_" + funcName) as CC_EvtActions; //Dbg.Assert(m_CC != null, "CCEditor._MatchEventGOAndAnimEvent: failed to get CutsceneController"); //newAct.CC = m_CC; string tpName = "MH.CC_" + funcName; Type tp = RCall.GetTypeFromString(tpName); Dbg.Assert(tp != null, "CCEditor._MatchEventGOAndAnimEvent: failed to get type from string: {0}", tpName); CC_EvtActions newAct = newEvtGO.AddComponent(tp) as CC_EvtActions; Dbg.Assert(m_CC != null, "CCEditor._MatchEventGOAndAnimEvent: failed to get CutsceneController"); newAct.CC = m_CC; } else { m_evtGORefDict[oneTr] = true; //this event go is ref-ed, don't delete it } } // step 2 for (var ie = m_evtGORefDict.GetEnumerator(); ie.MoveNext();) { var pr = ie.Current; bool inUse = pr.Value; if (!inUse) { Transform tr = pr.Key; Dbg.Log("Sync AnimEvent with EventGO: delete EventGO: {0}", tr.name); GameObject.DestroyImmediate(tr.gameObject); } } m_evtGORefDict.Clear(); //clear the tmp data }
public void performGaze(GazeState gazeState, string target) { if (furhat.Asleeep) { return; } if (keepTrackingPlayerCoroutine != null) { StopCoroutine(keepTrackingPlayerCoroutine); } if (autoGazeCoroutine != null) { StopCoroutine(autoGazeCoroutine); } currentGazeTarget = gazeState; Dbg.Log(LogMessageType.ROBOT_GAZE_TARGET, new List <string>() { gazeState.ToString(), target }); switch (gazeState) { case GazeState.ROBOT_DISTRACTED: furhatInterfaceGaze.SetGaze(DistractedGazeTarget.transform.position); furhat.Gaze(DistractedPointsToLookAt[UnityEngine.Random.Range(0, DistractedPointsToLookAt.Count)]); autoGazeCoroutine = StartCoroutine(WaitForAutoGazeTest(TimesAutoDistracted)); break; case GazeState.ROBOT_LOOKING_AT_PLAYER: furhatInterfaceGaze.SetGaze(PlayerGazeTarget.transform.position); keepTrackingPlayerCoroutine = StartCoroutine(keepTrackingPlayer()); autoGazeCoroutine = StartCoroutine(WaitForAutoGazeTest(TimesAutoPlayer)); break; case GazeState.ROBOT_LOOKING_AT_QUADRANT: furhatInterfaceGaze.SetGazeToQuadrant(target); furhat.gaze(target); autoGazeCoroutine = StartCoroutine(WaitForAutoGazeTest(TimesAutoQuadrant)); break; case GazeState.EVENT_PLAYER_STARTED_SPEAKING: furhatInterfaceGaze.SetGaze(PlayerGazeTarget.transform.position); keepTrackingPlayerCoroutine = StartCoroutine(keepTrackingPlayer()); autoGazeCoroutine = StartCoroutine(WaitForAutoGazeTest(TimesLookingAtUserSpeaking)); break; case GazeState.EVENT_PIECE_MOVED: furhatInterfaceGaze.SetGazeToPiece(target); furhat.gaze(target); autoGazeCoroutine = StartCoroutine(WaitForAutoGazeTest(TimesBoardEvents)); break; case GazeState.EVENT_PLAYER_LOOKING_AT_QUADRANT: furhatInterfaceGaze.SetGazeToPiece(target); furhat.gaze(target); autoGazeCoroutine = StartCoroutine(WaitForAutoGazeTest(TimesLookingAtQuadrant)); break; case GazeState.EVENT_PLAYER_LOOKING_AT_ROBOT: furhatInterfaceGaze.SetGaze(PlayerGazeTarget.transform.position); keepTrackingPlayerCoroutine = StartCoroutine(keepTrackingPlayer()); autoGazeCoroutine = StartCoroutine(WaitForAutoGazeTest(TimesLookingAtRobotMimick)); break; default: break; } }
// public method #endregion "public method" #region "private method" // private method private void _ConvertAnim(string newClipAssetPath) { // 0. prepare if (!m_Animator.isHuman) { Dbg.LogWarn("MuscleClipConverterEditor._ConvertAnim: Need to change to Humanoid rig first!"); return; } m_SMR = m_Animator.GetComponentInChildren <SkinnedMeshRenderer>(); if (m_SMR == null) { Dbg.LogWarn("MuscleClipConverterEditor._ConvertAnim: failed to find SMR under {0}", m_Animator.name); return; } m_Animator.Update(0); #if !U5 var ainfos = m_Animator.GetCurrentAnimationClipState(0); //only effect after Update is called #else var ainfos = m_Animator.GetCurrentAnimatorClipInfo(0); //only effect after Update is called #endif AnimationClip clip = ainfos[0].clip; AnimationClipSettings clipSetting = AnimationUtility.GetAnimationClipSettings(clip); //{//debug // var bindings = AnimationUtility.GetCurveBindings(clip); // foreach( var b in bindings) // { // Dbg.Log("path: {0}, prop: {1}", b.path, b.propertyName); // } //} Transform animatorTr = m_Animator.transform; Transform hipsBone = null; CurveDict curveDict = new CurveDict(); float SAMPLE_RATE = clip.frameRate; float clipLen = clip.length; Matrix4x4 animatorInitW2LMat = animatorTr.worldToLocalMatrix; Matrix4x4 hipsInitW2LMat = Matrix4x4.identity; List <Transform> boneLst = new List <Transform>(); for (HumanBodyBones boneIdx = 0; boneIdx < HumanBodyBones.LastBone; ++boneIdx) { Transform tr = m_Animator.GetBoneTransform(boneIdx); //Dbg.Log("Map: {0}->{1}", boneIdx, tr); if (tr != null) { boneLst.Add(tr); if (boneIdx == HumanBodyBones.Hips) { hipsBone = tr; hipsInitW2LMat = hipsBone.parent.worldToLocalMatrix; //clipSetting.level = -hipsBone.localPosition.y; // set Y offset clipSetting.keepOriginalPositionY = false; //use RootNode position } } } Transform[] bones = boneLst.ToArray(); // init curves for each bone for (int idx = 0; idx < bones.Length; ++idx) { Transform oneBone = bones[idx]; string trPath = AnimationUtility.CalculateTransformPath(oneBone, animatorTr); var curves = new _Curves(); curves.relPath = trPath; curveDict.Add(oneBone, curves); } // init rootmotion curve { var curves = new _Curves(); curveDict.Add(animatorTr, curves); } AnimatorStateInfo curStateInfo = m_Animator.GetCurrentAnimatorStateInfo(0); float nt = curStateInfo.normalizedTime; m_Animator.Update(-nt * clipLen); //revert to 0 time { // 1. bake animation info into curve on all bones transform float time = 0f; float deltaTime = 1f / (SAMPLE_RATE); for (; time <= clipLen || Mathf.Approximately(time, clipLen); ) { //Dbg.Log("nt = {0}", m_Animator.GetCurrentAnimatorStateInfo(0).normalizedTime); // bone for (int idx = 0; idx < bones.Length; ++idx) { Transform oneBone = bones[idx]; _Curves curves = curveDict[oneBone]; if (oneBone == hipsBone) { continue; //skip the HipsBone. This is to add rootMotion matrix on hips, so Legacy is right } Vector3 pos = oneBone.localPosition; Quaternion rot = oneBone.localRotation; curves.X.AddKey(time, rot.x); curves.Y.AddKey(time, rot.y); curves.Z.AddKey(time, rot.z); curves.W.AddKey(time, rot.w); curves.PX.AddKey(time, pos.x); curves.PY.AddKey(time, pos.y); curves.PZ.AddKey(time, pos.z); } // root motion process { { //on Animator transform Vector3 pos = /*animatorTr.localPosition*/ animatorTr.position; Vector3 fwd = animatorTr.forward; Vector3 up = animatorTr.up; _Curves rootMotionCurves = curveDict[animatorTr]; Vector3 lpos = animatorInitW2LMat.MultiplyPoint(pos); Vector3 lfwd = animatorInitW2LMat.MultiplyVector(fwd); Vector3 lup = animatorInitW2LMat.MultiplyVector(up); Quaternion rot = Quaternion.LookRotation(lfwd, lup); rootMotionCurves.X.AddKey(time, rot.x); rootMotionCurves.Y.AddKey(time, rot.y); rootMotionCurves.Z.AddKey(time, rot.z); rootMotionCurves.W.AddKey(time, rot.w); rootMotionCurves.PX.AddKey(time, lpos.x); rootMotionCurves.PY.AddKey(time, lpos.y); rootMotionCurves.PZ.AddKey(time, lpos.z); } { //on hips transform if (hipsBone != null) { Vector3 pos = hipsBone.position; Vector3 fwd = hipsBone.forward; Vector3 up = hipsBone.up; _Curves hipsCurves = curveDict[hipsBone]; Vector3 lpos = hipsInitW2LMat.MultiplyPoint(pos); Vector3 lfwd = hipsInitW2LMat.MultiplyVector(fwd); Vector3 lup = hipsInitW2LMat.MultiplyVector(up); //Dbg.Log("time: {0}, lpos: {1}", time, lpos.ToString("F2")); Quaternion rot = Quaternion.LookRotation(lfwd, lup); hipsCurves.X.AddKey(time, rot.x); hipsCurves.Y.AddKey(time, rot.y); hipsCurves.Z.AddKey(time, rot.z); hipsCurves.W.AddKey(time, rot.w); hipsCurves.PX.AddKey(time, lpos.x); hipsCurves.PY.AddKey(time, lpos.y); hipsCurves.PZ.AddKey(time, lpos.z); } } } if (!Mathf.Approximately(time + deltaTime, clipLen)) { m_Animator.Update(deltaTime); time += deltaTime; } else { m_Animator.Update(deltaTime - 0.005f); //keep it in the range, if go beyond, something bad could happen time += deltaTime - 0.005f; } } } //end of 1. { // 2. set animation clip and store in AssetDatabase AnimationClip newClip = new AnimationClip(); newClip.frameRate = SAMPLE_RATE; newClip.localBounds = clip.localBounds; // set bone curves for (var ie = curveDict.GetEnumerator(); ie.MoveNext();) { var curves = ie.Current.Value; if (ie.Current.Key == animatorTr) { //root motion newClip.SetCurve(curves.relPath, typeof(Animator), "MotionT.x", curves.PX); newClip.SetCurve(curves.relPath, typeof(Animator), "MotionT.y", curves.PY); newClip.SetCurve(curves.relPath, typeof(Animator), "MotionT.z", curves.PZ); newClip.SetCurve(curves.relPath, typeof(Animator), "MotionQ.x", curves.X); newClip.SetCurve(curves.relPath, typeof(Animator), "MotionQ.y", curves.Y); newClip.SetCurve(curves.relPath, typeof(Animator), "MotionQ.z", curves.Z); newClip.SetCurve(curves.relPath, typeof(Animator), "MotionQ.w", curves.W); } else { newClip.SetCurve(curves.relPath, typeof(Transform), "localRotation.x", curves.X); newClip.SetCurve(curves.relPath, typeof(Transform), "localRotation.y", curves.Y); newClip.SetCurve(curves.relPath, typeof(Transform), "localRotation.z", curves.Z); newClip.SetCurve(curves.relPath, typeof(Transform), "localRotation.w", curves.W); newClip.SetCurve(curves.relPath, typeof(Transform), "localPosition.x", curves.PX); newClip.SetCurve(curves.relPath, typeof(Transform), "localPosition.y", curves.PY); newClip.SetCurve(curves.relPath, typeof(Transform), "localPosition.z", curves.PZ); } } // 2.1 copy the unmapped curves to new clip( not mapped by Muscle clip ) _CopyOtherCurves(newClip, clip); // some setting work newClip.EnsureQuaternionContinuity(); #if !U5 AnimationUtility.SetAnimationType(newClip, m_AnimType); RCall.CallMtd("UnityEditor.AnimationUtility", "SetAnimationClipSettings", null, newClip, clipSetting); #else if (m_AnimType == ModelImporterAnimationType.Legacy) { newClip.legacy = true; } AnimationUtility.SetAnimationClipSettings(newClip, clipSetting); #endif EUtil.SaveAnimClip(newClip, newClipAssetPath); EUtil.ShowNotification("Converted to: " + m_AnimType + (hipsBone != null ? ("\nroot=" + AnimationUtility.CalculateTransformPath(hipsBone, animatorTr)) : ""), 3f ); } //end of 2. // 3. clean job curveDict = null; AssetDatabase.SaveAssets(); Dbg.Log("Converted: {0}", newClipAssetPath); }
public static void Log <T>(T message, Color col) { Dbg.Log(message.ToString(), col); }
public void Highlight() { Dbg.Log(this, "Highlight"); GetComponentInChildren <Light>().intensity = 0.75f; }
public void OnRightCommand() { Dbg.Log(this, "OnRightCommand"); Destroy(localTellerStartRight); }
public void Initialize() { Dbg.Log("GPGService is initialized"); Social.localUser.Authenticate(OnAuthenticate); }
public static void Respawn() { Dbg.Log("", "Respawn"); hasRespawned = true; SceneManager.LoadScene("Level" + currentLevelIndex); }
private void OnAuthenticate(bool success) { Dbg.Log("Successfully connected to Google Play Games: " + success); }
void ProcessResp() { StopTimer(); string tmpFile = Path.GetTempFileName(); Dbg.Log($"Processing Response, attempts = {m_attemptsCount + 1}."); m_exHandler = RespExceptionHandler; var netEngin = new NetEngin(Program.NetworkSettings); using (new AutoReleaser(() => File.Delete(tmpFile))) { SetProgressMessage("Réception des données à partir du serveur..."); try { netEngin.Download(tmpFile, Urls.ConnectionRespURL, true); } catch (Exception ex) { Dbg.Log(ex.Message); DialogEngin.WriteConnectionsResp(tmpFile, Enumerable.Empty <HubCore.DLG.Message>()); } IEnumerable <HubCore.DLG.Message> messages = DialogEngin.ReadConnectionsResp(tmpFile); HubCore.DLG.Message[] msgs = (from resp in messages where resp.ReqID >= m_msgID select resp).ToArray(); HubCore.DLG.Message msg = msgs.Where(m => m.ReqID == m_msgID).SingleOrDefault(); uint clID = msg == null ? 0 : BitConverter.ToUInt32(msg.Data, 0); if (msg != null && clID == m_clInfo.ClientID) { switch (msg.MessageCode) { case Message_t.InvalidID: Dbg.Log($"Got invalid ID! (ClientID = {m_clInfo.ClientID})."); ClientInfo clInfo = ClientInfo.CreateClient(m_clInfo.ProfileID); clInfo.ContaclEMail = m_clInfo.ContaclEMail; clInfo.ContactName = m_clInfo.ContactName; clInfo.ContactPhone = m_clInfo.ContactPhone; m_clInfo = clInfo; if (++m_attemptsCount >= SettingsManager.MaxConnectAttemps) { if (ShowMessage(MAX_ATTEMPTS_ERROR, MessageBoxButtons.YesNo) != DialogResult.Yes) { CloseDialog(); return; } else { m_attemptsCount = 0; } } PostReq(); break; case Message_t.Ok: Dbg.Log("Client registered :-)!"); Program.Settings.ClientInfo = m_clInfo; SetProgressMessage("Enregistrement terminé."); //creation des fichier dlg string dlgFile = SettingsManager.GetClientDialogFilePath(clID); DialogEngin.WriteHubDialog(dlgFile, clID, Enumerable.Empty <HubCore.DLG.Message>()); try { netEngin.Upload(SettingsManager.GetClientDialogURL(clID), dlgFile, true); } catch (Exception ex) { Dbg.Log(ex.Message); } ShowMessage("Votre enregistrement est maintenant terminé. " + "Vous pouvez commencer à utiliser l’application."); IsRegistered = true; CloseDialog(); break; case Message_t.InvalidProfile: Dbg.Log($"Got invalid Profile! (ProfileID: = {m_clInfo.ProfileID})."); ShowMessage(SRV_ERROR); CloseDialog(); return; case Message_t.Rejected: Dbg.Log("Got reject connection!"); ShowMessage(REJECT_CONNCTION_ERROR); CloseDialog(); return; default: Dbg.Log("Got invalid response!!!!"); Dbg.Assert(false); break; } } else if (msgs.Length > 0) { Dbg.Log("Request message lost."); if (++m_attemptsCount >= SettingsManager.MaxConnectAttemps) { if (ShowMessage(MAX_ATTEMPTS_ERROR, MessageBoxButtons.YesNo) != DialogResult.Yes) { CloseDialog(); return; } else { m_attemptsCount = 0; } } PostReq(); } else if (++m_attemptsCount >= SettingsManager.MaxConnectAttemps) { Dbg.Log("Timeout."); if (ShowMessage(MAX_ATTEMPTS_ERROR, MessageBoxButtons.YesNo) == DialogResult.Yes) { StartTimer(); m_attemptsCount = 0; PostReq(); } else { CloseDialog(); } } else { StartTimer(); SetProgressMessage("Attente de la réponse du serveur..."); } } }
public GpgService() { Dbg.Log("GPGService is Started".Color(Color.green)); PlayGamesPlatform.Activate(); }