void OnTriggerEnter2D(Collider2D other) //method called when any object enter the player collider { if (other.CompareTag("Platform")) //check if the tag is "Platform" { PlatformScript script = other.GetComponent <PlatformScript>(); //the we get the script component attach to it if (script.Scored == false) //check if the scored is false { audioS.PlayOneShot(land); //then we play land sound GameManager.instance.currentScore += (script.PlatformIndex - GameManager.instance.currentScore); //increase the score UIManager.instance.inGameScore.text = "" + GameManager.instance.currentScore; //update the score text script.Scored = true; //set scored value to true } } if (other.CompareTag("Coin")) //check if the tag is "Coin" { audioS.PlayOneShot(coinCollect); //then we play coin colect sound other.gameObject.SetActive(false); GameManager.instance.currentCoins++; //increase the current coin value GameManager.instance.coins++; //increase the total coins value UIManager.instance.inGameCoinText.text = "" + GameManager.instance.currentCoins; //set the coin text value GameManager.instance.Save(); //save the data } if (other.CompareTag("Enemy")) //check if the tag is "Enemy" { audioS.PlayOneShot(dead); //then we play death sound GameManager.instance.isGameOver = true; //set gameover to true UIManager.instance.GameOver(); //call gameover method of UImanager StopPlatforms(); //stop movements of platfroms Destroy(gameObject, 1f); //we destroy the player after 1 sec } }
// Start is called before the first frame update void Awake() { if (instance == null) { instance = this; } }
// Called when the script instance is being loaded. private void Awake() { // Instantiate StateMachine. stateMachine = new StateMachine <GameScript>(this); // Get Main Player object. GameObject gameObject = GameObject.Find("MainPlayer"); if (gameObject == null) { Debug.LogError("GameScript.cs: Game Object \"MainPlayer\" not found."); } else { // Get the PlayerScript component attached to GameObject. playerScript = gameObject.GetComponent <PlayerScript>(); if (playerScript == null) { Debug.LogError("GameScript.cs: PlayerScript component not found."); } } // Get platform Script platformScript = GetComponent <PlatformScript>(); if (platformScript == null) { Debug.LogError("GameScript.cs: PlatformScript not found on this object!"); } }
////////End movement void LogCheck() { logCheckRay.origin = transform.position; logCheckRay.direction = Vector3.up * -1; RaycastHit hit; if (Physics.Raycast(logCheckRay, out hit)) { if (hit.collider.tag == "Platform") { onLog = true; } else { onLog = false; } } if (onLog) { PlatformScript log = hit.collider.GetComponent <PlatformScript>(); if (log != null) { if (!log.isStatic) { transform.position = new Vector3(transform.position.x + log.speed, transform.position.y, transform.position.z); } } } }
// Start is called before the first frame update void Start() { GetComponent <SpriteRenderer>().sprite = normalBall; platform = FindObjectOfType <PlatformScript>(); transform.position = new Vector3(platform.transform.position.x, platform.transform.position.y + deltaY, 0); deltaPosition = transform.position - platform.transform.position; deltaPosition.y = deltaY; }
void OnNetworkInstantiate(NetworkMessageInfo info) { if(networkView.isMine) { StartCoroutine(DestroyAfter(duration)); } platfom = GameObject.FindGameObjectWithTag("GameController").GetComponent<PlatformManagerScript>().FindNearestPlatform(transform.position); transform.parent = platfom.transform; }
private void Awake() { charCReference = gameObject.GetComponent <Character>(); platformScript = GameObject.FindGameObjectWithTag("Platforms").GetComponent <PlatformScript>(); gameQReference = gameObject.GetComponent <GameQuestions>(); buttonsGame = gameObject.GetComponent <ButtonsGame>(); animReference = gameObject.GetComponent <AnimationScript>(); uIGameReference = gameObject.GetComponent <UIGame>(); camMReference = gameObject.GetComponent <CameraManager>(); }
void FixedUpdate() { PlatformScript p = new PlatformScript(); if(!onPlatform) swingMomentum = movementSpeed; else swingMomentum=p.platformSpeed+movementSpeed; if(onPlatform && p.charge!=playerCharge)//Moves the player towards the killBox if the charges are different transform.position=Vector3.MoveTowards(transform.position,killBox.position,5f); }
private int totalPlatforms = 0; // this number stores the total platforms picked up last check. #endregion Fields #region Methods /// <summary> /// Called when the main light is changed /// </summary> /// <param name='mainColour'> /// The colour of the main light. /// </param> public void OnLightChange(PlatformScript.Colour mainColour) { // set the light colour to what colour the main light has been set to MainlightColour = mainColour; // and then retrigger the platform just to make sure if it is active it stays active if(isActive) { Triggered = true; } }
public override void OnInspectorGUI() { PlatformScript myPlatScript = (PlatformScript)target; int width, height; if (GUILayout.Button("Build Platform")) { myPlatScript.BuildPlatform(); } DrawDefaultInspector(); }
public void SetLightColour(PlatformScript.Colour colour) { // set the light colour light.color = Colours[(int)colour]; // and send a call to all platforms to makesure their colour is updated // create an array of platforms GameObject[] platforms = GameObject.FindGameObjectsWithTag("Platform");//>(); foreach(GameObject platform in platforms) { platform.SendMessage("UpdateState",colour); } }
void OnCollisionStay(Collision other) { currentJumps = 0; PlatformScript platform = other.gameObject.GetComponent <PlatformScript>(); if (platform) { if (platform.color != color) { Death(); } } }
public void Execute() { if (IsAlive) { if (!CurrentPlatform) { if (SheepAgent) { SheepAgent.nextPosition = GetPosition().position; SheepAgent.updatePosition = true; IsPatrol = true; IsOnPlatform = false; } FindPlatform(); if (CurrentPlatform) { PlatformScript = CurrentPlatform.GetComponent <PlatformScript>(); if (PlatformScript.IsPossibleToClimb) { if (SheepAgent) { IsPatrol = false; SheepAgent.destination = CurrentPlatform.transform.position; } } else { IsPatrol = true; SheepAgent.ResetPath(); } } } if (SheepAgent) { Patrol(SheepAgent, 15, IsPatrol); } if (SheepRigidbody) { if (SheepRigidbody.velocity.y < -10 || SheepRigidbody.velocity.y > 10) { SheepRigidbody.velocity = new Vector3(SheepRigidbody.velocity.x, 0, SheepRigidbody.velocity.z); } } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "platform") { Jump(); PlatformScript ps = collision.transform.GetComponent <PlatformScript>(); ps.cloneMe(); if (!ps.takenPoint) { pc.points++; ps.takenPoint = true; } } else if (collision.tag == "ziemia") { Jump(); } }
public void interact_with_platform() { PlatformScript current_platform = GameObject.FindGameObjectWithTag("GameController").GetComponent <MainWorldScript>().find_current_platform(this.gameObject).GetComponent <PlatformScript>(); if (current_platform.gives_coins) { this.give_coins(200); } else if (current_platform.has_minigame) { Debug.Log("Minigame launching..."); SceneManager.LoadScene("BulletDodge"); //Launch minigame! } else if (current_platform.has_store) { Debug.Log("Interacting with store..."); } }
// Use this for initialization void Start() { Vector3 spawnPosition = new Vector3(); for (int i = 0; i < numberOfPlatforms; i++) { spawnPosition.y += Random.Range(minY, maxY); spawnPosition.x = Random.Range(-levelWidth, levelWidth); GameObject platform = Instantiate(platformPrefab, spawnPosition, Quaternion.identity); //(Quaternion.identity means we won't rotate the object at all) PlatformScript ps = platform.GetComponent <PlatformScript> (); if (ps != null) { ps.SetGenerator(this); } } currentTop = spawnPosition.y; //Debug.Log (currentTop); }
void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Ground")) { if (_trueVelocity.x < 0.25f && _trueVelocity.y < 0.25f) { _circleCollider.enabled = false; _boxCollider.enabled = true; } jumpParticleSystem.Play(); PlatformScript platformScript = collision.gameObject.GetComponent <PlatformScript>(); if (isPlaying && !platformScript.Touched) { combo++; platformScript.PlayerTouch(); } isSlingShotReady = true; // if traveling fast enough then shake camera if (rigidbody2D.velocity.x > 3500 || velocity.y > 3500) { followCam.Shake(); } //if (Mathf.Abs(rigidbody2D.velocity.x) < 500.0f && Mathf.Abs(rigidbody2D.velocity.y) < 500.0f) //{ // _boxCollider.enabled = true; // _circleCollider.enabled = false; //} } }
public void Setup() { testObject = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Demigod/Prefabs/MovingPlatform.prefab"); testObject = GameObject.Instantiate(testObject); platformScript = testObject.AddComponent <PlatformScript>(); }
public void RegisterPlatform(PlatformScript p) { platforms.Add(p); }
void OnCollisionEnter2D(Collision2D coll) { if (coll.collider.tag == "MainPlatformBody") { touchingBody = true; if (transform.position.y > coll.gameObject.transform.position.y + collider.radius / 3.5f || transform.position.y < coll.gameObject.transform.position.y - collider.radius / 3.5f) { savedYVelocity = rigidbody.velocity.y; if (!touchingRight && !touchingLeft && !touchingBody && !touchingLeftPlatform && !touchingRightPlatform) { cornerYVelocity = rigidbody.velocity.y; } if (transform.position.y < coll.gameObject.transform.position.y) //boulder is coming from below { rigidbody.velocity = new Vector2(goingRight ? maxXVelocity : -maxXVelocity, -Mathf.Min(Mathf.Abs(potentialYVelocity), Mathf.Abs(maxYVelocity))); goingUp = false; goingDown = true; } else //boulder is coming from above { rigidbody.velocity = new Vector2(goingRight ? maxXVelocity : -maxXVelocity, Mathf.Min(Mathf.Abs(potentialYVelocity), Mathf.Abs(maxYVelocity))); goingUp = true; goingDown = false; } } } if (coll.collider.tag == "RightPlatform") { float appliedVelocity = Mathf.Min(potentialYVelocity, maxYVelocity); if (!touchingRight && !touchingLeft && !touchingBody && !touchingLeftPlatform && !touchingRightPlatform) { cornerYVelocity = rigidbody.velocity.y; } GameObject platform = coll.transform.parent.gameObject; PlatformScript platformScript = (PlatformScript)platform.GetComponent("PlatformScript"); if (!platformScript.isColliderOverlapRight && !touchingBody && !touchingRightPlatform) { rigidbody.velocity = new Vector2(maxXVelocity, goingUp ? appliedVelocity : -appliedVelocity); goingRight = true; goingLeft = false; potentialYVelocity = potentialYVelocity * 1.05f; } touchingRight = true; } if ((coll.collider.tag == "LeftPlatform")) { float appliedVelocity = Mathf.Min(potentialYVelocity, maxYVelocity); if (!touchingRight && !touchingLeft && !touchingBody && !touchingLeftPlatform && !touchingRightPlatform) { cornerYVelocity = rigidbody.velocity.y; } GameObject platform = coll.transform.parent.gameObject; PlatformScript platformScript = (PlatformScript)platform.GetComponent("PlatformScript"); if (!platformScript.isColliderOverlapLeft && !touchingBody && !touchingLeftPlatform) { rigidbody.velocity = new Vector2(-maxXVelocity, goingUp ? appliedVelocity : -appliedVelocity); goingRight = rigidbody.velocity.x > 0; goingLeft = !goingRight; potentialYVelocity = potentialYVelocity * 1.05f; } touchingLeft = true; } if (coll.gameObject.tag == "Boulder") { Vector2 velocity = new Vector2(maxXVelocity, currentYVelocity); Vector2 location = new Vector2(transform.position.x, transform.position.y); int level = boulderLevel; Destroy(this.gameObject); Destroy(coll.gameObject); boulderCollisionScript.makeBoulder(velocity, location, goingRight, potentialYVelocity, boulderLevel); } if (coll.gameObject.tag == "RightSide") { savedYVelocity = rigidbody.velocity.y; if (!touchingBody && !touchingLeftPlatform && !touchingRightPlatform && !touchingRight && !touchingBottom && !touchingTop) { cornerYVelocity = rigidbody.velocity.y; } touchingRight = true; rigidbody.velocity = new Vector2(-maxXVelocity, currentYVelocity); goingRight = false; goingLeft = true; } if (coll.gameObject.tag == "LeftSide") { savedYVelocity = rigidbody.velocity.y; if (!touchingBody && !touchingLeftPlatform && !touchingRightPlatform && !touchingLeft && !touchingBottom && !touchingTop) { cornerYVelocity = rigidbody.velocity.y; } touchingLeft = true; rigidbody.velocity = new Vector2(maxXVelocity, currentYVelocity); goingRight = true; goingLeft = false; } if (coll.gameObject.tag == "TopSide") { savedYVelocity = rigidbody.velocity.y; if (!touchingBody && !touchingLeftPlatform && !touchingRightPlatform && !touchingLeft && !touchingBottom && !touchingTop) { cornerYVelocity = rigidbody.velocity.y; } touchingTop = true; rigidbody.velocity = new Vector2(goingRight ? maxXVelocity : -maxXVelocity, -Mathf.Min(Mathf.Abs(potentialYVelocity), Mathf.Abs(maxYVelocity))); goingDown = true; goingUp = false; } if (coll.gameObject.tag == "BottomSide") { savedYVelocity = rigidbody.velocity.y; if (!touchingBody && !touchingLeftPlatform && !touchingRightPlatform && !touchingLeft && !touchingBottom && !touchingTop) { cornerYVelocity = rigidbody.velocity.y; } touchingBottom = true; rigidbody.velocity = new Vector2(goingRight ? maxXVelocity : -maxXVelocity, Mathf.Min(Mathf.Abs(potentialYVelocity), Mathf.Abs(maxYVelocity))); goingDown = false; goingUp = true; } }
void OnCollisionStay2D(Collision2D coll) { float maxVelocity = Mathf.Max(Mathf.Abs(savedYVelocity), Mathf.Abs(currentYVelocity), Mathf.Abs(cornerYVelocity), Mathf.Abs(potentialYVelocity)); float appliedVelocity = Mathf.Min(maxVelocity, maxYVelocity); if (coll.collider.tag == "RightSide") { goingRight = false; goingLeft = true; touchingRight = true; } if (coll.collider.tag == "LeftSide") { goingRight = true; goingLeft = false; touchingLeft = true; } if (coll.collider.tag == "TopSide") { goingUp = false; goingDown = true; touchingTop = true; } if (coll.collider.tag == "BottomSide") { goingUp = true; goingDown = false; touchingBottom = true; } if (coll.collider.tag == "RightPlatform") { touchingRightPlatform = true; GameObject platform = coll.transform.parent.gameObject; PlatformScript platformScript = (PlatformScript)platform.GetComponent("PlatformScript"); if (!platformScript.isColliderOverlapRight) { goingRight = true; goingLeft = false; } } if (coll.collider.tag == "LeftPlatform") { touchingLeftPlatform = true; GameObject platform = coll.transform.parent.gameObject; PlatformScript platformScript = (PlatformScript)platform.GetComponent("PlatformScript"); if (!platformScript.isColliderOverlapLeft) { goingRight = false; goingLeft = true; } } if (coll.collider.tag == "MainPlatformBody") { if (transform.position.y > coll.gameObject.transform.position.y) { goingUp = true; goingDown = false; } else { goingUp = false; goingDown = true; } touchingBody = true; if (goingUp) { rigidbody.velocity = new Vector2(goingRight ? maxXVelocity : -maxXVelocity, appliedVelocity); } else { rigidbody.velocity = new Vector2(goingRight ? maxXVelocity : -maxXVelocity, -appliedVelocity); } } }
private void Initialize(PlatformScript parent, Vector3 pos, string n) { willFall = true; gm = FindObjectOfType <RestrictionScript> (); obs = GameObject.FindGameObjectWithTag("Respawn"); mesh = parent.mesh; material = parent.material; transform.parent = parent.transform; transform.localScale = Vector3.one; endPos = pos; //pos.y = -2f; startPos = pos; startTime = Time.deltaTime; isMoving = true; transform.localPosition = pos; posName = n; int x = 0; PlatformScript[] ps = FindObjectsOfType <PlatformScript> (); foreach (PlatformScript p in ps) { if (transform.position == p.transform.position) { x++; if (x == 2) { Destroy(gameObject); //Destroy duplicates } } } if (gm.rNum >= 4) { float distance = Random.Range(0.05f, 0.165f); if (transform.position.x > 0) { pos.x += distance; } else { pos.x -= distance; } transform.localPosition = pos; //Platform distance } if (gm.rNum >= 3) { float xpos = Random.Range(-0.425f, 0.425f); float ypos = Random.Range(0.3f, 1.5f); pos = new Vector3(xpos, ypos, 0); GameObject ob = Instantiate(obs, Vector3.zero, Quaternion.identity, gameObject.transform); //Spawn obstacle ob.transform.localPosition = pos; Color c = new Color(Random.Range(0, 1f), Random.Range(0, 1f), Random.Range(0, 1f), Random.Range(0, 1f)); ob.GetComponent <MeshRenderer> ().material.color = c; } if (x < 2) { float r1 = Random.Range(0, 10); float r2 = Random.Range(0, 10); float r3 = Random.Range(0, 10); if (r1 <= 5) { gm.SpawnStuff(1, transform.position); } if (r2 <= 7) { gm.SpawnStuff(2, transform.position); } if (r3 <= 4) { gm.SpawnStuff(3, transform.position); //Spawn stuff } } }
void FixedUpdate() { if (Input.touchCount == 2) { Touch touch0 = Input.GetTouch(0); Touch touch1 = Input.GetTouch(1); Vector2 touch0PrevPos = touch0.position - touch0.deltaPosition; Vector2 touch1PrevPos = touch1.position - touch1.deltaPosition; float prevMagnitude = (touch0PrevPos - touch1PrevPos).magnitude; float curMagnitude = (touch0.position - touch1.position).magnitude; float distance = curMagnitude - prevMagnitude; float moveDist = distance * 0.01f; gameCamera.ZoomInOut(moveDist); } else if (Input.touchCount == 1) { Touch touch = Input.GetTouch(0); Vector2 pos = Camera.main.ScreenToWorldPoint(touch.position); RaycastHit2D hit = Physics2D.Raycast(pos, Camera.main.transform.forward); if (buildStateActive) { float distance = Vector3.Distance(activeObject.transform.position, pos); PlatformScript platformScript = activeObject.GetComponent(typeof(PlatformScript)) as PlatformScript; /*Debug.Log(distance); * Debug.Log(activeObject.transform.position); * Debug.Log(pos);*/ if (touch.phase == TouchPhase.Began && willBuildObject != null && touch.position.y > 30 && hit.collider == null && distance <= 1.75f && platformScript != null && platformScript.canHaveMoreRoad() ) { IBuyAble buyAble = willBuildObject.GetComponent(typeof(IBuyAble)) as IBuyAble; if (buyAble != null && resourceManagerScript.canBuy(buyAble.getGoldPrice(), buyAble.getMinaralPrice())) { GameObject newObj = Instantiate(willBuildObject, pos, Quaternion.identity); IcanHaveRoad haveRoad = newObj.GetComponent(typeof(IcanHaveRoad)) as IcanHaveRoad; // rotate new object face to the platform Vector2 rotationVector = new Vector2( activeObject.transform.position.x - newObj.transform.position.x, activeObject.transform.position.y - newObj.transform.position.y ); newObj.transform.up = rotationVector; // Create road GameObject connetionRoad = Instantiate(road, activeObject.transform.position, Quaternion.identity); // rotate and scale the road between newObj and platform connetionRoad.transform.localScale += new Vector3(0, distance, 1); connetionRoad.transform.up = rotationVector; Vector3 roadPos = new Vector3( (newObj.transform.position.x + activeObject.transform.position.x) / 2, (newObj.transform.position.y + activeObject.transform.position.y) / 2, 15f ); connetionRoad.transform.position = roadPos; RoadScript roadScript = connetionRoad.GetComponent(typeof(RoadScript)) as RoadScript; // Set Road variables roadScript.setTopObject(newObj); // top object the builded object roadScript.setBottomObject(activeObject); // bottom object platform // Add road to new builded object haveRoad.addRoad(roadScript); // Adding roads to platformObject platformScript.addRoad(roadScript); if (newObj.CompareTag("Mine")) { checkMineAndMinaralConnetion(newObj); } if (newObj.CompareTag("House")) { resourceManagerScript.updateMaxPopulationCount(5); } if (newObj.CompareTag("defenceBuildings")) { TowerScript newDefenceBuilding = newObj.GetComponent(typeof(TowerScript)) as TowerScript; defanceBuildings.Add(newDefenceBuilding); } // Buy the building resourceManagerScript.buyBuilding(buyAble.getGoldPrice(), buyAble.getMinaralPrice()); } else { Debug.Log("you cant buy"); } } endBuildingState(); } else if (touch.phase == TouchPhase.Began) //check for the first touch { fp = Camera.main.ScreenToWorldPoint(touch.position); lp = Camera.main.ScreenToWorldPoint(touch.position); } else if (touch.phase == TouchPhase.Moved) // update the last position based on where they moved { lp = Camera.main.ScreenToWorldPoint(touch.position); if (Mathf.Abs(lp.x - fp.x) > dragDistance || Mathf.Abs(lp.y - fp.y) > dragDistance) { Vector3 camMovePos = lp - fp; gameCamera.Move(camMovePos); } } else if (touch.phase == TouchPhase.Ended) //check if the finger is removed from the screen { lp = Camera.main.ScreenToWorldPoint(touch.position); if (Mathf.Abs(lp.x - fp.x) > dragDistance || Mathf.Abs(lp.y - fp.y) > dragDistance) { Vector3 camMovePos = lp - fp; gameCamera.Move(camMovePos); } else { if (EventSystem.current.IsPointerOverGameObject() && buildPanel.activeSelf) { Debug.Log("on game object"); } else { if (buildPanel.activeSelf) { buildPanel.SetActive(false); } else { if (touch.position.y > 30) { if (hit.collider != null) { if (activeObject != null) { IselectAble tmp = activeObject.GetComponent(typeof(IselectAble)) as IselectAble; tmp.setSelect(false); activeObject = hit.collider.gameObject; IselectAble selectedObject = activeObject.GetComponent(typeof(IselectAble)) as IselectAble; selectedObject.setSelect(true); } else { activeObject = hit.collider.gameObject; IselectAble selectedObject = activeObject.GetComponent(typeof(IselectAble)) as IselectAble; selectedObject.setSelect(true); } } else { if (activeObject != null) { IselectAble platform = activeObject.GetComponent(typeof(IselectAble)) as IselectAble; if (platform != null) { platform.setSelect(false); activeObject = null; } } } } else { // menu element } } } } } } }
private void Start() { GameObject Bullet = GameObject.FindWithTag("Bullet"); GameObject Block = GameObject.FindWithTag("Blocks"); GameObject Edge = GameObject.FindWithTag("Edge"); GameObject Hollow = GameObject.FindWithTag("HollowFill"); GameObject LevelHollows = GameObject.FindWithTag("LevelHollows"); bullet = new ObjectPoolItem(); bullet.shouldExpand = true; bullet.amountToPool = 3; bullet.objectToPool = Bullet; bullet.objectTag = Bullet.tag; block = new ObjectPoolItem(); block.shouldExpand = false; block.amountToPool = TutorialManager.instance.blockNumber; block.objectToPool = Block; block.objectTag = Block.tag; TutorialManager.instance.blocks[0] = Block; Block.SetActive(false); edge = new ObjectPoolItem(); edge.shouldExpand = true; edge.amountToPool = 17; edge.objectToPool = Edge; edge.objectTag = Edge.tag; hollow = new ObjectPoolItem(); //float distHollow = 0f; if (Hollow != null) { hollow.shouldExpand = false; hollow.amountToPool = 3; hollow.objectToPool = Hollow; hollow.objectTag = Hollow.tag; TutorialManager.instance.Hollows.Add(hollow.objectToPool); TutorialManager.instance.Hollows[0].GetComponent <TutHollowFillScript>().SetQueNumber(0); //distHollow = TutorialManager.instance.hollowUpdateDist; Hollow.SetActive(false); } /* else * { * hollow.amountToPool = 14; * hollow.objectToPool = GameObject.FindWithTag("Hollow"); * distHollow = 50f; * }*/ fullHollows = new ObjectPoolItem(); fullHollows.shouldExpand = true; fullHollows.amountToPool = 50; fullHollows.objectToPool = LevelHollows.transform.GetChild(0).gameObject; fullHollows.objectTag = LevelHollows.transform.GetChild(0).gameObject.tag; itemsToPool.Add(bullet); itemsToPool.Add(block); itemsToPool.Add(edge); itemsToPool.Add(hollow); itemsToPool.Add(fullHollows); pooledObjects = new List <GameObject>(); //Debug.Log("Object Pooler created pooled objects"); float distEdge = 20f; float fullDist = 10f; foreach (ObjectPoolItem item in itemsToPool) { for (int i = 0; i < item.amountToPool; i++) { if (item == fullHollows) { GameObject obj = (GameObject)Instantiate(item.objectToPool, LevelHollows.transform); //obj.SetActive(false); pooledObjects.Add(obj); TutorialManager.instance.LevelupHollows.Add(obj); fullDist = LevelHollowGetDistance.SetHollow(TutorialManager.instance.LevelupHollows[i], fullDist); } else { GameObject obj = (GameObject)Instantiate(item.objectToPool, GameObject.FindWithTag("ALLPLATFORM").transform); pooledObjects.Add(obj); if (item == block) { TutorialManager.instance.blocks[i + 1] = obj; } if (item == edge) { TutorialManager.instance.Edges.Add(obj); distEdge = PlatformScript.SetPlatform(TutorialManager.instance.Edges[i], distEdge); } if (item == hollow) { obj.SetActive(false); TutorialManager.instance.Hollows.Add(obj); TutorialManager.instance.Hollows[i + 1].GetComponent <TutHollowFillScript>().SetQueNumber(i + 1); } } } } }
void Awake() { Instance = this; }
void OnEnable() { _target = (PlatformScript) target; _target.Start(); }