public Unit truck; // Add in scene // Start is called before the first frame update void Start() { _unitCommandManager = UnitCommandManager.Instance; _uiOverlayManager = UiOverlayManager.Instance; _ringVisibilityManager = RingVisibilityManager.Instance; _startingPoint = new Vector3(); _endingPoint = new Vector3(); _markedUnitsMemory = new List <GameObject> [10]; for (int i = 0; i < 10; i++) { _markedUnitsMemory[i] = new List <GameObject>(); } truck = GameObject.Find("BulletTowerTruck").GetComponent <Unit>(); }
public void Start() { if (_startHasRun) { return; } Health = MaxHealth; _animRef = GetComponentInChildren <Animator>(); if (_animRef != null) { _animRef.SetFloat("RandomOffset", UnityEngine.Random.Range(0f, 1f)); } if (TryGetComponent <IAstarAI>(out _aiRef)) { _aiRef.maxSpeed = MoveSpeed; ((RichAI)_aiRef).rotationSpeed = MaxRotatingSpeed; } if (TryGetComponent <RVOController>(out _rvoRef)) { _rvoRef.StartMoving += AnimatorStartMoving; _rvoRef.StopMoving += AnimatorStopMoving; } if (TryGetComponent <RTSAvoidance>(out _avoidanceRef)) { _avoidanceRef.ReachedDestinationCallback += NextDestination; } _rangeCollider = gameObject.AddComponent <SphereCollider>(); _rangeCollider.radius = DetectionRange; _rangeCollider.isTrigger = true; if (TryGetComponent <Weapon>(out _weaponRef)) { _weaponRef.RotationSpeed = _weaponRef.CanMoveWhileAttacking ? _weaponRef.RotationSpeed : MaxRotatingSpeed; } _armorRef = GetComponent <Armor>(); _light = GetComponent <UnitAlignmentIndicator>(); Rigidbody rigidbody = gameObject.AddComponent <Rigidbody>(); rigidbody.isKinematic = true; _uiOverlayManager = UiToGameManager.Instance.GetUiOverlayManager(); _healthBar = _uiOverlayManager.CreateUnitHealthBar(Health, MaxHealth, this.Alignment); if (this.Alignment == Alignment.Friendly) { DeathCallback = () => { RTSUnitManager.Instance.ReportUnitDead(gameObject); }; } else { DeathCallback = () => { ResourceManager.Instance.IncreaseRamen(OnEnemyDeathReward); }; } if (selectRingPrefab != null) { _selectRing = Instantiate(selectRingPrefab, gameObject.transform); _selectRing.transform.localScale = selectRingSize; } if (_aiRef != null) { Move(transform.position, MovementMode.Move); } _startHasRun = true; }
void Start() { _uiOverlayManager = UiOverlayManager.Instance; }