Пример #1
0
        public override void Initialize(IAppContext context)
        {
            _menuGenerator = context.Container.GetInstance <MenuGenerator>();
            _menuListener  = context.Container.GetInstance <MenuListener>();

            context.Toolbox.AddTools(GetType().Assembly.GetTools());
        }
Пример #2
0
 public override void Initialize(IAppContext context)
 {
     _context          = context;
     _menuListener     = _context.Container.GetSingleton <MenuListener>();
     _projectListener  = _context.Container.GetInstance <ProjectListener>();
     _dockPanelService = _context.Container.GetInstance <DockPanelService>();
 }
Пример #3
0
    public void Move(GameObject piece, Vector2Int gridPoint)
    {
        Piece pieceComponent = piece.GetComponent<Piece>();
        if (pieceComponent.type == PieceType.Pawn && !HasPawnMoved(piece))
        {
            movedPawns.Add(piece);
        }

        if (PieceAtGrid(gridPoint) != null) CapturePieceAt(gridPoint);

        Vector2Int startGridPoint = GridForPiece(piece);
        pieces[startGridPoint.x, startGridPoint.y] = null;
        pieces[gridPoint.x, gridPoint.y] = piece;
        board.MovePiece(piece, gridPoint);
        underCheck = false;

        // Smecheria aia cu rocada
        if (!movedPieces.Contains(piece)) movedPieces.Add(piece);
        if (pieceComponent.type == PieceType.King && Mathf.Abs(startGridPoint.x - gridPoint.x) > 1)
        {
            Vector2Int rook_start, rook_destination;
            // Verifica rocada mica
            if (gridPoint.x == 6)
            {
                rook_start = new Vector2Int(7, gridPoint.y);
                rook_destination = new Vector2Int(5, gridPoint.y);
            }
            // Rocada mare
            else
            {
                rook_start = new Vector2Int(0, gridPoint.y);
                rook_destination = new Vector2Int(2, gridPoint.y);
            }
            pieces[rook_destination.x, rook_destination.y] = pieces[rook_start.x, rook_start.y];
            board.MovePiece(pieces[rook_start.x, rook_start.y], rook_destination);
            pieces[rook_start.x, rook_start.y] = null;
        }

        // Alegere piesa noua
        if (pieceComponent.type == PieceType.Pawn && (gridPoint.y == 0 || gridPoint.y == 7))
        {
            if (!currentPlayer.AI)
            {
                board.GetComponent<MoveSelector>().TriggerPawnSelection(piece, gridPoint);
                MenuListener.ShowMessage("Chose a piece to replace your pawn", 120);
            }
            else
            {
                currentPlayer.pieces.Remove(piece);
                movedPawns.Remove(piece);
                Destroy(piece);
                pieces[gridPoint.x, gridPoint.y] = null;

                GameObject prefab;
                if (currentPlayer.name == "white") prefab = whiteQueen;
                else prefab = blackQueen;
                GameManager.instance.AddPiece(prefab, GameManager.instance.currentPlayer, gridPoint.x, gridPoint.y);
            }
        }
    }
Пример #4
0
 public void DeclarePat()
 {
     // COMPLETARE CU UI
     Debug.Log("Pat!");
     MenuListener.ShowMessage("Draw!", 120);
     RestartGame(settings);
 }
Пример #5
0
    public void DebugButton(GameObject obj)
    {
        MenuListener.ShowMessage("Mesaj", 120);
        //var gameObject = Instantiate(obj);
        //PawnPicker.Prepare(gameObject); // setez pawn picker

        //PawnPicker.Activate(DebugChoice);
    }
