/////////////////////////////////////////////////////////// // in 'Start' we do things that potentially depend on all // other components first having run their 'Awake' calls /////////////////////////////////////////////////////////// void Start() { // set up weapon availability. if a weapon is not in this // list the script won't allow the player to use it. all // weapons are available by default. // NOTE: this is just a placeholder for your game's actual // inventory system (as is ammo availability, which is set // on every vp_FPSShooter individually) foreach (GameObject weapon in Camera.Weapons) { m_AvailableWeapons.Add(weapon); } // use the 'SetWeaponAvailable' method to give or take weapons // from the player, and check 'WeaponAvailable' to see if the player // has a certain weapon. all weapons can be taken away by doing: // 'm_AvailableWeapons.Clear();' // attempt to set weapon 1 if (WeaponCount > 0) { Camera.SetWeapon(1); } }
/////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////// void Start() { // get hold of the FPSCamera and FPSController components // attached to this game object m_Camera = gameObject.GetComponentInChildren<vp_FPSCamera>(); m_Controller = gameObject.GetComponent<vp_FPSController>(); // load textures if (m_DemoMode) { LoadCamera("Examples/ImmobileCamera"); m_Camera.SetWeapon(1); m_ImageAllParams = (Texture)Resources.Load("Examples/Images/AllParams"); m_ImageEditorPreview = (Texture)Resources.Load("Examples/Images/EditorPreview"); m_ImageEditorPreviewShow = (Texture)Resources.Load("Examples/Images/EditorPreviewShow"); m_ImageCameraMouse = (Texture)Resources.Load("Examples/Images/CameraMouse"); m_ImagePresetDialogs = (Texture)Resources.Load("Examples/Images/PresetDialogs"); m_ImageShooter = (Texture)Resources.Load("Examples/Images/Shooter"); m_ImageWeaponPosition = (Texture)Resources.Load("Examples/Images/WeaponPosition"); m_ImageWeaponPerspective = (Texture)Resources.Load("Examples/Images/WeaponRendering"); m_ImageWeaponPivot = (Texture)Resources.Load("Examples/Images/WeaponPivot"); m_ImageEditorScreenshot = (Texture)Resources.Load("Examples/Images/EditorScreenshot"); m_ImageLeftArrow = (Texture)Resources.Load("Examples/Images/LeftArrow"); m_ImageRightArrow = (Texture)Resources.Load("Examples/Images/RightArrow"); m_ImageCheck = (Texture)Resources.Load("Examples/Images/Check"); m_ImageLeftPointer = (Texture)Resources.Load("Examples/Images/LeftPointer"); m_ImageRightPointer = (Texture)Resources.Load("Examples/Images/RightPointer"); m_ImageUpPointer = (Texture)Resources.Load("Examples/Images/UpPointer"); m_ImageCrosshair = (Texture)Resources.Load("Examples/Images/Crosshair"); m_ImageFullScreen = (Texture)Resources.Load("Examples/Images/Fullscreen"); // on small screen resolutions the editor preview screenshot // panel is minimized by default, otherwise expanded if (Screen.width < 1024) m_EditorPreviewSectionExpanded = false; // add an audio source to the camera, for playing various demo sounds m_AudioSource = (AudioSource)m_Camera.gameObject.AddComponent("AudioSource"); } }