示例#1
0
 private void TryToKill()
 {
     if (timeFinished && particlesFinished && soundFinished)
     {
         GobPool.Destroy(gameObject);
     }
 }
示例#2
0
    private void ShootBullet()
    {
        GameObject b  = GobPool.Instantiate(bulletPrefab);
        Bullet     bc = b.GetComponent <Bullet>();

        b.transform.SetPositionAndRotation(gunBarrel.position, gunBarrel.rotation);
        bc.Start();
        bc.Velocity = gunBarrel.forward * 30 + velocity;
        bc.wobble   = 0;
        if (gunPower / maxGunPower > gunWaveThreshold)
        {
            bc.wobble = 0.5f;
        }
        if (gunPower / maxGunPower > gunSpreadThreshold)
        {
            bc.wobble = 1;
            b         = GobPool.Instantiate(bulletPrefab);
            bc        = b.GetComponent <Bullet>();
            b.transform.SetPositionAndRotation(gunBarrel.position, gunBarrel.rotation * Quaternion.FromToRotation(Vector3.forward, new Vector3(0, 0.25f, 0.75f)));
            bc.Start();
            bc.Velocity = b.transform.forward * 30 + velocity;
            bc.wobble   = 0.5f;

            b  = GobPool.Instantiate(bulletPrefab);
            bc = b.GetComponent <Bullet>();
            b.transform.SetPositionAndRotation(gunBarrel.position, gunBarrel.rotation * Quaternion.FromToRotation(Vector3.forward, new Vector3(0, -0.25f, 0.75f)));
            bc.Start();
            bc.Velocity = b.transform.forward * 30 + velocity;
            bc.wobble   = 0.5f;
        }
    }
示例#3
0
    private void NonStaticCreateFx(int fxIndex, Vector3 position, Quaternion rotation)
    {
        var gob = GobPool.Instantiate(Fx[fxIndex]);

        gob.transform.position = position;
        gob.transform.rotation = rotation;
    }
示例#4
0
 public static void Clear()
 {
     foreach (var p in _instance.pool.Keys)
     {
         ClearPool(p);
     }
     _instance = null;
 }
示例#5
0
 void Start()
 {
     if (instance != null)
     {
         Clear();
     }
     instance = this;
     pool     = new Dictionary <string, Stack <GameObject> >();
 }
示例#6
0
 void Update()
 {
     realPosition      += Velocity * Time.deltaTime;
     transform.position = realPosition + (transform.up * wobble * Mathf.Sin((Time.time - startTime) * 50));
     timer -= Time.deltaTime;
     if (timer < 0)
     {
         GobPool.Destroy(gameObject);
     }
 }
示例#7
0
    void SpawnBird()
    {
        GameObject gob = GobPool.Instantiate(birdPrefab);

        gob.transform.SetPositionAndRotation(transform.position, transform.rotation);
        BirdDriver bd = gob.GetComponent <BirdDriver>();

        if (bd)
        {
            bd.Start();
        }
    }
示例#8
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag.Equals("PlayerBullet"))
     {
         GobPool.Destroy(other.gameObject);
         bossHP--;
         DataDump.SetInt("BossHP", bossHP);
         if (bossHP < 0)
         {
             Doomed();
         }
     }
 }
示例#9
0
 public static void Destroy(GameObject o)
 {
     if (instance == null)
     {
         instance = GameObject.Find("GameDirector").GetComponent <GobPool>();
     }
     if (!instance.pool.ContainsKey(o.tag))
     {
         instance.pool.Add(o.tag, new Stack <GameObject>());
     }
     instance.pool[o.tag].Push(o);
     o.SetActive(false);
 }
示例#10
0
    public static GameObject Instantiate(GameObject o)
    {
        if (instance == null)
        {
            instance = GameObject.Find("GameDirector").GetComponent <GobPool>();
        }
        GameObject newObject = instance.pool.ContainsKey(o.tag) && instance.pool[o.tag].Count > 0 ?
                               instance.pool[o.tag].Pop() :
                               GameObject.Instantiate(o);

        newObject.SetActive(true);
        return(newObject);
    }
示例#11
0
 public static void Clear()
 {
     if (instance == null)
     {
         return;
     }
     foreach (var p in instance.pool.Values)
     {
         while (p.Count > 0)
         {
             Destroy(p.Pop());
         }
     }
     instance.pool.Clear();
     instance = null;
 }
示例#12
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag.Equals("PlayerBullet"))
     {
         GobPool.Destroy(other.gameObject);
         DataDump.SetInt("BirdsKilled", DataDump.GetInt("BirdsKilled") + 1);
         var df = GobPool.Instantiate(deadFacade);
         df.transform.SetPositionAndRotation(transform.position, Quaternion.identity);
         Doomed();
     }
     if (other.tag.Equals("Player"))
     {
         DataDump.SetInt("BirdsKilled", DataDump.GetInt("BirdsKilled") + 1);
         other.GetComponent <ShipDriver>().TakeDamage(1);
         var df = GobPool.Instantiate(deadFacade);
         df.transform.SetPositionAndRotation(transform.position, Quaternion.identity);
         Doomed();
     }
 }
示例#13
0
    private void Update()
    {
        stateTimer -= Time.deltaTime;
        if (stateTimer < 0)
        {
            switch (state)
            {
            case State.Wave:
                stateTimer = 15;
                spawnWave.SetActive(true);
                spawnBomb.SetActive(false);
                state = State.Bombers;
                break;

            case State.Bombers:
                stateTimer = 15;
                spawnWave.SetActive(false);
                spawnBomb.SetActive(true);
                state = State.Rest;
                break;

            case State.Rest:
                stateTimer = 10;
                spawnWave.SetActive(false);
                spawnBomb.SetActive(false);
                state = State.Wave;
                break;
            }
        }
        if (hpSpawns * 100 > bossHP)
        {
            hpSpawns--;
            var gob = GobPool.Instantiate(hpDrop);
            gob.transform.SetPositionAndRotation(transform.position, transform.rotation);
        }
    }
示例#14
0
 void Start()
 {
     GobPool.Clear();
     currentState = new IntroState();
     currentState.OnEnter();
 }
示例#15
0
 protected virtual void Doomed()
 {
     lifeTimer = 10;
     GobPool.Destroy(gameObject);
 }
示例#16
0
 public virtual void Doomed()
 {
     lifeTimer   = 10;
     sentMessage = false;
     GobPool.Destroy(gameObject);
 }
示例#17
0
 private void Awake()
 {
     _instance = this.CheckSingleton(_instance);
     pool      = new Dictionary <string, Stack <GameObject> >();
 }