Beispiel #1
0
        public GameSetup() : base(false)
        {
            playerAlreadyDead = false;

            GM.engineM.DebugDisplay = Debug.none;// Debug.fps | Debug.version | Debug.sprite;
            GM.engineM.ScreenColour = Color.Black;

            //create players and generate level layout
            playerChar = new PlayerOne();

            //Create cursor and places centre on mouse position
            Cursor cursor = new Cursor();

            //new PlayerTwo();
            GenerateLevel();

            //create a timer to track game time
            GM.eventM.AddTimer(tiGameTimer = new Event(0.01f, "timer"));

            //listen out for player death to manage lives and score
            MessageBus.Instance.Subscribe(ExtraMessageTypes.PlayerDestroyed, PlayerKilled);

            //Enemy generation
            enemySpawnSystem = new EnemySpawnSystem();
        }
        public void TestEnemySpawnSystem()
        {
            Texture2D tex = null;

            AssetsManager.Instance.AddTexture("sprEnemy0", tex);
            AssetsManager.Instance.AddTexture("sprEnemy1", tex);
            AssetsManager.Instance.AddTexture("sprEnemy2", tex);
            AssetsManager.Instance.AddAnimation("sprEnemy0", null);
            AssetsManager.Instance.AddAnimation("sprEnemy1", null);
            AssetsManager.Instance.AddAnimation("sprEnemy2", null);
            var state = new GameState();

            for (int i = 0; i < NUMBER_OF_ENTITIES; ++i)
            {
                state.GameData.EnemySpawner[i] = new EnemySpawner();
                state.GameData.Tags[i]         = 1;

                state.EntityCount++;
            }

            Console.WriteLine($"Number of entities: {state.EntityCount}");
            for (int i = 1; i < 33; ++i)
            {
                var system = new EnemySpawnSystem("EnemySpawn", state);
                RunSystem(system, i);
            }
            state.ClearState();
        }
Beispiel #3
0
 public static EnemySpawnSystem GetInstance()
 {
     if (Instance == null)
     {
         Instance = new EnemySpawnSystem();
     }
     return(Instance);
 }
Beispiel #4
0
 private void Start()
 {
     enemySpawnSystem = EnemySpawnSystem.Instance;
     foreach (var trigger in enemySpawnTrigger)
     {
         trigger.SetCollider(GetComponent <Collider>());
     }
 }
Beispiel #5
0
 void Start()
 {
     poolPoint = GameObject.FindGameObjectWithTag("PoolPoint").GetComponent <BulletPooler>();                 //Point pooler
     StartCoroutine("AddRotation");                                                                           //Add rotation
     spriteRendererComponent = GetComponentInChildren <SpriteRenderer>();
     lifeScript       = GetComponent <EnemyLife>();                                                           //Get life script
     enemySpawnSystem = GameObject.FindGameObjectWithTag("GameController").GetComponent <EnemySpawnSystem>(); //Find the enemySpawnSystem
 }
Beispiel #6
0
 void Update()
 {
     InputSystem.GetInstance().Update();
     PlayerMovementSystem.GetInstance().Update();
     SkillSystem.GetInstance().Update();
     EnemySpawnSystem.GetInstance().Update();
     EnemyMoveSystem.GetInstance().Update();
 }
Beispiel #7
0
    void Awake()
    {
        InputSystem.GetInstance();
        PlayerMovementSystem.GetInstance();
        SkillSystem.GetInstance();
        EnemySpawnSystem.GetInstance();
        EnemyMoveSystem.GetInstance();

        singletonContainer = transform.GetChild(0).gameObject;
        singletonContainer.AddComponent <InputSingleton>();
    }
Beispiel #8
0
    void Awake()
    {
        // if the singleton hasn't been initialized yet
        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
            return;
        }

        Instance = this;
    }
