2019-04-27 11:06:48 UNSELECTED

Unknown type code

Copy Copied! Full
--簡略化 STAT = vci.state ASET = vci.assets --Unity玉の名称 BALL_STR = { "red", "red1", "red2", "red3", "red4", "red5", "red6", "red7", "red8", "red9", "red10", "red11", "red12", "red13", "red14", "red15", "blue", "blue1", "blue2", "blue3", "blue4", "blue5", "blue6", "blue7", "blue8", "blue9", "blue10", "blue11", "blue12", "blue13", "blue14", "blue15", "green", "green1", "green2", "green3", "green4", "green5", "green6", "green7", "green8", "green9", "green10", "green11", "green12", "green13", "green14", "green15", "black", "black1", "black2", "black3", "black4", "black5", "black6", "black7", "black8", "black9", "black10", "black11", "black12", "black13", "black14", "black15" } --盤上に玉を配置する順番(rand) BALL_NUM = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } --Unity穴あきバーの名称 BAR_STR = { "box", "tate0", "tate1", "tate2", "tate3", "tate4", "tate5", "tate6", "tate7", "yoko0", "yoko1", "yoko2", "yoko3", "yoko4", "yoko5", "yoko6", "yoko7" } --どれだけ引き出されたか判断用 BAR_NUM = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } --Unity穴あきバー移動用かぷセエ宇の名称 PURAMAI_STR = { "tatepura0", "tatemai0", "tatepura1", "tatemai1", "tatepura2", "tatemai2", "tatepura3", "tatemai3", "tatepura4", "tatemai4", "tatepura5", "tatemai5", "tatepura6", "tatemai6", "tatepura7", "tatemai7", "yokopura0", "yokomai0", "yokopura1", "yokomai1", "yokopura2", "yokomai2", "yokopura3", "yokomai3", "yokopura4", "yokomai4", "yokopura5", "yokomai5", "yokopura6", "yokomai6", "yokopura7", "yokomai7" } FIRST_FIRST_FLG = true--根本初期化用 FIRST_FLG = true--初期化用 STAT.Set("FIRST_FLG", FIRST_FLG) HOSEI_NUM = 0--意味ないかも STAT.Set("HOSEI_NUM", HOSEI_NUM) HOSEI_TI = 0--±考える STAT.Set("HOSEI_TI", HOSEI_TI) ---アイテムを生成したユーザーで毎フレーム呼ばれる function update() --box取得 OBJ = ASET.GetSubItem(BAR_STR[1]) POS = OBJ.GetPosition() ANG = Vector3.Angle(Vector3.__new(0, 0, 1), OBJ.GetForward()) if OBJ.GetForward().x < 0 then ANG = -1 * ANG end --根本初期化 if FIRST_FIRST_FLG == true then OBJ.SetPosition(Vector3.__new(POS.x, 0.6, POS.z)) Move_STROBJ() FIRST_FIRST_FLG = false end --±したいボードが選択されているか HOSEI_NUM = STAT.Get("HOSEI_NUM") if HOSEI_NUM==nil then HOSEI_NUM=0 STAT.Set("HOSEI_NUM", HOSEI_NUM) end if HOSEI_NUM >=1 then HOSEI_TI = STAT.Get("HOSEI_TI") --±1以内 if (BAR_NUM[2 + math.floor((HOSEI_NUM - 1) / 2)] + HOSEI_TI<2)and(BAR_NUM[2 + math.floor((HOSEI_NUM - 1) / 2)] + HOSEI_TI>-2) then BAR_NUM[2 + math.floor((HOSEI_NUM - 1) / 2)] = BAR_NUM[2 + math.floor((HOSEI_NUM - 1) / 2)] + HOSEI_TI end HOSEI_NUM = 0 STAT.Set("HOSEI_NUM", HOSEI_NUM) HOSEI_TI = 0 STAT.Set("HOSEI_TI", HOSEI_TI) end --ゲーム初期化 FIRST_FLG = STAT.Get("FIRST_FLG") if FIRST_FLG == true then --ボール配置、色初期化 for i = 1, #BAR_NUM do BAR_NUM[i] = 0 end for i = 1, #BALL_NUM do BALL_NUM[i] = 0 end OBJ = ASET.GetSubItem(BAR_STR[1]) POS = OBJ.GetPosition() ANG = Vector3.Angle(Vector3.__new(0, 0, 1), OBJ.GetForward()) if OBJ.GetForward().x < 0 then ANG = -1 * ANG end --シード決定 math.randomseed(os.clock()) zero_flg = true--配置されていないものがある while zero_flg == true do for i = 1, #BALL_NUM do rand = math.random(1, 64) flg = true--配置に同じ番号が来ない for i2 = 1, #BALL_NUM do if BALL_NUM[i2] == rand then flg = false break end end --重なってないので入力 if flg == true then BALL_NUM[i] = rand else i = 1 end end --while抜ける処理 zero_flg = false for i = 1, #BALL_NUM do --全部配置されていれば if BALL_NUM[i] == 0 then zero_flg = true end end end --玉配置 for i = 1, #BALL_NUM do OBJS = ASET.GetSubItem(BALL_STR[BALL_NUM[i]]) sho = (-3.5 + math.floor((i - 1) / 8)) * 0.06 ama = (-3.5 + (i - 1) % 8) * 0.06 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho pow2 = ama * ama OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * math.sin(math.pi * (ANG2 - ANG) / 180), POS.y + 0.01, POS.z - math.sqrt(pow1 + pow2) * math.cos(math.pi * (ANG2 - ANG) / 180) ) ) end FIRST_FLG = false STAT.Set("FIRST_FLG", FIRST_FLG) end end function onUse(use) --初期化用キューブ if use == "Cube" then FIRST_FLG = true STAT.Set("FIRST_FLG", FIRST_FLG) end --カプセルに対応したバーが移動 HOSEI_NUM = 0--±する奴の番号 STAT.Set("HOSEI_NUM", HOSEI_NUM) HOSEI_TI = 0--±どっちに行くか STAT.Set("HOSEI_TI", HOSEI_TI) for i = 1, #PURAMAI_STR do if PURAMAI_STR[i] == use then --atai = BAR_NUM[2 + math.floor((i - 1) / 2)] if (i % 2) == 1 then --if atai < 1 then HOSEI_NUM = i STAT.Set("HOSEI_NUM", HOSEI_NUM) HOSEI_TI = 1 STAT.Set("HOSEI_TI", HOSEI_TI) --end else --if atai > -1 then HOSEI_NUM = i STAT.Set("HOSEI_NUM", HOSEI_NUM) HOSEI_TI = -1 STAT.Set("HOSEI_TI", HOSEI_TI) -- end end end end end function onTriggerExit(it, h) --全部力とか0 for i = 1, #BAR_STR do Velo_Ang_Zero(BAR_STR[i]) end Velo_Ang_Zero("Cube") end function onCollisionExit(it, h) --全部力とか0 for i = 1, #BAR_STR do Velo_Ang_Zero(BAR_STR[i]) end Velo_Ang_Zero("Cube") end function onUngrab(tar) --Boardならば、全部力とか0 if BAR_STR[1] == tar then for i = 1, #BAR_STR do Velo_Ang_Zero(BAR_STR[i]) end end Velo_Ang_Zero(tar) end --角度と力0 function Velo_Ang_Zero(item) OBJ = ASET.GetSubItem(item) OBJ.SetVelocity(Vector3.__new(0, 0, 0)) OBJ.SetAngularVelocity(Vector3.__new(0, 0, 0)) --Boardが動いたならば if item == BAR_STR[1] then ANG = Vector3.Angle(Vector3.__new(0, 0, 1), OBJ.GetForward()) if OBJ.GetForward().x < 0 then ANG = -1 * ANG end OBJ.SetRotation(Quaternion.Euler(0, ANG, 0)) Move_STROBJ() end end --バーを動かす function Move_STROBJ() --バーを動かす処理 for i = 1, #BAR_STR do OBJS = ASET.GetSubItem(BAR_STR[i]) if i == 1 then POS = OBJS.GetPosition() elseif i == 2 then sho = (6 + BAR_NUM[i]) * 0.06 + 0.02 ama = 4 * 0.06 - 0.03 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho pow2 = ama * ama OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y - 0.005, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) OBJS.SetRotation(Quaternion.Euler(0, ANG + 180, 0)) OBJS = ASET.GetSubItem(PURAMAI_STR[(i - 2) * 2 + 1]) sho = 8 * 0.06 + 0.02 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) OBJS = ASET.GetSubItem(PURAMAI_STR[(i - 2) * 2 + 2]) sho = -8 * 0.06 - 0.02 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) elseif i == 3 then sho = (6 + BAR_NUM[i]) * 0.06 + 0.02 ama = 3 * 0.06 - 0.03 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho pow2 = ama * ama OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y - 0.005, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) OBJS.SetRotation(Quaternion.Euler(0, ANG + 180, 0)) OBJS = ASET.GetSubItem(PURAMAI_STR[(i - 2) * 2 + 1]) sho = 8 * 0.06 + 0.02 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) OBJS = ASET.GetSubItem(PURAMAI_STR[(i - 2) * 2 + 2]) sho = -8 * 0.06 - 0.02 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) elseif i == 4 then sho = (6 + BAR_NUM[i]) * 0.06 + 0.02 ama = 2 * 0.06 - 0.03 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho pow2 = ama * ama OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y - 0.005, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) OBJS.SetRotation(Quaternion.Euler(0, ANG + 180, 0)) OBJS = ASET.GetSubItem(PURAMAI_STR[(i - 2) * 2 + 1]) sho = 8 * 0.06 + 0.02 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) OBJS = ASET.GetSubItem(PURAMAI_STR[(i - 2) * 2 + 2]) sho = -8 * 0.06 - 0.02 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) elseif i == 5 then sho = (6 + BAR_NUM[i]) * 0.06 + 0.02 ama = 1 * 0.06 - 0.03 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho pow2 = ama * ama OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y - 0.005, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) OBJS.SetRotation(Quaternion.Euler(0, ANG + 180, 0)) OBJS = ASET.GetSubItem(PURAMAI_STR[(i - 2) * 2 + 1]) sho = 8 * 0.06 + 0.02 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) OBJS = ASET.GetSubItem(PURAMAI_STR[(i - 2) * 2 + 2]) sho = -8 * 0.06 - 0.02 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) elseif i == 6 then sho = (6 + BAR_NUM[i]) * 0.06 + 0.02 ama = -0.03 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho pow2 = ama * ama OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y - 0.005, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) OBJS.SetRotation(Quaternion.Euler(0, ANG + 180, 0)) OBJS = ASET.GetSubItem(PURAMAI_STR[(i - 2) * 2 + 1]) sho = 8 * 0.06 + 0.02 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) OBJS = ASET.GetSubItem(PURAMAI_STR[(i - 2) * 2 + 2]) sho = -8 * 0.06 - 0.02 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) elseif i == 7 then sho = (6 + BAR_NUM[i]) * 0.06 + 0.02 ama = -1 * 0.06 - 0.03 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho pow2 = ama * ama OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y - 0.005, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) OBJS.SetRotation(Quaternion.Euler(0, ANG + 180, 0)) OBJS = ASET.GetSubItem(PURAMAI_STR[(i - 2) * 2 + 1]) sho = 8 * 0.06 + 0.02 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) ) OBJS = ASET.GetSubItem(PURAMAI_STR[(i - 2) * 2 + 2]) sho = -8 * 0.06 - 0.02 ANG2 = Vector3.Angle(Vector3.__new(0, 0, 1), Vector3.__new(sho, 0, ama).normalized) if sho < 0 then ANG2 = -1 * ANG2 end pow1 = sho * sho OBJS.SetPosition( Vector3.__new( POS.x + math.sqrt(pow1 + pow2) * -math.sin(math.pi * (ANG2 - ANG) / 180), POS.y, POS.z - math.sqrt(pow1 + pow2) * -math.cos(math.pi * (ANG2 - ANG) / 180) ) )
RECOMMEND