Esempio n. 1
0
    // Starts constructing the wing
    static public void AttachWing(GameObject body, Phenotype type)
    {
        int wingParts = type.TypeChromosomes.Count + 1;

        // Create wing segments
        Rigidbody[]  wingSegments = new Rigidbody[2 * wingParts];
        HingeJoint[] wingJoints   = new HingeJoint[2 * wingParts];

        segmentPos = 0;
        nextChrom  = -1;
        leftWing   = true;
        attachNextSegment(body, type, type.rootChromL, 0, wingSegments, wingJoints); // Left wing
        nextChrom = -1;
        leftWing  = false;
        attachNextSegment(body, type, type.rootChromR, 0, wingSegments, wingJoints); // Right wing


        // Add the wing to the global set via the WingFactory
        WingSetFactory.AddWing(body, type, wingSegments, wingJoints);


        // Attach the second bone of the wings, to the body (the second bone is always one parallel to the body, simulating the length where the wing is connected to the body)
        addBoneJoint(body, wingSegments[1].gameObject, type.rootChromL.boneOffset, type.rootChromL.boneOffset.magnitude, 0, 0, type.rootChromL.muscleForce / 3);
        addBoneJoint(body, wingSegments[wingParts + 1].gameObject, type.rootChromR.boneOffset, type.rootChromR.boneOffset.magnitude, 0, 0, type.rootChromR.muscleForce / 3);
    }
    void OnDestroy()
    {
        if (index == -1)
        {
            return;
        }

        // Destroy the wing membrane
        WingSetFactory.DestroyWing(wingSet);
    }
 public void RenderVisualisation(bool render)
 {
     if (render)
     {
         if (polyset == null)
         {
             polyset = WingSetFactory.VisualizeWingMembrane(segments);
         }
     }
     else if (polyset != null)
     {
         polyset.Destroy(); polyset = null;
     }
 }
Esempio n. 4
0
    static public void Init()
    {
        GameObject mainControler = GameObject.Find("MainControler");

        envControlerScr = (EnvironmentControler)mainControler.GetComponent(typeof(EnvironmentControler));
        AIControlerScr  = (AIControler)mainControler.GetComponent(typeof(AIControler));
        GUIControlerScr = (GUIControler)mainControler.GetComponent(typeof(GUIControler));
        wingFactory     = (WingSetFactory)mainControler.GetComponent(typeof(WingSetFactory));

        mainCameraScr = (MainCameraScript)GameObject.Find("MainCamera").GetComponent(typeof(MainCameraScript));


        currentScene = SceneManager.GetActiveScene();

        mainAIScene = SceneManager.GetSceneByName("MainScene");
        cliffScene  = SceneManager.GetSceneByName("CliffSimulation");
    }