Пример #1
0
        // --------------------------------------------------------------------------------------------
        public static GameCamera Create(Game game, float initOribitAngle, Vector3 initLookAt)
        {
            GameCamera toReturn = new GameCamera(game);

            toReturn._orbitAngle             = initOribitAngle;
            toReturn._distanceFromLookTarget = 46f;
            toReturn._horizonAngle           = 35f;

            toReturn.LookingAt = initLookAt;

            toReturn.Tag                   = "MainCamera";
            toReturn.LocalPosition         = toReturn.LookingAt + toReturn.CalculateOffsetFromTarget();
            toReturn.LocalRotation         = Quaternion.LookRotation(initLookAt - toReturn.LocalPosition, Vector3.up);
            toReturn.CameraClearFlags      = CameraClearFlags.SolidColor;
            toReturn.CameraBackgroundColor = Color.black;
            toReturn.CameraFieldOfView     = 30f;

            UIWorldInteractionPanel.AddListener(toReturn);

            return(toReturn);
        }
Пример #2
0
        // --------------------------------------------------------------------------------------------
        public Game(List <PlayerData> playerDatas, int localPlayerIndex)
        {
            _currentPlayerIndex = 0;
            _localPlayerIndex   = localPlayerIndex;

            // TODO: when networked, we need to share this in the room properites and then deserialize it on all clients
            _random = SerializedRandom.CreateNewInstance(1024);

            board = new Board(this, 5, 5);
            board.Render(AppManager.Transform);

            sun = SharpLight.Sun();
            sun.LocalRotation = Quaternion.Euler(125, 45, 0);
            sun.Render(AppManager.Transform);

            _players = new List <Player>();
            for (int i = 0; i < playerDatas.Count; i++)
            {
                // TODO: players need to have a synced initial seed
                Player player = new Player(playerDatas[i], this, i, (uint)i);
                player.PlayerLost += OnPlayerLost;
                _players.Add(player);
            }

            // This needs to happen before gameCamera, since it needs to register itself as a listener to UIWorldIteractionPanel
            _uiWorldInteractionPanel = UIWorldInteractionPanel.Create(this);

            _unitActionManager = new UnitActionManager(this, this);
            UIWorldInteractionPanel.AddListener(_unitActionManager);

            gameCamera = GameCamera.Create(this, -90, board.CenterPos + Vector3.down * BoardTileView.Size / 2f);
            gameCamera.Render(AppManager.Transform);

            _playerActions = new List <PlayerAction>();
            _actionIndex   = -1;

            _hudManager = HUDManager.Create(this);
            _hudManager.Render(AppManager.Transform);
        }