Exemple #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;
        }
 private void Start()
 {
     //get the parent class component
     thisShip = GetComponent <Enemy>();
     //get the rigidbody2d component
     thisShip.controller = this.GetComponent <Rigidbody2D>();
     //get the turretsystem component
     shipTurrets = this.GetComponent <TurretSystem>();
 }
 public override void OnInspectorGUI()
 {
     turretSystem = target as TurretSystem;
     serializedObject.Update();
     groupList.DoLayoutList();
     turretList.DoLayoutList();
     if (GUILayout.Button("Sort Turrets")) {
         turretSystem.turrets.Sort(delegate(Turret a, Turret b) {
             return a.name.CompareTo(b.name);
         });
     }
     EditorGUILayout.PropertyField(serializedObject.FindProperty("tempTarget"));
     if (GUILayout.Button("Set All Turrets Target")) {
         turretSystem.SetAllTurretsTarget();
     }
     serializedObject.ApplyModifiedProperties();
 }
Exemple #4
0
 // Use this for initialization
 void Awake()
 {
     Debug.Log("nut1");
     initMaxSpeed     = maxSpeed;
     initShotInterval = shotInterval;
     //get the ship's rigidbody2d component, setting it in the controller variable
     attachTurretSystem         = this.GetComponent <TurretSystem>();
     controller                 = GetComponent <Rigidbody2D>();
     shipSizes                  = new Vector2(this.GetComponent <BoxCollider2D>().size.x, this.GetComponent <BoxCollider2D>().size.y);
     sharedInstance             = this;
     currentSpeed               = startSpeed;
     animComponent              = this.GetComponent <Animate>();
     animComponent.moveJoystick = moveJoystick;
     animComponent.go           = this.gameObject;
     this.transform.GetChild(0).GetComponent <Animate>().moveJoystick = moveJoystick;
     this.transform.GetChild(0).GetComponent <Animate>().go           = this.transform.GetChild(0).gameObject;
 }
Exemple #5
0
        /// <summary>
        ///     Unit initialization shared by both real units and their ghosts.
        /// </summary>
        /// <param name="freshUnit"></param>
        /// <param name="config"></param>
        private static void MakeUnitCommon(GameObject freshUnit, Unit armoryUnit)
        {
            freshUnit.name = armoryUnit.Name;
            freshUnit.SetActive(false);

            GameObject art = Object.Instantiate(armoryUnit.ArtPrefab);

            art.transform.parent = freshUnit.transform;

            DataComponent.CreateDataComponent(
                freshUnit, armoryUnit.Config, armoryUnit.MobilityData);

            // freshUnit.AddComponent<UnitDispatcher>().enabled = false;
            // freshUnit.AddComponent<MovementComponent>().enabled = false;
            // prototype.AddComponent<NetworkIdentity>();

            TurretSystem turretSystem = freshUnit.GetComponent <TurretSystem>();

            turretSystem.Initialize(freshUnit, armoryUnit);
        }
Exemple #6
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;
        }
 private void OnEnable()
 {
     turretSystem = target as TurretSystem;
     turretSystem.CollectTurrets();
     turretList = new ReorderableList(serializedObject, serializedObject.FindProperty("turrets"), true, true, false, false);
     turretList.drawElementCallback += DrawTurretCallback;
     turretList.drawHeaderCallback += DrawHeaderCallback;
     turretList.onSelectCallback -= SelectTurret;
     groupList = new ReorderableList(serializedObject, serializedObject.FindProperty("turretGroups"), true, true, true, true);
     groupList.elementHeight = EditorGUIUtility.singleLineHeight;
     //groupList.elementHeight = 6 * EditorGUIUtility.singleLineHeight;
     groupList.drawElementCallback += DrawTurretGroup;
     groupList.drawHeaderCallback += DrawTurretGroupHeader;
     groupList.onAddCallback += AddGroup;
     groupList.onCanRemoveCallback += CanRemoveGroup;
     groupList.onRemoveCallback += RemoveGroup;
     turretGroupNames = new List<string>();
     for (int i = 0; i < turretSystem.turretGroups.Count; i++) {
         turretGroupNames.Add(turretSystem.turretGroups[i].groupId);
     }
 }