示例#1
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Start");
        instance = this;

        generator = GetComponent <BouyancyGenerator>();
        generator.SetShouldEffectAll(true);
        ForceManager.AddGenerator(generator);
    }
示例#2
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Start");
        instance = this;

        particleManager = this.gameObject.AddComponent <ParticleManager>();
        generator       = GetComponent <BouyancyGenerator>();
        generator.SetShouldEffectAll(true);
        ForceManager.AddGenerator(generator);
        resolver = this.gameObject.AddComponent <ContactResolver>();
    }
示例#3
0
    public static void MakeProjectile(Transform trans, GameObject type)
    {
        GameObject projectile = Instantiate(type, trans.position, trans.rotation);
        Vector3    direction  = Vector3.right;
        float      angle      = trans.eulerAngles.z * Mathf.Deg2Rad;
        float      sin        = Mathf.Sin(angle);
        float      cos        = Mathf.Cos(angle);

        Vector3 forward = new Vector3(
            direction.x * cos - direction.y * sin,
            direction.x * sin + direction.y * cos,
            0f);



        projectile.GetComponent <Particle2D>().Create(1, forward, new Vector2(0, -.01f), 0.999f, 10, unitID);
        particleList.Add(projectile);
        unitID += 1;
        if (type.name.Contains("Spring"))
        {
            GameObject projectile2 = Instantiate(type, trans.position, trans.rotation);
            projectile2.GetComponent <Particle2D>().Create(1, forward, new Vector2(0, -.01f), 0.999f, 1, unitID);
            particleList.Add(projectile2);
            unitID += 1;
            SpringGenerator newGenerator = new SpringGenerator();
            newGenerator.SetShouldEffectAll(false);
            ForceManager.AddGenerator(newGenerator);
            newGenerator.SetID(projectile.GetComponent <Particle2D>().GetID(), projectile2.GetComponent <Particle2D>().GetID());
        }
        else if (type.name.Contains("Rod"))
        {
            GameObject projectile2 = Instantiate(type, trans.position, trans.rotation);
            projectile2.GetComponent <Particle2D>().Create(1, forward, new Vector2(0, -.01f), 0.999f, 2, unitID);
            particleList.Add(projectile2);
            unitID += 1;
            Particle2DLink newLink = new Particle2DLink();
            newLink.id1 = projectile.GetComponent <Particle2D>().GetID();
            newLink.id2 = projectile2.GetComponent <Particle2D>().GetID();

            linkList.Add(newLink);
        }
    }