Exemple #1
0
        public override void Start()
        {
            base.Start();

            Debug.Log("Player controller start");

            if (!CameraRoot)
            {
                CameraRoot = transform.Find("CameraRoot");
            }

            if (!ModelRoot)
            {
                ModelRoot = transform.GetChild(0).gameObject;
            }

            if (!MovementComponent)
            {
                MovementComponent = GetComponent <PlayerMovementComponent>();
            }

            if (!WeaponComponent)
            {
                WeaponComponent = GetComponentInChildren <PlayerWeaponComponent>();
            }

            if (!CameraZoomComponent)
            {
                CameraZoomComponent = GetComponentInChildren <PlayerCameraZoomComponent>(true);
            }

            if (!DeathComponent)
            {
                DeathComponent = GetComponentInChildren <PlayerDeathComponent>();
            }

            if (!HUDScript)
            {
                HUDScript = (RpgHUDController)BaseHUDController.Current; //I would not recommend this cast
            }

            if (!HUDScript && AutoinitHud)
            {
                Instantiate <GameObject>(CoreUtils.LoadResource <GameObject>("UI/DefaultWorldHUD"), CoreUtils.GetUIRoot());
                if (EventSystem.current == null)
                {
                    Instantiate(CoreUtils.LoadResource <GameObject>("UI/DefaultEventSystem"));
                }

                HUDScript = (RpgHUDController)BaseHUDController.Current;
            }

            MessageInterface = new QdmsMessageInterface(gameObject);

            LockPauseModule.CaptureMouse = true;

            SetDefaultPlayerView();
            SetInitialViewModels();
        }
Exemple #2
0
        public override void Start()
        {
            base.Start();

            Debug.Log("Player controller start");

            if (!CameraRoot)
            {
                CameraRoot = transform.Find("CameraRoot");
            }

            if (!ModelRoot)
            {
                ModelRoot = transform.GetChild(0).gameObject;
            }

            if (!MovementComponent)
            {
                MovementComponent = GetComponent <PlayerMovementComponent>();
            }

            if (!WeaponComponent)
            {
                WeaponComponent = GetComponentInChildren <PlayerWeaponComponent>();
            }

            if (!CameraZoomComponent)
            {
                CameraZoomComponent = GetComponentInChildren <PlayerCameraZoomComponent>(true);
            }

            if (!DeathComponent)
            {
                DeathComponent = GetComponentInChildren <PlayerDeathComponent>();
            }

            if (!ShieldComponent)
            {
                ShieldComponent = GetComponent <PlayerShieldComponent>();
            }

            if (LightReportingComponent == null)
            {
                LightReportingComponent = GetComponentInChildren <IReportLight>() as MonoBehaviour;
            }

            if (!HUDScript)
            {
                HUDScript = SharedUtils.TryGetHudController() as RpgHUDController;
            }

            if (!HUDScript && AutoinitHud)
            {
                Instantiate <GameObject>(CoreUtils.LoadResource <GameObject>("UI/DefaultWorldHUD"), CoreUtils.GetUIRoot());
                if (EventSystem.current == null)
                {
                    Instantiate(CoreUtils.LoadResource <GameObject>("UI/DefaultEventSystem"));
                }

                HUDScript = SharedUtils.TryGetHudController() as RpgHUDController;
                if (HUDScript == null)
                {
                    Debug.LogError("[PlayerController] Failed to initialize HUD properly");
                }
            }

            MessageInterface = new QdmsMessageInterface(gameObject);

            LockPauseModule.CaptureMouse = true;

            SetDefaultPlayerView();
            SetInitialViewModels();

            ShieldComponent.Ref()?.HandleLoadStart();

            TryExecuteOnComponents(component => component.Init(this));
            Initialized = true;
        }