public AbilityHUDController(AbilityHUDModelView modelView, ShipModelView ship) { hudMV = modelView; defaultSprite = hudMV.PrimarySlot.sprite; shipMV = ship; shipMV.OnPrimaryAbilityChanged += HandnePrimaryAbilityChanged; shipMV.OnSecondaryAbilityChanged += HandleSecondaryAbilityChanged; }
public static ShipModelView CreateShipModelView(Transform transform) { GameObject testShipPrefab = Resources.Load <GameObject>("Prefabs/Ship/BoozeBoat"); ShipModelView modelView = UnityEngine.Object.Instantiate(testShipPrefab, transform.position, transform.rotation) .GetComponent <ShipModelView>(); return(modelView); }
public PlayerPilotController(PlayerPilotModelView player, ShipModelView ship, TrackPath checkpoints, DirectionArrowModelView dirHUDArrow) { playerModelView = player; shipModelView = ship; checkpointsPath = checkpoints; directionArrow = dirHUDArrow; checkpointsPath.SetObjPosition(shipModelView.transform, ship, true, true); directionArrow.CheckpointDirection = checkpointsPath.GetNextGatePoint(shipModelView.transform); directionArrow.ShipDirection = shipModelView.transform; playerModelView.OnMovingInput += HandleMovingInput; InputControl.Instance.OnActionInput += HandleActionInput; playerModelView.OnTriggerCollision += HandleTriggerCollision; }
/// <summary> /// Конструктор корабля /// </summary> /// <param name="shipModelView">Модель-представление этого корабля</param> /// <param name="shipHPModelView">Полоска ХП этого корабля</param> public ShipController(ShipModelView shipModelView, HitpointsCanvasModelView shipHPModelView) { shipHPMV = shipHPModelView; shipMV = shipModelView; rbStartDrag = shipMV.Rigidbody.drag; //EventHandlers shipMV.OnInput += HandleInput; shipMV.OnAction += HandleAction; shipMV.OnTriggerIN += HandleTriggerIN; shipMV.OnTriggerOUT += HandleTriggerOUT; shipMV.OnDamageRecieved += HandleRecieveDamage; shipMV.OnFixedUpdate += HandleFixedUpdate; previousAngularDrag = shipMV.Rigidbody.angularDrag; }
private int runOutDirection = 2; // TODO переделать этот костыль public EnemyPilotController(EnemyPilotModelView enemyPilot, ShipModelView ship, TrackPath checkpoints) { pilotModelView = enemyPilot; shipModelView = ship; checkpointsPath = checkpoints; checkpointsPath.SetObjPosition(ship.transform, shipModelView, true); currentAim = checkpointsPath.GetStartPosition(); pilotModelView.ChechpointTarget = currentAim.position; pilotModelView.OnMovingInput += HandleMovingInput; pilotModelView.OnActionInput += HandleActionInput; pilotModelView.OnTriggerCollision += HandleTriggerCollision; shipModelView.OnSecondaryAbilityChanged += HandleShipSecondaryAbilityChanged; SetAimAndOffset(); }
public static ShipController CreateShipController(ShipModelView shipMV, HitpointsCanvasModelView shipHP) { return(new ShipController(shipMV, shipHP)); }
public static EnemyPilotController CreateEnemyPilotController(EnemyPilotModelView enemyMV, ShipModelView shipMV, TrackPath checkpoints) { return(new EnemyPilotController(enemyMV, shipMV, checkpoints)); }
public static PlayerPilotController CreatePlayerPilotController(PlayerPilotModelView playerMV, ShipModelView shipMV, TrackPath checkpoints, DirectionArrowModelView dirArrowHUD) { return(new PlayerPilotController(playerMV, shipMV, checkpoints, dirArrowHUD)); }
public GameController(Canvas mainCanvas, Camera mainCam, GameStats gameStat, int lapsCount, int shipCount) // конструктор игры, можно сделать несколько конструкторов(например сколько противников, какая сложность, какая трасса) { mainCamera = mainCam; objectsInGame = new List <GameObject>(); canvas = mainCanvas; gameStats = gameStat; //создаем трассу trackMV = TrackFactory.CreateBigTrackModelView(gameStats.testTrackPrefab); // создаем трассу и добавляем в лист объектов в игре trackMV.OnPause += HandleGamePause; // подписываем обработчик паузы на событие паузы objectsInGame.Add(trackMV.gameObject); //создаем сеть чекпоинтов checkpointsPath = TrackFactory.CreateBigTrackPath(gameStats.testTrackPathPrefab, lapsCount); checkpointsPath.OnFinish += HandleTrackFinish; objectsInGame.Add(checkpointsPath.gameObject); // создаем объект размещения кораблей на трассе StartPlacerModelView placerMV = TrackFactory.CreateStartPlacer(checkpointsPath.GetStartPosition(), gameStats.placerPrefab); // создаем корабль игрока ShipModelView playerShipMV = ShipFactory.CreateShipModelView(placerMV.GetSpawnPoint(0)); ShipController shipController = ShipFactory.CreateShipController(playerShipMV, null); playerShipMV.gameObject.AddComponent <AudioListener>(); objectsInGame.Add(playerShipMV.gameObject); playerShipMV.name = "Player"; ///Создаем эффект песчаной бури и привязываем к игроку EffectModelView effectModelView = EffectsFactory.CreateSandstormEffect(gameStats.sandStormPrefab); effectModelView.transform.parent = playerShipMV.transform; effectModelView.transform.position = playerShipMV.transform.position; // создаем HUD стрелку направления DirectionArrowModelView HUDarrowMV = UIFactory.CreateDirectionArrow(canvas); // создаем пилота игрока PlayerPilotModelView playerPilotMV = PilotFactory.CreatePlayerPilotModelView(playerShipMV.transform); PlayerPilotController playerController = PilotFactory.CreatePlayerPilotController(playerPilotMV, playerShipMV, checkpointsPath, HUDarrowMV); objectsInGame.Add(playerPilotMV.gameObject); UIFactory.AddMinimapPointToPlayer(playerPilotMV.transform); for (int i = 1; i < shipCount; i++) { // создаем корабль противника ShipModelView enemyShipMV = ShipFactory.CreateShipModelView(placerMV.GetSpawnPoint(i)); objectsInGame.Add(enemyShipMV.gameObject); enemyShipMV.name = $"Enemy {i}"; // создаем показатель хитпоинтов корабля противника HitpointsCanvasModelView enemyHp = UIFactory.CreateShipHealthBar(enemyShipMV.transform); if (enemyHp == null) { Debug.Log("HP NOT CREATED!!"); } objectsInGame.Add(enemyHp.gameObject); // создаем контроллер корабля противника ShipController enemyShipController = ShipFactory.CreateShipController(enemyShipMV, enemyHp); // создаем пилота противника EnemyPilotModelView enemyPilotMV = PilotFactory.CreateEnemyPilotModelView(enemyShipMV.transform); EnemyPilotController enemyPilotController = PilotFactory.CreateEnemyPilotController(enemyPilotMV, enemyShipMV, checkpointsPath); enemyShipMV.enemyPilotController = enemyPilotController; objectsInGame.Add(enemyPilotMV.gameObject); UIFactory.AddMinimapPointToEnemy(enemyPilotMV.transform); } // TODO создаем HUD отображение способностей (ТЕСТОВОЕ!!!) AbilityHUDModelView abilityHUDMV = UIFactory.CreatePlayerAbilityUI(canvas); objectsInGame.Add(abilityHUDMV.gameObject); AbilityHUDController abilityHUDController = new AbilityHUDController(abilityHUDMV, playerShipMV); // создаем риг камер CinemachineModelView cameraMV = CameraFactory.CreateCameraRig(playerShipMV.transform); mainCamera.gameObject.SetActive(false); // отключаем основную камеру после появления рига objectsInGame.Add(cameraMV.gameObject); //Создание синглтона Ввода данных от пользователя GameObject inputController = new GameObject(); inputController.AddComponent <InputControl>(); objectsInGame.Add(inputController); //Создание синглтона контроля за TimeScale GameObject timeFollowController = new GameObject(); timeFollowController.AddComponent <TimeFollowController>(); objectsInGame.Add(timeFollowController); // создаем окно оповещений alertsModelView = UIFactory.CreateAlertsModelView(canvas); objectsInGame.Add(alertsModelView.gameObject); //Создаём окно позиции в гонке: TrackPositionModelView trackposMenuModel = UIFactory.CreateTrackPositionModelView(canvas); trackposMenuModel.trackPath = checkpointsPath; objectsInGame.Add(trackposMenuModel.gameObject); // создаем миникарту GameObject minimapCamera = UnityEngine.Object.Instantiate(Resources.Load <GameObject>("Prefabs/MinimapCamera")); objectsInGame.Add(minimapCamera); GameObject miniMap = UIFactory.CreateMinimapObj(canvas); objectsInGame.Add(miniMap); }