public void GotoState(enState s, object param) { enState lastState = m_state; m_state = s; m_states[s].OnEnter(lastState, param); }
public static string GetColorState(enState state) { string Color = string.Empty; switch (state) { case enState.Production: Color = "#A5CC48"; break; case enState.Pause: Color = "#FFE941"; break; case enState.Error: Color = "#cc3333"; break; case enState.Manual: Color = "#98C2ED"; break; default: Color = "#aaa"; break; } return(Color); }
public static void LogOut(UserObject pUserObject) { pUserObject.UserID = ""; pUserObject.UserInitial = ""; ClearCredential(pUserObject); _state = enState.LogOut; }
private bool ParseByte(byte data) { switch (__State) { case enState.wHeader: if (data == 0xFF) { __State = enState.wHeader2; } break; case enState.wHeader2: __State = data == 0xFF ? enState.wSize : enState.wHeader; break; case enState.wSize: __State = enState.wSize2; __WaitForSize = (ushort)(data << 8); break; case enState.wSize2: __WaitForSize |= data; __State = __WaitForSize == 0 || __WaitForSize > __Buffer.Length ? enState.wHeader : enState.wCommand; break; case enState.wCommand: __Command = data; __WaitForSize--; __BufferPos = 0; if (__WaitForSize > 0) { __State = enState.rData; } else { __State = enState.wHeader; ExecCommand(); } break; case enState.rData: __Buffer[__BufferPos] = data; __BufferPos++; if (__WaitForSize == __BufferPos) { __State = enState.wHeader; ExecCommand(); } break; } return(__State == enState.wHeader); }
public static void LogOut() { _userID = ""; _userInitial = ""; ClearCredential(); _state = enState.LogOut; }
public static void AlwaysAuthenticate() { SecurityManager.IsAuthenticate("WRT", EncodePassword("wirwir")); IsAuthenticate("WRT", EncodePassword("wirwir")); _state = enState.LogIn; }
protected virtual void OnOnStateChanged(enState state, uint bytes = 0) { StateChangedDeletage handler = OnStateChanged; if (handler != null) { handler(state, bytes); } }
protected float myRotationSpeed; // The base speed at which this enemy will "turn". //============================================================================= // Default ctor public Enemy() { this.myState = enState.IDLE; this.myType = enType.UNDEF; this.myHealth = 1; this.myDamage = -1; this.myRotationSpeed = 1; }
/// <summary> /// Validates the state change against game rules. /// If the state change is valid, then it is peformed /// </summary> /// <param name="NextState"></param> public void SetState(enState NextState) { bool blnValidStateChange = false; switch (NextState) { case enState.ArriveAtNewLevel: blnValidStateChange = true; break; case enState.Spawning: blnValidStateChange = true; //reset all animation flags ResetAllAnimationFlags(); break; case enState.Hailing: if (state == enState.Spawning) blnValidStateChange = true; break; case enState.Boarding: if (state == enState.Hailing) blnValidStateChange = true; break; case enState.Riding: if (state == enState.Boarding) { blnValidStateChange = true; ResetAllAnimationFlags(); } break; case enState.Deboarding: if (state == enState.Riding) blnValidStateChange = true; break; case enState.Leaving: if (state == enState.Deboarding) { blnValidStateChange = true; ResetAllAnimationFlags(); } break; case enState.Dying: blnValidStateChange = true; break; case enState.Dead: if (state == enState.Dying) { blnValidStateChange = true; ResetAllAnimationFlags(); } break; default: blnValidStateChange = true; ResetAllAnimationFlags(); break; } //if the state change passed validation, then perform it if (blnValidStateChange == true) state = NextState; }
public void OnBegin(Material m) { m_state = enState.init; m_lastTime = -1; m_lastLoop = -1; m_uvOffset = Vector2.zero; m_isEnd = false; FindPropertyName(m); OnUpdateMaterial(m, 0); }
public static void AlwaysAuthenticate() { //_userID = "RAY"; //_userInitial = "RAY"; //SecurityManager.IsAuthenticate("RAY", EncodePassword("12345")); SecurityManager.IsAuthenticate("WRT", EncodePassword("wirwir")); IsAuthenticate("WRT", EncodePassword("wirwir")); //SecurityManager.RecordLoginHistory(); //if (SecurityManager.IsPasswordExpired()) //{ // frmChangePassword ifrmChild = new frmChangePassword(true); // ifrmChild.Show(); //} _state = enState.LogIn; }
public void OnUpdateCamera(PostEffectsBase fx, float time) { m_curTime = time; enState state = CalcState(); if (m_fieldInfo != null)//找不到属性不需要变化 { switch (m_type) { case enType.Color: UpdateColor(fx); break; //如果是颜色渐变 case enType.Float: UpdateFloat(fx); break; //如果是float值渐变 default: Debuger.LogError("未知的类型{0}", m_type); break; } } m_state = state; m_lastTime = m_curTime; }
public void OnBegin(PostEffectsBase fx) { m_state = enState.init; m_lastTime = -1; m_isEnd = false; //找到对应的字段 Type t = fx.GetType(); m_fieldInfo = t.GetField(m_fieldName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (m_fieldInfo == null) { m_fieldInfo = t.GetField("m_" + m_fieldName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); } if (m_fieldInfo == null) { Debuger.LogError("找不到字段:{0}", m_fieldName); } OnUpdateCamera(fx, 0); }
public void OnUpdateMaterial(Material m, float time) { m_curTime = time; m_curLoop = m_onceDuration <= 0 ? m_curLoop + 1 : Mathf.CeilToInt(time / m_onceDuration); enState state = CalcState(); if (!string.IsNullOrEmpty(m_findPropertyName))//找不到属性不需要变化 { //如果uv滚动 if (m_type == enType.ScrollingUV) { UpdateScrollingUV(m); } //如果是纹理的Tile渐变 else if (m_type == enType.ScrollingUV) { UpdateTileTexture(m); } //带渐变的效果 else { if (state != m_state || (m_state != enState.middle && m_state != enState.over))//有些状态不需要变化 { switch (m_type) { case enType.Color: UpdateColor(m); break; //如果是颜色渐变 case enType.Float: UpdateFloat(m); break; //如果是float值渐变 default: Debuger.LogError("未知的类型{0}", m_type); break; } } } } m_state = state; m_lastTime = m_curTime; m_lastLoop = m_curLoop; }
/** * Initialize a interactive instance * * @param type The type of the person * @param color The color of the person */ public virtual void initInstance(enType type, enColor color, bool isPlayer = false) { Color32 c32; // Set the instance's properties this.type = type; this.color = color; // Make sure this person can be bribed/influenced this.state = enState.free; this.isWhite = false; this.dir = enDir.none; // Always start on idle forceAIState(enAIState.idle); this.sprBody = null; this.fixLayer = this.GetComponentInChildren<FixLayer>(); if (this.fixLayer != null) { this.fixLayer.fixLayer(this, isPlayer); this.sprBody = this.fixLayer.getBody(); } switch(type) { case enType.level_0: this.fixLayer.setType(0); break; case enType.level_1: this.fixLayer.setType(1); break; case enType.level_2: this.fixLayer.setType(2); break; } switch (this.color) { case enColor.red: c32 = new Color32(0xed, 0x6a, 0x6a, 0xff); break; case enColor.green: c32 = new Color32(0x3e, 0xb7, 0x79, 0xff); break; case enColor.blue: c32 = new Color32(0x54, 0x57, 0x9e, 0xff); break; case enColor.magenta: c32 = new Color32(0xda, 0x71, 0xb0, 0xff); break; case enColor.cyan: c32 = new Color32(0x69, 0xb6, 0xd3, 0xff); break; case enColor.yellow: c32 = new Color32(0xe1, 0xda, 0x4f, 0xff); break; case enColor.black: c32 = new Color32(0xff, 0xff, 0xff, 0xff); break; case enColor.white: c32 = new Color32(0xff, 0xff, 0xff, 0xff); break; default: c32 = new Color32(0xff, 0xff, 0xff, 0xff); break; } if (this.sprBody) { this.sprBody.color = new Color((float)c32.r / 255.0f, (float)c32.g / 255.0f, (float)c32.b / 255.0f); } // Randomize the position this.transform.position = new Vector3(Random.Range( PersonBrain.minHorPosition + 0.5f, PersonBrain.maxHorPosition - 0.5f), 0, 0); // Activate the object's physics/behavious/etc this.gameObject.SetActive(true); }
public static bool IsAuthenticate(string userID, string password) { bool valid = false; DataTable dt; using (Database db = new Database()) { db.Commands.Add(db.CreateCommand("usp_SecurityUsers_AUTHENTICATE")); db.Commands[0].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); db.Commands[0].Parameters.Add(new Parameter("@password", SqlDbType.VarChar, password)); dt = db.Commands[0].ExecuteDataTable(); } if (dt.Rows.Count > 0) { _userID = userID; _userName = dt.Rows[0]["UserName"].ToString(); _userInitial = dt.Rows[0]["Initial"].ToString(); _TglPassword = (DateTime)dt.Rows[0]["TglPassword"]; _active = bool.Parse(dt.Rows[0]["Active"].ToString()); if (_active) { using (Database db = new Database()) { //Get Parts db.Commands.Add(db.CreateCommand("usp_vwSecurityPartsUsers_LIST")); db.Commands[0].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); dt = db.Commands[0].ExecuteDataTable(); _parts = new List <string>(); foreach (DataRow dr in dt.Rows) { _parts.Add(dr["PartID"].ToString()); } //Get Rights db.Commands.Add(db.CreateCommand("usp_SecurityUsersRights_LIST")); db.Commands[1].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); dt = db.Commands[1].ExecuteDataTable(); _rights = new List <string>(); foreach (DataRow dr in dt.Rows) { _rights.Add(dr["RightID"].ToString()); } //Get App Roles db.Commands.Add(db.CreateCommand("usp_SecurityRolesUsers_LIST")); db.Commands[2].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); db.Commands[2].Parameters.Add(new Parameter("@roleType", SqlDbType.VarChar, "Application")); dt = db.Commands[2].ExecuteDataTable(); _appRoles = new List <string>(); foreach (DataRow dr in dt.Rows) { _appRoles.Add(dr["RoleID"].ToString()); } //Get Biz Roles db.Commands.Add(db.CreateCommand("usp_SecurityRolesUsers_LIST")); db.Commands[3].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); db.Commands[3].Parameters.Add(new Parameter("@roleType", SqlDbType.VarChar, "Business")); dt = db.Commands[3].ExecuteDataTable(); _bizRoles = new List <string>(); foreach (DataRow dr in dt.Rows) { _bizRoles.Add(dr["RoleID"].ToString()); } } valid = true; } else { MessageBox.Show(Messages.Error.AccountInactive, "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //get IP Address IPAddress[] localIPs = Dns.GetHostAddresses(System.Net.Dns.GetHostName()); if (valid) { SecurityManager.ResetCounter(); _state = enState.LogIn; } return(valid); }
public static bool IsAuthenticate(string userID, string password, string dbName) { bool valid = false; DataTable dt, dtU; Database db; if (dbName != "") { db = new Database(dbName); } else { db = new Database(); } db.Commands.Add(db.CreateCommand("usp_SecurityUsers_AUTHENTICATE")); db.Commands[0].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); db.Commands[0].Parameters.Add(new Parameter("@password", SqlDbType.VarChar, password)); dt = db.Commands[0].ExecuteDataTable(); if (dt.Rows.Count > 0) { _userID = userID; _userName = dt.Rows[0]["UserName"].ToString(); _userInitial = dt.Rows[0]["Initial"].ToString(); _TglPassword = DateTime.Parse(dt.Rows[0]["TglPassword"].ToString()); _active = bool.Parse(dt.Rows[0]["Active"].ToString()); if (_active) { //Get Parts db.Commands[0].Parameters.Clear(); db.Commands.RemoveAt(0); db.Commands.Add(db.CreateCommand("usp_vwSecurityPartsUsers_LIST")); db.Commands[0].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); dt = db.Commands[0].ExecuteDataTable(); _parts = new List <string>(); foreach (DataRow dr in dt.Rows) { _parts.Add(dr["PartID"].ToString()); } //Get Rights db.Commands.Add(db.CreateCommand("usp_SecurityUsersRights_LIST")); db.Commands[1].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); dt = db.Commands[1].ExecuteDataTable(); _rights = new List <string>(); foreach (DataRow dr in dt.Rows) { _rights.Add(dr["RightID"].ToString()); } //Get App Roles db.Commands.Add(db.CreateCommand("usp_SecurityRolesUsers_LIST")); db.Commands[2].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); db.Commands[2].Parameters.Add(new Parameter("@roleType", SqlDbType.VarChar, "Application")); dt = db.Commands[2].ExecuteDataTable(); _appRoles = new List <string>(); foreach (DataRow dr in dt.Rows) { _appRoles.Add(dr["RoleID"].ToString()); } //Get Biz Roles db.Commands.Add(db.CreateCommand("usp_SecurityRolesUsers_LIST")); db.Commands[3].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); db.Commands[3].Parameters.Add(new Parameter("@roleType", SqlDbType.VarChar, "Business")); dt = db.Commands[3].ExecuteDataTable(); _bizRoles = new List <string>(); foreach (DataRow dr in dt.Rows) { _bizRoles.Add(dr["RoleID"].ToString()); } db.Commands.Add(db.CreateCommand("usp_UserLogin_AUTHENTICATE")); db.Commands[4].Parameters.Add(new Parameter("@Username", SqlDbType.VarChar, userID)); dtU = db.Commands[4].ExecuteDataTable(); if (dtU.Rows.Count > 0) { _tgl = DateTime.Parse(dtU.Rows[0]["LastLogin"].ToString()); } //if (GlobalVar.GetServerDate.Date < _tgl.Date) //{ // MessageBox.Show("Tanggal server tidak valid", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // valid = false; //} //else if (DateTime.Today.Date < _tgl.Date) //{ // MessageBox.Show("Tanggal client tidak valid", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // valid = false; //} //else //{ // valid = true; //} valid = true; } else { MessageBox.Show(Messages.Error.AccountInactive, "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //get IP Address IPAddress[] localIPs = Dns.GetHostAddresses(System.Net.Dns.GetHostName()); if (valid) { SecurityManager.ResetCounter(); _state = enState.LogIn; } return(valid); }
public CompanionInterface() { ConnectionState = enState.ci_not_connected; }
public static bool IsAuthenticate(string userID, string password, UserObject pUserObject) { bool valid = false; DataTable dt; using (Database db = new Database()) { db.Commands.Add(db.CreateCommand("usp_SecurityUsers_AUTHENTICATE")); db.Commands[0].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); db.Commands[0].Parameters.Add(new Parameter("@password", SqlDbType.VarChar, password)); dt = db.Commands[0].ExecuteDataTable(); } if (dt.Rows.Count > 0) { pUserObject.UserID = userID; pUserObject.UserName = dt.Rows[0]["UserName"].ToString(); pUserObject.UserInitial = dt.Rows[0]["Initial"].ToString(); pUserObject.TglPassword = DateTime.Parse(Tools.isNull(dt.Rows[0]["TglPassword"], DateTime.Today).ToString()); pUserObject.Active = bool.Parse(dt.Rows[0]["Active"].ToString()); pUserObject.CabangID = Tools.isNull(dt.Rows[0]["CabangID"], "").ToString(); if (pUserObject.Active) { using (Database db = new Database()) { //Get Parts db.Commands.Add(db.CreateCommand("usp_vwSecurityPartsUsers_LIST")); db.Commands[0].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); dt = db.Commands[0].ExecuteDataTable(); pUserObject.Parts = new List <string>(); foreach (DataRow dr in dt.Rows) { pUserObject.Parts.Add(dr["PartID"].ToString()); } //Get Rights db.Commands.Add(db.CreateCommand("usp_SecurityUsersRights_LIST")); db.Commands[1].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); dt = db.Commands[1].ExecuteDataTable(); pUserObject.Rights = new List <string>(); foreach (DataRow dr in dt.Rows) { pUserObject.Rights.Add(dr["RightID"].ToString()); } //Get App Roles db.Commands.Add(db.CreateCommand("usp_SecurityRolesUsers_LIST")); db.Commands[2].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); db.Commands[2].Parameters.Add(new Parameter("@roleType", SqlDbType.VarChar, "Application")); dt = db.Commands[2].ExecuteDataTable(); pUserObject.AppRoles = new List <string>(); foreach (DataRow dr in dt.Rows) { pUserObject.AppRoles.Add(dr["RoleID"].ToString()); } //Get Biz Roles db.Commands.Add(db.CreateCommand("usp_SecurityRolesUsers_LIST")); db.Commands[3].Parameters.Add(new Parameter("@userID", SqlDbType.VarChar, userID)); db.Commands[3].Parameters.Add(new Parameter("@roleType", SqlDbType.VarChar, "Business")); dt = db.Commands[3].ExecuteDataTable(); pUserObject.BizRoles = new List <string>(); foreach (DataRow dr in dt.Rows) { pUserObject.BizRoles.Add(dr["RoleID"].ToString()); } } valid = true; } } //get IP Address IPAddress[] localIPs = Dns.GetHostAddresses(System.Net.Dns.GetHostName()); if (valid) { SecurityManager.ResetCounter(); _state = enState.LogIn; } return(valid); }
/// <summary> /// /// </summary> /// <param name="InitialState"></param> public clsPassengerStateManager(enState InitialState) { SetState(InitialState); }
//============================================================================= // set the state of this enemy public enState setState(enState newState) { return(this.myState = newState); }
private List <long> GetDataGroup(List <HistoryStateModel> data, List <DateTime> days, enAggregation granularity, enState state) { List <long> lista = new List <long>(); switch (granularity) { case enAggregation.Day: lista = days.Select(d => data.Where(w => w.enState == state && w.Day.Value == d) .Select(s => s.ElapsedTime ?? 0).DefaultIfEmpty(0).First()).ToList(); break; case enAggregation.Week: var weeks = data.Where(w => w.enState == state).GroupBy(a => a.Day.Value.GetWeekNumber()) .Select(n => new { week = n.Key, somma = n.Sum(o => o.ElapsedTime ?? 0) }).ToList(); lista = days.Select(s => s.GetWeekNumber()).Distinct().ToList() .Select(d => weeks.Where(l => l.week == d).FirstOrDefault()?.somma ?? 0).ToList(); break; case enAggregation.Month: var months = data.Where(w => w.enState == state).GroupBy(a => a.Day.Value.Month) .Select(n => new { month = n.Key, somma = n.Sum(o => o.ElapsedTime ?? 0) }).ToList(); lista = days.Select(s => s.Month).Distinct().ToList() .Select(d => months.Where(l => l.month == d).FirstOrDefault()?.somma ?? 0).ToList(); break; case enAggregation.Quarter: var quarters = data.Where(w => w.enState == state).GroupBy(a => a.Day.Value.GetQuarter() + (a.Day.Value.Year * 10)) .Select(n => new { quarter = n.Key, somma = n.Sum(o => o.ElapsedTime ?? 0) }).ToList(); lista = days.Select(s => s.GetQuarter() + (s.Year * 10)).Distinct().ToList() .Select(d => quarters.Where(l => l.quarter == d).FirstOrDefault()?.somma ?? 0).ToList(); break; case enAggregation.Year: var years = data.Where(w => w.enState == state).GroupBy(a => a.Day.Value.Year) .Select(n => new { year = n.Key, somma = n.Sum(o => o.ElapsedTime ?? 0) }).ToList(); lista = days.Select(s => s.Year).Distinct().ToList() .Select(d => years.Where(l => l.year == d).FirstOrDefault()?.somma ?? 0).ToList(); break; default: break; } return(lista); }
private IEnumerator doAI() { this.isRunningAI = true; if (this.state == enState.bribed && this.aiState != enAIState.talk) { int num; num = PersonBrain.lvlManager.countFreeWithColor(this.color, this.type); if (num > 0) { this.aiState = enAIState.pursue; } else if (!isWhite) { // Gradually change the player color to white StartCoroutine(fadeToWhite()); } } switch (aiState) { case enAIState.idle: { float time; this.rbody.velocity = Vector2.zero; time = Random.Range(minIdleTime, maxIdleTime); Debug.Log("Idle for " + time.ToString() + "s"); animator.SetFloat("MovBlend", 0); yield return new WaitForSeconds(time); Debug.Log("Exiting idle!"); // Select new state if (Random.Range(0, 1) == 0) { this.aiState = enAIState.walk; } else { this.aiState = enAIState.idle; } } break; case enAIState.walk: { float time; // Set speed if (this.transform.position.x <= PersonBrain.minHorPosition) { this.rbody.velocity = new Vector2(this.horizontalSpeed, 0.0f); } else if (this.transform.position.x >= PersonBrain.maxHorPosition) { this.rbody.velocity = new Vector2(-this.horizontalSpeed, 0.0f); } else if (Random.Range(0, 1) == 0) { this.rbody.velocity = new Vector2(-this.horizontalSpeed, 0.0f); } else { this.rbody.velocity = new Vector2(this.horizontalSpeed, 0.0f); } // Make the person walk more to the oposing direction if (this.transform.position.x < PersonBrain.lvlManager.width / 8f) { this.rbody.velocity = new Vector2(this.horizontalSpeed, 0.0f); time = Random.Range(minWalkTime * 1.5f, maxWalkTime * 2f); } else if (this.transform.position.x > PersonBrain.lvlManager.width / 8f) { this.rbody.velocity = new Vector2(-this.horizontalSpeed, 0.0f); time = Random.Range(minWalkTime * 1.5f, maxWalkTime * 2f); } else { time = Random.Range(minWalkTime, maxWalkTime); } Debug.Log("Walking for " + time.ToString() + "s"); animator.SetFloat("MovBlend", 1); yield return new WaitForSeconds(time); Debug.Log("Exiting walk!"); this.rbody.velocity = Vector2.zero; // Always go back to idle, after this this.aiState = enAIState.idle; } break; case enAIState.talk: { this.rbody.velocity = Vector2.zero; // Since both people must talk for the same amount of time they // should wait for the same amount of time animator.SetTrigger("Bribe"); yield return new WaitForSeconds(this.influenceTime); if (this.state == enState.influenced) { // Gradually change the player color to white StartCoroutine(fadeToWhite()); } } break; case enAIState.getBribed: { this.rbody.velocity = Vector2.zero; // Since both people must talk for the same amount of time they // should wait for the same amount of time animator.SetTrigger("Bribe"); yield return new WaitForSeconds(this.influenceTime); this.state = enState.bribed; PersonBrain.lvlManager.currentFollowers++; PersonBrain.lvlManager.accBribed++; } break; case enAIState.follow: { Transform player; player = PersonBrain.lvlManager.player; animator.SetFloat("MovBlend", 1); while (Vector3.Distance(player.transform.position, this.transform.position) > this.maxDistanceFromPlayer) { // Go after the player if (player.transform.position.x < this.transform.position.x && this.rbody.velocity.x >= 0) { this.rbody.velocity = new Vector2(-this.horizontalSpeed, 0.0f); Debug.Log("Player is to my left"); } else if (player.transform.position.x > this.transform.position.x && this.rbody.velocity.x <= 0) { this.rbody.velocity = new Vector2(this.horizontalSpeed, 0.0f); Debug.Log("Player is to my right"); } else { Debug.Log("Going the right direction!"); } yield return null; } } break; case enAIState.pursue: { PersonBrain target; target = PersonBrain.lvlManager.getNextInfluentiable(this.color, this.type); Debug.Log("Entered pursue!"); while (target.state == enState.free) { // Go after that person if (target.transform.position.x < this.transform.position.x && this.rbody.velocity.x >= 0) { this.rbody.velocity = new Vector2(-this.horizontalSpeed, 0.0f); Debug.Log("Target is to my left"); } else if (target.transform.position.x > this.transform.position.x && this.rbody.velocity.x <= 0) { this.rbody.velocity = new Vector2(this.horizontalSpeed, 0.0f); Debug.Log("Target is to my right"); } else { Debug.Log("Going the right direction!"); } // Wait until this person overlap its target or the target // gets influenced/bribed by another yield return null; } } break; } this.isRunningAI = false; this.runningCoroutine = null; if (this.state != enState.free) { if (Vector3.Distance(PersonBrain.lvlManager.player.transform.position, this.transform.position) > this.maxDistanceFromPlayer) { this.aiState = enAIState.follow; } else { this.aiState = enAIState.idle; } } }