コード例 #1
0
        void Start()
        {
            if (isLocalPlayer)
            {
                DisableControls = false;
                gameObject.GetComponent<AudioSource>().enabled = true;
                MyCamera.SetActive(true);
            }

            _spawnRotation = transform.rotation;
            _spawnPosition = transform.position;
            HealthIndicator.SetHealth(100);
            _firstPersonUi = (GameObject)Instantiate(Resources.Load("UI"));
            _healthBar =
                _firstPersonUi.transform.GetComponentsInChildren<RadialSlider>().First(s => s.tag == "HealthBar");
            //_healthBar = GameObject.FindGameObjectWithTag("HealthBar").GetComponent<RadialSlider>();
            //_reloadBar = GameObject.FindGameObjectWithTag("ReloadBar").GetComponent<RadialSlider>();
            _reloadBar =
                _firstPersonUi.transform.GetComponentsInChildren<RadialSlider>().First(s => s.tag == "ReloadBar");
            _reloadBar.gameObject.SetActive(false);
            _rb = gameObject.GetComponent<Rigidbody>();
            _health = Health;
            _mineAmount = MineStartAmount;
            _mineBar = _firstPersonUi.transform.GetComponentsInChildren<UiMineController>().First(s => s.tag == "MinesBar");
            _missileBar = _firstPersonUi.transform.GetComponentsInChildren<UiMissileController>().First(s => s.tag == "MissilesBar");
            _missileAmount = MissileStartAmount;
            //_mineBar = GameObject.FindGameObjectWithTag("MinesBar").GetComponent<UiMineController>();
            _mineBar.SetAvailableMines(_mineAmount);
            UpdateCameraMode();
            if (_weapon == null)
                _weapon = GameObject.FindGameObjectWithTag("GameScripts").GetComponent<BulletManager>();
            if (_missiles == null)
                _missiles = GameObject.FindGameObjectWithTag("GameScripts").GetComponent<MissileManager>();

            networkId = (short)GetComponent<NetworkIdentity>().netId.Value;
            _roundKeeper = GameObject.FindObjectOfType<RoundKeeper>();
        }
コード例 #2
0
ファイル: EnemyMovement.cs プロジェクト: wadum/TankDestroyers
        void Start()
        {
            NetworkId = (short)GetComponent<NetworkIdentity>().netId.Value;

            if (!isServer)
                return;

            GetComponent<NavMeshAgent>().enabled = true;
            InitiateSoundSettings();
            _bc = GameObject.FindGameObjectWithTag("GameScripts").GetComponent<BulletManager>();

            var allWaypoints = GameObject.FindGameObjectsWithTag(Constants.Tags.Waypoint).ToList();
            var selectedWapoints = allWaypoints.Select(go => go.transform)
                .OrderBy(t => Random.Range(0, allWaypoints.Count))
                .Take(NumberOfWaypoints)
                .ToList();

            _nav = GetComponent<NavMeshAgent>();
            _chaseState = new ChaseState(_nav);
            _patrolState = new PatrolState(_nav, selectedWapoints);
            _currentState = _patrolState;

            _spawnPos = transform.position;
            _spawnRot = transform.rotation;

            GameObject.FindGameObjectsWithTag("Waypoint");
            _roundKeeper = FindObjectOfType<RoundKeeper>();
        }