Пример #1
0
        public void Initialize(PlatoonBehaviour platoon)
        {
            TargetTuple = new TargetTuple(this);
            Platoon     = platoon;

            _unitData = gameObject.GetComponent <DataComponent>();

            _voiceComponent = gameObject.transform.Find("VoiceComponent")
                              .GetComponent <VoiceComponent>();
            _movementComponent = gameObject.GetComponent <MovementComponent>();
            _healthComponent   = gameObject.GetComponent <HealthComponent>();
            _armorComponent    = gameObject.GetComponent <ArmorComponent>();
            VisionComponent    = gameObject.GetComponent <VisionComponent>();
            _turretSystem      = gameObject.GetComponent <TurretSystem>();

            // Only used in this class, not really configurable,
            // and no way to get a reference to it here if it's
            // instantiated in the UnitFitter.
            // I think it's fine to leave it here.
            _selectionCircle = Instantiate(
                Resources.Load <GameObject>("SelectionCircle"), Transform);

            _movementComponent.Initialize();
            _healthComponent.Initialize(this, _unitData);
            VisionComponent.Initialize(this, _unitData);
            _armorComponent.Initialize(_healthComponent, _unitData, _movementComponent);

            _targetingOverlay = OverlayFactory.Instance.CreateTargetingOverlay(this);
            _targetingOverlay.gameObject.transform.parent = gameObject.transform;
        }
Пример #2
0
        public void Initialize(
            PlatoonBehaviour platoon,
            GameObject art,
            GameObject deathEffect,
            VoiceComponent voice)
        {
            _unitData = gameObject.GetComponent <DataComponent>();

            TargetType type = _unitData.ApImmunity ? TargetType.INFANTRY : TargetType.VEHICLE;

            TargetTuple = new TargetTuple(this, type);
            Platoon     = platoon;

            _art         = art;
            _deathEffect = deathEffect?.GetComponent <WreckComponent>();

            _voiceComponent    = voice;
            _movementComponent = gameObject.GetComponent <MovementComponent>();
            _healthComponent   = gameObject.GetComponent <HealthComponent>();
            _armorComponent    = gameObject.GetComponent <ArmorComponent>();
            VisionComponent    = gameObject.GetComponent <VisionComponent>();
            _turretSystem      = gameObject.GetComponent <TurretSystem>();

            // Only used in this class, not really configurable,
            // and no way to get a reference to it here if it's
            // instantiated in the UnitFitter.
            // I think it's fine to leave it here.
            _selectionCircle = Instantiate(
                Resources.Load <GameObject>("SelectionCircle"), Transform);

            _movementComponent.Initialize();

            _healthComponent.Initialize(this, _unitData);
            VisionComponent.Initialize(this, _unitData);
            _armorComponent.Initialize(_healthComponent, _unitData, _movementComponent);

            _targetingOverlay = OverlayFactory.Instance.CreateTargetingOverlay(this);
            _targetingOverlay.gameObject.transform.parent = gameObject.transform;
        }