Inheritance: MonoBehaviour
Example #1
0
 // Use this for initialization
 void Awake()
 {
     //Make a reference to this
     current = this;
     //tweak position of the asteroid spawner
     spawnValues = transform.position;
     //SET THE POOLINGLIST, AND ADD INACTIVE GAMEOBJECTS
     hazardPool = new List <GameObject> ();
     //Loop through all the asteroid types
     for (int i = 0; i < hazards.Count; i++)
     {
         //Get a hazard from list
         hazard = hazards [i];
         //Add all the asteroids to the pool
         for (int p = 0; p < maxHazPool; p++)
         {
             //Instatiate the Asteroid
             GameObject obj = (GameObject)Instantiate(hazard);
             //make the hazards child of the Spawner
             obj.transform.parent = transform;
             //Set the pooled hazard to inactive
             obj.SetActive(false);
             //Add the pooled hazard to the hazardslist.
             hazardPool.Add(obj);
         }
     }
     //Start the SpawnWave routine
     StartCoroutine(SpawnWave());
 }
 public void setValues(float health, Vector2 direction, Size size, AsteroidSpawner parent)
 {
     this.parent = parent;
     parent.changeAsteroidCount(1);
     this.health      = health;
     this.baseHealth  = health;
     this.maxDamage   = this.maxDamage - ((2 - (int)size) * 0.25f) * this.maxDamage;
     this.score       = (int)(this.score - ((2 - (int)size) * 0.25f) * this.score);
     this.direction   = direction;
     this.rb.velocity = direction;
     this.size        = size;
     if (size == Size.Large)
     {
         this.rb.mass = 8f;
         this.transform.localScale = new Vector3(1f, 1f, 1f);
     }
     else if (size == Size.Medium)
     {
         this.rb.mass = 4f;
         this.transform.localScale = new Vector3(0.65f, 0.65f, 0.65f);
     }
     else if (size == Size.Small)
     {
         this.rb.mass = 2f;
         this.transform.localScale = new Vector3(0.35f, 0.35f, 0.35f);
     }
     //this.rb.angularVelocity = Random.Range(-3.8f* (2 - (int)size), 3.8f * (2 - (int)size));
 }
Example #3
0
        public Game(MainWindow window)
        {
            Window = window;
            Scene  = new Scene(this);

            AS = new AsteroidSpawner(this, 30, 100, 150, 100, 120, 1.7);
        }
Example #4
0
    public override void OnInspectorGUI()
    {
        AsteroidSpawner astSpawner = (AsteroidSpawner)target;

        DrawDefaultInspector();

        if (GUILayout.Button("Create Asteroid"))
        {
            if (astSpawner.asteroid != null)
            {
                DestroyImmediate(ProcAsteroid.asteroid);
                DestroyImmediate(astSpawner.asteroid);
            }

            astSpawner.CreateAsteroid();
        }

        if (astSpawner.asteroid && GUILayout.Button("Save Asteroid"))
        {
            System.IO.Directory.CreateDirectory(path);
            Mesh mesh = astSpawner.asteroid.GetComponent <MeshFilter>().sharedMesh;
            AssetDatabase.CreateAsset(mesh, assetpath + mesh.name + ".asset");
            AssetDatabase.SaveAssets();

            PrefabUtility.SaveAsPrefabAsset(astSpawner.asteroid, assetpath + filename + ".prefab");

            DestroyImmediate(ProcAsteroid.asteroid);
            DestroyImmediate(astSpawner.asteroid);
        }
    }
    void OnEnable()
    {
        spawner = GameObject.Find("GameController").GetComponent <AsteroidSpawner>();

        // when the asteroid is made, add force in a random direction as an impulse
        rb.AddForce(new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)) * pushForce, ForceMode2D.Impulse);
    }
 /// <summary>
 /// Start()
 /// Used for initialization
 /// </summary>
 void Start()
 {
     playerData   = GetComponent <PlayerData>();
     shipInfo     = ship.GetComponent <ShipInfo>();
     spawner      = GetComponent <AsteroidSpawner>();
     guiHandler   = GetComponent <GUIHandler>();
     inputHandler = GetComponent <InputHandler>();
 }
