Ejemplo n.º 1
0
        ////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////

        //Just get it off me - assumed stack level == 1
        public void ejectFlyover()
        {
            pollAllEvents();
            if (foUnit_ == null)
            {
                return;
            }

            //second send home
            var ord = new COrder(COrderConstants.ORD_GO_HOME);

            setAndExecuteUnitOrder(foUnit_.gid_, ord);
            pollAllEvents();
            if (foUnit_ == null)
            {
                return;
            }

            //third. move in open space
            for (int i = CMapUtil.NORTH; i < CMapUtil.NODIR; i++)
            {
                CLoc uloc = foUnit_.getLoc();
                CLoc loc  = map_.getNextLocationFromDir(uloc.x, uloc.y, i);
                if (loc == null)
                {
                    continue;
                }
                CUnit cu = getHostAtLoc(loc, CUnitConstants.LVL_GROUND, 0u);
                if (cu == null || (cu.owner_ != position_ && !foUnit_.entry_.isCity()))
                {
                    ord = new COrder(COrderConstants.ORD_MOVE_DIR, i);
                    setAndExecuteUnitOrder(foUnit_.gid_, ord);
                    pollAllEvents();
                }
                if (foUnit_ == null)
                {
                    return;
                }
            }
            //finally disband
            disbandUnit(foUnit_.gid_);
            pollAllEvents();
        }