private IEnumerator SetInitialPosition(WWW req) { yield return(req); Vector2 pos = JsonConvert.DeserializeObject <Vector2>(req.text); Movement movement = player.GetComponent <Movement>(); WorldData.Layer layer = GameObject.Find("Layer4").GetComponent <WorldData.Layer>(); pos = new Vector2(world.layers[4].Ratio * (pos.x / 10.0f - 5.0f), (100 - pos.y) / 10.0f - 5.0f); movement.SetPlayerPosition(pos); }
private void InstantiateScriptable(WorldData.Sprite s, GameObject worldLayer, WorldData.Layer layer, int i) { Vector3 pos = new Vector3(layer.Ratio * (s.x / 10.0f - 5.0f), (100 - s.y) / 10.0f - 5.0f, world.layers.Count - i - (s.zIndex + 1) / 1000.0f); float scale = layer.Ratio * s.size / 10.0f; Quaternion rotation = Quaternion.Euler(0.0f, 0.0f, -s.rotation); string pathname = "Scriptables/" + sprites[s.id].name; GameObject scriptable = (GameObject)Instantiate((GameObject)Resources.Load(pathname)); UpdateLayer(scriptable, LayerMask.NameToLayer(worldLayer.name.ToLower())); scriptable.transform.parent = worldLayer.transform; scriptable.transform.position = pos; scriptable.transform.localScale *= scale; scriptable.transform.rotation = rotation; }
private void InstantiateSprite(WorldData.Sprite s, GameObject worldLayer, WorldData.Layer layer, int i) { Vector3 pos = new Vector3(layer.Ratio * (s.x / 10.0f - 5.0f), (100 - s.y) / 10.0f - 5.0f, world.layers.Count - i - (s.zIndex + 1) / 1000.0f); float scale = layer.Ratio * s.size / 10.0f; Quaternion rotation = Quaternion.Euler(0.0f, 0.0f, -s.rotation); GameObject worldSprite = (GameObject)Instantiate(_sprite); SpriteRenderer spriteRenderer = worldSprite.GetComponent <SpriteRenderer>(); Sprite sprite = sprites[s.id].image; spriteRenderer.sprite = sprite; worldSprite.transform.parent = worldLayer.transform; worldSprite.transform.position = pos; worldSprite.transform.localScale *= scale; worldSprite.transform.rotation = rotation; worldSprite.layer = worldLayer.layer; }