Exemplo n.º 1
0
        internal void InitializeBoard()
        {
            // Bootstrapper
            var boardService = new BoardService();

            var gameModel      = new GameModel(boardService);
            var gameController = new GameController(gameModel);

            var boardModel      = new BoardModel(boardService);
            var boardController = new BoardController(boardModel);

            var boardViewModel = new BoardViewModel(BoardCanvas, gameModel, boardModel);

            var userMessageController = new UserMessageController(boardViewModel);
            var rendererController    = new RendererController(boardViewModel);

            boardModel.NewPieceAdded    += rendererController.DrawNewPiece;
            boardModel.NewPieceAdded    += gameController.IncreasePieceCount;
            boardModel.PieceRemoved     += rendererController.DeletePiece;
            boardModel.PieceRemoved     += gameController.DecreaseOpponentPieceCount;
            boardModel.PieceMoved       += rendererController.MovePiece;
            boardModel.SelectionChanged += rendererController.ChangeSelection;
            gameModel.TurnTaken         += rendererController.UpdateRendererModel;

            rendererController.NotifyUser    += userMessageController.SetUserMessage;
            boardViewModel.NotifyUser        += userMessageController.SetUserMessage;
            boardViewModel.SelectPiece       += boardController.ChangeSelection;
            boardViewModel.RemovePiece       += boardController.RemovePiece;
            boardViewModel.TakeTurn          += gameController.TakeTurn;
            boardViewModel.AddPiece          += boardController.AddNewPiece;
            boardViewModel.MoveSelectedPiece += boardController.MoveSelectedPiece;

            DataContext = boardViewModel;
            gameController.StartGame();
        }
        private static RendererController CreateController(RouteData routeData = null)
        {
            var controller = new RendererController();

            HttpContextBase wrapper;

            if (HttpContext.Current != null)
            {
                wrapper = new HttpContextWrapper(System.Web.HttpContext.Current);
            }
            else
            {
                throw new InvalidOperationException("Can't create Controller Context if no active HttpContext instance is available.");
            }

            if (routeData == null)
            {
                routeData = new RouteData();
            }

            // add the controller routing if not existing
            if (!routeData.Values.ContainsKey("controller") && !routeData.Values.ContainsKey("Controller"))
            {
                routeData.Values.Add("controller", controller.GetType().Name.ToLower().Replace("controller", ""));
            }

            controller.ControllerContext = new ControllerContext(wrapper, routeData, controller);
            return(controller);
        }
Exemplo n.º 3
0
    private void Awake()
    {
        rb = GetComponent <Rigidbody>();
        rendererController = mainRenderer.GetComponent <RendererController>();

        //TODO, test
        if (isPlayer)
        {
            SetCameraTarget();
        }
    }
Exemplo n.º 4
0
        public Renderer()
        {
            InitializeComponent();
            this.Loaded   += Renderer_Loaded;
            this.Unloaded += Renderer_Unloaded;

            RendererController = new RendererController(this);
            stopWatch          = new Stopwatch();
            this.DataContext   = this;

            thread = new Thread(() => { CalcFPS(); });
        }
Exemplo n.º 5
0
        public void GettingAnEvenPositionTriangle()
        {
            RendererController renderer = new RendererController(null);

            string[] ROWS = { "A", "B", "C", "D", "E", "F" };
            foreach (string row in ROWS)
            {
                for (int i = 1; i < 13; i++)
                {
                    Point[]           pixelsOfTriangle  = renderer.Get(row, i);
                    Point[]           vertices          = FindVertices(pixelsOfTriangle);
                    LocatorController locatorController = new LocatorController(null);
                    string[]          position          = locatorController.Get(vertices[0].X + "," + vertices[0].Y, vertices[1].X + "," + vertices[1].Y, vertices[2].X + "," + vertices[2].Y);
                    Assert.AreEqual(row + i, position[0]);
                }
            }
        }
Exemplo n.º 6
0
        private void ApplyAlpha(Vector3 _from, Vector3 _to)
        {
            const float MIN_DISTANCE = 1f;

            Vector3 rayStart     = _from;
            Vector3 rayDirection = _to - _from;

            while (rayDirection.sqrMagnitude > MIN_DISTANCE)
            {
                RaycastHit castResult  = new RaycastHit();
                Ray        obstacleRay = new Ray(rayStart, rayDirection.normalized);

                Debug.DrawRay(rayStart, rayDirection, Color.red);
                if (!Physics.Raycast(obstacleRay, out castResult, rayDirection.magnitude))
                {
                    return;
                }

                GameObject obj = castResult.collider.gameObject;
                while (obj != null)
                {
                    RendererController ctrl = obj.GetComponent <RendererController>();
                    if (ctrl != null)
                    {
                        ctrl.ApplyAlpha(m_Behavior.m_GameObjectAlpha);
                        obj = null;
                    }
                    else
                    {
                        if (obj.transform.parent != null)
                        {
                            obj = obj.transform.parent.gameObject;
                        }
                        else
                        {
                            obj = null;
                        }
                    }
                }

                rayStart     = rayStart + rayDirection.normalized * (castResult.distance + 0.01f);
                rayDirection = _to - rayStart;
            }
        }
Exemplo n.º 7
0
 private void Awake()
 {
     rendererController = GetComponentInChildren <RendererController>();
 }