void OnDrawGizmos() { // Register the game controller for easier access if (GameController == null) { GameController = (CSGGameController)FindObjectOfType(typeof(CSGGameController)); } }
/// <summary> /// Start is only called once in the lifetime of the behaviour. /// The difference between Awake and Start is that Start is only called if the script instance is enabled. /// This allows you to delay any initialization code, until it is really needed. /// Awake is always called before any Start functions. /// This allows you to order initialization of scripts /// </summary> void Start() { // Register the game controller for easier access if (gameController == null) { gameController = (CSGGameController)FindObjectOfType(typeof(CSGGameController)); } // Set the current color of the object, based on the index SetColor(colorIndex); // Go to the next color every few moments InvokeRepeating("NextColor", 2, switchColorTime); }
/// <summary> /// Start is only called once in the lifetime of the behaviour. /// The difference between Awake and Start is that Start is only called if the script instance is enabled. /// This allows you to delay any initialization code, until it is really needed. /// Awake is always called before any Start functions. /// This allows you to order initialization of scripts /// </summary> void Start() { thisTransform = transform; // Register the game controller for easier access if (GameController == null) { GameController = (CSGGameController)FindObjectOfType(typeof(CSGGameController)); } if (PlayerObject == null) { PlayerObject = (CSGPlayer)FindObjectOfType(typeof(CSGPlayer)); } // Assign the color of this block from the list of colors in the gamecontroller if (colorIndex < GameController.colorList.Length) { GetComponent <SpriteRenderer>().color = GameController.colorList[colorIndex]; } }
// Use this for initialization void Start() { thisTransform = transform; // Register the game controller for easier access if (gameController == null) { gameController = (CSGGameController)FindObjectOfType(typeof(CSGGameController)); } // Register the rigidbody for easier access rigidBody = GetComponent <Rigidbody2D>(); if (rigidBody == null) { rigidBody = this.gameObject.AddComponent <Rigidbody2D>(); } // Register the camera for easier access if (Camera.main.transform) { cameraObject = Camera.main.transform; } //Assign the sound source for easier access if (GameObject.FindGameObjectWithTag(soundSourceTag)) { soundSource = GameObject.FindGameObjectWithTag(soundSourceTag); } // Check if we have a shop in this level and get the current player sprite from it if (shopObject == null && FindObjectOfType(typeof(CSGShop))) { shopObject = (CSGShop)FindObjectOfType(typeof(CSGShop)); //coloredObject.GetComponent<SpriteRenderer>().sprite = shopObject.playerBalls[PlayerPrefs.GetInt("PlayerIndex", 0)].icon; } coloredObject.GetComponent <SpriteRenderer>().sprite = playerBalls[PlayerPrefs.GetInt("PlayerIndex", 0)]; // Set the current color of the object, based on the index SetColor(0); }