Пример #6
0
    public void NextPlayer()
    {
        Vector2Int kingPos = new Vector2Int(-1, -1);
        for (int i = 0; i < 8; i++)
            for (int j = 0; j < 8; j++)
            {
                if (pieces[i, j] != null && pieces[i, j].GetComponent<Piece>().type == PieceType.King)
                {
                    if (otherPlayer.pieces.Contains(pieces[i, j]))
                    {
                        kingPos = new Vector2Int(i, j);
                    }
                }
            }

        if (kingPos == new Vector2Int(-1, -1))
        {
            Debug.LogWarning("Can't find the king of current player! Can't undeCheck for check");
            Player tmp = currentPlayer;
            currentPlayer = otherPlayer;
            otherPlayer = tmp;
            return;
        }

        foreach (var piece in currentPlayer.pieces)
        {
            List<Vector2Int> moves = MovesForPiece(piece);
            if (moves.Contains(kingPos))
            {
                underCheck = true;
                if (currentPlayer.AI)
                    MenuListener.ShowMessage("Check!", 120);
                break;
            }
        }

        Player tempPlayer = currentPlayer;
        currentPlayer = otherPlayer;
        otherPlayer = tempPlayer;

        bool pat = true;
        foreach (var piece in currentPlayer.pieces)
        {
            List<Vector2Int> moves = MovesForPiece(piece);
            if (moves.Count > 0)
            {
                pat = false;
                break;
            }
        }

        if (pat)
        {
            if (underCheck) DeclareWin(otherPlayer);
            else GameManager.instance.DeclarePat();
        }
    }
Пример #7
0
        public override void Initialize(IAppContext context)
        {
            _context = context;

            _menuGenerator    = context.Container.GetInstance <MenuGenerator>();
            _menuListener     = context.Container.GetInstance <MenuListener>();
            _mapListener      = context.Container.GetInstance <MapListener>();
            _dockPanelService = context.Container.GetInstance <DockPanelService>();
        }
Пример #8
0
 public static void CloseSession()
 {
     userInfo   = null;
     webAddress = null;
     if (MenuListener != null)
     {
         MenuListener.LogOff();
         LogOff();
     }
 }
Пример #9
0
        public override void Initialize(IAppContext context)
        {
            _context = context;

            _metadataService = context.Container.GetSingleton <SymbologyMetadataService>();
            _labelMover      = context.Container.GetSingleton <LabelMover>();
            _legendListener  = context.Container.GetInstance <LegendListener>();
            _menuGenerator   = context.Container.GetInstance <MenuGenerator>();
            _menuListener    = context.Container.GetInstance <MenuListener>();
        }
