コード例 #1
0
    /*
     * public static ParticleSystem GetSystem()
     * {
     *  ParticleSystem retSystem;
     *
     *  if (deadParticleSystems.Count > 0)
     *  {
     *      retSystem = deadParticleSystems[0];
     *      deadParticleSystems.RemoveAt(0);
     *      particleSystems.Add(retSystem);
     *      return retSystem;
     *  }
     *  GameObject newSystem = Instantiate(particleSystemFab);
     *  retSystem = newSystem.GetComponent<ParticleSystem>();
     *  particleSystems.Add(retSystem);
     *  return retSystem;
     * }
     */

    public static ParticleSystem MakeSystem(ProjectileParticles projectileType)
    {
        ParticleSystem newSystem;

        //Debug.Log("Making a " + (int)projectileType);
        newSystem = Instantiate(projectileFabs[(int)projectileType]);
        return(newSystem);
    }
コード例 #2
0
ファイル: Projectile.cs プロジェクト: Arqu3/Sol
    void OnCollisionEnter2D(Collision2D col)
    {
        GameObject particles = (GameObject)SolGame.SpawnResourceByName("ProjectileParticles", col.contacts[0].point, 1.0f);
        Vector2    normal    = col.contacts[0].normal;

        particles.transform.rotation = Quaternion.FromToRotation(Vector3.forward, normal);
        ProjectileParticles pp = particles.GetComponent <ProjectileParticles>();

        if (pp)
        {
            pp.SetColor(GetComponent <SpriteRenderer>().color);
        }

        PhysicsEntity pEntity = col.gameObject.GetComponent <PhysicsEntity>();

        if (pEntity)
        {
            pEntity.OnHit();
        }

        if (m_Bounce)
        {
            if (m_CurBounce >= m_NumBounce)
            {
                Destroy(gameObject);
            }
            else
            {
                ++m_CurBounce;
                m_Rigidbody.velocity = Vector2.Reflect(m_Velocity, normal);
                m_Velocity           = m_Rigidbody.velocity;
            }
        }
        else
        {
            Destroy(gameObject);
        }
    }
コード例 #3
0
 public void SetParticleSystems(ProjectileParticles effect, ProjectileParticles explosion)
 {
     this.effect    = effect;
     this.explosion = explosion;
 }
コード例 #4
0
 public static void SetSystem(ParticleSystem particleSystem, ProjectileParticles projectileType)
 {
     particleSystem = projectileFabs[(int)projectileType];
 }