private IEnumerator FarAttack(RaycastHit2D enemy)// 遠距離攻撃 { EnemyControll enemyControll = enemy.collider.gameObject.GetComponent <EnemyControll>(); while (FarRayHitJudge()) { if (enemy.collider.gameObject.tag == enemyTagName)// 雑魚エネミーなら { enemyControll.EnemyHPMinus(); if (enemyControll.EnemyHPReturn() <= 0)// 雑魚エネミーのHPが0になったら { break; } } else if (enemy.collider.gameObject.tag == bossTagName)// ボスエネミーなら { enemyControll.EnemyBossHPMinus(); if (enemyControll.EnemyBossHPReturn() <= 0)// ボスエネミーのHPが0になったら { break; } } } yield break; }
/// ******************************************************* /// <summary>更新処理</summary> /// ******************************************************* public void OnUpdate(EnemyControll character) { if (Scripts == null) { return; } if (Scripts.ScriptLine.Count == 0) { return; } if (Limit == LIMIT_TYPE.TIME) { PastTime++; if (PastTime > WaitTime) { PlayNextLine(character); } } if (Limit == LIMIT_TYPE.NEAR) { var dst = Vector2.Distance(character.TargetPosition, character.Position); if (dst < 0.5) { PlayNextLine(character); } } if (Shots != null) { Shots.ForEach(shot => shot.OnUpdate(character)); RemoveShots.ForEach(shot => Shots.Remove(shot)); } }
/// ******************************************************* /// <summary>コマンド実行</summary> /// ******************************************************* private void PlayLine(EnemyControll character, ScriptLine line) { var last_limit = Limit; CommandAttribute keY_atr = line.GetAttribute("key"); bool have_key = (keY_atr != null); Limit = LIMIT_TYPE.NEAR; switch (line.CommandName) { case "position": character.TargetDirection = TargetType.DIRECTION_POSITION; break; case "target": character.TargetDirection = TargetType.DIRECTION_TARGET; break; case "angle": character.TargetDirection = TargetType.DIRECTION_ANGLE; break; case "bottom": character.TargetDirection = TargetType.DIRECTION_BOTTOM; break; case "top": character.TargetDirection = TargetType.DIRECTION_TOP; break; case "left": character.TargetDirection = TargetType.DIRECTION_LEFT; break; case "right": character.TargetDirection = TargetType.DIRECTION_RIGHT; break; case "shot": ShotCommand(character, line); return; } line.Attributes.ForEach(atr => { if (RunAttribute(atr) == false) { Manager.OverrideParam(atr, have_key); } }); }
private void CreateChar(string keyword) { GameObject self_go = StageManager.Instance.InstantiateObject("TestEnemy2"); EnemyControll self_ctrl = self_go.GetComponent <EnemyControll>(); self_ctrl.SpawnKey = keyword; self_go.SetActive(true); }
/// ******************************************************* /// <summary>次コマンド実行</summary> /// ******************************************************* public void PlayNextLine(EnemyControll character) { LineIndex++; if (LineIndex >= Scripts.ScriptLine.Count) { LineIndex = 0; } WaitTime = 0; PastTime = 0; PlayLine(character, Scripts.ScriptLine[LineIndex]); }
/// ******************************************************* /// <summary>コマンド実行</summary> /// ******************************************************* private void PlayLine(EnemyControll character, ScriptLine line) { line.Attributes.ForEach(atr => { switch (atr.Name) { case "time": WaitTime = atr.FloatValue; break; case "tough": Manager.Character.ToughPoint = atr.FloatValue; break; default: Manager.OverrideParam(atr, false); break; } }); }
/// ******************************************************* /// <summary>射撃アトリビュート解析</summary> /// ******************************************************* private void ShotCommand(EnemyControll character, ScriptLine line) { Limit = LIMIT_TYPE.TIME; WaitTime = 0; PastTime = 0; line.Attributes.ForEach(atr => { switch (atr.Name) { case "time": WaitTime = atr.IntValue; break; } }); Shots.Add(new ShotScript(this, line)); }
/// ******************************************************* /// <summary>コマンド実行</summary> /// ******************************************************* private void SpawnLine(ScriptLine line) { string source = null; string key = null; float spd = 0; float dir = 0; line.Attributes.ForEach(atr => { switch (atr.Name) { case "source": source = atr.StringValue; break; case "key": key = atr.StringValue; break; case "spd": spd = atr.FloatValue; break; case "dir": dir = atr.FloatValue; break; } }); if (string.IsNullOrEmpty(source) == false) { //Debug.Log("Spawn:" + source + " / " + key); GameObject spawner = StageManager.Instance.InstantiateObject(source); EnemyControll self_ctrl = spawner.GetComponent <EnemyControll>(); FortressControll fortress_ctrl = spawner.GetComponent <FortressControll>(); if (self_ctrl != null) { self_ctrl.SpawnKey = key; } if (fortress_ctrl != null) { fortress_ctrl.MoveSpeed = spd / 100f; fortress_ctrl.FortressDirection = dir; } spawner.SetActive(true); } }
private void NearAttack(RaycastHit2D enemy)// 近距離攻撃 { if (jumpFlag) { animator.SetBool(jumpAttackAnimFlag, true); animator.SetBool(jumpAttackAnimFlag, false); } else { animator.SetBool(attackAnimFlag, true);// 攻撃アニメーション再生 animator.SetBool(attackAnimFlag, false); } EnemyControll enemyControll = enemy.collider.gameObject.GetComponent <EnemyControll>(); if (enemy.collider.gameObject.tag == enemyTagName)// 雑魚エネミーなら { enemyControll.EnemyHPMinus(); } else if (enemy.collider.gameObject.tag == bossTagName)// ボスエネミーなら { enemyControll.EnemyBossHPMinus(); } }
void Start() { myAnim = GetComponent <Animator> (); myRg = GetComponent <Rigidbody2D> (); myPro = GetComponent <EnemyControll> (); }
/// ******************************************************* /// <summary>コンストラクタ</summary> /// ******************************************************* public EnemyScriptMain(EnemyControll character, InitialData initial, string key) { Character = character; Initial = initial; SpawnKey = key; }
private void CreateEnemy() { enemyGO = Instantiate(enemyPrefab); enemyControll = enemyGO.GetComponent <EnemyControll>(); enemyControll.ball = ballGO; }