void Start() { m_WeaponsManager = GameObject.FindObjectOfType <PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullFindObject <PlayerWeaponsManager, CrosshairManager>(m_WeaponsManager, this); OnWeaponChanged(m_WeaponsManager.GetActiveWeapon()); m_WeaponsManager.OnSwitchedToWeapon += OnWeaponChanged; }
void OnShoot() { m_ShootTime = Time.time; //発射時間 m_LastRootPosition = root.position; //最後のルートの位置 = ルートの位置 m_Velocity = transform.forward * speed; //速度 = 向き * 速さ m_IgnoredColliders = new List <Collider>(); //無視されたコライダー = 新しいリストのコライダー transform.position += m_ProjectileBase.inheritedMuzzleVelocity * Time.deltaTime; //変換位置 += 発射台.継承されたマズル向き * 処理終了時間 // Ignore colliders of owner //所有者のコライダーを無視します Collider[] ownerColliders = m_ProjectileBase.owner.GetComponentsInChildren <Collider>(); //所有者コライダー = 発射台.オーナー.子コンポーネントの取得<コライダー> m_IgnoredColliders.AddRange(ownerColliders); //無視されたコライダー.範囲を追加(所有者のコライダー) // Handle case of player shooting (make projectiles not go through walls, and remember center-of-screen trajectory) //プレーヤーの射撃のケースを処理します(発射体が壁を通過しないようにし、画面の中心の軌跡を覚えておいてください) PlayerWeaponsManager playerWeaponsManager = m_ProjectileBase.owner.GetComponent <PlayerWeaponsManager>(); //プレイヤーウェポンマネージャーのコンポーネント情報を取得 if (playerWeaponsManager) { m_HasTrajectoryOverride = true; //軌道オーバーライド = 有効 Vector3 cameraToMuzzle = (m_ProjectileBase.initialPosition - playerWeaponsManager.weaponCamera.transform.position); //3Dベクトル 銃口へのカメラ = (発射台.初期位置 - プレイヤーの武器マネージャー.武器カメラ.位置) m_TrajectoryCorrectionVector = Vector3.ProjectOnPlane(-cameraToMuzzle, playerWeaponsManager.weaponCamera.transform.forward); //軌道修正ベクトル = 3Dベクトル平面上のプロジェクト(-銃口にカメラ, プレイヤーの武器マネージャー.武器カメラ.変換フォワード) if (trajectoryCorrectionDistance == 0) //もし、軌道修正距離 == 0 { transform.position += m_TrajectoryCorrectionVector; //変換位置 += 軌道修正ベクトル m_ConsumedTrajectoryCorrectionVector = m_TrajectoryCorrectionVector; } else if (trajectoryCorrectionDistance < 0) { m_HasTrajectoryOverride = false; } if (Physics.Raycast(playerWeaponsManager.weaponCamera.transform.position, cameraToMuzzle.normalized, out RaycastHit hit, cameraToMuzzle.magnitude, hittableLayers, k_TriggerInteraction)) { if (IsHitValid(hit)) { OnHit(hit.point, hit.normal, hit.collider); //ヒット(ヒットポイント, ヒット法線, ヒットコライダー) } } } }
// Start is called before the first frame update void Start() { ez = new EzNet(); lastPos = new Vector3(0, 0, 0); player = GameObject.Find("Player"); weapon = player.GetComponent <PlayerWeaponsManager>(); enemies = new Dictionary <string, GameObject>(); }
void Awake() { PlayerWeaponsManager playerWeaponsManager = FindObjectOfType <PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullFindObject <PlayerWeaponsManager, NotificationHUDManager>(playerWeaponsManager, this); playerWeaponsManager.onAddedWeapon += OnPickupWeapon; //Jetpack jetpack = FindObjectOfType<Jetpack>(); //DebugUtility.HandleErrorIfNullFindObject<Jetpack, NotificationHUDManager>(jetpack, this); //jetpack.onUnlockJetpack += OnUnlockJetpack; }
void Awake() { PlayerWeaponsManager playerWeaponsManager = FindObjectOfType <PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullFindObject <PlayerWeaponsManager, NotificationHUDManager>(playerWeaponsManager, this); playerWeaponsManager.onAddedWeapon += OnPickupWeapon; StartCoroutine(OnSceneLoad(SceneManager.GetActiveScene().name)); /* Jetpack jetpack = FindObjectOfType<Jetpack>(); * DebugUtility.HandleErrorIfNullFindObject<Jetpack, NotificationHUDManager>(jetpack, this); * jetpack.onUnlockJetpack += OnUnlockJetpack; */ }
public void Initialize(WeaponController weapon, int weaponIndex) { m_Weapon = weapon; //weaponCounterIndex = weaponIndex; //weaponImage.sprite = weapon.weaponIcon; m_PlayerWeaponsManager = FindObjectOfType <PlayerWeaponsManager>(); // DebugUtility.HandleErrorIfNullFindObject<PlayerWeaponsManager, AmmoCounter>(m_PlayerWeaponsManager, this); // weaponIndexText.text = (weaponCounterIndex + 1).ToString(); // FillBarColorChange.Initialize(1f, m_Weapon.GetAmmoNeededToShoot()); }
// Send current coordinates to server internal void HandlePlayerUpdate() { if (player == null && isAlive) { player = Instantiate(prefabPlayer, RandomizePosition(), transform.rotation); Attributes attributes = player.GetComponent <Attributes>(); attributes.setAttributes(playerAttrib.hp, playerAttrib.ammo, playerAttrib.exp); gameFlowManager.enabled = true; } else if (!isAlive) { return; } else if (isAlive && isRespawning) { player.SetActive(true); player.transform.position = RandomizePosition(); Attributes attributes = player.GetComponent <Attributes>(); attributes.fullstate(); PlayerCharacterController playerCharacterController = player.GetComponent <PlayerCharacterController>(); playerCharacterController.isDead = false; PlayerWeaponsManager playerWeaponsManager = player.GetComponent <PlayerWeaponsManager>(); playerWeaponsManager.SwitchToWeaponIndex(0, true); Health health = player.GetComponent <Health>(); health.IsDead = false; Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; isRespawning = false; } else { PLAYER_TRANSFORM = player.transform; Attributes attributes = player.GetComponent <Attributes>(); playerAttrib.hp = attributes.getHp(); playerAttrib.ammo = attributes.getAmmo(); playerAttrib.exp = attributes.getExp(); } string position = PLAYER_TRANSFORM.position.x + "," + PLAYER_TRANSFORM.position.y + "," + PLAYER_TRANSFORM.position.z; string rotation = PLAYER_TRANSFORM.eulerAngles.x + "," + PLAYER_TRANSFORM.eulerAngles.y + "," + PLAYER_TRANSFORM.eulerAngles.z; if (!position.Equals(lastCoordinate)) { SendMessage("position," + position + ",rotation," + rotation + ";"); } lastCoordinate = position; }
void OnShoot() { m_ShootTime = Time.time; m_LastRootPosition = root.position; m_Velocity = transform.forward * speed; m_IgnoredColliders = new List <Collider>(); transform.position += m_ProjectileBase.inheritedMuzzleVelocity * Time.deltaTime; // Ignore colliders of owner if (m_ProjectileBase.owner) { Collider[] ownerColliders = m_ProjectileBase.owner.GetComponentsInChildren <Collider>(); m_IgnoredColliders.AddRange(ownerColliders); } // Handle case of player shooting (make projectiles not go through walls, and remember center-of-screen trajectory) PlayerWeaponsManager playerWeaponsManager = null; if (m_ProjectileBase.owner) { playerWeaponsManager = m_ProjectileBase.owner.GetComponent <PlayerWeaponsManager>(); } if (playerWeaponsManager) { m_HasTrajectoryOverride = true; Vector3 cameraToMuzzle = (m_ProjectileBase.initialPosition - playerWeaponsManager.weaponCamera.transform.position); m_TrajectoryCorrectionVector = Vector3.ProjectOnPlane(-cameraToMuzzle, playerWeaponsManager.weaponCamera.transform.forward); if (trajectoryCorrectionDistance == 0) { transform.position += m_TrajectoryCorrectionVector; m_ConsumedTrajectoryCorrectionVector = m_TrajectoryCorrectionVector; } else if (trajectoryCorrectionDistance < 0) { m_HasTrajectoryOverride = false; } if (Physics.Raycast(playerWeaponsManager.weaponCamera.transform.position, cameraToMuzzle.normalized, out RaycastHit hit, cameraToMuzzle.magnitude, hittableLayers, k_TriggerInteraction)) { if (IsHitValid(hit)) { OnHit(hit.point, hit.normal, hit.collider); } } } }
void Awake() { PlayerWeaponsManager playerWeaponsManager = FindObjectOfType <PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullFindObject <PlayerWeaponsManager, NotificationHUDManager>(playerWeaponsManager, this); playerWeaponsManager.OnAddedWeapon += OnPickupWeapon; Jetpack jetpack = FindObjectOfType <Jetpack>(); DebugUtility.HandleErrorIfNullFindObject <Jetpack, NotificationHUDManager>(jetpack, this); jetpack.OnUnlockJetpack += OnUnlockJetpack; EventManager.AddListener <ObjectiveUpdateEvent>(OnObjectiveUpdateEvent); }
void Start() { m_InputHandler = FindObjectOfType <PlayerInputHandler>(); Assert.IsNotNull(m_InputHandler); m_PlayerWeaponsManager = FindObjectOfType <PlayerWeaponsManager>(); Assert.IsNotNull(m_PlayerWeaponsManager); canvas = transform.Find("Canvas"); Assert.IsNotNull(canvas); table = canvas.Find("Table"); Assert.IsNotNull(table); rowPrefab = (GameObject)Resources.Load("WeaponRow"); Assert.IsNotNull(rowPrefab); }
void Start() { m_PlayerWeaponsManager = FindObjectOfType <PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullFindObject <PlayerWeaponsManager, WeaponHUDManager>(m_PlayerWeaponsManager, this); BasicWeapon activeWeapon = m_PlayerWeaponsManager.GetActiveWeapon(); if (activeWeapon) { AddWeapon(activeWeapon, m_PlayerWeaponsManager.activeWeaponIndex); ChangeWeapon(activeWeapon); } m_PlayerWeaponsManager.onAddedWeapon += AddWeapon; m_PlayerWeaponsManager.onRemovedWeapon += RemoveWeapon; m_PlayerWeaponsManager.onSwitchedToWeapon += ChangeWeapon; }
void Start() { foreach (var wpnMgr in GameObject.FindObjectsOfType <PlayerWeaponsManager>()) { if (wpnMgr != null && wpnMgr.isActiveAndEnabled) { m_WeaponsManager = wpnMgr; DebugUtility.HandleErrorIfNullFindObject <PlayerWeaponsManager, CrosshairManager>(m_WeaponsManager, this); OnWeaponChanged(m_WeaponsManager.GetActiveWeapon()); m_WeaponsManager.onSwitchedToWeapon += OnWeaponChanged; break; } } }
void OnPicked(PlayerCharacterController byPlayer) { PlayerWeaponsManager playerWeaponsManager = byPlayer.GetComponent <PlayerWeaponsManager>(); if (playerWeaponsManager) { if (playerWeaponsManager.AddWeapon(weaponPrefab)) { // Handle auto-switching to weapon if no weapons currently if (playerWeaponsManager.GetActiveWeapon() == null) { playerWeaponsManager.SwitchWeapon(true); } m_Pickup.PlayPickupFeedback(); } } }
public void Initialize(WeaponController weapon, int weaponIndex) { //Parent prefab is being instantiated gameObject.name = $"AmmoCounter{(weaponIndex+1)}"; transform.SetSiblingIndex(weaponIndex); m_Weapon = weapon; weaponCounterIndex = weaponIndex; weaponImage.sprite = weapon.weaponIcon; //original icon WeaponIconUpdater weaponIconUpdater = FindObjectOfType <WeaponIconUpdater>(); weaponImage.sprite = weaponIconUpdater.GetIcon(weapon); //dynamic icon m_PlayerWeaponsManager = FindObjectOfType <PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullFindObject <PlayerWeaponsManager, AmmoCounter>(m_PlayerWeaponsManager, this); weaponIndexText.text = (weaponCounterIndex + 1).ToString(); FillBarColorChange.Initialize(1f, m_Weapon.GetAmmoNeededToShoot()); }
void OnPicked(PlayerCharacterController player) { PlayerCharacterController playercontroller = player.GetComponent <PlayerCharacterController>(); DebugUtility.HandleErrorIfNullGetComponent <PlayerCharacterController, PoisonPickUp>(playercontroller, this, gameObject); PlayerWeaponsManager weaponcontroller = player.GetComponent <PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullGetComponent <PlayerWeaponsManager, PoisonPickUp>(weaponcontroller, this, gameObject); playercontroller.poisonTaken(SpeedDecreaseAmount); int numberofweapons = weaponcontroller.m_WeaponSlots.Length; for (int i = 0; i < numberofweapons; i++) { WeaponController temp = weaponcontroller.m_WeaponSlots[i]; temp.poisonTaken(); } m_Pickup.PlayPickupFeedback(); Destroy(gameObject); }
// Start is called before the first frame update void Start() { Physics.IgnoreLayerCollision(LayerMask.NameToLayer("Default"), LayerMask.NameToLayer("DontHit"), true); _playerCharacterController = GetComponent <PlayerCharacterController>(); DebugUtility.HandleErrorIfNullGetComponent <PlayerCharacterController, PlayerWeaponsManager>(_playerCharacterController, this, gameObject); _playerWeaponsManager = GetComponent <PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullGetComponent <PlayerWeaponsManager, PlayerWeaponsManager>(_playerWeaponsManager, this, gameObject); _hud = GetComponentInChildren <HUD>(); DebugUtility.HandleErrorIfNullGetComponent <HUD, PlayerWeaponsManager>(_hud, this, gameObject); _weaponController = _playerWeaponsManager.GetActiveWeapon(); rng = new System.Random(); numBasicPickups = 0; nonShootingSpeedModifier = 1f; }
void Start() { // add this objective to the list contained in the objective manager ObjectiveManager objectiveManager = FindObjectOfType <ObjectiveManager>(); DebugUtility.HandleErrorIfNullFindObject <ObjectiveManager, Objective>(objectiveManager, this); objectiveManager.RegisterObjective(this); // register this objective in the ObjectiveHUDManger m_ObjectiveHUDManger = FindObjectOfType <ObjectiveHUDManger>(); DebugUtility.HandleErrorIfNullFindObject <ObjectiveHUDManger, Objective>(m_ObjectiveHUDManger, this); m_ObjectiveHUDManger.RegisterObjective(this); // register this objective in the NotificationHUDManager m_NotificationHUDManager = FindObjectOfType <NotificationHUDManager>(); DebugUtility.HandleErrorIfNullFindObject <NotificationHUDManager, Objective>(m_NotificationHUDManager, this); m_NotificationHUDManager.RegisterObjective(this); player = GameObject.FindWithTag("Player").GetComponent <PlayerWeaponsManager>(); }
void OnPicked(PlayerCharacterController byPlayer) { Debug.Log($"WeaponPickup OnPicked() weaponName={weaponPrefab.weaponName}"); PlayerWeaponsManager playerWeaponsManager = byPlayer.GetComponent <PlayerWeaponsManager>(); if (playerWeaponsManager) { if (playerWeaponsManager.AddWeapon(weaponPrefab, weaponPrefab.weaponName)) { // Handle auto-switching to weapon if no weapons currently if (playerWeaponsManager.GetActiveWeapon() == null) { playerWeaponsManager.SwitchWeapon(true); } m_Pickup.PlayPickupFeedback(); Destroy(gameObject); } } }
public void Initialize(WeaponController weapon, int weaponIndex) { m_Weapon = weapon; WeaponCounterIndex = weaponIndex; WeaponImage.sprite = weapon.WeaponIcon; if (!weapon.HasPhysicalBullets) { BulletCounter.transform.parent.gameObject.SetActive(false); } else { BulletCounter.text = weapon.GetCarriedPhysicalBullets().ToString(); } m_PlayerWeaponsManager = FindObjectOfType <PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullFindObject <PlayerWeaponsManager, AmmoCounter>(m_PlayerWeaponsManager, this); WeaponIndexText.text = (WeaponCounterIndex + 1).ToString(); FillBarColorChange.Initialize(1f, m_Weapon.GetAmmoNeededToShoot()); }
void Start() { // fetch components on the same gameObject controller = GetComponent <CharacterController>(); inputHandler = GetComponent <PlayerInputHandler>(); weaponsManager = GetComponent <PlayerWeaponsManager>(); health = GetComponent <Health>(); actor = GetComponent <Actor>(); controller.enableOverlapRecovery = true; health.onDie += OnDie; // force the crouch state to false when starting SetCrouchingState(false, true); UpdateCharacterHeight(true); }
void Start() { // fetch components on the same gameObject m_Controller = GetComponent <CharacterController>(); DebugUtility.HandleErrorIfNullGetComponent <CharacterController, PlayerCharacterController>(m_Controller, this, gameObject); m_InputHandler = GetComponent <PlayerInputHandler>(); DebugUtility.HandleErrorIfNullGetComponent <PlayerInputHandler, PlayerCharacterController>(m_InputHandler, this, gameObject); m_WeaponsManager = GetComponent <PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullGetComponent <PlayerWeaponsManager, PlayerCharacterController>(m_WeaponsManager, this, gameObject); m_Health = GetComponent <Health>(); DebugUtility.HandleErrorIfNullGetComponent <Health, PlayerCharacterController>(m_Health, this, gameObject); m_Actor = GetComponent <Actor>(); DebugUtility.HandleErrorIfNullGetComponent <Actor, PlayerCharacterController>(m_Actor, this, gameObject); m_Controller.enableOverlapRecovery = true; m_Health.onDie += OnDie; //List<Vector3> startPositionList = new List<Vector3> //{ // new Vector3(-18, 1, 5), new Vector3(-18, 1, 0), new Vector3(-18, 1, -5), // new Vector3(-23, 1, 5), new Vector3(-23, 1, 0), new Vector3(-23, 1, -5), // new Vector3(-28, 1, 5), new Vector3(-28, 1, 0), new Vector3(-28, 1, -5), //}; //System.Random rd = new System.Random(); //int startIndex = rd.Next(startPositionList.Count); //transform.localPosition = startPositionList[startIndex]; transform.position = new Vector3(-58, 0, -58); // force the crouch state to false when starting SetCrouchingState(false, true); UpdateCharacterHeight(true); }
void OnPicked(PlayerCharacterController byPlayer) { PlayerWeaponsManager playerWeaponsManager = byPlayer.GetComponent <PlayerWeaponsManager>(); if (playerWeaponsManager) { if (playerWeaponsManager.AddWeapon(weaponPrefab)) { // Handle auto-switching to weapon if no weapons currently if (playerWeaponsManager.GetActiveWeapon() == null) { playerWeaponsManager.SwitchWeapon(true); } m_Pickup.PlayPickupFeedback(); TelemetryLogger.LogCollect("Weapon", transform.position, weaponPrefab.weaponName, playerWeaponsManager.GetWeaponsHeldCount()); Destroy(gameObject); } } }
// Start is called before the first frame update private void Start() { m_CharacterController = GetComponent <CharacterController>(); m_playerLook = GetComponent <PlayerLookController>(); m_AudioSource = GetComponent <AudioSource>(); Character = GetComponent <Character>(); PlayerWeaponsManager = GetComponent <PlayerWeaponsManager>(); m_HeadBob.Setup(MainCamera, m_StepInterval); m_playerLook.Init(transform, RotatePoint); m_FovKick.Setup(MainCamera); m_OriginalCameraPosition = MainCamera.transform.localPosition; m_StepCycle = 0f; m_NextStep = m_StepCycle / 2f; m_Jumping = false; CurrentStamina = MaxStamina; Character.Health.onDie += OnDie; Character.Health.onDamaged += OnDamage; Instance = this; }
void Start() { // fetch components on the same gameObject m_Controller = GetComponent <CharacterController>(); DebugUtility.HandleErrorIfNullGetComponent <CharacterController, PlayerCharacterController>(m_Controller, this, gameObject); m_InputHandler = GetComponent <PlayerInputHandler>(); DebugUtility.HandleErrorIfNullGetComponent <PlayerInputHandler, PlayerCharacterController>(m_InputHandler, this, gameObject); m_WeaponsManager = GetComponent <PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullGetComponent <PlayerWeaponsManager, PlayerCharacterController>(m_WeaponsManager, this, gameObject); m_Actor = GetComponent <Actor>(); DebugUtility.HandleErrorIfNullGetComponent <Actor, PlayerCharacterController>(m_Actor, this, gameObject); m_Controller.enableOverlapRecovery = true; // force the crouch state to false when starting SetCrouchingState(false, true); UpdateCharacterHeight(true); }
void Awake() { if (Online) { PlayerWeaponsManager_Photon playerWeaponsManager = FindObjectOfType <PlayerWeaponsManager_Photon>(); DebugUtility.HandleErrorIfNullFindObject <PlayerWeaponsManager_Photon, NotificationHUDManager>(playerWeaponsManager, this); playerWeaponsManager.onAddedWeapon += OnPickupWeaponPhoton; JetPack_Photon jetpack = FindObjectOfType <JetPack_Photon>(); DebugUtility.HandleErrorIfNullFindObject <JetPack_Photon, NotificationHUDManager>(jetpack, this); jetpack.onUnlockJetpack += OnUnlockJetpack; } else { PlayerWeaponsManager playerWeaponsManager = FindObjectOfType <PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullFindObject <PlayerWeaponsManager, NotificationHUDManager>(playerWeaponsManager, this); playerWeaponsManager.onAddedWeapon += OnPickupWeapon; Jetpack jetpack = FindObjectOfType <Jetpack>(); DebugUtility.HandleErrorIfNullFindObject <Jetpack, NotificationHUDManager>(jetpack, this); jetpack.onUnlockJetpack += OnUnlockJetpack; } }
// Start is called before the first frame update void Awake() { health = GetComponent <Health>(); playerWeaponsManager = GetComponent <PlayerWeaponsManager>(); }
void Start() { m_PlayerWeaponsManager = FindObjectOfType <PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullFindObject <PlayerWeaponsManager, WeaponHUDManager>(m_PlayerWeaponsManager, this); }
// Start is called before the first frame update void Start() { m_PlayerWeaponsManager = FindObjectOfType <PlayerWeaponsManager>(); }