示例#1
0
        private void Start()
        {
            if (PlayerController == null)
            {
                PlayerController = GetComponentInParent <PlayerController>();
            }

            if (PlayerController == null)
            {
                Debug.LogError($"{nameof(PlayerMovebobComponent)} on {name} can't find {nameof(PlayerController)}");
                enabled = false;
                return;
            }

            if (MovementComponent == null)
            {
                MovementComponent = GetComponentInParent <PlayerMovementComponent>();
            }

            if (MovementComponent == null)
            {
                Debug.LogError($"{nameof(PlayerMovebobComponent)} on {PlayerController.name} can't find {nameof(PlayerMovementComponent)}");
                enabled = false;
                return;
            }
        }
示例#2
0
        private void Start()
        {
            if (MovementComponent == null)
            {
                MovementComponent = GetComponentInParent <PlayerMovementComponent>();
            }

            if (MovementComponent == null)
            {
                Debug.LogError($"{nameof(WeaponMovebobComponent)} on {name} can't find {nameof(PlayerMovementComponent)}");
                enabled = false;
                return;
            }

            if (WeaponComponent == null)
            {
                WeaponComponent = GetComponentInParent <PlayerWeaponComponent>();
            }

            if (WeaponComponent == null)
            {
                Debug.LogError($"{nameof(WeaponMovebobComponent)} on {name} can't find {nameof(PlayerWeaponComponent)}");
                enabled = false;
                return;
            }

            WasInADS = WeaponComponent.IsADS;
        }
示例#3
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();
        }
示例#4
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;
        }