public void SetConstructorArguments(EnemyScriptableObject _enemyScriptableObject, Vector3?_spawnPos = null) { // if(this.enemyScriptableObject!=null) // { // return; // } // if(this.currentEnemyView!=null) // { // this.currentEnemyView.gameObject.transform.position= new Vector3(UnityEngine.Random.Range(-30,30),0,UnityEngine.Random.Range(-30,30)); // return; // } if (currentEnemyView != null) { SetViewActive(); return; } enemyScriptableObject = _enemyScriptableObject; if (_spawnPos != null) { CreateModel(_enemyScriptableObject, _spawnPos); } else { CreateModel(_enemyScriptableObject); } currentState = currentEnemyView.gameObject.GetComponent <PatrollingState>(); currentStateMachine.ChangeCurrentState(currentEnemyView.gameObject.GetComponent <PatrollingState>()); enemyID = currentEnemyModel.GetID(); }
private void StartGame() { enemyConfig = enemyList.enemy[UnityEngine.Random.Range(0, enemyList.enemy.Length)]; if (Input.GetKeyDown(KeyCode.Space)) { CreateEnemy(); } }
public EnemyModel(EnemyScriptableObject _enemyScriptableObject) { enemyMaterial = _enemyScriptableObject.enemyMaterial; enemySpeed = _enemyScriptableObject.enemySpeed; enemyModel = _enemyScriptableObject.enemyPrefab; health = _enemyScriptableObject.enemyHealth; enemyType = _enemyScriptableObject.type; enemyID += 1; }
private void CreateModel(EnemyScriptableObject _enemyScriptableObject, Vector3?_spawnPos = null) { EnemyModel _enemyModel = new EnemyModel(_enemyScriptableObject); currentEnemyModel = _enemyModel; if (_spawnPos != null) { SpawnEnemy(_enemyModel, _spawnPos); } else { SpawnEnemy(_enemyModel); } }
public EnemyController(IEnemyService _enemyService, IPathService _pathService, IGameService _gameService, Vector3 _spawnLocation, EnemyScriptableObject _enemyScriptableObject, int _currentNodeID, Directions _spawnDirection, bool _hasShield) { currentEnemyService = _enemyService; spawnLocation = _spawnLocation; enemyScriptableObject = _enemyScriptableObject; pathService = _pathService; spawnDirection = _spawnDirection; currentNodeID = _currentNodeID; gameService = _gameService; hasShield = _hasShield; stateMachine = new EnemyStateMachine(); SpawnEnemyView(); PopulateDirectionList(); }
public Vector3 CreateEnemyController(EnemyScriptableObject _enemyScriptableObject, Vector3?_spawnPos = null) { EnemyController enemy = objectPool.Get <EnemyController>(); enemy.SetConstructorArguments(_enemyScriptableObject, _spawnPos = null); var view = enemy.GetView(); var t = view.gameObject.transform; t.SetParent(enemyHolder.transform); var currentLocation = enemy.GetPosition(); //spawnedEnemies.Add(enemy); return(currentLocation); }
private void SpawnEnemyControllers() { if (listOfEnemies.isUnique) { if (listOfEnemies.enemiesToSpawn > listOfEnemies.enemyList.Count) { Debug.Log("More scirptable objects needed"); return; } } for (int i = 0; i < listOfEnemies.enemiesToSpawn; i++) { EnemyData newData = new EnemyData(); int index = UnityEngine.Random.Range(0, listOfEnemies.enemyList.Count); newData.indexOfScriptableObj = index; EnemyScriptableObject _newEnemyObj = listOfEnemies.enemyList.ElementAt(index); newData.spawnPosition = CreateEnemyController(_newEnemyObj); enemyDataList.Add(newData); } }
public SniperEnemyController(IEnemyService _enemyService, IPathService _pathService, IGameService _gameService, Vector3 _spawnLocation, EnemyScriptableObject _enemyScriptableObject, int currentNodeID, Directions spawnDirection, bool _hasShield) : base(_enemyService, _pathService, _gameService, _spawnLocation, _enemyScriptableObject, currentNodeID, spawnDirection, _hasShield) { enemyType = EnemyType.SNIPER; }
public GuardWithTorchEnemyController(IEnemyService _enemyService, IPathService _pathService, IGameService _gameService, Vector3 _spawnLocation, EnemyScriptableObject _enemyScriptableObject, int currentNodeID, Directions spawnDirection, bool _hasShield) : base(_enemyService, _pathService, _gameService, _spawnLocation, _enemyScriptableObject, currentNodeID, spawnDirection, _hasShield) { enemyType = EnemyType.GUARD_TORCH; }
public BiDirectionalEnemyController(IEnemyService _enemyService, IPathService _pathService, IGameService _gameService, Vector3 _spawnLocation, EnemyScriptableObject _enemyScriptableObject, int currentNodeID, Directions spawnDirection, bool _hasShield) : base(_enemyService, _pathService, _gameService, _spawnLocation, _enemyScriptableObject, currentNodeID, spawnDirection, _hasShield) { enemyType = EnemyType.BIDIRECTIONAL; SetSecondDirection(); }
public RotatingKnifeEnemyController(IEnemyService _enemyService, IPathService _pathService, IGameService _gameService, Vector3 _spawnLocation, EnemyScriptableObject _enemyScriptableObject, int currentNodeID, Directions spawnDirection, bool _hasShield) : base(_enemyService, _pathService, _gameService, _spawnLocation, _enemyScriptableObject, currentNodeID, spawnDirection, _hasShield) { enemyType = EnemyType.ROTATING_KNIFE; }
public DogsEnemyController(IEnemyService _enemyService, IPathService _pathService, IGameService _gameService, SignalBus _signalBus, Vector3 _spawnLocation, EnemyScriptableObject _enemyScriptableObject, int currentNodeID, Directions spawnDirection, bool _hasShield) : base(_enemyService, _pathService, _gameService, _spawnLocation, _enemyScriptableObject, currentNodeID, spawnDirection, _hasShield) { enemyType = EnemyType.DOGS; signalBus = _signalBus; newDirection = spawnDirection; signalBus.Subscribe <NewDogDestinationSignal>(ChangeDestination); }
private List <IEnemyController> SpawnSingleEnemyLocations(EnemyScriptableObject _enemyScriptableObject) { List <EnemySpawnData> spawnNodeID = new List <EnemySpawnData>(); List <IEnemyController> newEnemyControllers = new List <IEnemyController>(); spawnNodeID.Clear(); spawnNodeID = pathService.GetEnemySpawnLocation(_enemyScriptableObject.enemyType); switch (_enemyScriptableObject.enemyType) { case EnemyType.STATIC: for (int i = 0; i < spawnNodeID.Count; i++) { Vector3 spawnLocation = pathService.GetNodeLocation(spawnNodeID[i].node); IEnemyController newEnemy = new StaticEnemyController(enemyService, pathService, gameService, spawnLocation, _enemyScriptableObject, spawnNodeID[i].node, spawnNodeID[i].dir, spawnNodeID[i].hasShield); newEnemyControllers.Add(newEnemy); } break; case EnemyType.PATROLLING: for (int i = 0; i < spawnNodeID.Count; i++) { Vector3 spawnLocation = pathService.GetNodeLocation(spawnNodeID[i].node); IEnemyController newEnemy = new PatrollingEnemyController(enemyService, pathService, gameService, spawnLocation, _enemyScriptableObject, spawnNodeID[i].node, spawnNodeID[i].dir, spawnNodeID[i].hasShield); newEnemyControllers.Add(newEnemy); } break; case EnemyType.ROTATING_KNIFE: for (int i = 0; i < spawnNodeID.Count; i++) { Vector3 spawnLocation = pathService.GetNodeLocation(spawnNodeID[i].node); IEnemyController newEnemy = new RotatingKnifeEnemyController(enemyService, pathService, gameService, spawnLocation, _enemyScriptableObject, spawnNodeID[i].node, spawnNodeID[i].dir, spawnNodeID[i].hasShield); newEnemyControllers.Add(newEnemy); } break; case EnemyType.CIRCULAR_COP: for (int i = 0; i < spawnNodeID.Count; i++) { Vector3 spawnLocation = pathService.GetNodeLocation(spawnNodeID[i].node); IEnemyController newEnemy = new CircularCopEnemyController(enemyService, pathService, gameService, spawnLocation, _enemyScriptableObject, spawnNodeID[i].node, spawnNodeID[i].dir, spawnNodeID[i].hasShield); newEnemy.SetCircularCopID(cID); newEnemyControllers.Add(newEnemy); cID++; } break; case EnemyType.DOGS: for (int i = 0; i < spawnNodeID.Count; i++) { Vector3 spawnLocation = pathService.GetNodeLocation(spawnNodeID[i].node); IEnemyController newEnemy = new DogsEnemyController(enemyService, pathService, gameService, signalBus, spawnLocation, _enemyScriptableObject, spawnNodeID[i].node, spawnNodeID[i].dir, spawnNodeID[i].hasShield); newEnemyControllers.Add(newEnemy); } break; case EnemyType.SNIPER: for (int i = 0; i < spawnNodeID.Count; i++) { Vector3 spawnLocation = pathService.GetNodeLocation(spawnNodeID[i].node); IEnemyController newEnemy = new SniperEnemyController(enemyService, pathService, gameService, spawnLocation, _enemyScriptableObject, spawnNodeID[i].node, spawnNodeID[i].dir, spawnNodeID[i].hasShield); newEnemyControllers.Add(newEnemy); } break; case EnemyType.TARGET: for (int i = 0; i < spawnNodeID.Count; i++) { Vector3 spawnLocation = pathService.GetNodeLocation(spawnNodeID[i].node); IEnemyController newEnemy = new TargetEnemyController(enemyService, pathService, gameService, spawnLocation, _enemyScriptableObject, spawnNodeID[i].node, spawnNodeID[i].dir, spawnNodeID[i].hasShield); newEnemyControllers.Add(newEnemy); } break; case EnemyType.BIDIRECTIONAL: for (int i = 0; i < spawnNodeID.Count; i++) { Vector3 spawnLocation = pathService.GetNodeLocation(spawnNodeID[i].node); IEnemyController newEnemy = new BiDirectionalEnemyController(enemyService, pathService, gameService, spawnLocation, _enemyScriptableObject, spawnNodeID[i].node, spawnNodeID[i].dir, spawnNodeID[i].hasShield); newEnemyControllers.Add(newEnemy); } break; case EnemyType.GUARD_TORCH: for (int i = 0; i < spawnNodeID.Count; i++) { Vector3 spawnLocation = pathService.GetNodeLocation(spawnNodeID[i].node); IEnemyController newEnemy = new GuardWithTorchEnemyController(enemyService, pathService, gameService, spawnLocation, _enemyScriptableObject, spawnNodeID[i].node, spawnNodeID[i].dir, spawnNodeID[i].hasShield); newEnemyControllers.Add(newEnemy); } break; default: break; } return(newEnemyControllers); }
public CircularCopEnemyController(IEnemyService _enemyService, IPathService _pathService, IGameService _gameService, Vector3 _spawnLocation, EnemyScriptableObject _enemyScriptableObject, int currentNodeID, Directions spawnDirection, bool _hasShield) : base(_enemyService, _pathService, _gameService, _spawnLocation, _enemyScriptableObject, currentNodeID, spawnDirection, _hasShield) { enemyType = EnemyType.CIRCULAR_COP; }