// Use this for initialization
    void Awake()
    {
        GameObject temp = LoadShipManagement.LoadShip(GameManager.nameVessel);

        temp.transform.SetParent(GameObject.Find("Ship").transform);
        temp.GetComponent <WeaponShootManager>().GetShipReference(GameObject.Find("Ship").GetComponent <Ship>());

        introDone = false;
        saveCoro  = StartCoroutine(TempoFadeIn());

        colliders = GameObject.Find("Ship").GetComponentsInChildren <MeshCollider>();
        foreach (MeshCollider mc in colliders)
        {
            mc.enabled = false;
        }
    }
Example #2
0
    // Use this for initialization
    void Awake()
    {
        if (LoadPath == null)
        {
            LoadPath = "PrefabSave/NoneMB/";
        }

        if (arrayOfID == null)
        {
            TextAsset asset = Resources.Load <TextAsset>(LoadPath + "ID");
            JObject   data  = JObject.Parse(asset.text);
            JArray    IDs   = data["uniqueID"].Value <JArray>();
            arrayOfID = new string[IDs.Count];
            for (int i = 0; i < arrayOfID.Length; i++)
            {
                arrayOfID[i] = IDs[i].Value <string>();
            }
        }

        int        randValue = Random.Range(0, arrayOfID.Length);
        GameObject ship      = LoadShipManagement.LoadShip("Ally_" + allyNumberCount, 1, LoadPath + arrayOfID[randValue]);

        allyNumberCount++;
        ship.tag = "Ally";
        ship.transform.parent        = transform;
        ship.transform.localPosition = Vector3.zero;
        MeshCollider[] colliders = GetComponentsInChildren <MeshCollider>(true);
        foreach (MeshCollider mc in colliders)
        {
            mc.enabled = true;
        }

        /*MeshFilter[] filters = GetComponentsInChildren<MeshFilter>();
         * foreach (MeshFilter mf in filters)
         * {
         *      MeshCollider mesh = mf.gameObject.AddComponent<MeshCollider>();
         *      mesh.sharedMesh = mf.sharedMesh;
         *      mesh.inflateMesh = true;
         *      mesh.convex = true;
         * }
         * // UNTIL WE HAVE TEXTURES
         * MeshRenderer[] renderers = GetComponentsInChildren<MeshRenderer>();
         * foreach (MeshRenderer mr in renderers)
         * {
         *      mr.material.color = GetComponent<Enemy>() != null ? new Color(1f, 0.25f, 0f) : Color.blue;
         * }*/
    }