private void IdleState() { GetBoolFromEmpty(); if (FBSodes && !FWSodes) { if (BSodes) { StateMob = StateMobs.Walk; GoForward(speedWalk); } } else { if (BSodes) { Rb.velocity = new Vector2(0, Rb.velocity.y); } if (StateMob != StateMobs.Idle) { StateMob = StateMobs.Idle; timefromState = Time.realtimeSinceStartup; } if (Time.realtimeSinceStartup - timefromState > timeState && StateMob == StateMobs.Idle) { StateMob = StateMobs.Walk; Rotate(); } } }
private bool GoToPlayer() { if (CheckLastPositionPlayer() && endAnimAtack) { GetBoolFromEmpty(); if (endAnimAtack && FBSodes && !FWSodes) { StateMob = StateMobs.Run; if (BSodes) { GoForward(speedRun); } } else { StateMob = StateMobs.Idle; if (BSodes) { Rb.velocity = new Vector2(0, Rb.velocity.y); } } return(true); } return(false); }
void Update() { //если не умер if (!Death()) { //если находится в зоне реагирования на плеера if (Atack_Ready) { checkEye(); } playerFinded = TimeActiveSearch(); //если if (playerFinded) { checkState(); if (!RightMove()) { Rotate(); } if (!GoToPlayer()) { if (CheckAtackPlayer()) { StateMob = StateMobs.Atack; } else { StateMob = StateMobs.Idle; } } } else { IdleState(); } GetPlayerInAtackCircle(); } else { PlayerStat.Instance.CountKillsUp(); this.gameObject.layer = 12; StateMob = StateMobs.Death; for (int i = 0; i < 6; ++i) { Destroy(transform.GetChild(i).gameObject); } Destroy(this); } }