Example #1
0
        public void notifyCastle(UnitCore enCastle)
        {
            var t = new List <Pos>();

            t.Add(new Pos(enCastle.x, enCastle.y));
            this.targets = t;
        }
Example #2
0
        private void makeWorker(UnitCore maker, Resource target)
        {
            maker.order = "0";
            var w = new Worker(maker.x, maker.y);

            w.setPattern(WorkerPattern.StayResource, target.getTargetForWorker());
            this.myWorkers.Add(w);
            this.myUnits.Add(w);
            this.resourceManager.setWorkerForResource(w, target);
        }
Example #3
0
 public void inputEnUnit(UnitCore u)
 {
     if ((u.type == UnitType.CASTLE) && (this.atackManager.enCastle == null))
     {
         Console.Error.WriteLine("enemy castle found");
         this.atackManager.findEnemyCastle(u);
         foreach (var k in this.myKnights)
         {
             k.notifyCastle(u);
         }
     }
 }
Example #4
0
        public void initStage(int currentStage)
        {
            this.currentStage = currentStage;

            this.myUnits     = new List <UnitCore>();
            this.myWorkers   = new List <Worker>();
            this.myKnights   = new List <Knight>();
            this.myFighters  = new List <UnitCore>();
            this.myAssassins = new List <UnitCore>();

            this.myCastle = new UnitCore(-1, -1, UnitType.CASTLE);
            this.myUnits.Add(this.myCastle);

            this.myWorkerFactorys  = new List <WorkerFactory>();
            this.myWarriorFactorys = new List <UnitCore>();

            this.resourceManager = new ResourceManager();
            this.atackManager    = new AttackManager();
        }
Example #5
0
        private bool input()
        {
            var remainingTime = int.Parse(Console.ReadLine());
            var currentStage  = int.Parse(Console.ReadLine());
            var currentTurn   = int.Parse(Console.ReadLine());

            if (currentTurn == 0)
            {
                Console.Error.WriteLine("stage: {0}", currentStage);
                this.king.initStage(currentStage);
            }
            var currentResource = int.Parse(Console.ReadLine());

            this.king.initTurn(currentTurn, currentResource);

            var myNum = int.Parse(Console.ReadLine());

            for (int i = 0; i < myNum; i++)
            {
                var u = new UnitCore(Console.ReadLine());
                this.king.inputMyUnit(u);
            }

            var enNum = int.Parse(Console.ReadLine());

            for (int i = 0; i < enNum; i++)
            {
                var u = new UnitCore(Console.ReadLine());
                this.king.inputEnUnit(u);
            }

            var resNum = int.Parse(Console.ReadLine());

            for (int i = 0; i < resNum; i++)
            {
                var r = new Resource(Console.ReadLine());
                this.king.inputResource(r);
            }

            string end = Console.ReadLine();

            return(end == "END");
        }
Example #6
0
 public void inputMyUnit(UnitCore u)
 {
     if (this.currentTurn == 0)
     {
         if (u.type == UnitType.CASTLE)
         {
             this.myCastle.setId(u.id);
             this.myCastle.update(u.x, u.y, u.hp);
         }
         else
         {
             var w = new Worker(u.x, u.y);
             w.setId(u.id);
             w.update(u.x, u.y, u.hp);
             this.myWorkers.Add(w);
             this.myUnits.Add(w);
         }
     }
     else
     {
         var t = this.myUnits.Find(x => x.id == u.id);
         if (t != null)
         {
             // id一致(既存Unit)
             t.update(u.x, u.y, u.hp);
         }
         else
         {
             // id不一致(新規Unit)
             var s = this.myUnits.Find(x => (x.id == -1) && (x.x == u.x) && (x.y == u.y) && (x.type == u.type));
             if (s != null)
             {
                 s.setId(u.id);
                 s.update(u.x, u.y, u.hp);
             }
             else
             {
                 Console.Error.WriteLine("unknown unit. id:{0}, type:{1}", u.id, u.type);
             }
         }
     }
 }
Example #7
0
        /*
         * 思考ロジック (攻撃担当)
         */
        private void think_A()
        {
            foreach (var k in this.myKnights)
            {
                k.thinkOrder();
            }

            // 拠点の管理
            if (this.myWarriorFactorys.Count < 1 && this.currentResource >= UnitCost.WARRIOR_FACTORY)
            {
                var maker = this.myWorkers.Find(x => x.pattern == WorkerPattern.WarriorFactoryMaker);
                if (maker == null)
                {
                    // ピンチ!拠点生産担当が死亡
                }
                else if (maker.order == "")
                {
                    // 拠点生産を指示
                    maker.order           = "6";
                    maker.pattern         = WorkerPattern.Free;
                    this.currentResource -= UnitCost.WARRIOR_FACTORY;
                    var newWarFac = new UnitCore(maker.x, maker.y, UnitType.WARRIOR_FACTORY);
                    this.myWarriorFactorys.Add(newWarFac);
                    this.myUnits.Add(newWarFac);
                }
            }

            // ナイトを生産してみる
            foreach (var warFac in this.myWarriorFactorys)
            {
                if (this.currentResource >= UnitCost.KNIGHT)
                {
                    warFac.order          = "1";
                    this.currentResource -= UnitCost.KNIGHT;
                    var newKni = new Knight(warFac.x, warFac.y);
                    newKni.targets = this.atackManager.getTarget();
                    this.myKnights.Add(newKni);
                    this.myUnits.Add(newKni);
                }
            }
        }
Example #8
0
 public void findEnemyCastle(UnitCore castle)
 {
     this.enCastle = castle;
 }
Example #9
0
 public AttackManager()
 {
     this.enCastle = null;
     this.r        = 0;
 }