Example #1
0
        /// <summary>
        /// Create and configure the Player health bar HUD
        /// </summary>
        /// <param name="rMotionController"></param>
        /// <param name="rSceneCanvas"></param>
        protected virtual void SetupPlayerHUD(MotionController rMotionController, Canvas rSceneCanvas)
        {
            // We want a single Player HUD in the scene, so attempt to find a HUD that is not set to World Space
            List <BasicCombatantHUD> lHUDs      = FindObjectsOfType <BasicCombatantHUD>().ToList();
            BasicCombatantHUD        lPlayerHUD = null;

            if (lHUDs != null)
            {
                lPlayerHUD = lHUDs.FirstOrDefault(x => !x.DisplayInWorldSpace);
            }

            if (lPlayerHUD != null)
            {
                lPlayerHUD.UsePlayer       = true;
                lPlayerHUD.BasicAttributes = rMotionController.GetComponent <BasicAttributes>();
                lPlayerHUD.HealthKey       = "Health";
                lPlayerHUD.HideWhenFull    = PlayerHealthBarHideWhenFull;
            }
            else
            {
                lPlayerHUD      = Instantiate(PlayerHealthBarPrefab);
                lPlayerHUD.name = "Player HUD";
                lPlayerHUD.transform.SetParent(rSceneCanvas.transform);
                lPlayerHUD.transform.ResetRect();
            }
        }
Example #2
0
        /// <summary>
        /// Create and configure the NPC combatant HUD. Right now, only uses a HUD drawn in World Space (attached to the character)
        /// </summary>
        /// <param name="rMotionController"></param>
        protected virtual void SetupCombatantHUD(MotionController rMotionController)
        {
            //bool lIsWorldSpacePrefab = false;

            //if (CombatantHealthBarPrefab != null)
            //{
            //    lIsWorldSpacePrefab = CombatantHealthBarPrefab.DisplayInWorldSpace;
            //}

            //// If the HUD is set up to display in world space, then we just need to ensure an instance is attached to the character
            //if (!lIsWorldSpacePrefab) return;

            // Check to see if the current character GameObject already has a HUD attached
            BasicCombatantHUD lCombatantHUD = rMotionController.GetComponentInChildren <BasicCombatantHUD>();

            // Instantiate the HUD prefab if it wasn't found
            if (lCombatantHUD == null)
            {
                lCombatantHUD      = Instantiate(CombatantHealthBarPrefab);
                lCombatantHUD.name = "Combatant HUD";
                lCombatantHUD.transform.SetParent(rMotionController.gameObject.transform);
                lCombatantHUD.transform.Reset();
                lCombatantHUD.transform.position = new Vector3(0, WorldSpaceHUDPosition, 0);
            }

            // Set up the HUD for this character

            lCombatantHUD.UsePlayer       = false;
            lCombatantHUD.BasicAttributes = rMotionController.GetComponent <BasicAttributes>();
            lCombatantHUD.HealthKey       = "Health";

            // TODO: allow AI characters to share a single instance of a HUD; we would reassign the HUD to an AI character
            // when the player's targeted Combatant changes.
        }
Example #3
0
        protected virtual void OnEnable()
        {
            if (string.IsNullOrEmpty(DisplayText))
            {
                SetDefaultDisplayText();
            }

            mHasRequiredPacks = CheckRequiredMotionPacks();

            // If there are no saved preferences for certain prefabs, load the default ones
            if (CombatantHealthBarPrefab == null)
            {
                CombatantHealthBarPrefab = Resources.Load <BasicCombatantHUD>("UI/Combatant HUD");
            }

            if (PlayerHealthBarPrefab == null)
            {
                PlayerHealthBarPrefab = Resources.Load <BasicCombatantHUD>("UI/Player HUD");
            }

            if (ReticlePrefab == null)
            {
                ReticlePrefab = Resources.Load <Reticle>("UI/Reticle");
            }

#if OOTII_CC
            CameraPrefab = Resources.Load <CameraController>("Camera Rig [Advanced]");
#else
            CameraPrefab = Resources.Load <BaseCameraRig>("Camera Rig [Orbit]");
#endif

            InitializeModules();
        }
Example #4
0
        /// <summary>
        /// Checks if a Canvas with RenderMode == WorldSpace is a child of this gameObject.
        /// </summary>
        /// <returns></returns>
        protected virtual bool IsInWorldSpace()
        {
            bool lWorldSpace = false;

            BasicCombatantHUD lCombatantHUD = (BasicCombatantHUD)target;

            if (lCombatantHUD == null)
            {
                return(false);
            }

            Canvas lCanvas = lCombatantHUD.gameObject.GetComponentInChildren <Canvas>();

            if (lCanvas != null)
            {
                lWorldSpace = lCanvas.renderMode == RenderMode.WorldSpace;
            }

            return(lWorldSpace);
        }