예제 #1
0
    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;
    }
예제 #2
0
        /// *******************************************************
        /// <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));
            }
        }
예제 #3
0
        /// *******************************************************
        /// <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);
                }
            });
        }
예제 #4
0
    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);
    }
예제 #5
0
 /// *******************************************************
 /// <summary>次コマンド実行</summary>
 /// *******************************************************
 public void PlayNextLine(EnemyControll character)
 {
     LineIndex++;
     if (LineIndex >= Scripts.ScriptLine.Count)
     {
         LineIndex = 0;
     }
     WaitTime = 0;
     PastTime = 0;
     PlayLine(character, Scripts.ScriptLine[LineIndex]);
 }
예제 #6
0
        /// *******************************************************
        /// <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;
                }
            });
        }
예제 #7
0
        /// *******************************************************
        /// <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));
        }
예제 #8
0
        /// *******************************************************
        /// <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);
            }
        }
예제 #9
0
    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();
        }
    }
예제 #10
0
 void Start()
 {
     myAnim = GetComponent <Animator> ();
     myRg   = GetComponent <Rigidbody2D> ();
     myPro  = GetComponent <EnemyControll> ();
 }
예제 #11
0
 /// *******************************************************
 /// <summary>コンストラクタ</summary>
 /// *******************************************************
 public EnemyScriptMain(EnemyControll character, InitialData initial, string key)
 {
     Character = character;
     Initial   = initial;
     SpawnKey  = key;
 }
예제 #12
0
 private void CreateEnemy()
 {
     enemyGO            = Instantiate(enemyPrefab);
     enemyControll      = enemyGO.GetComponent <EnemyControll>();
     enemyControll.ball = ballGO;
 }