Пример #10
0
        protected override OfficeDocument Open(System.IO.FileInfo file, String contentid, String rep)
        {
            object         missing        = Type.Missing;
            object         format         = Word.WdSaveFormat.wdFormatDocument;
            OfficeDocument officeDocument = null;
            object         filedocxtoOpen = file.FullName;

            if (file.Exists)
            {
                try
                {
                    Word.Document doc = application.Documents.Open(ref filedocxtoOpen, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                    officeDocument = new Word2010OfficeDocument(doc);
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.StackTrace);
                    String   path  = file.FullName.Replace(".doc", ".html");
                    FileInfo fHTML = new FileInfo(path);
                    if (fHTML.Exists)
                    {
                        filedocxtoOpen = path;
                        Word.Document doc = application.Documents.Open(ref filedocxtoOpen, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                        filedocxtoOpen = file.FullName;
                        doc.SaveAs(ref filedocxtoOpen, ref format, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                        doc.ActiveWindow.View.Type = Word.WdViewType.wdPrintView;
                        officeDocument             = new Word2010OfficeDocument(doc);
                    }
                }
            }
            else
            {
                String   path  = file.FullName.Replace(".doc", ".html");
                FileInfo fHTML = new FileInfo(path);
                if (fHTML.Exists)
                {
                    filedocxtoOpen = path;
                    Word.Document doc = application.Documents.Open(ref filedocxtoOpen, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                    filedocxtoOpen = file.FullName;
                    doc.SaveAs(ref filedocxtoOpen, ref format, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                    doc.ActiveWindow.View.Type = Word.WdViewType.wdPrintView;
                    officeDocument             = new Word2010OfficeDocument(doc);
                }
            }
            if (officeDocument != null)
            {
                officeDocument.SaveContentProperties(contentid, rep);
                if (MenuListener != null)
                {
                    MenuListener.DocumentPublished();
                }
            }
            return(officeDocument);
        }
Пример #11
0
 public void DeclareWin(Player p)
 {
     Debug.Log(p.name + " wins!");
     //MenuListener.ShowMessage(p.name + " wins!", 120);
     // COMPLETARE AICI CU UI
     //RestartGame(settings);
     if (p.AI)
         MenuListener.FindInActiveObjectByName("CanvasLose").SetActive(true);
     else
         MenuListener.FindInActiveObjectByName("CanvasWin").SetActive(true);
 }
Пример #12
0
        public override void Initialize(IAppContext context)
        {
            _context = context;

            var container = context.Container;

            _mapListener     = container.GetInstance <MapListener>();
            _menuGenerator   = container.GetInstance <MenuGenerator>();
            _menuListener    = container.GetInstance <MenuListener>();
            _projectListener = container.GetInstance <ProjectListener>();
            _menuUpdater     = container.GetInstance <MenuUpdater>();
        }
Пример #13
0
        public override void Initialize(IAppContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            _context       = context;
            _menuGenerator = context.Container.GetInstance <MenuGenerator>();
            _menuListener  = context.Container.GetInstance <MenuListener>();
            _mapListener   = context.Container.GetInstance <MapListener>();
            _menuUpdater   = context.Container.GetInstance <MenuUpdater>();
        }
Пример #14
0
        public override void Initialize(IAppContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            _context = context;

            _menuGenerator    = _context.Container.GetInstance <MenuGenerator>();
            _menuListener     = _context.Container.GetSingleton <MenuListener>();
            _mapListener      = _context.Container.GetSingleton <MapListener>();
            _projectListener  = _context.Container.GetSingleton <ProjectListener>();
            _dockPanelService = _context.Container.GetInstance <DockPanelService>();
        }
Пример #15
0
    public static int ElmCounts;                                                //安在地板上的器件总个数

    void Start()
    {
        plate            = GameObject.Find("Plate");                                        //获取底板引用
        holdingName      = "null";                                                          //手持元器件置null
        audioManager     = transform.GetComponent <AudioManager> ();                        //获取音效脚本
        cameraController = GameObject.Find("CameraController");                             //获取摄像机管理对象
        camera           = GameObject.Find("CameraController/Main Camera");                 //获取摄像机对象
        if (Application.loadedLevel == Utils.ExperimentalInterface)                         //如果是实验界面
        {
            Magnifier = GameObject.Find("Magnifier");                                       //获取摄像机对象
            Magnifier.SetActive(false);                                                     //不可见放大镜
            menuListener = GameObject.Find("Canvas").GetComponent <MenuListener> ();        //获取菜单管理脚本
            MyMicphone   = GameObject.Find("MicphoneObject").GetComponent <MicphoneTest>(); //获取录音脚本
        }
    }
Пример #16
0
    public static void Activate(callbackType _callback)
    {
        callback = _callback;
        _picker  = MenuListener.FindInActiveObjectByName("PawnPicker");
        _picker.SetActive(true);
        //Instantiate(MenuListener.FindInActiveObjectByName("PawnPicker"));
        //MenuListener.FindInActiveObjectByName("PawnPicker").SetActive(true);
        //GameManager.instance.board_picker.SetActive(true);

        /*
         * foreach (Transform child in GameManager.instance.board.transform)
         * {
         *  if (child.name == "PawnPicker")
         *  {
         *      //MenuListener.FindInActiveObjectByName("DDDText").SetActive(true);
         *      child.gameObject.SetActive(true);
         *      Debug.Log("Child found. Mame: " + child.name);
         *      break;
         *  }
         * }*/
    }
Пример #17
0
        /// <summary>
        /// The initialize method, called when the plug-in is loaded
        /// </summary>
        /// <param name="context">The application context.</param>
        public override void Initialize(IAppContext context)
        {
            // Save to local properties:
            _context = context;

            // Will better to preserve state if plugin is unloaded, therefore singleton
            // Because SampleDockWindow is injected in MenuListener and MapListener it should be call before them:
            _sampleDockWindow = context.Container.GetSingleton <SampleDockWindow>();

            _menuGenerator = context.Container.GetInstance <MenuGenerator>();
            _menuListener  = context.Container.GetInstance <MenuListener>();
            _mapListener   = context.Container.GetInstance <MapListener>();

            // Event handlers are in the MapListener class:

            // Just to show case:
            Debug.WriteLine("Number of layers loaded" + _context.Layers.Count());

            // adding all the available tools in the toolbox
            _context.Toolbox.AddTools(GetType().Assembly.GetTools());
        }
Пример #18
0
    private void HandleTouch(Ray touchRay, TouchPhase touchPhase)
    {
        switch (touchPhase)
        {
        case TouchPhase.Began:
            RaycastHit hit;
            if (Physics.Raycast(touchRay, out hit))
            {
                if (hit.collider == MenuListener.FindInActiveObjectByName("PPKnight").GetComponent <Collider>())
                {
                    HandlePick(PieceType.Knight);
                }
                else if (hit.collider == MenuListener.FindInActiveObjectByName("PPBishop").GetComponent <Collider>())
                {
                    HandlePick(PieceType.Bishop);
                }
                else if (hit.collider == MenuListener.FindInActiveObjectByName("PPRook").GetComponent <Collider>())
                {
                    HandlePick(PieceType.Rook);
                }
                else if (hit.collider == MenuListener.FindInActiveObjectByName("PPQueen").GetComponent <Collider>())
                {
                    HandlePick(PieceType.Queen);
                }
            }
            break;

        case TouchPhase.Moved:
            // Not needed
            break;

        case TouchPhase.Ended:
            // Not needed
            break;
        }
    }
Пример #19
0
		/// <summary>
		/// Adds a listener for menu events.
		/// </summary>
		public void addMenuListener(MenuListener @l)
		{
		}
Пример #20
0
        public MainPresenter(
            IAppContext context,
            IMainView view,
            IProjectService projectService,
            IConfigService configService,
            LegendPresenter legendPresenter,
            ToolboxPresenter toolboxPresenter,
            IRepository repository)
            : base(view)
        {
            Logger.Current.Trace("Start MainPresenter");
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }
            if (projectService == null)
            {
                throw new ArgumentNullException("projectService");
            }
            if (configService == null)
            {
                throw new ArgumentNullException("configService");
            }
            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            // PM 2016-03-02 Added:
            if (legendPresenter == null)
            {
                throw new ArgumentNullException("legendPresenter");
            }
            if (toolboxPresenter == null)
            {
                throw new ArgumentNullException("toolboxPresenter");
            }

            _context        = context;
            _projectService = projectService;
            _configService  = configService;

            GlobalListeners.Attach(Logger.Current);

            view.Map.Lock();
            try
            {
                var appContext = context as AppContext;
                if (appContext == null)
                {
                    throw new InvalidCastException("Invalid type of IAppContext instance");
                }

                appContext.Init(view, projectService, configService, legendPresenter, toolboxPresenter, repository);

                view.Map.Initialize();
                view.Map.ApplyConfig(configService);

                view.ViewClosing  += OnViewClosing;
                view.ViewUpdating += OnViewUpdating;
                view.BeforeShow   += OnBeforeShow;

                var container = context.Container;
                _statusBarListener  = container.GetSingleton <StatusBarListener>();
                _menuGenerator      = container.GetSingleton <MenuGenerator>();
                _menuListener       = container.GetSingleton <MenuListener>();
                _mapListener        = container.GetSingleton <MapListener>();
                _mainPluginListener = container.GetSingleton <MainPluginListener>();
                _legendListener     = container.GetSingleton <LegendListener>();

                _menuUpdater = new MenuUpdater(_context, PluginIdentity.Default);

                SplashView.Instance.ShowStatus("Loading plugins");
                // must be called after docking is initialized:
                appContext.InitPlugins(configService, p => SplashView.Instance.ShowStatus($"Loading plugins: {p.Name}"));

                // this will display progress updates and debug window
                // file based-logger is already working
                Logger.Current.Init(appContext);
            }
            finally
            {
                view.Map.Unlock();
                context.Legend.Unlock();
            }

            View.AsForm.Shown += ViewShown;
            Logger.Current.Trace("End MainPresenter");
        }
Пример #21
0
        public MainPresenter(
            IAppContext context,
            IMainView view,
            IProjectService projectService,
            IConfigService configService
            )
            : base(view)
        {
            Logger.Current.Trace("Start MainPresenter");
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }
            if (projectService == null)
            {
                throw new ArgumentNullException("projectService");
            }
            if (configService == null)
            {
                throw new ArgumentNullException("configService");
            }

            // PM 2016-03-02 Added:
            //修改,依据界面类型来判断是否为一般形态还是Ribbon


            _context        = context;
            _projectService = projectService;
            _configService  = configService;
            GdalConfiguration.ConfigureOgr();
            GlobalListeners.Attach(Logger.Current);


            try
            {
                var appContext = context as AppContext;
                if (appContext == null)
                {
                    throw new InvalidCastException("Invalid type of IAppContext instance");
                }

                appContext.Init(view, projectService, configService);


                view.ViewClosing  += OnViewClosing;
                view.ViewUpdating += OnViewUpdating;
                view.BeforeShow   += OnBeforeShow;

                var container = context.Container;
                _statusBarListener  = container.GetSingleton <StatusBarListener>();
                _menuGenerator      = container.GetSingleton <MenuGenerator>();
                _menuListener       = container.GetSingleton <MenuListener>();
                _mainPluginListener = container.GetSingleton <MainPluginListener>();
                _menuUpdater        = new MenuUpdater(_context, PluginIdentity.Default);
                SplashView.Instance.ShowStatus("Loading plugins");
                appContext.InitPlugins(configService); // must be called after docking is initialized

                // this will display progress updates and debug window
                // file based-logger is already working
                Logger.Current.Init(appContext);
            }
            finally
            {
            }

            View.AsForm.Shown += ViewShown;
            Logger.Current.Trace("End MainPresenter");
        }
Пример #22
0
        internal static bool TryLogOn()
        {
            bool tryLogOn = false;

            if (userInfo == null || webAddress == null)
            {
                LogOn();
                if (userInfo == null || webAddress == null)
                {
                    LogOff();
                    tryLogOn = false;
                }
                else
                {
                    MenuListener.LogOn();
                    tryLogOn = true;
                }
            }
            else
            {
                tryLogOn = true;
            }
            if (tryLogOn)
            {
                try
                {
                    OfficeApplicationProxy.isValidVersion(m_version);
                    if (MenuListener != null)
                    {
                        MenuListener.LogOn();
                    }
                    URIConfigurationList uRIConfigurationList = new URIConfigurationList();
                    String uri = OfficeApplicationProxy.WebAddress.ToString();
                    if (uri.EndsWith("gtw"))
                    {
                        uri = uri.Substring(0, uri.Length - 3);
                    }
                    uRIConfigurationList.Add(OfficeApplicationProxy.Credentials.UserName, new Uri(uri));
                    MenuListener.LogOn();
                }
                catch (HttpException e)
                {
                    MenuListener.LogOff();
                    tryLogOn = false;
                    if (e.Code == HttpStatusCode.NotFound)
                    {
                        RtlAwareMessageBox.Show(null, "No se puede conectar a la dirección web, o la dirección es incorrecta o no se tiene habilitada la publicación de contenidos", "Iniciar sessión", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else if (e.Code == HttpStatusCode.Forbidden)
                    {
                        RtlAwareMessageBox.Show(null, "Su clave o contraseña es incorrecta", "Iniciar sessión", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        RtlAwareMessageBox.Show(null, e.Message, "Iniciar sessión", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    }
                    OfficeApplication.LogOff();
                }
                catch (WebException e)
                {
                    MenuListener.LogOff();
                    tryLogOn = false;
                    if (e.Status == WebExceptionStatus.ConnectFailure)
                    {
                        RtlAwareMessageBox.Show(null, "El sitio web con el que intenta trabajar, se encuentra apagado o no se puede acceder al mismo.", "Iniciar sessión", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        RtlAwareMessageBox.Show(null, e.Message, "Iniciar sessión", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    OfficeApplication.LogOff();
                }
                catch (Exception e)
                {
                    OfficeApplication.WriteError(e);
                    MenuListener.LogOff();
                    RtlAwareMessageBox.Show(null, e.Message, "Iniciar sessión", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    tryLogOn = false;
                    OfficeApplication.LogOff();
                }
            }
            return(tryLogOn);
        }
Пример #23
0
 /// <summary>
 /// Removes a listener for menu events.
 /// </summary>
 public void removeMenuListener(MenuListener @l)
 {
 }
Пример #24
0
 /// <summary>
 /// Adds a listener for menu events.
 /// </summary>
 public void addMenuListener(MenuListener @l)
 {
 }
Пример #25
0
 private void DebugChoice(PieceType choice)
 {
     MenuListener.FindInActiveObjectByName("DDDText").SetActive(true);
     Debug.Log("Choice: " + choice);
 }
Пример #26
0
		/// <summary>
		/// Removes a listener for menu events.
		/// </summary>
		public void removeMenuListener(MenuListener @l)
		{
		}