Example #1
0
        // PUBLIC


        // PUBLIC STATIC
        /// <summary>
        /// Dos the create spider.
        /// </summary>
        public GameObject doCreateSpider(RoundDataVO aRoundDataVO)
        {
            //POSITION
            float spawnRadius_float  = _getRadiusFromGameObject(spawnSphereGameObject);
            float attackRadius_float = _getRadiusFromGameObject(attackSphereGameObject);
            //
            float spawnAngle_float;

            if (enemyPlacement == EnemyPlacement.DEBUG)
            {
                spawnAngle_float = 90;
            }
            else
            {
                spawnAngle_float = Random.Range(0, 360);

                //round to 'space apart' the spawning
                //NOTE: This discourages (but not eliminates) placing overlapping spiders
                spawnAngle_float = Mathf.Round(spawnAngle_float / 36) * 36;
            }


            //
            spawnAngle_float = Mathf.Deg2Rad * spawnAngle_float;
            float spawnX_float = Mathf.Cos(spawnAngle_float) * spawnRadius_float;
            float spawnZ_float = Mathf.Sin(spawnAngle_float) * spawnRadius_float;


            //CREATE ENEMY AND SET THE TARGET IS SHOULD CHASE
            GameObject spider_gameobject =
                Instantiate(
                    spiderPrefabGameObject,
                    new Vector3(spawnX_float, EnemyUI.DEFAULT_Y_POSITION, spawnZ_float), Quaternion.identity
                    ) as GameObject;

            //
            spider_gameobject.transform.parent = enemyParentGameObject.transform;

            //SET BASIC PARAMETERS FOR BEHAVIOR
            float enemyHealth_float = aRoundDataVO.enemyHealthRange.getRandomIntValueWithinRange();             //use int
            float enemySpeed_float  = aRoundDataVO.enemySpeedRange.getRandomFloatValueWithinRange();            //use float

            spider_gameobject.GetComponent <EnemyUI>().setParameters(
                targetGameObject,
                attackRadius_float,
                enemyHealth_float,
                enemySpeed_float);

            //TODO: ENSURE A SPIDER IS NOT SPAWNED ON TOP OF AN OTHER ONE
            //TODO: ENSURE SPIDERS COME FROM 'ALL AROUND' WITHOUT 'REPEATING TOO MUCH'

            //
            return(spider_gameobject);
        }
Example #2
0
        /// <summary>
        /// Do create next spider batch.
        /// </summary>
        /// <param name="aRoundDataVO">A round data V.</param>
        private void _doCreateNextSpiderBatch(RoundDataVO aRoundDataVO)
        {
            //how many to create?
            //1. get a number within range
            //2. be sure not to exceed the remaining allowed
            int enemiesToSpawnAtOnce_int = aRoundDataVO.enemiesSpawnedAtOnceRange.getRandomIntValueWithinRange();

            enemiesToSpawnAtOnce_int = (int)Mathf.Clamp((float)enemiesToSpawnAtOnce_int, 0, iGameModel.currentRoundDataVO.enemiesTotalToCreate - iGameModel.currentRoundDataVO.enemiesCreated);

            //
            for (var enemyToSpawnIndex_int = 0; enemyToSpawnIndex_int < enemiesToSpawnAtOnce_int; enemyToSpawnIndex_int++)
            {
                iGameModel.currentRoundDataVO.addEnemy(view.doCreateSpider(iGameModel.currentRoundDataVO));
            }
        }
Example #3
0
        /// <summary>
        /// Starts the next round.
        /// </summary>
        public void doRoundStart()
        {
            //
            _currentRound_uint++;

            //
            uint  enemiesPerRound_uint       = _currentRound_uint * _ENEMIES_PER_ROUND / 2;
            Range enemiesSpawnedAtOnce_range = new Range(1, _currentRound_uint);
            Range enemyHealth_range          = new Range(11, 22);
            Range enemySpeed_range           = new Range(1f, 2f);

            //
            currentRoundDataVO = new RoundDataVO(
                _currentRound_uint,
                enemiesPerRound_uint,
                enemiesSpawnedAtOnce_range,
                enemyHealth_range,
                enemySpeed_range
                );
        }
Example #4
0
        /// <summary>
        /// Starts the next round.
        /// </summary>
        public void doRoundStart()
        {
            //
            _currentRound_uint++;

            //
            uint  goalsRequiredToWin_uint    = _currentRound_uint * _GOALS_REQUIRED_PER_ROUND;
            Range enemiesSpawnedAtOnce_range = new Range(1, _currentRound_uint);
            Range enemyHealth_range          = new Range(11, 22);
            Range enemySpeed_range           = new Range(1f, 2f);

            //
            currentRoundDataVO = new RoundDataVO(
                _currentRound_uint,
                goalsRequiredToWin_uint,
                enemiesSpawnedAtOnce_range,
                enemyHealth_range,
                enemySpeed_range
                );
        }
Example #5
0
        /// <summary>
        /// Starts the next round.
        /// </summary>
        public void doRoundStart()
        {
            //
            _currentRound_uint++;

            //
            uint  currentRound_uint        = _currentRound_uint;
            uint  playerGoalsRequiredToWin = _currentRound_uint * _PLAYER_GOALS_REQUIRED_PER_ROUND_MULTIPLYER;
            uint  cpuGoalsRequiredToLose   = _CPU_GOALS_REQUIRED_PER_ROUND;
            Range cpuMoveSpeed_range       = new Range(
                Constants.PADDLE_Y_LERP_ACCELERATION_DEFAULT_MINIMUM,
                Constants.PADDLE_Y_LERP_ACCELERATION_DEFAULT_MAXIMUM
                );                 //lock to one value, but you can put a range here (optional)

            //
            currentRoundDataVO = new RoundDataVO(
                currentRound_uint,
                playerGoalsRequiredToWin,
                cpuGoalsRequiredToLose,
                cpuMoveSpeed_range
                );
        }
Example #6
0
        //	PUBLIC


        // PRIVATE

        // PRIVATE STATIC

        // PRIVATE COROUTINE

        // PRIVATE INVOKE

        //--------------------------------------
        //  Events
        //--------------------------------------
        /// <summary>
        /// When the round started signal.
        /// </summary>
        /// <param name="aRoundDataVO">A round data V.</param>
        //TODO: IS THIS SIGNAL NEEDED, WHY NOT JUST CHECK ONGAMESTATE?
        private void _onRoundStartedSignal(RoundDataVO aRoundDataVO)
        {
        }