// Use this for initialization void Start() { _transform = GetComponent <Transform>(); _lastMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); _backgroundLayers = null; _currentBackground = null; _parallaxingManager = new Parallaxing(); _frameCounter = 0; Init(0); }
void StartWorking() { previousCamPos = cam.position; parallaxScales = new float[backgrounds.Length]; for (int i = 0; i < backgrounds.Length; i++) { parallaxScales[i] = backgrounds[i].position.z * -1; } if (instance != null) { Destroy(gameObject); } else { instance = this; } }
// Creates a buddy on the required side void MakeNewBuddy(int leftOrRight) { // create the position for the new buddy Vector3 pos = new Vector3(trans.position.x + width * leftOrRight, trans.position.y, trans.position.z); Transform buddy = Instantiate(trans, pos, trans.rotation) as Transform; /// if not tileable then reverse the x size /// of the object to make it seems as it is repeating if (reverseScale) { buddy.localScale = new Vector3(buddy.localScale.x * -1, buddy.localScale.y, buddy.localScale.z); } buddy.parent = trans.parent; if (leftOrRight > 0) { buddy.GetComponent <Tiling>().leftBuddy = true; } else { buddy.GetComponent <Tiling>().rightBuddy = true; } // Add to Game manager GameObject. if (addtoGM) { GameObject gm = GameObject.Find("_GM"); if (gm == null) { Debug.LogError("Could not find '_GM' GameObject ignoring 'addToGM' value"); } else { Parallaxing parallax = gm.GetComponent <Parallaxing> (); parallax.AddBG(buddy); } } }
void Awake() { camEffects = GetComponent <CameraEffects>(); parallaxing = GetComponent <Parallaxing>(); audio = GetComponent <AudioSource>(); }