Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Create a pair of platoon and ghost platoon with units, but don't
        ///     activate any real units yet (only ghost mode).
        /// </summary>
        /// <param name="unit"></param>
        /// <param name="owner"></param>
        /// <returns></returns>
        public static PlatoonBehaviour CreateGhostMode(Unit unit, PlayerData owner)
        {
            PlatoonBehaviour realPlatoon = Instantiate(
                Resources.Load <GameObject>(
                    "Platoon")).GetComponent <PlatoonBehaviour>();

            realPlatoon.GhostPlatoon = Instantiate(
                Resources.Load <GameObject>(
                    "GhostPlatoon")).GetComponent <GhostPlatoonBehaviour>();

            realPlatoon.GhostPlatoon.Initialize(unit, owner);
            realPlatoon.Initialize(unit, owner);

            return(realPlatoon);
        }
Ejemplo n.º 3
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;
        }