Beispiel #1
0
        /// <summary>
        /// Initiate region AI process
        /// </summary>
        /// <param name="org"></param>
        public void region(Region freg, String org)
        {
            reg = freg;
            useUnit = true;
            reg_step = Region_Steps.FIND;
            type = AI_Type.REGION;
            iorg = org;

            needDelay = true;
            isActive = true;
        }
Beispiel #2
0
        /// <summary>
        /// resumes AI process after delay
        /// </summary>
        private void region_resume()
        {
            if (reg_step == Region_Steps.FIND)
            {
                ActionUnit au=ActionUnit.Null;

                au = findActionUnit(iorg);

                if (au == ActionUnit.Null)
                {
                    isActive = false;

                    if (done != null)
                        done(this, null);

                    return;
                }

                map.focus(au.unit.X, au.unit.Y);

                needDelay = true;

                reg_step = Region_Steps.MOVE;
            }
            else if (reg_step == Region_Steps.MOVE)
            {
                ActionUnit au = findActionUnit(iorg);

                Unit mu=umap.get(au.move.X, au.move.Y);
                Unit eu = umap.get(au.unit.X, au.unit.Y);

                if (mu!=null&&mu.Organization == "main")
                {
                    eu.movement = 0;

                    Objective o = new Objective();
                    o.setDefeatAll();

                    inBattle = true;

                    Battle b = new Battle(mu, eu, reg, o);

                    b.done = battle_done;

                    reg_step = Region_Steps.FIND;

                    StateManager.Instance.goForward(b);
                }
                else
                {
                    umap.move(au.unit.X, au.unit.Y, au.move.X, au.move.Y);
                    umap.update(map);

                    eu.movement--;

                    map.focus(au.move.X, au.move.Y);
                    needDelay = true;
                    reg_step = Region_Steps.FIND;
                }

                umap.remDeadUnit();
            }
        }