示例#1
0
 // Use this for initialization
 void Start()
 {
     mainCam = FindObjectOfType <CamScript>();
     if (mainCam == null)
     {
         mainCam = Camera.main.gameObject.AddComponent <CamScript>();
     }
 }
示例#2
0
 void Awake()
 {
     // Ensure the index of the cam container is the first
     // among its siblings. Other scripts rely on this!
     transform.SetSiblingIndex(0);
     camScript = transform.parent.parent.GetComponent <CamScript>();
     canvas    = GameObject.Find("Canvas");
 }
示例#3
0
    ExtinguisherScript extinguisher; //used to control the extinguisher

    // Use this for initialization
    void Start()
    {
        health = GetComponent <HealthScript>();
        health.initialize(maxHealth, maxHealth);
        cc           = GetComponent <CharacterController> ();
        cam          = Camera.main.GetComponent <CamScript> ();
        extinguisher = GetComponentInChildren <ExtinguisherScript> ();
    }
示例#4
0
 void Awake()
 {
     scoreManager    = GameObject.FindGameObjectWithTag("ScoreManager").GetComponent <ScoreManager>();
     gameManager     = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();
     cam             = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CamScript>();
     backgroundColor = GameObject.FindGameObjectWithTag("BackgroundColor").GetComponent <BackgroundColor>();
     soundManager    = GameObject.FindGameObjectWithTag("SoundManager").GetComponent <SoundManager>();
 }
示例#5
0
 void Start()
 {
     rigid          = GetComponent <Rigidbody2D>();
     spriteRenderer = GetComponent <SpriteRenderer>();
     camScript      = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CamScript>();
     scoreScript    = GameObject.FindGameObjectWithTag("Score").GetComponent <ScoreScript>();
     background     = GameObject.FindGameObjectWithTag("Background").GetComponent <SpriteRenderer>();
     Destroy(gameObject, killTime);
 }
示例#6
0
 void Start()
 {
     // create empty list of cars and networks
     cars = new List <GameObject>();
     SpawnCars(carPopulation);
     ruleCar = Instantiate(carPrefab, carPrefab.transform.position, carPrefab.transform.rotation);
     ruleCar.SetActive(false);
     ruleCar.GetComponent <Controller>().useNN    = false;
     ruleCar.GetComponent <RuleBased>().ruleBased = true;
     SetIDs();
     camScript     = cam.GetComponent <CamScript>();
     camScript.car = cars[controllers[0].ID];
     startPos      = carPrefab.transform.position;
     startRotation = carPrefab.transform.rotation;
 }
示例#7
0
 void Start()
 {
     ShotTime = 100;
     cam      = FindObjectOfType <CamScript>();
 }
示例#8
0
 // Start is called before the first frame update
 void Start()
 {
     cs = GetComponent <CamScript>();
 }
示例#9
0
 // Use this for initialization
 void Start()
 {
     player = FindObjectOfType <playerController>();
     cam    = FindObjectOfType <CamScript>();
     //  cameraZone = FindObjectOfType<CameraZoneScript>();
 }
示例#10
0
    GameObject potato;     //the current potato

    void Start()
    {
        launchable = true;
        camScript  = Camera.main.GetComponent <CamScript> ();
    }
示例#11
0
 // Start is called before the first frame update
 void Start()
 {
     camScript = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CamScript>();
     rigid     = GetComponent <Rigidbody2D>();
 }
示例#12
0
 // Use this for initialization
 void Start()
 {
     player = FindObjectOfType <playerController>();
     cam    = FindObjectOfType <CamScript>();
     //  camerazoneBox = GetComponent<BoxCollider2D>();
 }
示例#13
0
 // Use this for initialization
 void Start()
 {
     cam = FindObjectOfType <CamScript>();
 }
    // Camera prefabs added to, removed from or swapped order in the scene
    // will update internally only once OnInspectorGUI() executes after
    // the modification. This happens when the Source Camera Controller
    // scene object is selected.

    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        DrawDefaultInspector();

        CamScript cameraScript = ((CamScript)target);

        SerializedProperty sourceCameras = serializedObject.FindProperty("sourceCameras");

        sourceCameras.arraySize = numCameras;
        // Add data for all cameras in the scene in the inspector, using default hotkeys
        for (int iCam = 0; iCam < numCameras; ++iCam)
        {
            // Add camera transforms and hotkeys in the inspector
            SerializedProperty tCamera =
                sourceCameras.GetArrayElementAtIndex(iCam).FindPropertyRelative("transform");
            SerializedProperty hotkey =
                sourceCameras.GetArrayElementAtIndex(iCam).FindPropertyRelative("hotkey");

            if (iCam == 0)
            {
                // Add the main camera first
                // Transform
                tCamera.objectReferenceValue = (Object)Camera.main.transform;
                // Hotkey
                if (hotkey.enumNames[hotkey.enumValueIndex] == "None")
                {
                    hotkey.enumValueIndex = defaultBaseKeyCode;
                }
            }
            else
            {
                // Add other camera containers after the main camera
                // Transform
                tCamera.objectReferenceValue = (Object)cameraScript.transform.GetChild(iCam - 1);

                // Hotkey
                // If KeyCode.None, init with the base value (main camera hotkey)
                if (hotkey.enumValueIndex == 0)
                {
                    hotkey.enumValueIndex = defaultBaseKeyCode;
                }

                // Keep increasing the hotkey index from Unity default (duplicated
                // from an earlier entry) until a free key is found.
                bool isDuplicateHotkey;
                do
                {
                    isDuplicateHotkey = false;

                    for (int jCam = 0; jCam < iCam; ++jCam)
                    {
                        // Debug.Log(sourceCameras.GetArrayElementAtIndex(jCam).FindPropertyRelative("hotkey").enumValueIndex + ", " + hotkey.enumValueIndex);
                        if (hotkey.enumValueIndex == sourceCameras.GetArrayElementAtIndex(jCam).
                            FindPropertyRelative("hotkey").enumValueIndex) // 0 == KeyCode.None
                        {
                            isDuplicateHotkey = true;
                            ++hotkey.enumValueIndex;
                            break;
                        }
                    }
                } while (isDuplicateHotkey);
            }
        }
        serializedObject.ApplyModifiedProperties();
    }