Example #7
0
 void OnDisable()
 {
     Score.OnChanged -= ScoreChanged;
     if (AsteroidSpawner.Exists())
     {
         AsteroidSpawner.Instance.OnAsteroidDestroyed -= AsteroidDestroyed;
     }
 }
 /// <summary>
 /// Start()
 /// Used for initialization
 /// </summary>
 void Start()
 {
     shipMovement    = ship.GetComponent <ShipMovement>();
     shipShooting    = ship.GetComponent <ShipShooting>();
     shipInfo        = ship.GetComponent <ShipInfo>();
     guiHandler      = GetComponent <GUIHandler>();
     asteroidSpawner = GetComponent <AsteroidSpawner>();
 }
Example #9
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         AsteroidSpawner script = this.transform.parent.GetComponent <AsteroidSpawner>();
         script.startStop();
     }
 }
Example #10
0
 //Property
 public static AsteroidSpawner GetInstance()
 {
     if (Instance == null)
     {
         Instance = new AsteroidSpawner();
     }
     return(Instance);
 }
Example #11
0
 public void TriggerSpawnpoints()
 {
     for (int i = 0; i < gameObject.transform.GetChildCount(); i++)
     {
         Transform _child = gameObject.transform.GetChild(i);
         _spawner = _child.gameObject.GetComponent <AsteroidSpawner>();
         _spawner.SpawnWithChance();
     }
 }
Example #12
0
    // Start is called before the first frame update
    void Start()
    {
        Instance = this;

        Spawn(1);
        Spawn(2);
        Spawn(3);
        Spawn(4);
    }
Example #13
0
 void Awake()
 {
     lifeTracker     = GameObject.FindGameObjectWithTag(Tags.guiController).GetComponent <LifeTracker>();
     respawnPosition = GameObject.FindGameObjectWithTag(Tags.player).transform.position;
     respawnRotation = GameObject.FindGameObjectWithTag(Tags.player).transform.rotation;
     hash            = GameObject.FindGameObjectWithTag(Tags.dataController).GetComponent <HashIDs>();
     gameOver        = GameObject.FindGameObjectWithTag(Tags.guiController).GetComponent <GameOverGUI>();
     spawner         = GameObject.FindGameObjectWithTag(Tags.dataController).GetComponent <AsteroidSpawner>();
 }
Example #14
0
 // Use this for initialization
 void Start()
 {
     TimeSinceLastSpawn = 0;
     Spawning           = false;
     Instance           = this;
     style                  = new GUIStyle();
     style.fontSize         = 32;
     style.normal.textColor = Color.black;
     style.alignment        = TextAnchor.MiddleCenter;
 }
Example #15
0
 protected override void Awake()
 {
     instance = this;
     base.Awake();
     spawner       = GetComponent <AsteroidSpawner>();
     ufoSpawner    = GetComponent <UFOSpawner>();
     BulletSpawner = GetComponent <BasicBulletSpawner>();
     spawner.AsteroidSplitDepth = DefaultAsteroidSplitCount;
     asteroidSplitCount         = DefaultAsteroidSplitCount;
 }
Example #16
0
    private void OnEnable()
    {
        // Init new "empty" Asteroid object
        AsteroidSpawner asteroidSpawner = GameObject.FindWithTag("Spawner").GetComponent <AsteroidSpawner>();

        data   = asteroidSpawner.asteroidData;
        level  = 0;
        Player = FindPlayer();
        SetLifeAndSprite();
    }
    private void Start()
    {
        if (instance != null)
        {
            Destroy(gameObject);
            return;
        }

        instance = this;
    }
Example #18
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #19
0
    public void Start()
    {
        CurrentLevelState   = LevelState.Paused;
        AsteroidThreatList  = new ArrayList();
        CurrentHomePosition = new Vector2(0, 0);
        levelIndex          = 0;

        asteroidSpawner = SpawnerObject.GetComponent <AsteroidSpawner>();

        _initializeSolarSystem();
    }
Example #20
0
    void Start()
    {
        // Initialize components
        _asteroidSpawner = Camera.main.GetComponent <AsteroidSpawner>();
        _rigidBody       = this.GetComponent <Rigidbody2D> ();
        _collider        = this.GetComponent <CircleCollider2D> ();

        rad = _collider.radius;
        colliderHalfWidth  = rad;
        colliderHalfHeight = rad;
    }
Example #21
0
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
     }
 }
