Пример #1
0
        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();
     }
 }
Пример #3
0
 public EnemyModel(EnemyScriptableObject _enemyScriptableObject)
 {
     enemyMaterial = _enemyScriptableObject.enemyMaterial;
     enemySpeed    = _enemyScriptableObject.enemySpeed;
     enemyModel    = _enemyScriptableObject.enemyPrefab;
     health        = _enemyScriptableObject.enemyHealth;
     enemyType     = _enemyScriptableObject.type;
     enemyID      += 1;
 }
Пример #4
0
        private void CreateModel(EnemyScriptableObject _enemyScriptableObject, Vector3?_spawnPos = null)
        {
            EnemyModel _enemyModel = new EnemyModel(_enemyScriptableObject);

            currentEnemyModel = _enemyModel;
            if (_spawnPos != null)
            {
                SpawnEnemy(_enemyModel, _spawnPos);
            }
            else
            {
                SpawnEnemy(_enemyModel);
            }
        }
Пример #5
0
        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();
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
            }
        }
Пример #8
0
 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;
 }
Пример #9
0
 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;
 }
Пример #10
0
 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();
 }
Пример #11
0
 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;
 }
Пример #12
0
        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);
        }
Пример #13
0
        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);
        }
Пример #14
0
 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;
 }