public void HandleColor(int n) { HurtCount += n; anim.SetInteger("state", 3); anim.speed = 0; transform.GetComponent <BoxCollider2D>().enabled = false; spR.DOColor(new Color32(255, 150, 150, 255), 0.3f) .OnComplete(() => { spR.DOColor(new Color32(255, 255, 255, 255), 0.2f) .OnComplete(() => { transform.GetComponent <BoxCollider2D>().enabled = true; anim.speed = 1; anim.SetInteger("state", 0); if (transform.parent.name.CompareTo("m1") == 0) { _monster.SetState(new m1IdleState(_monster)); } else if (transform.parent.name.CompareTo("Dog") == 0) { _monster.SetState(new DogWalkState(_monster)); } }); }); }
private void chooseThinkTime(int time) { float randomtime; switch (time) { case 0: randomtime = Random.Range(1.2f, 2.0f); _monster.SetState(new BossIdleState(_monster, randomtime)); break; case 1: randomtime = Random.Range(1.4f, 2f); _monster.SetState(new BossIdleState(_monster, randomtime)); break; case 2: _monster.SetState(new BossIdleState(_monster, 0.45f)); break; case 3: randomtime = Random.Range(1.2f, 2.0f); _monster.SetState(new BossIdleState(_monster, randomtime)); break; } }
public void Update() { if (isCd == true) { waterCd += Time.deltaTime; if (waterCd > 35.0f) { isCd = false; } } ThinkTime += Time.deltaTime; float playerdis = _monster.trs.position.x - _monster.playerTrs.position.x; float playerdisY = _monster.trs.position.y - _monster.playerTrs.position.y; if (ThinkTime > 1.1f) { if (Mathf.Abs(playerdis) <= 0.5f && Mathf.Abs(playerdisY) < 1.5f) { _monster.anim.SetFloat("Num", -1); _monster.anim.SetInteger("state", 2); _monster.SetState(new m1AttackState(_monster)); return; } else if (Mathf.Abs(playerdis) <= 4 && Mathf.Abs(playerdisY) < 1.5f) { float a = Random.Range(0f, 8.0f); if (a >= 6.0f && isCd == false) { isCd = true; waterCd = 0; _monster.anim.SetFloat("Num", 1); _monster.anim.SetInteger("state", 2); _monster.SetState(new m1AttackState(_monster)); return; } else { _monster.anim.SetInteger("state", 1); _monster.SetState(new m1RunState(_monster)); return; } } else { _monster.anim.SetInteger("state", 1); _monster.SetState(new m1RunState(_monster)); return; } } }
public void Update() { _stateInfo = _monster.anim.GetCurrentAnimatorStateInfo(0); if (_stateInfo.IsName("Attack") && _stateInfo.normalizedTime > 1.0f) { _monster.anim.SetInteger("state", 0); _monster.SetState(new DogWalkState(_monster)); return; } if (isFinish == false) { float a = Random.Range(0.0f, 12.0f); if (a >= 8.0f) { _monster.trs.DOMoveZ(0.000001f, 0.25f).OnComplete(LoadBullet); _monster.trs.DOMoveZ(0.00001f, 1.6f).OnComplete(LoadBullet); isFinish = true; } else { _monster.trs.DOMoveZ(0.000001f, 0.25f).OnComplete(LoadBullet); isFinish = true; } } if (_monster.anim.GetInteger("state") == 3) { return; } }
// Update is called once per frame public void Update() { t1 += Time.deltaTime; if (t1 > 0.70f && finishAdd == false) { go = true; } if (go == true) { GameObject g1 = GameObject.Instantiate(Resources.Load <GameObject>("Bullet/BotBullet")); if (_monster.trs.rotation.y == 0) { g1.transform.Rotate(new Vector3(0, 180, 0)); } g1.transform.parent = _monster.trs; g1.transform.localPosition = new Vector3(-0.33f, 0, 0); g1.transform.parent = null; go = false; finishAdd = true; } if (_monster.anim.GetInteger("state") == 3) { return; } if (_monster.anim.GetInteger("state") == 0) { _monster.SetState(new BotWalkState(_monster)); } }
public void Update() { if (_monster.anim.GetInteger("state") == 3) { return; } ThinkTime += Time.deltaTime; float dis = _monster.pos.x - _monster.trs.position.x; float playerdis = _monster.trs.position.x - _monster.playerTrs.position.x; float playerdisY = _monster.trs.position.y - _monster.playerTrs.position.y; if (ThinkTime > 2.8f) { if (Mathf.Abs(playerdis) < 4 && Mathf.Abs(playerdisY) < 3) { if (playerdis < 0 && _monster.trs.rotation.y == 0) { _monster.trs.Rotate(new Vector3(0, 180, 0)); } else if (playerdis > 0 && _monster.trs.rotation.y != 0) { _monster.trs.Rotate(new Vector3(0, -180, 0)); } _monster.anim.SetInteger("state", 1); _monster.SetState(new BotAttackState(_monster)); } } /*if (Mathf.Abs(dis)>5) * { * needBack = true; * } * if(needBack==true) * { * if(Mathf.Abs(dis)<=0.5) * { * needBack = false; * } * else * { * _monster.trs.Translate(Vector2.right * Time.deltaTime); * } * }*/ if (Mathf.Abs(dis) >= maxMove) { _monster.trs.Rotate(_monster.trs.rotation.y == 0?new Vector3(0, 180, 0): new Vector3(0, -180, 0)); } // { if (_monster.trs.rotation.y == 0) { _monster.trs.position = Vector2.MoveTowards(_monster.trs.position, p1, Time.deltaTime); } else { _monster.trs.position = Vector2.MoveTowards(_monster.trs.position, p2, Time.deltaTime); } }
public void Update() { _stateInfo = _monster.anim.GetCurrentAnimatorStateInfo(0); if (_stateInfo.IsName("m1Attack") && _stateInfo.normalizedTime > 1.0f) { _monster.anim.SetInteger("state", 0); _monster.SetState(new m1IdleState(_monster)); } }
// Update is called once per frame public void Update() { _stateInfo = _monster.anim.GetCurrentAnimatorStateInfo(0); if (_stateInfo.IsName("BossRun") && _stateInfo.normalizedTime > 1.0f) { _monster.anim.SetInteger("state", 0); _monster.SetState(new BossIdleState(_monster, 1.0f)); } if (model == 1) { _monster.trs.position = Vector2.MoveTowards(_monster.trs.position, p1, Time.deltaTime * 11.0f); } }
public void Update() { if (_monster.anim.GetInteger("state") == 3) { return; } ThinkTime += Time.deltaTime; float dis = _monster.pos.x - _monster.trs.position.x; float playerdis = _monster.trs.position.x - _monster.playerTrs.position.x; float playerdisY = _monster.trs.position.y - _monster.playerTrs.position.y; if (ThinkTime > 3.0f) { if (Mathf.Abs(playerdis) < 5 && Mathf.Abs(playerdisY) < 2) { if (playerdis < 0 && _monster.trs.rotation.y != 0) { _monster.trs.Rotate(new Vector3(0, 180, 0)); } else if (playerdis > 0 && _monster.trs.rotation.y == 0) { _monster.trs.Rotate(new Vector3(0, -180, 0)); } _monster.anim.SetInteger("state", 1); _monster.SetState(new DogAttackState(_monster)); return; } } if (Mathf.Abs(dis) >= maxMove) { _monster.trs.Rotate(_monster.trs.rotation.y != 0 ? new Vector3(0, 180, 0) : new Vector3(0, -180, 0)); } // { if (_monster.trs.rotation.y != 0) { _monster.trs.position = Vector2.MoveTowards(_monster.trs.position, p1, Time.deltaTime); } else { _monster.trs.position = Vector2.MoveTowards(_monster.trs.position, p2, Time.deltaTime); } }
private void Choose(int dex) { switch (dex) { case 0: nowTime = 0; break; case 1: _monster.anim.SetInteger("state", 1); _monster.SetState(new BossRunState(_monster, 0)); break; case 2: _monster.anim.SetInteger("state", 1); _monster.SetState(new BossRunState(_monster, 1)); break; case 3: _monster.anim.SetInteger("state", 2); _monster.anim.SetFloat("Num", 1); _monster.SetState(new BossAttackState(_monster, 0)); break; case 4: _monster.anim.SetInteger("state", 2); _monster.anim.SetFloat("Num", 2); _monster.SetState(new BossAttackState(_monster, 1)); break; case 5: _monster.anim.SetInteger("state", 2); _monster.anim.SetFloat("Num", 3); _monster.SetState(new BossAttackState(_monster, 2)); break; case 6: _monster.anim.SetInteger("state", 2); _monster.anim.SetFloat("Num", 1); _monster.SetState(new BossAttackState(_monster, 3)); break; } }
public void Update() { if (m1IdleState.isCd == true) { m1IdleState.waterCd += Time.deltaTime; if (m1IdleState.waterCd > 35.0f) { m1IdleState.isCd = false; } } float playerdis = _monster.trs.position.x - _monster.playerTrs.position.x; float dis = _monster.pos.x - _monster.trs.position.x; float playerdisY = _monster.trs.position.y - _monster.playerTrs.position.y; if (Mathf.Abs(playerdis) <= 1.5f && Mathf.Abs(playerdisY) <= 1.0f) { _monster.anim.SetFloat("Num", -1); _monster.anim.SetInteger("state", 2); _monster.SetState(new m1AttackState(_monster)); return; } else if (Mathf.Abs(playerdis) <= 4 && Mathf.Abs(playerdisY) < 1.5f) { float a = Random.Range(0f, 8f); if (a >= 6.0f && m1IdleState.isCd == false) { m1IdleState.isCd = true; m1IdleState.waterCd = 0; _monster.anim.SetFloat("Num", 1); _monster.anim.SetInteger("state", 2); _monster.SetState(new m1AttackState(_monster)); return; } } if (Mathf.Abs(dis) >= maxMove) { _monster.trs.Rotate(_monster.trs.rotation.y == 0 ? new Vector3(0, 180, 0) : new Vector3(0, -180, 0)); } /* else if(Mathf.Abs(playerdis) <=4.5f&& Mathf.Abs(dis) <=maxMove-1) * * { * /*if (playerdis < 0 && _monster.trs.rotation.y == 0) * { * _monster.trs.Rotate(new Vector3(0, 180, 0)); * } * else if (playerdis > 0 && _monster.trs.rotation.y != 0) * { * _monster.trs.Rotate(new Vector3(0, -180, 0)); * }*/ //} if (_monster.trs.rotation.y == 0) { _monster.trs.position = Vector2.MoveTowards(_monster.trs.position, p1, Time.deltaTime * 1.4f); } else { _monster.trs.position = Vector2.MoveTowards(_monster.trs.position, p2, Time.deltaTime * 1.4f); } }