void Start() { this.speed = 10.0f; this.currentSpeed = this.speed; this.currentFirstHability = 0.0f; this.waitingFirstHability = 4.0f; this.currentTime = 0.0f; this.waitingTime = 8.0f; this.stageAttack = true; this.isAttacking = true; this.isAnimation = true; this.isMove = false; this.player = GameObject.Find("Jumba").transform; this.life = GetComponent <SwordBossLife>(); this.stateBoss = stateSwordBoss.MOVE; }
/// <summary> /// Metodo que retorna um array de estados possiveis para o inimigo /// <returns>The state available.</returns> stateSwordBoss[] getStateAvailable() { float _tempLife = this.life.getCurrentLife(); stateSwordBoss[] _tempArrayState; if ((_tempLife > ((this.life.life * _MEDIUM) / _MAX))) { _tempArrayState = new stateSwordBoss[1]; _tempArrayState[0] = stateSwordBoss.SECONDSKILL; } else if ((_tempLife > ((this.life.life * _MIN) / _MAX)) && (_tempLife <= ((this.life.life * _MEDIUM) / _MAX))) { this.waitingTime = 6.0f; _tempArrayState = new stateSwordBoss[2]; _tempArrayState[0] = stateSwordBoss.SECONDSKILL; _tempArrayState[1] = stateSwordBoss.THIRDSKILL; } else { this.waitingTime = 4.0f; _tempArrayState = new stateSwordBoss[2]; _tempArrayState[0] = stateSwordBoss.THIRDSKILL; _tempArrayState[1] = stateSwordBoss.FOURTHSKILL; } return(_tempArrayState); }
/// <summary> /// Changes the state. /// /// Metodo resposavel por fazer a troca de estado do inimigo /// /// </summary> /// <param name="_currentStateBoss">_current state boss.</param> /// passa como parametro o estado atual do inimigo public void changeState(stateSwordBoss _currentStateBoss) { stateSwordBoss[] _arrayStateAvailable = getStateAvailable(); float _randomNumber = UnityEngine.Random.Range(0, 100); if (_currentStateBoss == stateSwordBoss.MOVE) { if (_randomNumber < _MIN) { this.stateBoss = stateSwordBoss.IDLE; } else { this.stateBoss = _arrayStateAvailable[UnityEngine.Random.Range(0, _arrayStateAvailable.Length)]; } } else if (_currentStateBoss == stateSwordBoss.IDLE) { if (_randomNumber < _MIN) { this.stateBoss = stateSwordBoss.MOVE; } else { this.stateBoss = _arrayStateAvailable[UnityEngine.Random.Range(0, _arrayStateAvailable.Length)]; } } else { if (_randomNumber < _MEDIUM && stateBoss != stateSwordBoss.FIRSTSKILL) { this.stateBoss = stateSwordBoss.MOVE; } else { this.stateBoss = stateSwordBoss.IDLE; } } this.addEachTime(); this.chargeRotate(); this.isAnimation = true; this.currentTimeEachSkill = 0; this.currentTime = 0; }
public void setStateSwordBoss(stateSwordBoss state) { this.stateBoss = state; }
//Responsavel pela movimentaçao e condiçoes dos golpes void Update() { if (stateBoss != stateSwordBoss.DEAD) { this.distance = Vector3.Distance(transform.position, player.position); this.timeOut(); } if (stateBoss == stateSwordBoss.DEAD) { this.chargeAnimation("State", 6); } else if (stateBoss == stateSwordBoss.IDLE) { this.chargeAnimation("State", 0); this.chargeRotate(); if (distance <= 12.0f) { if (this.currentFirstHability >= waitingFirstHability) { this.isAnimation = true; this.stageAttack = true; this.currentFirstHability = 0.0f; this.stateBoss = stateSwordBoss.FIRSTSKILL; } } else if (distance <= 100.0f) { if (this.isAttacking) { this.changeState(this.stateBoss); } } } else if (stateBoss == stateSwordBoss.MOVE) { this.chargeAnimation("State", 1); this.moveForward(); if (distance <= 12.0f) { this.resetState(); this.stateBoss = stateSwordBoss.IDLE; } else if (distance <= 100.0f) { if (this.isAttacking) { this.changeState(this.stateBoss); } } } else if (stateBoss == stateSwordBoss.FIRSTSKILL) { this.chargeAnimation("State", 2); if (this.isMove) { transform.Translate(new Vector3(this.currentSpeed, 0, 0) * Time.deltaTime); } } else if (stateBoss == stateSwordBoss.SECONDSKILL) { this.chargeAnimation("State", 3); if (this.isMove) { transform.Translate(new Vector3(this.currentSpeed * 2, 0, 0) * Time.deltaTime); if (distance >= 17.0f && distance <= 18.0f && this.stageAttack) { this.chargePositionX(); this.chargeRotate(); this.currentSpeed = this.speed * 2; this.waitingTimeEachSkill = 1.5f; this.currentTimeEachSkill = 0; this.stageAttack = false; } if (this.currentTimeEachSkill >= waitingTimeEachSkill) { this.resetState(); } else if (this.currentTimeEachSkill < waitingTimeEachSkill) { this.currentTimeEachSkill += Time.deltaTime; } } } else if (stateBoss == stateSwordBoss.THIRDSKILL) { this.chargeAnimation("State", 4); if (this.isMove) { transform.Translate(new Vector3(0, -this.currentSpeed * 6 * Time.deltaTime, 0)); if (this.currentTimeEachSkill >= waitingTimeEachSkill) { this.resetState(); } else { this.currentTimeEachSkill += Time.deltaTime; } } } else if (stateBoss == stateSwordBoss.FOURTHSKILL) { this.chargeAnimation("State", 5); if (this.stageAttack) { sword(); this.stageAttack = false; } } }