Beispiel #9
0
 public void Start()
 {
     BPButtonOne       = GameObject.Find("BPButtonEN");
     BuildPanel        = GameObject.Find("InGameUI").transform.Find("BuildPanel").gameObject;
     _buildSystem      = GameObject.Find("UniversalManager").GetComponent <BuildSystem>();
     _enemySpawnSystem = GameObject.Find("UniversalManager").GetComponent <EnemySpawnSystem>();
     _player           = GameObject.Find("Player").GetComponent <Player>();
     healthText        = healthTextGO.GetComponent <TextMeshProUGUI>();
     bankText          = bankTextGO.GetComponent <TextMeshProUGUI>();
     wavesText         = wavesTextGO.GetComponent <TextMeshProUGUI>();
     scoreText         = scoreTextGO.GetComponent <TextMeshProUGUI>();
     waveTimerText     = waveTimerTextGO.GetComponent <TextMeshProUGUI>();
 }
 void Start()
 {
     if(instance == null){ //checks if singleton exist or not
         instance = this;
     }else{ //if exists
         waiting_to_attack.Clear(); //clear the list of enemy attacks
         waiting_to_attack.TrimExcess(); //trims queue to original capacity
         Enemy.enemyAttack = false; //resets enemy permission to attack
         count = 0;
         Object.Destroy(this.gameObject); // destroys potential new instance of SpawnSystem
         index = 0;
     }
     DontDestroyOnLoad(transform.gameObject);
     spawn();
 }
    void Start()
    {
        chapter = select_manager.GetEChapter;

#if UNITY_EDITOR
        // for debug
        if (onDebug)
        {
            chapter = debug_chapter;
        }
#endif
        // none is for debug
        if (chapter == EChapter.none)
        {
            spawnLimits = new SpawnLimits(
                new SpawnLimit(soldier_SpawnTime, soldier_MaxNum),
                new SpawnLimit(tower_SpawnTime, tower_MaxNum),
                new SpawnLimit(roller_SpawnTime, roller_MaxNum));
            boss_obj = boss1_obj;
        }
        else if (chapter == EChapter.chapter_one)
        {
            spawnLimits = st1_limit;
            boss_obj    = boss1_obj;
        }
        else if (chapter == EChapter.chapter_two)
        {
            spawnLimits = st2_limit;
            boss_obj    = boss2_obj;
        }
        else if (chapter == EChapter.chapter_three)
        {
            spawnLimits = st3_limit;
            boss_obj    = boss3_obj;
        }

        enemySpawnSystems[(int)EEnemy.SOLDIER] = new EnemySpawnSystem(soldier_obj, soldier_offset_pos, soldier_spawn_range, spawnLimits.Soldier);
        enemySpawnSystems[(int)EEnemy.TOWER]   = new EnemySpawnSystem(tower_obj, tower_offset_pos, tower_spawn_range, spawnLimits.Tower);
        enemySpawnSystems[(int)EEnemy.ROLLER]  = new EnemySpawnSystem(roller_obj, roller_offset_pos, roller_spawn_range, spawnLimits.Roller);

        //enemySpawnSystems[(int)EEnemy.SOLDIER] = new EnemySpawnSystem(soldier_obj, soldier_offset_pos, soldier_spawn_range, soldier_spawn_time, soldier_max_num);
        //enemySpawnSystems[(int)EEnemy.TOWER] = new EnemySpawnSystem(tower_obj, tower_offset_pos, tower_spawn_range, tower_spawn_time, tower_max_num);
        //enemySpawnSystems[(int)EEnemy.ROLLER] = new EnemySpawnSystem(roller_obj, roller_offset_pos, roller_spawn_range, roller_spawn_time, roller_max_num);

        bossSpawnSystem = new EnemySpawnSystem(boss_obj, boss_offset_pos, boss_spawn_range);

        turn_dir_time = base_turn_dir_time;
    }
    void Start()
    {
        enemySpawnSystem = EnemySpawnSystem.Instance;
        if (enemySpawnSystem == null)
        {
            throw new System.Exception("no enemySpawnSystem in scene");
        }

        col = GetComponent <Collider>();
        if (col != null)
        {
            col.isTrigger = true;
        }
        defalseSpawnParticle = enemySpawnSystem.defalseSpawnParticle;
        defalseSpawnParticle.gameObject.SetActive(true);
    }
