Exemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyUp(KeyCode.Alpha1) || Input.GetKeyUp(KeyCode.Keypad1))
     {
         machine.PoweredGear = gear1;
         machine.RecalculateGears();
     }
     if (Input.GetKeyUp(KeyCode.Alpha2) || Input.GetKeyUp(KeyCode.Keypad2))
     {
         machine.PoweredGear = gear2;
         machine.RecalculateGears();
     }
 }
Exemplo n.º 2
0
    void AddGears()
    {
        if (numberOfInstances < 1)
        {
            numberOfInstances = 1;
        }

        if (numberOfInstances > 1)
        {
            GFGear gear = null;

            int     seqLen = 0;
            int     repeat = 0;
            int     n      = 0;
            Vector3 dir;
            for (int i = 0; i < numberOfInstances - 1; i += seqLen)
            {
                if (repeat == 1)
                {
                    repeat = 0;
                    seqLen++;
                }
                else
                {
                    repeat++;
                }

                for (int g = 0; g < seqLen; g++)
                {
                    if (instances.Count == numberOfInstances - 1)
                    {
                        i = 0;
                        break;
                    }
                    gear = instances.Count > 0 ? instances[instances.Count - 1] : gearToTest;

                    dir = Quaternion.AngleAxis(90f * n, Vector3.back) * Vector3.right;
                    GFGear newGear = gear.Clone(dir).GetComponent <GFGear>();
                    instances.Add(newGear);
                }
                n++;
                if (n >= 4)
                {
                    n = 0;
                }
            }

            machine.RecalculateGears();
        }
    }