// 拖动操作 protected void execute_dragging() { Vector2 mouse_pos = this.root.input.mouse_position; mouse_pos = Sprite2DRoot.get().convertMousePosition(mouse_pos); if (this.dragging.current) { if (!this.root.input.button.current) { this.dragging.current = false; } } else { if (this.focused.current) { if (this.root.input.button.current) { this.grab_offset = this.getPosition() - mouse_pos; this.dragging.current = true; } } } if (this.dragging.current) { this.setPosition(mouse_pos + this.grab_offset); } }
// 是否位于画面内? public bool isInScreen() { bool ret = false; Vector2 viewport_size = Sprite2DRoot.get().viewport_size; Vector2 position = this.transform.localPosition.xy(); do { float w = viewport_size.x / 2.0f + this.size.x / 2.0f; float h = viewport_size.y / 2.0f + this.size.y / 2.0f; if (position.x < -w || w < position.x) { break; } if (position.y < -h || h < position.y) { break; } ret = true; } while(false); return(ret); }
public override void initialize() { this.player = PartyControl.get().getLocalPlayer(); this.player_weapon = this.player.gameObject.findDescendant("anim_wepon"); this.data = GameObject.Find("EventDataIceAtari").GetComponent <EventDataIceAtari>(); // 당첨의 막대 모델. this.ice_bar = this.data.prefab_ice_atari_bar.instantiate(); this.ice_bar.setParent(this.player.gameObject.findDescendant("anim_wrist_R")); this.ice_bar.setLocalPosition(new Vector3(-0.056f, -0.086f, 0.039f)); this.ice_bar.SetActive(false); // "!" 말풍선. this.sprite_bikkuri = Sprite2DRoot.get().createSprite(this.data.texture_bikkuri, true); this.sprite_bikkuri.setVisible(false); // 당첨 말풍선. this.sprite_atari = Sprite2DRoot.get().createSprite(this.data.texture_atari, true); this.sprite_atari.setPosition(new Vector2(0.0f, 150.0f)); this.sprite_atari.setVisible(false); this.sprite_ice_bar = Sprite2DRoot.get().createSprite(this.data.texture_ice_bar, true); this.sprite_ice_bar.setVisible(false); this.sprite_ice_bar.setMaterial(this.data.material_ice_sprite); this.spline = this.data.gameObject.findDescendant("spline_ice").GetComponent <SimpleSplineObject>(); this.tracer.attach(this.spline.curve); }
// 창이 클릭되었다. public bool clickWindow(Vector2 position) { bool is_clicked = false; this.clicked_slot = -1; do { // 이동 중이 아닐 때는 아이템을 사용할 수 없다. if (this.player.step.get_current() != chrBehaviorLocal.STEP.MOVE) { break; } is_clicked = true; Vector2 p = Sprite2DRoot.get().convertScreenPosition(position); this.clicked_slot = System.Array.FindIndex(this.sprite_miscs, x => x.isContainPoint(p)); if (this.clicked_slot >= 0) { break; } is_clicked = false; } while(false); return(is_clicked); }
// ================================================================ // public void create() { // 꼬리. this.mini_moya_sprite = new Sprite2DControl[2]; this.mini_moya_sprite[0] = Sprite2DRoot.get().createSprite(this.kara_texture, true); this.mini_moya_sprite[0].setSize(new Vector2(this.kara_texture.width, this.kara_texture.height) * 0.05f); this.mini_moya_sprite[0].transform.parent = this.root_sprite.transform; this.mini_moya_sprite[1] = Sprite2DRoot.get().createSprite(this.kara_texture, true); this.mini_moya_sprite[1].setSize(new Vector2(this.kara_texture.width, this.kara_texture.height) * 0.1f); this.mini_moya_sprite[1].transform.parent = this.root_sprite.transform; // 파/유자. this.negi_sprite = Sprite2DRoot.get().createSprite(this.negi_texture, true); this.negi_sprite.setSize(new Vector2(this.negi_texture.width, this.negi_texture.height) / 4.0f); this.negi_sprite.transform.parent = this.root_sprite.transform; this.yuzu_sprite = Sprite2DRoot.get().createSprite(this.yuzu_texture, true); this.yuzu_sprite.setSize(new Vector2(this.yuzu_texture.width, this.yuzu_texture.height) / 4.0f); this.yuzu_sprite.transform.parent = this.root_sprite.transform; // this.step.set_next(STEP.UUN); }
public void create() { Vector2 root_position = new Vector2(640.0f / 2.0f - 100.0f, 480.0f / 2.0f - 100.0f); // 아래에 깔리는 레이스. this.lace_sprite = Sprite2DRoot.get().createSprite(this.lace_texture, true); this.lace_sprite.setSize(new Vector2(128.0f, 128.0f) * SCALE); // 쿠키(대강의 HP). this.cookie_sprite = Sprite2DRoot.get().createSprite(this.cookie_icon_textures[0], true); this.cookie_sprite.setSize(new Vector2(80.0f, 80.0f) * SCALE); // 얼굴 아이콘. this.face_sprite = Sprite2DRoot.get().createSprite(this.face_icon_texture, true); this.face_sprite.setSize(new Vector2(80.0f, 80.0f) * SCALE); // 수치(세 자리). this.digit_sprites = new Sprite2DControl[3]; for (int i = 0; i < 3; i++) { Sprite2DControl digit = Sprite2DRoot.get().createSprite(this.number_textures[0], true); digit.setSize(new Vector2(48.0f, 48.0f) * SCALE); this.digit_sprites[i] = digit; } this.setPosition(root_position); }
// 设置顶点的位置(2D) public void setVertexPositions(Vector2[] positions) { Vector3[] positions_3d = new Vector3[positions.Length]; for (int i = 0; i < positions.Length; i++) { positions_3d[i] = positions[i]; } Sprite2DRoot.get().setVertexPositionsToSprite(this, positions_3d); }
// ================================================================ // void Awake() { this.colors.current = new Color(0.0f, 0.0f, 0.0f, 0.0f); this.colors.goal = this.colors.current; this.sprite = Sprite2DRoot.get().createSprite(this.texture, true); this.sprite.setDepthLayer("fader"); this.sprite.setSize(new Vector2(Screen.width, Screen.height)); this.sprite.setVisible(false); }
// 设置深度值 protected void calc_depth() { float depth = Sprite2DRoot.get().depthLayerToFloat(this.depth_layer, depth_offset); Vector3 position = this.transform.localPosition; position.z = depth; this.transform.localPosition = position; }
public void create(Texture texture) { this.sprite = Sprite2DRoot.get().createSprite(texture, true); this.sprite.setSize(Vector2.one * 64.0f); this.sprite.setVisible(false); this.fcurve = new ipModule.FCurve(); this.fcurve.setSlopeAngle(70.0f, 5.0f); this.fcurve.setDuration(0.7f); this.fcurve.start(); }
// 设置层级深度 public void setDepthLayer(string depth_layer) { this.depth_layer = depth_layer; if (!Sprite2DRoot.get().isHasLayer(this.depth_layer)) { Debug.LogError("Depth Layer \"" + depth_layer + "\" not exists."); } this.calc_depth(); }
// ================================================================ // public void create(Texture moji_texture, Texture moji_mae_texture) { this.moji_texture = moji_texture; this.moji_mae_texture = moji_mae_texture; this.moji_texture_size = new Vector2(this.moji_texture.width, this.moji_texture.height); this.sprite = Sprite2DRoot.get().createSprite(this.moji_mae_texture, true); this.sprite.setSize(Vector2.one * 64.0f); this.fcurve = new ipModule.FCurve(); this.fcurve.setSlopeAngle(70.0f, 5.0f); this.fcurve.setDuration(0.3f); this.spring = new ipModule.Spring(); this.spring.k = 100.0f; this.spring.reduce = 0.90f; }
public void create() { Vector2 root_position = new Vector2(640.0f / 2.0f - 100.0f, 0.0f); // 아래에 깔리는 레이스. this.lace_sprite = Sprite2DRoot.get().createSprite(this.lace_texture, true); this.lace_sprite.setSize(new Vector2(96.0f, 96.0f) * SCALE); // 쿠키. this.cookie_sprite = Sprite2DRoot.get().createSprite(this.cookie_icon_textures[0], true); this.cookie_sprite.setSize(new Vector2(60.0f, 60.0f) * SCALE); // 얼굴 아이콘. this.face_sprite = Sprite2DRoot.get().createSprite(this.face_icon_texture, true); this.face_sprite.setSize(new Vector2(60.0f, 60.0f) * SCALE); this.setPosition(root_position); }
// ================================================================ // // MonoBehaviour에서 상속. void Awake() { this.root_sprite = Sprite2DRoot.get().createNull(); this.cookie_sprite = Sprite2DRoot.get().createSprite(this.cookie_icon_textures[0], true); this.cookie_sprite.setMaterial(this.cookie_material); this.cookie_sprite.setSize(this.cookie_size); this.cookie_sprite.setParent(this.root_sprite); this.cookie_material.SetTexture("_MainTexture", this.cookie_icon_textures[0]); this.cookie_material.SetTexture("_HariTexture", this.hari_shadow_texture); this.hari_sprite = Sprite2DRoot.get().createSprite(this.hari_texture, true); this.hari_sprite.setSize(this.hari_size); this.hari_sprite.setParent(this.root_sprite); this.hari_sprite.setPosition(this.hari_position); this.root_sprite.setPosition(new Vector2(0.0f, 160.0f)); }
// テキストを追加する. public void addText(string text) { TextLine new_line = new TextLine(); new_line.text = text; new_line.sprite = Sprite2DRoot.get().createTextSprite(font, text, this.font_size, true); new_line.sprite.setDepthLayer("ui.item"); new_line.sprite.setParent(this.waku.null_sprite); Vector2 position = Vector2.zero; position.x = -this.window_size.x / 2.0f + text.Length * this.font_size / 2.0f; position.y = this.window_size.y / 2.0f - this.font_size / 2.0f - this.lines.Count * this.font_size; new_line.sprite.setPosition(position); this.lines.Add(new_line); }
// ================================================================ // // 생성. public void create() { // 밑받침 (팔 주위 파란 테두리). this.under_sprite = Sprite2DRoot.get().createSprite(this.under_texture, true); this.under_sprite.setSize(new Vector2(this.under_texture.width, this.under_texture.height) / 4.0f); // 몸. this.karada_sprite = Sprite2DRoot.get().createSprite(this.karada_texture, true); this.karada_sprite.setSize(new Vector2(this.karada_texture.width, this.karada_texture.height) / 4.0f); // 팔. this.ude_sprite = Sprite2DRoot.get().createSprite(this.ude_texture, true); this.ude_sprite.setSize(new Vector2(this.ude_texture.width, this.ude_texture.height) / 4.0f); // 위치를 설정해 둔다. this.base_position = this.base_position_start; this.set_position(); }
// 更新焦点获取状态 protected void update_focuse_status(bool is_focusable) { this.focused.previous = this.focused.current; // ---------------------------------------------------------------- // // 获得焦点(ROLL_OVER鼠标进入) Vector2 mouse_pos = this.root.input.mouse_position; mouse_pos = Sprite2DRoot.get().convertMousePosition(mouse_pos); this.focused.current = false; if (this.is_active) { if (is_focusable) { if (this.isContainPoint(mouse_pos)) { this.focused.current = true; } } } else { // 如果从禁止焦点转移到焦点状态时, // 将一直保持焦点状态直到失去焦点 if (this.focused.previous) { if (is_focusable) { if (this.isContainPoint(mouse_pos)) { this.focused.current = true; } } } } this.focused.update_trigger(); }
// フォーカス状態の更新. protected void update_focuse_status(bool is_focusable) { this.focused.previous = this.focused.current; // ---------------------------------------------------------------- // // フォーカス(ロールオーバー). Vector2 mouse_pos = this.root.input.mouse_position; mouse_pos = Sprite2DRoot.get().convertMousePosition(mouse_pos); this.focused.current = false; if (this.is_active) { if (is_focusable) { if (this.isContainPoint(mouse_pos)) { this.focused.current = true; } } } else { // フォーカスが禁止にされる前からフォーカスしていた場合は、 // フォーカスアウトするまでフォーカス状態を維持する. if (this.focused.previous) { if (is_focusable) { if (this.isContainPoint(mouse_pos)) { this.focused.current = true; } } } } this.focused.update_trigger(); }
// ================================================================ // // 아이템 창의 좌표??. public bool isPositionInWindow(Vector2 position) { bool ret = false; Vector2 p = Sprite2DRoot.get().convertScreenPosition(position); do { if (p.x < BASE_POS.x - WINDOW_SIZE.x / 2.0f || BASE_POS.x + WINDOW_SIZE.x / 2.0f < p.x) { break; } if (p.y < BASE_POS.y - WINDOW_SIZE.y / 2.0f || BASE_POS.y + WINDOW_SIZE.y / 2.0f < p.y) { break; } ret = true; } while(false); return(ret); }
public void create() { // 스프라이트를 만든다. this.sprite = Sprite2DRoot.get().createSprite(this.font_texture, 3, true); this.sprite.setSize(this.font_size); // 변형용 정점을 초기화해 둔다.. Vector3[] positions = this.sprite.getVertexPositions(); this.vertices = new ControlVertex[positions.Length]; for (int i = 0; i < this.vertices.Length; i++) { this.vertices[i] = new ControlVertex(); this.vertices[i].position = positions[i]; this.vertices[i].position_org = this.vertices[i].position; this.vertices[i].velocity = Vector2.zero; } // 초기 위치를 난수로 변경하고 형태를 왜곡한다. for (int i = 0; i < this.vertices.Length; i++) { this.vertices[i].position *= Random.Range(0.8f, 1.3f); positions[i] = this.vertices[i].position; } this.sprite.setVertexPositions(positions); this.sprite.setVisible(false); this.time_scale = Random.Range(0.9f, 1.2f); this.step.set_next(STEP.HIDE); }
// ================================================================ // // 생성한다. public void create() { this.root_sprite = Sprite2DRoot.get().createNull(); // 캐릭터. this.chr_sprite = Sprite2DRoot.get().createSprite(this.uun_texture, true); this.chr_sprite.setSize(new Vector2(this.uun_texture.width, this.uun_texture.height) / 4.0f); this.chr_sprite.transform.parent = this.root_sprite.transform; // 모락모락. this.moya = new WeaponSelectNavi.Moya(); this.moya.root_sprite = this.root_sprite; this.moya.negi_texture = this.moya_negi_texture; this.moya.yuzu_texture = this.moya_yuzu_texture; this.moya.oke_texture = this.moya_oke_texture; this.moya.kara_texture = this.moya_kara_texture; this.moya.selecting_icon = this; this.moya.create(); this.moya.setPosition(new Vector3(20.0f, 50.0f, 0.0f)); // this.setPosition(Vector3.zero); }
// 生成する. public void create(Vector2 size) { this.size = size; this.null_sprite = Sprite2DRoot.get().createNull(); // for (int i = 0; i < (int)PART.NUM; i++) { this.sprites.Add(null); } this.sprites[(int)PART.CENTER] = Sprite2DRoot.get().createSprite(this.root.texture_white8x8, 2, true); this.sprites[(int)PART.CENTER].name = "Botan.waku"; this.sprites[(int)PART.CENTER].setSize(size); this.sprites[(int)PART.CENTER].setDepthLayer("ui.item"); // this.sprites[(int)PART.RIGHT_TOP] = Sprite2DRoot.get().createSprite(this.root.texture_waku_kado, 2, true); this.sprites[(int)PART.RIGHT_TOP].name = "Botan.waku"; this.sprites[(int)PART.RIGHT_TOP].setPosition(new Vector2((size.x / 2.0f + this.margin / 2.0f), size.y / 2.0f + this.margin / 2.0f)); this.sprites[(int)PART.RIGHT_TOP].setAngle(-90.0f); this.sprites[(int)PART.RIGHT_TOP].setSize(Vector2.one * this.margin); this.sprites[(int)PART.RIGHT_TOP].setDepthLayer("ui.item"); this.sprites[(int)PART.RIGHT_BOTTOM] = Sprite2DRoot.get().createSprite(this.root.texture_waku_kado, 2, true); this.sprites[(int)PART.RIGHT_BOTTOM].name = "Botan.waku"; this.sprites[(int)PART.RIGHT_BOTTOM].setPosition(new Vector2((size.x / 2.0f + this.margin / 2.0f), -(size.y / 2.0f + this.margin / 2.0f))); this.sprites[(int)PART.RIGHT_BOTTOM].setAngle(-180.0f); this.sprites[(int)PART.RIGHT_BOTTOM].setSize(Vector2.one * this.margin); this.sprites[(int)PART.RIGHT_BOTTOM].setDepthLayer("ui.item"); this.sprites[(int)PART.LEFT_TOP] = Sprite2DRoot.get().createSprite(this.root.texture_waku_kado, 2, true); this.sprites[(int)PART.LEFT_TOP].name = "Botan.waku"; this.sprites[(int)PART.LEFT_TOP].setPosition(new Vector2(-(size.x / 2.0f + this.margin / 2.0f), size.y / 2.0f + this.margin / 2.0f)); this.sprites[(int)PART.LEFT_TOP].setSize(Vector2.one * this.margin); this.sprites[(int)PART.LEFT_TOP].setDepthLayer("ui.item"); this.sprites[(int)PART.LEFT_BOTTOM] = Sprite2DRoot.get().createSprite(this.root.texture_waku_kado, 2, true); this.sprites[(int)PART.LEFT_BOTTOM].name = "Botan.waku"; this.sprites[(int)PART.LEFT_BOTTOM].setPosition(new Vector2(-(size.x / 2.0f + this.margin / 2.0f), -(size.y / 2.0f + this.margin / 2.0f))); this.sprites[(int)PART.LEFT_BOTTOM].setAngle(90.0f); this.sprites[(int)PART.LEFT_BOTTOM].setSize(Vector2.one * margin); this.sprites[(int)PART.LEFT_BOTTOM].setDepthLayer("ui.item"); // this.sprites[(int)PART.RIGHT] = Sprite2DRoot.get().createSprite(this.root.texture_waku_ue, 2, true); this.sprites[(int)PART.RIGHT].name = "Botan.waku"; this.sprites[(int)PART.RIGHT].setPosition(new Vector2(size.x / 2.0f + this.margin / 2.0f, 0.0f)); this.sprites[(int)PART.RIGHT].setAngle(-90.0f); this.sprites[(int)PART.RIGHT].setSize(new Vector2(size.y, this.margin)); this.sprites[(int)PART.RIGHT].setDepthLayer("ui.item"); this.sprites[(int)PART.LEFT] = Sprite2DRoot.get().createSprite(this.root.texture_waku_ue, 2, true); this.sprites[(int)PART.LEFT].name = "Botan.waku"; this.sprites[(int)PART.LEFT].setPosition(new Vector2(-(size.x / 2.0f + this.margin / 2.0f), 0.0f)); this.sprites[(int)PART.LEFT].setAngle(90.0f); this.sprites[(int)PART.LEFT].setSize(new Vector2(size.y, this.margin)); this.sprites[(int)PART.LEFT].setDepthLayer("ui.item"); this.sprites[(int)PART.TOP] = Sprite2DRoot.get().createSprite(this.root.texture_waku_ue, 2, true); this.sprites[(int)PART.TOP].name = "Botan.waku"; this.sprites[(int)PART.TOP].setPosition(new Vector2(0.0f, size.y / 2.0f + this.margin / 2.0f)); this.sprites[(int)PART.TOP].setSize(new Vector2(size.x, this.margin)); this.sprites[(int)PART.TOP].setDepthLayer("ui.item"); this.sprites[(int)PART.BOTTOM] = Sprite2DRoot.get().createSprite(this.root.texture_waku_ue, 2, true); this.sprites[(int)PART.BOTTOM].name = "Botan.waku"; this.sprites[(int)PART.BOTTOM].setPosition(new Vector2(0.0f, -(size.y / 2.0f + this.margin / 2.0f))); this.sprites[(int)PART.BOTTOM].setAngle(-180.0f); this.sprites[(int)PART.BOTTOM].setSize(new Vector2(size.x, this.margin)); this.sprites[(int)PART.BOTTOM].setDepthLayer("ui.item"); foreach (var sprite in this.sprites) { sprite.setParent(this.null_sprite); } }
// ================================================================ // public void create() { Navi navi = Navi.get(); // this.root_sprite = Sprite2DRoot.get().createNull(); this.root_sprite.setPosition(new Vector3(0.0f, POSITION_Y, 0.0f)); // 아이콘, 문자 오브젝트 생성. this.icon = new Yell.Icon(); this.icon.create(this.icon_texture); this.icon.sprite.transform.parent = this.root_sprite.transform; // this.mojis = new List <Yell.Moji>(); for (int i = 0; i < this.yell_words.Length; i++) { YellFontData font_data = navi.getYellFontData(this.yell_words[i]); Yell.Moji moji = new Yell.Moji(); moji.create(font_data.texture, this.moji_mae_texture); if (font_data.is_small) { moji.moji_mae_scale *= 0.5f; } moji.yell = this; moji.index = i; moji.sprite.transform.parent = this.root_sprite.transform; moji.reset(); if (i % 3 == 0) { moji.sprite.setVertexColor(new Color(1.0f, 1.0f, 0.5f)); } else if (i % 3 == 1) { moji.sprite.setVertexColor(new Color(1.0f, 0.7f, 0.7f)); } else if (i % 3 == 2) { moji.sprite.setVertexColor(new Color(0.3f, 1.0f, 1.0f)); } this.mojis.Add(moji); } this.icon.sprite.setDepth(this.mojis[this.mojis.Count - 1].sprite.getDepth() - 0.1f); // 문자 위치. float pitch = 54.0f; Vector2 p0 = Vector2.zero; Vector2 p1 = Vector2.zero; p0.x = (float)this.mojis.Count * pitch / 2.0f; p0.y = 0.0f; p1.x = 0.0f - ((float)this.mojis.Count) * pitch / 2.0f - pitch / 2.0f; p1.y = p0.y; this.icon.p0 = p0; this.icon.p1 = p1; p1.x += pitch; p0.x = p1.x; for (int i = 0; i < this.mojis.Count; i++) { YellFontData font_data = navi.getYellFontData(this.yell_words[i]); this.mojis[i].p0 = p0; this.mojis[i].reset(); if (font_data.is_small) { this.mojis[i].p0.x -= pitch * 0.25f; this.mojis[i].p0.y -= pitch * 0.25f; p0.x += pitch * 0.5f; } else { p0.x += pitch; } } }
// 设置UV public void setVertexUVs(Vector2[] uvs) { Sprite2DRoot.get().setVertexUVsToSprite(this, uvs); }
// 设置顶点的位置(3D) public void setVertexPositions(Vector3[] positions) { Sprite2DRoot.get().setVertexPositionsToSprite(this, positions); }
// 获取顶点的位置 public Vector3[] getVertexPositions() { return(Sprite2DRoot.get().getVertexPositionsFromSprite(this)); }
// 设置纹理(同时修改尺寸) public void setTextureWithSize(Texture texture) { this.GetComponent <MeshRenderer>().material.mainTexture = texture; Sprite2DRoot.get().setSizeToSprite(this, new Vector2(texture.width, texture.height)); }
// 设置顶点颜色的透明值 public void setVertexAlpha(float alpha) { Sprite2DRoot.get().setVertexColorToSprite(this, new Color(1.0f, 1.0f, 1.0f, alpha)); }
// 设置顶点颜色 public void setVertexColor(Color color) { Sprite2DRoot.get().setVertexColorToSprite(this, color); }
// 设置尺寸 public void setSize(Vector2 size) { Sprite2DRoot.get().setSizeToSprite(this, size); }