Beispiel #13
0
    private void Start()
    {
        //Initializing variables
        _buildSystem = GameObject.Find("UniversalManager").GetComponent <BuildSystem>();
        spawnSystem  = GameObject.Find("UniversalManager").GetComponent <EnemySpawnSystem>();
        _player      = GameObject.Find("Player").GetComponent <Player>();

        //Difficulty is increased by increasing the health of the enemy.
        //Health/Bounty is scaled by the current wave and a specified scale factor.
        float healthScale = (health * scaleFactor);

        health += (healthScale * spawnSystem.currentWave);
        float bountyScale = (float)(bounty * moneyScaleFactor);

        bounty    += (int)(bountyScale * spawnSystem.currentWave);
        baseHealth = health;
    }
Beispiel #14
0
    // Use this for initialization
    void Start()
    {
        GameManager.sTheGlobalBehavior = this;  // Singleton pattern
        // This must occur before EnemySystem's Start();
        Debug.Assert(mWayPoints != null);
        Debug.Assert(mHero != null);

        mMainCamera = Camera.main.GetComponent <CameraSupport>();
        Debug.Assert(mMainCamera != null);

        Bounds b = mMainCamera.GetWorldBound();

        mEnemySystem = new EnemySpawnSystem(b.min, b.max);
        // Make sure all enemy sees the same EnemySystem and WayPointSystem
        EnemyBehavior.InitializeEnemySystem(mEnemySystem, mWayPoints);
        mEnemySystem.GenerateEnemy();  // Can only create enemies when WayPoint is initialized in EnemyBehavior
    }
Beispiel #15
0
    public static void NewGame()
    {
        EnemySpawnSystem.SetupComponentData(World.Active.GetOrCreateManager <EntityManager>());

        var entityManager = World.Active.GetOrCreateManager <EntityManager>();

        var data = entityManager.GetComponentData <PlayerSessionData>(playerDataEntity);

        data.gameState = GameState.PLAYING;

        entityManager.SetComponentData(playerDataEntity, data);

//        var entityManager = World.Active.GetOrCreateManager<EntityManager>();

//        Entity curencyEntity = entityManager.CreateEntity(PlayerDataArchetype);
//        entityManager.SetComponentData(curencyEntity, new PlayerSessionData {CurrencyAmount = 10, Score = 0, Health = 10});
    }
Beispiel #16
0
    int NumEnemies()
    {
        int num = 0;

        if (spawnSystem == null)
        {
            spawnSystem = GetComponent <EnemySpawnSystem>();
        }

        foreach (GameObject enemy in spawnSystem.currentEnemies)
        {
            if (enemy != null && enemy.GetComponent <MemoryComponent>().IsActive())
            {
                num++;
            }
        }
        return(num);
    }
Beispiel #17
0
        public PlayState(StateManager managerRef)
        {
            manager = managerRef;
            //wonStateRef = new WonState(manager);
            if (GameData.currentLevel == 0)
            {
                Application.LoadLevel("ArcadeScene");
            }

            playerControllerRef = GameObject.Find("PlayerShip").GetComponent <PlayerController>();
            player = GameObject.FindGameObjectWithTag("Player");
            enemySpawnSystemRef                      = GameObject.Find("GameManager").GetComponent <EnemySpawnSystem>();
            playerControllerRef.canShoot             = true;
            player.GetComponent <Renderer>().enabled = true;
            lJet = player.GetComponentInChildren <ParticleSystem>();
            lJet.Play(true);
            healthBarLength = Screen.width / 4;
            Cursor.visible  = false;
        }
 // Start is called before the first frame update
 void Start()
 {
     enemySpawnSystem     = FindObjectOfType <EnemySpawnSystem>();
     enemyCount           = enemySpawnSystem.maxEnemys;
     currTimeBetweenWaves = maxTimebetweenWaves;
 }
Beispiel #19
0
 void Start()
 {
     scoreText      = GetComponent <Text>();
     scoreText.text = score.ToString();
     spawnSystem    = FindObjectOfType <EnemySpawnSystem>();
 }
Beispiel #20
0
 void Start()
 {
     spawnSystem = GetComponent <EnemySpawnSystem>();
     timekeeper  = Timekeeper.getInstance();
 }
 private void Awake()
 {
     instance = this;
 }
Beispiel #22
0
 static public void InitializeEnemySystem(EnemySpawnSystem s, WayPointSystem w)
 {
     sEnemySystem = s; sWayPoints = w;
 }