/// <summary> /// Create the coin mover for the play field /// </summary> private void CreateMover() { //Get the base object GameObject localObj = Resources.Load("Temp Background Tile") as GameObject; //Instantiate the mover coinMover = Instantiate(localObj); coinMover.name = "Coin Mover"; //Set the size and sprite of the object coinMover.GetComponent <RectTransform>().sizeDelta = new Vector2(tileSize, tileSize); coinMover.GetComponent <Image>().sprite = coinMoverSprite; //Set the parent and local position of the mover coinMover.transform.SetParent(transform); coinMover.transform.localPosition = tilePositions[new Vector2(width / 2, 0)] + Vector2.down * (tileSize / 2); //Add the mover component, and get the component on the object coinMover.AddComponent <CoinMover>(); CoinMover coinMoverComp = coinMover.GetComponent <CoinMover>(); //Set information about the mover coinMoverComp.gridPos = new Vector3(width / 2, 0); coinMoverComp.field = this; }
void setupNewCoin(GameObject coin) { CoinMover mover = coin.AddComponent <CoinMover> (); mover.rotationSpeed = 1.0f; mover.levelSceneController = levelSceneController; mover.coinVelocity = SceneConstants.BASE_COIN_VELOCITY; }
private void Awake() { _coinMover = new CoinMover(this); }