public void SetSystem(PlayerSystem player) { if (player == null) { Debug.LogError($"{this} owner player is null"); return; } Owner = player; HealthSystem = new HealthSystem(this) { IsVulnerable = true }; AbilityControlSystem.Set(Data.Abilities); TraitControlSystem.Set(Data.Traits); }
public void UpdateSystem() { HealthSystem?.UpdateSystem(); AbilityControlSystem.UpdateSystem(); if (IsOn) { var waypointReached = Prefab.GetDistanceTo(waypoints[WaypointIndex]) < 30; if (WaypointIndex < waypoints.Count - 1) { if (!waypointReached) { MoveAndRotateEnemy(); } else { WaypointIndex++; } } else { LastWaypointReached?.Invoke(this); } } void MoveAndRotateEnemy() { var lookRotation = Quaternion.LookRotation(waypoints[WaypointIndex] - Prefab.transform.position); var rotation = Quaternion.Lerp(Prefab.transform.rotation, lookRotation, Time.deltaTime * 10f); rotation.z = 0; rotation.x = 0; Prefab.transform.Translate(Vector3.forward * (float)(Time.deltaTime * Data.Get(Enums.Enemy.MoveSpeed).Sum), Space.Self); Prefab.transform.localRotation = rotation; } }