// Use this for initialization void Start() { m_cameraTransform = Camera.main.transform; //Handle for camera transform WorldLimits worldLimits = Camera.main.GetComponent <WorldLimits>(); m_worldHeight = worldLimits.WorldSpaceHeight; //World space height of whats visible }
// Use this for initialization void Start() { m_mainCameraTransform = Camera.main.transform; WorldLimits worldLimits = Camera.main.GetComponent <WorldLimits>(); transform.localScale = new Vector3(worldLimits.m_worldSpaceWidth, worldLimits.m_worldSpaceHeight, 1f); m_playerDeath = GameObject.Find("Player").GetComponent <PlayerDeath>(); }
void Start() { rb = GetComponent <Rigidbody2D>(); maxSpeed = 10f; level = GetComponent <Level>(); soundEffectsPlayer = GameObject.Find("SoundEffectsPlayer"); myAudio = soundEffectsPlayer.GetComponent <AudioSource>(); limits = GameObject.Find("Background").GetComponent <WorldLimits>(); }
public void SpawnClouds(Vector2 pos) { if (m_worldSpaceWidth == 0 || m_worldSpaceHeight == 0) { WorldLimits worldLimits = Camera.main.GetComponent <WorldLimits>(); m_worldSpaceWidth = worldLimits.WorldSpaceWidth; m_worldSpaceHeight = worldLimits.WorldSpaceHeight; } for (int i = 0; i < 3; ++i) { if (m_clouds.Count > 0 && m_clouds.First.Value.transform.position.y < m_player.position.y - m_worldSpaceHeight) { //Get the cloud to be moved GameObject cloud = m_clouds.First.Value; m_clouds.RemoveFirst(); //Randomize and set new position Vector2 newCloudPos = pos; newCloudPos.x += (Random.value - 0.5f) * 2f * m_worldSpaceWidth; newCloudPos.y += (Random.value - 0.5f) * m_worldSpaceHeight; cloud.transform.position = newCloudPos; //Re-queue and activate the cloud m_clouds.AddLast(cloud); cloud.SetActive(true); } //GameObject newCloud = Instantiate(m_simpleSpritePrefab, newCloudPos, Quaternion.identity) as GameObject; // m_clouds.Enqueue(newCloud); // int spriteNumber = Random.Range(0,4); //newCloud.GetComponent<SpriteRenderer>().sprite = m_cloudSprites[spriteNumber]; //float scale = Random.Range(0.6f, 1.3f); //newCloud.transform.localScale = new Vector2(scale, scale); //SimpleMovement simpleMovement = newCloud.GetComponent<SimpleMovement>(); //simpleMovement.Velocity = new Vector2(scale*-1/1.65f, 0.0f); //Debug.Log(m_clouds.Count); } }
void Awake() { gravityCenter = transform.position; target = new List <GameObject>(); //gravityField = GameObject.Find("GravityField"); pullRadius = 2; pullForce = 5f; rb = GetComponentInParent <Rigidbody2D>(); followSpeed = .01f; beingDamaged = false; hasStarted = false; playerProjectiles = GameObject.Find("PlayerProjectiles"); ballPrefab = Resources.Load("Prefabs/Ball") as GameObject; limits = GameObject.Find("Background").GetComponent <WorldLimits>(); clampedPosition = new Vector2(); inv = GameObject.Find("Inventory").GetComponent <Inventory>(); targets = GameObject.Find("Boxes").GetComponentsInChildren <Transform>(); health = GameObject.Find("Health").GetComponent <Health>(); toggle = GameObject.Find("Autoplay").GetComponent <Toggle>(); MakeBall(); }
// Use this for initialization void Start() { //m_clouds = new Queue<GameObject>(); WorldLimits worldLimits = Camera.main.GetComponent <WorldLimits>(); m_worldSpaceWidth = worldLimits.WorldSpaceWidth; m_worldSpaceHeight = worldLimits.WorldSpaceHeight; m_player = GameObject.FindWithTag("Player").transform; Debug.Log("Player found at pos: " + m_player.position); m_windController = m_player.gameObject.GetComponent <WindController>(); StartCoroutine("MoveCloudsHorizontal"); LinkedListNode <GameObject> it; for (it = m_clouds.First; it != m_clouds.Last.Next; it = it.Next) { m_windController.registerCloud(it.Value); } //m_mainCameraTransform = Camera.main.transform; //m_platformSpawner = GameObject.Find("Spawner").GetComponent<SpawnJumperPlatforms>(); /*for(ushort i = 0; i < 10; ++i) * { * Vector2 newCloudPos = m_platformSpawner.NewestPlatPos; * newCloudPos.x += (Random.value - 0.5f) * 2f * m_worldSpaceWidth; * newCloudPos.y += (Random.value - 0.5f) * 2f * m_worldSpaceHeight; * GameObject newCloud = Instantiate(m_cloudPrefabs[Random.Range(0, 2)], newCloudPos, Quaternion.identity) as GameObject; * m_clouds.AddLast(newCloud.transform); * } * * StartCoroutine("SpawnClouds");*/ }
// Use this for initialization void Start() { m_cosmeticsSpawner = GameObject.Find("BackgroundGFX").GetComponent <SpawnCosmetics>(); m_enemySpawner = GetComponent <SpawnEnemies>(); //m_worldVisible = (Vector2)(Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, Screen.height)) - Camera.main.transform.position); WorldLimits worldLimits = Camera.main.GetComponent <WorldLimits>(); m_worldSpaceVisibleSize.x = worldLimits.WorldSpaceWidth; m_worldSpaceVisibleSize.y = worldLimits.WorldSpaceHeight; m_nextId = 1; m_xMin = 5; m_xMax = worldLimits.WorldSpaceWidth; // Debug.Log("MIN ALLOWED X = " + m_xMin); // Debug.Log("MAX ALLOWED X = " + m_xMax); //m_xMax = 10; m_yMin = 2; // m_yMax = (int)(m_worldVisible.y * 1.5f); m_yMax = 8; //List of spawned platforms with jumpers m_jumperPlatforms = new LinkedList <GameObject>(); m_movingJumperPlatforms = new Queue <GameObject>(); m_platformsInUse = new Queue <GameObject>(); //Instantiate a first jumper platform in origo GameObject temp = Instantiate(m_largePlat, Vector2.zero, Quaternion.identity) as GameObject; temp.GetComponentInChildren <JumperData>().ID = m_nextId; m_jumperPlatforms.AddLast(temp); ++m_nextId; m_platformsInUse.Enqueue(temp); //Instantiate the rest of the platforms for (short i = 0; i < m_numberOfPlatforms - 1; ++i) { float newPosX, newPosY; do { newPosX = m_jumperPlatforms.Last.Value.transform.position.x + (Random.value - 0.5f) * m_xMax; }while(Mathf.Abs(newPosX - m_jumperPlatforms.Last.Value.transform.position.x) < m_xMin); //Maybe revert this to last platform width instead of static 4.0f // Debug.Log("NEW PLATFORM X_DIF = " + Mathf.Abs(newPosX - lastPlatPos.x)); newPosY = m_jumperPlatforms.Last.Value.transform.position.y + Random.Range(m_yMin, m_yMax); Vector2 newPlatPos = new Vector2(newPosX, newPosY); m_newestPlatPos = newPlatPos; //GameObject newPlat; if (m_nextId < 5) { temp = Instantiate(m_largePlat, newPlatPos, Quaternion.identity) as GameObject; m_cosmeticsSpawner.SpawnClouds(newPlatPos); } else { float spawnValue = Random.value; if (spawnValue > 0.8f) { temp = Instantiate(m_smallPlat, newPlatPos, Quaternion.identity) as GameObject; } else { temp = Instantiate(m_largePlat, newPlatPos, Quaternion.identity) as GameObject; } m_cosmeticsSpawner.SpawnClouds(newPlatPos); } temp.GetComponentInChildren <JumperData>().ID = m_nextId; m_jumperPlatforms.AddLast(temp); m_platformsInUse.Enqueue(temp); ++m_nextId; } Vector2 invisiblePos = new Vector2(0f, -20f); //Instantiate a few moving platforms as well for (int i = 0; i < m_numberOfPlatforms; ++i) { temp = Instantiate(m_movingPlat, invisiblePos * (i + 1), Quaternion.identity) as GameObject; temp.GetComponent <MoveAtoB>().initialize(1, 2, 2, 1.5f); m_movingJumperPlatforms.Enqueue(temp); } //Get player transform m_player = GameObject.FindWithTag("Player").transform; //Position used to determine when to move platforms }