using System;
using System.Collections.Generic;
using DxLibDLL;
using System.Collections;
using System.IO;


namespace HH
{
    delegate void attackMethodDelegate(CBasic attacker, CBasic target);

    class AttackSequence
    {
        public int timer;
        public bool isEnd = true;


        public CBasic attacker;
        public CBasic target;

        public Vector targetAimVector;

        public Hashtable list;


        public AttackSequence()
        {
            this.list = new Hashtable() ;
        }


        public AttackSequence(CBasic attacker, CBasic target)
        {
            this.attacker = attacker;
            this.target = target;
            this.targetAimVector = new Vector(0, 1);

            this.list = new Hashtable();

            string filename = attacker.scriptfile;

            if (filename == null) return;
            // ファイルからテキストを読み出し。
            using (StreamReader sr = new StreamReader(filename))
            {
                string line = "";
                string line1 = "";
                string line2 = "";

                while ((line = sr.ReadLine()) != null)          //1
                {
                    if (line.StartsWith(@"//") == false)
                        line1 = line;
                    line2 = sr.ReadLine();                      //2

                    this.list[Int32.Parse(line1)] = line2;
                }
            }
        }


        public void action()
        {
            this.timer++;

            
            if (list[timer] != null)
            {
                AttackMethods.Method m = 
                    (AttackMethods.Method) 
                    Enum.Parse(typeof(HH.AttackMethods.Method), list[timer].ToString() );

                switch (m)
                {
                    case AttackMethods.Method.aim:
                        AttackMethods.aim(attacker, target); break;

                    case AttackMethods.Method.fourWayAim:
                        AttackMethods.fourWayAim(attacker, target); break;

                    case AttackMethods.Method.threeWayAim:
                        AttackMethods.threeWayAim(attacker, target); break;

                    case AttackMethods.Method.threeWayDown:
                        AttackMethods.threeWayDown(attacker, target); break;

                    case AttackMethods.Method.threeWayDownMissile:
                        AttackMethods.threeWayDownMissile(attacker, target); break;

                    case AttackMethods.Method.spiralBar:
                        AttackMethods.spiralBar(attacker, target); break;

                    case AttackMethods.Method.endLoop:
                        this.timer = 0; break;
                }
            }
            
        }


    }
}