Example #22
0
    public AsteroidsPool(AsteroidModel asteroidModel, List <AsteroidView> asteroidsView, Transform poolsParent,
                         SpawnerModel spawnerModel, DestructionAsteroidView destructionAsteroidView)
    {
        PoolManager.SetRoot(poolsParent);
        foreach (var asterod in asteroidsView)
        {
            PoolManager.WarmPool(asterod.gameObject, asteroidModel.AsteroidsCountInPool);
        }
        PoolManager.WarmPool(destructionAsteroidView.gameObject, 5);

        _spawner = new AsteroidSpawner(spawnerModel, asteroidModel, GetAsteroidsByType(asteroidsView), destructionAsteroidView);
    }
Example #23
0
    void Start()
    {
        Go.defaultEaseType = GoEaseType.CircIn;

        score       = GameObject.Find("Score").GetComponent <Score>();
        spawner     = GameObject.Find("Asteroid Spawner").GetComponent <AsteroidSpawner>();
        canvas      = GameObject.Find("Canvas").GetComponent <Canvas>();
        autopilot   = GameObject.Find("Autopilot").GetComponent <Autopilot>();
        welcomeText = GameObject.Find("WelcomeText").GetComponent <Text>();

        autopilot.enabled = false;
    }
Example #24
0
    void Start()
    {
        Aspawner      = FindObjectOfType <AsteroidSpawner>();
        effectSpawner = FindObjectOfType <EffectSpawner>();
        target        = GameObject.FindGameObjectWithTag("Ship").transform;

        initialPosition = transform.position;

        StartCoroutine(MoveBetweenTwoLocations(destinations));

        InvokeRepeating("ShootPlayerShip", 1.5f, 2.0f);
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        AsteroidSpawner myScript = (AsteroidSpawner)target;

        if (GUILayout.Button("Regenerate"))
        {
            myScript.destroyAsteroids();
            myScript.spawnAsteroids();
        }
    }
Example #26
0
    void Start()
    {
        Go.defaultEaseType = GoEaseType.CircIn;

        score = GameObject.Find("Score").GetComponent<Score>();
        spawner = GameObject.Find("Asteroid Spawner").GetComponent<AsteroidSpawner>();
        canvas = GameObject.Find("Canvas").GetComponent<Canvas>();
        autopilot = GameObject.Find("Autopilot").GetComponent<Autopilot>();
        welcomeText = GameObject.Find("WelcomeText").GetComponent<Text>();

        autopilot.enabled = false;
    }
Example #27
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Example #28
0
        public override void Initialize()
        {
            Camera = new Camera((AsteroidDestroyer)game, new Vector3(0, 3, 10), 5f);

            skybox = new Skybox(game, Resources.Instance.GetModel("skybox"), Resources.Instance.GetTexture("stars"), this);
            game.Components.Add(skybox);

            spawner = new AsteroidSpawner((int)Resources.Instance.GameSize, (int)Resources.Instance.GameCount);

            modelLookup = new Dictionary<int, MobileMeshModel>();

            base.Initialize();
        }
Example #29
0
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
        }

        hitListener = new UnityAction(SpawAsteroids);
    }
Example #30
0
 void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         //  DontDestroyOnLoad(gameObject);
     }
     asteroids = new GameObject("asteroids");
 }
Example #31
0
 // spawn the asteroids when game is running
 // if it is currently level one, will spawn one set of asteroids every fix peroid of time
 // if it is currently level two, will spawn two set ...
 void SpawnAsteroids()
 {
     instantiationTimer -= Time.deltaTime;
     if (instantiationTimer <= 0 && gameRunning == true)
     {
         for (int i = 0; i < currentLevel; i++)
         {
             AsteroidSpawner.GetInstance().SpawnAsteroids(prefabs);
         }
         //spawn new asteroids every set seconds after the initial spawn
         instantiationTimer = respawnSeconds;
     }
 }
Example #32
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        spaceShip = FindObjectOfType <Spaceship>();
    }
Example #33
0
 void Awake()
 {
     if (this.gameObject.tag != "AsteroidSpawner")
     {
         this.gameObject.tag = "AsteroidSpawner";
         Debug.LogWarning("AsteroidSpawner tag was missing, adding.");
     }
     if (spawnerGod == null)
     {
         spawnerGod = this;
         Log("spawnerGod set to : " + this.gameObject.name);
     }
     //spawnerExists = true;
 }
Example #34
0
	void Awake () 
	{
		asteroidSpawner = GetComponent<AsteroidSpawner> ();
	}