void Start() { agent = GetComponent <NavMeshAgent>(); GameManagerRefarences.NullCheck(agent, "agent"); myTransform = this.transform; raycastLayer = 1 << LayerMask.NameToLayer("Player"); // コルーチンの実行 if (isServer) { StartCoroutine(DoCheck()); } }
void Start() { playerEnableScript = GetComponent <PlayerEnable>(); if (GameManagerRefarences.NullCheck(playerEnableScript, "playerEnableScript")) { return; } playerHealthScript = GetComponent <PlayerHealth>(); if (GameManagerRefarences.NullCheck(playerHealthScript, "playerHealthScript")) { return; } playerHealthScript.EventDie += DisablePlayer; }
void Start() { playerEnableScript = GetComponent <PlayerEnable>(); if (GameManagerRefarences.NullCheck(playerEnableScript, "playerEnableScript")) { return; } playerHealthScript = GetComponent <PlayerHealth>(); if (GameManagerRefarences.NullCheck(playerHealthScript, "playerHealthScript")) { return; } playerHealthScript.EventRespawn += EnablePlayer; SetRespawnButton(); }
void SpawnZombies() { counter++; GameObject zombie = GameObject.Instantiate(zombiePrefab, zombieSpawn.transform.position, Quaternion.identity) as GameObject; NetworkServer.Spawn(zombie); // ZombieにIDをつけていく ZombieID zombieID = zombie.GetComponent <ZombieID>(); if (GameManagerRefarences.NullCheck(zombieID, "zombieID")) { return; } zombieID.zombieID = "Zombie " + counter.ToString(); }
void CmdTellServerWhichZombieWasShow(string uniqueID, int dmg) { // ゾンビIDでGameObjectを取得 GameObject go = GameObject.Find(uniqueID); if (GameManagerRefarences.NullCheck(go, "zombieID" + uniqueID)) { return; } // ダメージを与える ZombieHealth zombieHealth = go.GetComponent <ZombieHealth>(); if (GameManagerRefarences.NullCheck(zombieHealth, "ZombieHealth")) { return; } zombieHealth.DeductHealth(dmg); }
void CmdTellServerWhoWasShow(string uniqueID, int dmg) { // 敵プレイヤーの名前でGameObjectを取得 GameObject go = GameObject.Find(uniqueID); if (GameManagerRefarences.NullCheck(go, "playerID" + uniqueID)) { return; } // ダメージを与える PlayerHealth playerHealth = go.GetComponent <PlayerHealth>(); if (GameManagerRefarences.NullCheck(playerHealth, "PlayerHealth")) { return; } playerHealth.DeductHealth(dmg); }
void SearchForTarger() { // サーバーじゃなければメソッド終了 if (!isServer) { return; } // プレイヤーをまだ取得していないとき if (targetTransform == null) { // Physics.OverlapSphere: ある地点を中心に球を作り、衝突したオブジェクトを取得する // 第一引数: 中心点,第二引数: 半径, 第三引数: 対象レイヤー Collider[] hitColliders = Physics.OverlapSphere(myTransform.position, radius, raycastLayer); if (hitColliders.Length > 0) { // プレイヤーを発見した int randomInt = Random.Range(0, hitColliders.Length); // 複数発見した時はランダムに取得 targetTransform = hitColliders[randomInt].transform; } } if (targetTransform != null) { BoxCollider box = null; for (int i = 0; i < 10; i++) { box = targetTransform.GetComponent <BoxCollider>(); if (GameManagerRefarences.NullCheck(box, "targetBoxCollinder")) { Debug.Log("TargetName:" + targetTransform.gameObject.name); return; } } if (box.enabled == false) { targetTransform = null; } } }
void Start() { NullCheck(crosshairImage, "crosshairImage"); NullCheck(respawnButton, "respawnButton"); instance = this; }