void Awake() { player = GameObject.FindGameObjectWithTag("Player"); playerAction = player.GetComponent <PlayerAction>(); boss = GameObject.FindGameObjectWithTag("Boss"); bossAction = boss.GetComponent <BossAction>(); rend = GetComponent <SpriteRenderer>(); if (bossAction.phase == 3) { isInstance = true; } else { isInstance = false; } if (isInstance) { verPos = transform.position.y; horPos = transform.position.x; dir = playerAction.dir; bulletSpeed = playerAction.bulletSpeed; } }
public override void setBossAction(BossAction newState) { if (state == newState) { // Same state. Do nothing. return; } Debug.Log("Set Boss Action: " + newState); _anim.SetBool("IsMoving", false); switch (newState) { case BossAction.move: _anim.SetBool("IsMoving", true); break; case BossAction.attack: _anim.SetTrigger("Attack"); break; case BossAction.dead: break; } base.setBossAction(newState); }
public override void setBossAction(BossAction newState) { switch (newState) { case BossAction.move: _anim.SetBool("IsMoving", true); break; case BossAction.attack: _anim.SetBool("IsMoving", false); _anim.SetTrigger("Attack"); break; case BossAction.special: _anim.SetBool("IsMoving", false); if (_useMissiles) { StartCoroutine(FireMissiles()); _useMissiles = false; } else { StartCoroutine(FireChestLaser()); _useMissiles = true; } break; case BossAction.dead: _anim.SetBool("IsMoving", false); SendMessageUpwards("bossDead", null, SendMessageOptions.DontRequireReceiver); break; } base.setBossAction(newState); }
protected override void PopulateActions() { _actions = new BossAction[2]; _actions[0] = new MoveLeftBossAction(); _actions[1] = new MoveRightBossAction(); SetPhasesForActions(); }
protected override void PopulateActions() { _actions = new BossAction[2]; _actions[0] = new MoveUpAndDownWithShotgun(); _actions[1] = new MoveUpAndDownWithShotgun(); SetPhasesForActions(); }
public override void setBossAction(BossAction newState) { if (state == newState) { // Same state. Do nothing. return; } switch (newState) { case BossAction.stand: isVulnerable = false; break; case BossAction.attack: _anim.SetTrigger("Attack"); break; case BossAction.special: _anim.SetTrigger("Vomit"); break; case BossAction.dead: break; } base.setBossAction(newState); }
public override void setBossAction(BossAction newState) { if (state == newState) { // Same state. Do nothing. return; } Debug.Log("Set Boss Action: " + newState); _anim.SetBool("IsMoving", false); switch (newState) { case BossAction.move: _anim.SetBool("IsMoving", true); break; case BossAction.attack: if (highGround) { // On High Ground. Throw bomb. _anim.SetTrigger("Bombthrow"); } else if (meleeCooldown <= 0) { // On low ground. Use melee. _anim.SetTrigger("Attack"); } break; case BossAction.retreat: // Retreat is when the boss leaves the stage. Let his lackeys do some death. _anim.SetTrigger("Drawsword"); break; case BossAction.reappear: // Boss is in the air. if (highGround) { // Position boss on the player's area. highGround = false; _anim.SetBool("HighGround", highGround); transform.position = new Vector3(-6.67f, 1.23f, transform.position.z); } else { // Position boss on his stand. highGround = true; _anim.SetBool("HighGround", highGround); transform.position = new Vector3(6.29f, 1.23f, transform.position.z); } break; case BossAction.dead: break; } base.setBossAction(newState); }
public override void setBossAction(BossAction newState) { switch (newState) { case BossAction.move: _anim.SetBool("IsMoving", true); break; case BossAction.attack: _anim.SetBool("IsMoving", false); // Randomize between a punch and kick. _anim.SetTrigger((Random.value > 0.5f) ? "Attack" : "Kick"); break; case BossAction.dying: _anim.SetBool("IsMoving", false); // No death animation; gets cutscene interrupted. SendMessageUpwards("bossDead", null, SendMessageOptions.DontRequireReceiver); break; } base.setBossAction(newState); }
public void AttackFinish() { actionCDtimer = actionCDset; currAction = BossAction.IDLE; anim.SetBool("StandAttack", false); agent.isStopped = false; }
public override void setBossAction(BossAction newState) { switch (newState) { case BossAction.attack: _anim.SetTrigger("Attack"); StartCoroutine(rapidFireWeb()); break; case BossAction.special: _anim.SetTrigger("Spray"); StartCoroutine(rapidFireAcid()); break; case BossAction.dying: _anim.SetBool("IsMoving", false); // No death animation; gets cutscene interrupted. SendMessageUpwards("bossDead", null, SendMessageOptions.DontRequireReceiver); break; case BossAction.reappear: transform.position = new Vector3(transform.position.x, spawnCeilingY, transform.position.z); transform.localScale = new Vector3(transform.localScale.x, normalHeight, transform.localScale.z); msState = MS_STATE_FALL; break; } base.setBossAction(newState); }
public void RpcDie() { anim.SetBool("StandAttack", false); anim.SetBool("IsRunning", false); agent.isStopped = true; anim.SetBool("Death", true); currAction = BossAction.DEATH; }
public void FarAttack() { if (this.currentBossAction != BossAction.遠距離攻擊) { this.currentBossAction = BossAction.遠距離攻擊; StartCoroutine(ReadyFarAttack(1)); //等待n秒後,進行遠距離攻擊 } }
SpriteRenderer rend; //the renderere that has our sprite // Use this for initialization void Start() { anim = GetComponent <Animator>(); col = GetComponent <Collider2D>(); actions = GetComponent <BossAction>(); mask = GetComponent <SpriteMask>(); rend = GetComponent <SpriteRenderer>(); IDLE = true; }
void Awake() { renderer = GetComponent <Renderer>(); //突撃タイマーの初期化 InitTimer = TotugekiTimer; //アクションタイムの初期化 ReSetTimer = ActionTime; bossAction = BossAction.FourPointFire; }
public override void OnInspectorGUI() { base.OnInspectorGUI(); BossController t = (BossController)target; float time = 0; for (int i = 0; i < t.bossScript.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("" + time, GUILayout.MaxWidth(20)); t.bossScript[i] = (BossAction)EditorGUILayout.EnumPopup(t.bossScript[i]); if ((int)t.bossScript[i] < t.actionTimes.Length) { time += t.actionTimes[(int)t.bossScript[i]]; } if (GUILayout.Button("-")) { t.bossScript.RemoveAt(i); i--; continue; } if (GUILayout.Button("+")) { t.bossScript.Insert(i, BossAction.Wait1); i--; continue; } if (selected == -1 && GUILayout.Button("Pick")) { selected = i; } if (i == selected) { if (selected != -1 && GUILayout.Button("Cancel")) { selected = -1; } } else if (selected != -1 && GUILayout.Button("Swap")) { BossAction x = t.bossScript[i]; t.bossScript[i] = t.bossScript[selected]; t.bossScript[selected] = x; selected = -1; } EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Add")) { t.bossScript.Add(BossAction.Wait1); } EditorUtility.SetDirty(target); }
public Boss(float x, float y, float width, float height, float speed, double attackSpeed, int leftTexture, int rightTexture, ShotCharacteristics shotChar, int hp, int damage, float shotSpeed, float shotRange, string name, BossAction skill) : base(x, y, width, height, speed, attackSpeed, leftTexture, rightTexture, shotChar, hp, damage, shotSpeed, shotRange, name) { _canUseSkill = true; _skill = skill; _isFinal = false; }
public void CreatBossRole(BossAction ai, string msg, Vector3 P, Quaternion Q) { Debug.Log("StartCreatModel"); ai.msg = msg; GameObject go = Resources.Load <GameObject>(msg); ai.Role = Instantiate(go, P, Q); ai.Role.GetComponent <PlayerHealth>().stateController = ai;// ai.Intialize(this); Boss.Add(ai); }
private void Update() { time += Time.deltaTime; if (isDefending) { defenseTime += Time.deltaTime; if (defenseTime >= DEFENCE_TIMER) { isDefending = false; } } animator.SetBool("isDeflecting", isDefending); BossAction action = actions[currentAction]; if ((action.action == ACTION.STAY || action.action == ACTION.SPAWN_WAVE || action.action == ACTION.SHOOT_LASER) && time - currentActionStartTime >= action.time) { NextAction(); } if (actions[currentAction].action == ACTION.STAY) { if (actionJustSwitched == true) { body.velocity = Vector2.zero; } } else if (actions[currentAction].action == ACTION.SPAWN_WAVE) { if (actionJustSwitched == true) { animator.SetTrigger("triggerWave"); MiteWaveMovement wave = Instantiate(wavePrefab, transform.position, Quaternion.identity).GetComponent <MiteWaveMovement>(); if (orientedLeft == true) { wave.movement.x = -wave.movement.x; wave.transform.position = new Vector3(wave.transform.position.x + 10, wave.transform.position.y, 0); } else { wave.transform.position = new Vector3(wave.transform.position.x - 10, wave.transform.position.y, 0); } Destroy(wave.gameObject, 10f); } } actionJustSwitched = false; }
public void NearAttack() { iTween.MoveTo(this.gameObject, iTween.Hash( "x", this.transform.position.x - this.NearAttackRunDistance, "time", this.NearAttackMoveTime, "easetype", iTween.EaseType.linear, "oncomplete", "NearAttackMoveComplete" )); this.currentBossAction = BossAction.近距離攻擊; }
void Awake() { bullet = GameObject.FindGameObjectWithTag("Bullet"); bulletSprite = bullet.GetComponent <SpriteRenderer>(); bulletSprite.enabled = false; gun = GameObject.FindGameObjectWithTag("Gun"); gunSprite = gun.GetComponent <SpriteRenderer>(); gunSprite.enabled = false; helmet = GameObject.FindGameObjectWithTag("Helmet"); helmetSprite = helmet.GetComponent <SpriteRenderer>(); helmetSprite.enabled = false; life1 = GameObject.FindGameObjectWithTag("PL_1"); life2 = GameObject.FindGameObjectWithTag("PL_2"); life3 = GameObject.FindGameObjectWithTag("PL_3"); life4 = GameObject.FindGameObjectWithTag("PL_4"); boss = GameObject.FindGameObjectWithTag("Boss"); bossAction = boss.GetComponent <BossAction>(); tiles = GameObject.FindGameObjectsWithTag("Tile"); sprite = GetComponentInChildren <SpriteRenderer>(); auw = GetComponent <AudioSource>(); bossHit = boss.GetComponent <AudioSource>(); bulletSpeed = 5f; dir = 1f; walkSpeed = 5f; jumpSpeed = 0.75f; gravity = 6f; maxJump = 2.5f; ground = -4f; lifes = 4; coolDown = true; grounded = false; up = false; down = false; jumping = false; isHit = false; above = false; under = false; hasHelmet = false; hasGun = false; cannotHarm = false; horPos = transform.position.x; verPos = transform.position.y; }
// Use this for initialization void Start() { chasePlayer = false; anim = GetComponent <Animator>(); agent = GetComponent <NavMeshAgent>(); currAction = BossAction.IDLE; actionCDset = 1f; actionCDtimer = actionCDset; runCDset = 2f; runCDtimer = runCDset; }
//状態変更に使える //引数は移動したい状態 void ChangeState(BossAction state) { //現在の状態が移動したい状態と違ったら if (bossAction != state) { //現在の状態の終了 OnStateExit(bossAction); //移動したい状態を代入 bossAction = state; //次の状態まで呼び出す OnStateEnter(state); } }
private void MakeDecision() { playerList = GameObject.FindGameObjectsWithTag("PlayerMain"); int i = Random.Range(0, playerList.Length); if (playerList[i].GetComponent <Interact>().bossArea) { targetPos = playerList[i].transform.position; } else { targetPos = transform.position; } runCDtimer = runCDset; currAction = BossAction.CHASE; }
//現在の状態が始まった時に一度だけ呼ばれる void OnStateEnter(BossAction state) { //切り替えたい状態を選択する switch (state) { case BossAction.FourPointFire: StartFier(); break; case BossAction.FallRaining: StartRain(); break; case BossAction.OpenFannel: StartFannel(); break; } }
void CreatTest(int type) { /* * Debug.Log("aIControllers CreatCount - " + aIControllers.Count); * AIController ai = new AIController(); * //ai set gameobj and model * Debug.Log("GetModel "); * GameObject go = Resources.Load<GameObject>("FSM/" + "TEnemy"); * ai.role = Instantiate(go); * ai.role.transform.position = new Vector3(CreatPOSCenter.transform.position.x + Random.Range(-10, 30), 1, CreatPOSCenter.transform.position.z+Random.Range(-10, 30)); * ai.aIGameManger = this; * ai.Start(); * aIControllers.Add(ai); * ai = null; * * Debug.Log("aIControllers CreatSuccess the new count is - " + aIControllers.Count); */ if (type == 0) { Vector3 P = new Vector3(Random.Range(-20, 20), 0, Random.Range(-20, 20)) + GameObject.FindGameObjectWithTag("Player").transform.position; EnemyAIStateController enemyai = new LittleMonsterStateController(); CreatEnemyRole(enemyai, "Enemy/" + "NS", P, Quaternion.identity); } else if (type == 1) { Vector3 P = new Vector3(Random.Range(-20, 20), 0, Random.Range(-20, 20)) + GameObject.FindGameObjectWithTag("Player").transform.position; CombineEnemyAIStateController enemyai = new CombineMonsterStateController(); CreatCombineEnemyRole(enemyai, "Enemy/" + "CB", P, Quaternion.identity); } else if (type == 2) { Vector3 P = new Vector3(Random.Range(-20, 20), 0, Random.Range(-20, 20)) + GameObject.FindGameObjectWithTag("Player").transform.position; BossAction enemyai = new BossAction(); CreatBossRole(enemyai, "Enemy/" + "Boss", P, Quaternion.identity); } //Vector3 P = new Vector3(Random.Range(-20, 20), 0, Random.Range(-20, 20)) + GameObject.FindGameObjectWithTag("Player").transform.position; //EnemyAIStateController enemyai = new LittleMonsterStateController(); //CreatEnemyRole(enemyai, "Enemy/" + "NS", P, Quaternion.identity); //Vector3 P = new Vector3(Random.Range(-20, 20), 0, Random.Range(-20, 20)) + GameObject.FindGameObjectWithTag("Player").transform.position; //CombineEnemyAIStateController enemyai = new CombineMonsterStateController(); //CreatCombineEnemyRole(enemyai, "Enemy/" + "CB", P, Quaternion.identity); }
public override void setBossAction(BossAction newState) { switch (newState) { case BossAction.move: _anim.SetBool("IsMoving", true); break; case BossAction.attack: _anim.SetBool("IsMoving", false); // Jump when enraged. Normal attack if calm. _anim.SetTrigger(enraged ? "JumpAttack" : "Attack"); break; case BossAction.dead: _anim.SetBool("IsMoving", false); break; } base.setBossAction(newState); }
//現在の状態を終了するときに一回呼ばれる void OnStateExit(BossAction state) { }
/// <summary> /// 魔王登場設定,並開始執行 /// </summary> void BossReadyAppear() { //魔王出現定位點為所有定位點清單中間值 this.currentBattlePositionIndex = this.BattlePositionList.Count / 2; //魔王從出生點移動到定位點 iTween.MoveTo(this.gameObject, iTween.Hash( "position", this.BattlePositionList[this.currentBattlePositionIndex].PositionTransform.position, "time", this.登場移動時間, //移動過程秒數 "easetype", iTween.EaseType.easeInOutQuad, "oncomplete", "BossAppearComplete" )); this.currentBossAction = BossAction.登場中; }
/// <summary> /// 當切換跑道完成後,執行此函式 /// </summary> /// <param name="index">切換跑道的index</param> void ChangeWalkComplete(int index) { this.currentBattlePositionIndex = index; this.currentBossAction = BossAction.閒置; }
private IEnumerator ExecuteSingleCommand(BossAction bossDirections) { waitAnimationEnd = true; switch (bossDirections) { case BossAction.UpLeft: GoUpLeft(); break; case BossAction.UpRight: GoUpRight(); break; case BossAction.DownLeft: GoDownLeft(); break; case BossAction.DownRight: GoDownRight(); break; case BossAction.HorizontalLeft: GoHorizontalLeft(); break; case BossAction.HorizontalRight: GoHorizontalRight(); break; case BossAction.Wait1: yield return(new WaitForSeconds(1)); waitAnimationEnd = false; break; case BossAction.Wait2: yield return(new WaitForSeconds(2)); waitAnimationEnd = false; break; case BossAction.Wait5: yield return(new WaitForSeconds(5)); waitAnimationEnd = false; break; case BossAction.ShootHeavy: if (bloodFill.bloodWellFull) { Transform shot = Instantiate(crosshairPrefab, player.transform.position, new Quaternion()); bloodFill.bloodWellFull = false; yield return(new WaitForSeconds(2)); bloodAnimator.SetTrigger("EmptyBlood"); Vector2 pos = shot.transform.position; Destroy(shot.gameObject); yield return(new WaitForSeconds(0.1f)); if (crosshairExplosion) { shot = Instantiate(crosshairExplosion, pos, Quaternion.Euler(0, 0, UnityEngine.Random.Range(0, 360))); Destroy(shot.gameObject, 5); ShootHeavy(); } } waitAnimationEnd = false; break; case BossAction.ShootLight: ShootLight(); yield return(new WaitForSeconds(0.2f)); ShootLight(); yield return(new WaitForSeconds(0.2f)); ShootLight(); yield return(new WaitForSeconds(0.2f)); ShootLight(); yield return(new WaitForSeconds(0.2f)); ShootLight(); yield return(new WaitForSeconds(0.2f)); waitAnimationEnd = false; break; default: break; } yield return(null); }
void ChangeWalkside() { int random; do { //選擇定位點,必須與當前定位點不同 random = Random.Range(0, this.BattlePositionList.Count); } while (this.currentBattlePositionIndex == random); iTween.MoveTo(this.gameObject, iTween.Hash( "position", this.BattlePositionList[random].PositionTransform.position, "time", this.ChangeWalksideMoveTime, "easetype", iTween.EaseType.linear, "oncomplete", "ChangeWalkComplete", "oncompleteparams", random )); this.currentBossAction = BossAction.切換跑道; }
/// <summary> /// 從近距離攻擊點移動至定位點完成後,執行此函式 /// </summary> void NearAttackFinishBackComplete() { this.currentBossAction = BossAction.閒置; this.ActionTimer.ChangeTimerState(true); }
/// <summary> /// 執行樹根攻擊 /// </summary> /// <param name="action">動作類型(大樹根攻擊or小樹根攻擊)</param> void TreeRootAttack(BossAction action) { this.currentBossAction = action; StartCoroutine(ReadyTreeRootAttack(this.CastingTime)); //等待吟詠咒語時間後,進行樹根攻擊 }
protected override void PopulateActions() { _actions = new BossAction[1]; _actions[0] = new StayStillAndSpray(); SetPhasesForActions(); }
/// <summary> /// UserTrigger,觸發判定 /// </summary> /// <param name="triggerEvent">觸發相關資訊</param> public void UserTrigger(SmoothMoves.UserTriggerEvent triggerEvent) { //確認是由"登場"動畫觸發的UserTrigger if (triggerEvent.animationName == "登場" & triggerEvent.boneName != "ChangeLayer") { //鏡頭震動 iTween.ShakePosition(Camera.main.gameObject, new Vector3(1, 1, 0), 0.15f); } //改變魔王Layer,更改為Boss Layer,啟動AI,角色開始攻擊 else if (triggerEvent.animationName == "登場" & triggerEvent.boneName == "ChangeLayer") { this.gameObject.layer = LayerMask.NameToLayer("Boss"); this.ActionTimer.ChangeTimerState(true); } //確認是由"遠距離攻擊"觸發的UserTrigger else if (triggerEvent.animationName == "遠距離攻擊") { //計算Boss與角色的距離 float distance = Mathf.Abs(RolesCollection.script.Roles[0].transform.position.x - this.transform.position.x); int damage = this.bossInfo.skillData.Find((GameDefinition.BossSkillData data) => { return data.SkillName == "遠距離攻擊"; }).Damage; //發射遠距離攻擊物件(目標為BOSS面前兩位角色) //目標為第一位角色 Vector3 Posv3 = RolesCollection.script.Roles[this.currentBattlePositionIndex].transform.position + new Vector3(distance, 0, 0); GameObject newObj = (GameObject)Instantiate(this.FarShootObject, Posv3, this.FarShootObject.transform.rotation); if (newObj.GetComponent<ShootObjectInfo_Once>()) newObj.GetComponent<ShootObjectInfo_Once>().Damage = damage; else if (newObj.GetComponent<ShootObjectInfo_Through>()) newObj.GetComponent<ShootObjectInfo_Through>().Damage = damage; //目標為第二位角色 Posv3 = RolesCollection.script.Roles[this.currentBattlePositionIndex + 1].transform.position + new Vector3(distance, 0, 0); newObj = (GameObject)Instantiate(this.FarShootObject, Posv3, this.FarShootObject.transform.rotation); if (newObj.GetComponent<ShootObjectInfo_Once>()) newObj.GetComponent<ShootObjectInfo_Once>().Damage = damage; else if (newObj.GetComponent<ShootObjectInfo_Through>()) newObj.GetComponent<ShootObjectInfo_Through>().Damage = damage; this.currentBossAction = BossAction.閒置; } }
private void Update() { Vector2 direction = (player.transform.position - transform.position).normalized; Vector2 per = Vector2.Perpendicular(direction); Vector2 dir2 = new Vector2(direction.x + per.x * angle, direction.y + per.y * angle); Vector2 dir3 = new Vector2(direction.x - per.x * angle, direction.y - per.y * angle); if (this.gameObject.GetComponent <EnemyDamage>().hp <= 40) { secondP = true; angle = 0.65f; } if (this.gameObject.GetComponent <EnemyDamage>().hp <= 20) { thirdP = true; secondP = false; angle = 0.60f; } //Debug.Log(state); //Debug.Log(rSkel); //Debug.Log(skeleTimer); //Debug.Log(wait); //Debug.Log(sTime); //Debug.Log(sCount); //Debug.Log(tsCount); switch (state) { case BossAction.Start: //animation or something state = BossAction.Idle; break; case BossAction.Idle: wait -= Time.deltaTime; if (wait <= 0) { int rState = Random.Range(0, 2); if (rState == 0) { if (!(tsCount == 2)) { sTime = Random.Range(3, 5); sCount = 0; state = BossAction.TripleBlaster; } else { state = BossAction.Idle; } } if (rState == 1) { if (sCount == 0) { rSkel = Random.Range(2, 4); tsCount = 0; state = BossAction.SummonSkeletons; } else { state = BossAction.Idle; } } if (rState == 2) { if (!(tsCount == 2)) { sTime = Random.Range(3, 5); sCount = 0; state = BossAction.TripleBlaster; } else { state = BossAction.Idle; } } } break; case BossAction.TripleBlaster: if (secondP == true) { fbSpeed = 3f; } else if (thirdP == true) { fbSpeed = 6f; } sTime -= Time.deltaTime; if (sTime >= 0) { timer -= Time.deltaTime; if (timer <= 0) { fireBall = Instantiate(fireBallPrefab, this.transform.position, Quaternion.identity); fireBall2 = Instantiate(fireBallPrefab, this.transform.position, Quaternion.identity); fireBall3 = Instantiate(fireBallPrefab, this.transform.position, Quaternion.identity); fireBall.GetComponent <Rigidbody2D>().velocity = direction * fbSpeed; fireBall2.GetComponent <Rigidbody2D>().velocity = dir2 * fbSpeed; fireBall3.GetComponent <Rigidbody2D>().velocity = dir3 * fbSpeed; if (secondP == true) { timer = 0.1f; } else if (thirdP == true) { timer = 0.03f; } else { timer = 1f; } } } if (sTime <= 0) { wait = 2.0f; tsCount += 1; state = BossAction.Idle; } break; case BossAction.SummonSkeletons: for (int i = 0; i < rSkel; i++) { rPosX = this.transform.position.x + Random.Range(-2, 2); rPosY = this.transform.position.y + Random.Range(-2, 2); Vector2 Pos = new Vector2(rPosX, rPosY); skeleton = Instantiate(skeletonPrefab, Pos, Quaternion.identity); } wait = 4.0f; sCount += 1; state = BossAction.Idle; break; } }
// Update is called once per frame void Update() { float dt = Time.deltaTime; if (health <= 0) { chasePlayer = false; if (isServer) { RpcDie(); } else { CmdDie(); } } if (chasePlayer) { actionCDtimer -= dt; runCDtimer -= dt; if (runCDtimer <= 0) { runCDtimer = 0; } if (currAction == BossAction.IDLE) { if (actionCDtimer <= 0) { actionCDtimer = 0; MakeDecision(); } } else if (currAction == BossAction.CHASE) { if (isServer) { RpcChasePlayer(targetPos); } else { CmdChasePlayer(targetPos); } if (agent.transform.position == agent.destination || runCDtimer <= 0) { currAction = BossAction.ATTACK; } } if (currAction == BossAction.ATTACK) { if (isServer) { RpcAttackPlayer(targetPos); } else { CmdAttackPlayer(targetPos); } } if (isServer) { RpcUpdateAgent(); } else { CmdUpdateAgent(); } } }
IEnumerator BacktoOriginPosition(float time) { yield return new WaitForSeconds(time); //等待n秒 iTween.MoveTo(this.gameObject, iTween.Hash( "x", this.transform.position.x + this.NearAttackRunDistance, "time", this.NearAttackMoveTime, "easetype", iTween.EaseType.linear, "oncomplete", "NearAttackFinishBackComplete" )); //移動過程需翻轉Scale Vector3 v3Scale = this.originScale; v3Scale.x = -Mathf.Abs(v3Scale.x); this.boneAnimation.mLocalTransform.localScale = v3Scale; this.currentBossAction = BossAction.近距離攻擊; }
/// <summary> /// 樹人長老BOSS準備進行樹根攻擊(小樹根攻擊、大樹根攻擊) /// </summary> /// <param name="time">等待秒數後開始樹根攻擊</param> /// <returns></returns> IEnumerator ReadyTreeRootAttack(float time) { int attackIndex = -1; //攻擊目標的索引 float playRootLength = -1; //儲存樹根動畫秒數 //小樹根攻擊(攻擊2位角色) if (this.currentBossAction == BossAction.小樹根攻擊) { for (int i = 0; i < 2; i++) { do { attackIndex = Random.Range(0, 4); } while (this.treeRootAttackList.Contains(attackIndex)); this.treeRootAttackList.Add(attackIndex); } //顯示提示提醒玩家(目標為隨機兩位角色) Instantiate(EffectCreator.script.道路危險提示[this.treeRootAttackList[0]]); Instantiate(EffectCreator.script.道路危險提示[this.treeRootAttackList[1]]); this.boneAnimation.Play("小樹根攻擊"); //開始播放小樹根攻擊動作 yield return new WaitForSeconds(time); //等待n秒(吟詠時間) //目標為兩位隨機角色 foreach (var attackTarget in this.treeRootAttackList) { //產生樹根,攻擊玩家 Vector3 pos = RolesCollection.script.Roles[attackTarget].transform.position - new Vector3(0, 0, 0.1f); GameObject newObj = (GameObject)Instantiate(this.TreeRootObject, pos, this.TreeRootObject.transform.rotation); SmoothMoves.BoneAnimation boneAnim = newObj.GetComponent<SmoothMoves.BoneAnimation>(); newObj.GetComponent<TreeElder_Root>().Damage = this.bossInfo.skillData.Find((GameDefinition.BossSkillData data) => { return data.SkillName == "小樹根攻擊"; }).Damage; boneAnim.playAutomatically = false; boneAnim.Play("小樹根"); //播放"小樹根"動畫 playRootLength = boneAnim["小樹根"].length;//計算"小樹根"長度(秒) } } //大樹根攻擊(攻擊1位角色) else if (this.currentBossAction == BossAction.大樹根攻擊) { attackIndex = Random.Range(0, 4); //顯示提示提醒玩家(目標為隨機一位角色) Instantiate(EffectCreator.script.道路危險提示[attackIndex]); this.boneAnimation.Play("大樹根攻擊"); //開始播放大樹根攻擊動作 yield return new WaitForSeconds(time); //等待n秒(吟詠時間) //目標為隨機一位角色 Vector3 pos = RolesCollection.script.Roles[attackIndex].transform.position - new Vector3(0, 0, 0.1f); GameObject newObj = (GameObject)Instantiate(this.TreeRootObject, pos, this.TreeRootObject.transform.rotation); SmoothMoves.BoneAnimation boneAnim = newObj.GetComponent<SmoothMoves.BoneAnimation>(); newObj.GetComponent<TreeElder_Root>().Damage = this.bossInfo.skillData.Find((GameDefinition.BossSkillData data) => { return data.SkillName == "大樹根攻擊"; }).Damage; boneAnim.playAutomatically = false; boneAnim.Play("大樹根"); //播放"大樹根"動畫 playRootLength = boneAnim["大樹根"].length;//計算"大樹根"長度(秒) } yield return new WaitForSeconds(playRootLength); //等待樹根動畫播完後 this.currentBossAction = BossAction.閒置; //狀態切回"閒置" this.NextActionTime = ActionTimer.使用樹根後等待時間; this.boneAnimation.Play("idle"); //播放"idle"動畫 this.treeRootAttackList.Clear(); //清除目前攻擊目標的清單 }
/// <summary> /// 魔王登場定位完成後,執行此函式 /// </summary> void BossAppearComplete() { this.currentBossAction = BossAction.閒置; this.ActionTimer.ChangeTimerState(false); this.boneAnimation.Play("登場"); //播放"登場"動畫 }
/// <summary> /// 從定位點移動至近距離攻擊點完成後,執行此函式 /// </summary> void NearAttackMoveComplete() { this.currentBossAction = BossAction.閒置; this.ActionTimer.ChangeTimerState(false); this.boneAnimation.Play("近距離攻擊"); //播放"近距離攻擊"動畫 StartCoroutine(BacktoOriginPosition(2.0f)); //等待n秒後,回到定位點 }
void Start() { this.objects = MystObjectManager.Instance; // Debug.Log("called"); WINDOW_TOP_LEFT = new Vector2(0, 24); WINDOW_BOTTOM_RIGHT = new Vector2(32, 0); AudioListener.volume = 0.05f; manager_state = 10; GOBJ_MAIN_CAMERA = GameObject.Find("Main Camera"); BLOOM = GOBJ_MAIN_CAMERA.transform.FindChild("EffectCam").GetComponent <Bloom>(); is_title_exit = false; GOBJ_CANVAS = GameObject.Find("Canvas"); ANIM_TITLE = GameObject.Find("Acters").GetComponent <Animator>(); ANIM_TITLE.enabled = false; GOBJ_TITLE = GOBJ_CANVAS.transform.FindChild("Title").gameObject; retry_count = 0; GOBJ_RETRY_COUNT_OVER = GOBJ_CANVAS.transform.FindChild("GameOver/RetryCount").gameObject; GOBJ_RETRY_COUNT_CLEAR = GOBJ_CANVAS.transform.FindChild("GameClear/RetryCount").gameObject; AUDIO_BGM = GetComponent <AudioSource>(); CLIP_BGM_TITLE = Resources.Load("BGM/そよぐ帳と夢の夢") as AudioClip; CLIP_BGM_MAIN = Resources.Load("BGM/New_Gear") as AudioClip; AUDIO_BGM.clip = CLIP_BGM_TITLE; AUDIO_BGM.Play(); PLAY_AREA = new Vector2(32, 24); GOBJ_PLAYER = GameObject.Find("MystPlayer"); GOBJ_PLAYER_CHARGE = GOBJ_PLAYER.transform.FindChild("Charge").gameObject; GOBJ_PLAYER_CHARGE.SetActive(false); player_enable_controlle = true; PLAYER_MOVE_SPEED = 8f; PLAYER_LAYER = LayerMask.GetMask(new string[] { "Player" }); PLAYER_LIFE_MAX = 1; player_life = PLAYER_LIFE_MAX; PLAYER_DAMAGE_PERIOD = 1f; GOBJ_OPTIONS = GameObject.Find("Options"); GOBJ_OPTIONS.SetActive(false); OPTIONS_ANIMATION = GOBJ_OPTIONS.transform.FindChild("OptionImage/myst").GetComponent <OptionAnimation>(); OPTIONS_MARGIN = 2f; options_direction = Vector2.right; OPTIONS_DIRECTION_SPD = 10f; option_state = 0; isLockOptionPosition = false; CHARGE_DURATION = 1f; OPTIONS_SPD = 70f; OPTIONS_BACK_SPD = 60f; OPTIONS_LAYER = LayerMask.GetMask(new string[] { "Bullet(Player)" }); PRFB_LOCK_OPTION = Resources.Load("Prefabs/Effects/LockEffect") as GameObject; PRFB_RELEASE_OPTION = Resources.Load("Prefabs/Effects/ReleaseEffect") as GameObject; PRFB_SHOT_OPTION = Resources.Load("Prefabs/Effects/ChargeShotEffect") as GameObject; ENEMYS_LAYER = LayerMask.GetMask(new string[] { "Enemy", "EnemyFly", "EnemyBullet" }); GOBJ_BOSS = GameObject.Find("MystBoss"); BOSS_ACTION = new BossAction(); BOSS_LIFE_MAX = 15; boss_life = BOSS_LIFE_MAX; GOBJ_BOSS_LIFE = GameObject.Find("BossLife"); BOSS_INITIAL_LIFE_HEIGHT = 1; BOSS_LIFE_HEIGHT_POINT = BOSS_INITIAL_LIFE_HEIGHT / BOSS_LIFE_MAX; BOSS_DAMAGE_PERIOD = 1f; PRFB_DAMAGE = Resources.Load("Prefabs/Effects/Damage") as GameObject; PRFB_DESTROY = Resources.Load("Prefabs/Effects/Destroy") as GameObject; _HIGH_PASS_FILTER = GetComponent <AudioHighPassFilter>(); #region Debug // StartCoroutine(InitializeOpenning()); // GOBJ_CANVAS.SetActive(false); #endregion // ゲーム状態初期化用にGameStopを呼びたいが、タイトル画面にオプションが表示されちゃう this.GameStop(); GOBJ_BOSS.transform.position = new Vector2(33f, 5.25f); GOBJ_BOSS_LIFE.SetActive(false); // GOBJ_OPTIONS.SetActive(false); }
// Use this for initialization void Start() { script = this; //載入敵人資訊 this.bossInfo = this.GetComponent<BossPropertyInfo>(); //設定BoneAnimation this.boneAnimation = this.GetComponent<SmoothMoves.BoneAnimation>(); this.boneAnimation.RegisterUserTriggerDelegate(UserTrigger); GameManager.script.RegisterBoneAnimation(this.boneAnimation); //註冊BoneAnimation,GameManager統一管理 this.boneAnimation.playAutomatically = false; this.boneAnimation.Play("nowake"); this.currentBossAction = BossAction.未甦醒; this.currentOpenFlowerCount = 0; //目前開出花朵的數目設定為0 this.addDamageValue = 0; //累積的傷害值設定為0 this.ActionTimer.ChangeTimerState(false); //關閉計時器功能 this.currentAttackProbability = this.minAttackProbability; //當前觸發樹根攻擊的機率為最小機率 this.currentAddFlowerOpenTime = this.ActionTimer.花朵生成時間; this.NextActionTime = this.ActionTimer.觸發小樹根間隔時間; }