Esempio n. 1
0
    public static void SetAllGameSlotReferences(Transform boardParent)
    {
        GameSlot slot;

        for (int i = 0; i < boardParent.childCount; i++)
        {
            slot = boardParent.GetChild(i).GetComponent <GameSlot>();
            for (int j = 0; j < slot.transform.childCount; j++)
            {
                Transform currentSlotChild = slot.transform.GetChild(j);

                GameShape gameShape = currentSlotChild.GetComponent <GameShape>();
                if (gameShape != null)
                {
                    slot.SetSlotShapeReference(currentSlotChild);
                    EditorUtility.SetDirty(slot);
                    continue;
                }

                SlotLock slotLock = currentSlotChild.GetComponent <SlotLock>();
                if (slotLock != null)
                {
                    slot.SetSlotLock(slotLock);
                    EditorUtility.SetDirty(slot);
                    continue;
                }
            }
        }
    }
Esempio n. 2
0
    public static void EditSlotLock(Transform slot, SlotLock.LockType lockType, int counter, float width)
    {
        SlotLock slotLock = slot.GetComponent <GameSlot>().GetSlotLock();

        slotLock.SetLockSettings(lockType, counter);
        slotLock.transform.localScale = new Vector3(width / baseLockSize, width / baseLockSize);

        EditorUtility.SetDirty(slotLock);
        EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
    }
Esempio n. 3
0
    public static void CreateSlotLock(Transform slot, SlotLock.LockType lockType, int counter, float width)
    {
        GameObject lockPrefab = Resources.Load <GameObject>("Prefabs/SlotLock");

        GameObject newLock = PrefabUtility.InstantiatePrefab(lockPrefab, slot) as GameObject;

        newLock.transform.localPosition = Vector3.zero;
        newLock.transform.localScale    = new Vector3(width / baseLockSize, width / baseLockSize);

        SlotLock slotLock = newLock.GetComponent <SlotLock>();

        slotLock.SetLockSettings(lockType, counter);

        slot.GetComponent <GameSlot>().SetSlotLock(slotLock);
        EditorUtility.SetDirty(slot.GetComponent <GameSlot>());
        EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
    }
Esempio n. 4
0
        async Task ProcessAsync(HttpListenerContext ctx)
        {
            if (ctx.Request.UserAgent != "osu!")
            {
                return;
            }
            if (ctx.Request.Url.AbsolutePath.StartsWith("/web/"))
            {
                return;
            }

            if (string.IsNullOrEmpty(ctx.Request.Headers["osu-token"]))
            {
                await Login.Handle(ctx);

                return;
            }

            Player p = Global.FindPlayer(ctx.Request.Headers["osu-token"]);

            if (p == null) // if they arent part of the player collection, force them to relogin
            {
                ctx.Response.StatusCode = 403;
                ctx.Response.OutputStream.Write(Packets.Packets.SingleIntPacket(5, -5));
                ctx.Response.Close();
                return;
            }

            using (MemoryStream ms = new MemoryStream())
                using (BinaryReader r = new BinaryReader(ms))
                {
                    await ctx.Request.InputStream.CopyToAsync(ms);

                    ms.Position = 0;
                    while (ms.Position < ctx.Request.ContentLength64 - 6)
                    {
                        short Id = r.ReadInt16();
                        ms.Position += 1;
                        int Length = r.ReadInt32();
                        if (ms.Position + Length > ctx.Request.ContentLength64)
                        {
                            break;
                        }
                        if (Id == 68 || Id == 79)
                        {
                            ms.Position += Length;
                            continue;
                        }

                        byte[] Data = r.ReadBytes(Length);
                        switch (Id)
                        {
                        case 4: p.Ping = DateTime.Now.Ticks; break;

                        case 0:
                            StatusUpdate.Handle(p, Data);
                            break;

                        case 1:
                            IrcMessage.Handle(p, Data);
                            break;

                        case 2:
                            Player.RemovePlayer(p);
                            break;

                        case 3:
                            await StatsUpdateRequest.Handle(p);

                            break;

                        case 16:
                            StartSpectating.Handle(p, Data);
                            break;

                        case 17:
                            StopSpectating.Handle(p);
                            break;

                        case 18:
                            SpectatorFrames.Handle(p, Data);
                            break;

                        case 25:
                            IrcMessage.HandlePrivate(p, Data);
                            break;

                        case 29:
                            Global.LeaveLobby(p);
                            break;

                        case 30:
                            Global.JoinLobby(p);
                            break;

                        case 31:
                            CreateMatch.Handle(p, Data);
                            break;

                        case 32:
                            JoinMatch.Handle(p, Data);
                            break;

                        case 33:
                            LeaveMatch.Handle(p);
                            break;

                        case 38:
                            ChangeSlot.Handle(p, Data);
                            break;

                        case 39:
                            MatchReady.Handle(p);
                            break;

                        case 40:
                            SlotLock.Handle(p, Data);
                            break;

                        case 41:
                            MatchSettings.Handle(p, Data);
                            break;

                        case 44:
                            MatchStart.Handle(p, Data);
                            break;

                        case 49:
                            MatchFinished.Handle(p);
                            break;

                        case 51:
                            ModsChange.Handle(p, Data);
                            break;

                        case 52:
                            MatchLoaded.Handle(p);
                            break;

                        case 54:
                            NoBeatmap.Handle(p);
                            break;

                        case 55:
                            MatchReady.Handle(p);
                            break;

                        case 56:
                            MatchFailed.Handle(p);
                            break;

                        case 59:
                            HasBeatmap.Handle(p);
                            break;

                        case 60:
                            MatchSkip.Handle(p);
                            break;

                        case 63:
                            ChannelJoinEvent.Handle(p, Data);
                            break;

                        case 70:
                            ChangeHost.Handle(p, Data);
                            break;

                        case 73:
                            AddFriend.Handle(p, Data);
                            break;

                        case 74:
                            RemoveFriend.Handle(p, Data);
                            break;

                        case 77:
                            ChangeTeam.Handle(p, Data);
                            break;

                        case 78:
                            ChannelLeaveEvent.Handle(p, Data);
                            break;

                        case 85:
                            StatsUpdateRequest.Handle(p, Data);
                            break;

                        case 90:
                            MatchChangePassword.Handle(p, Data);
                            break;

                        default:
                            Log.LogFormat($"%#FFFF%Unhandled Packet {Id} with {Length}");
                            break;
                        }
                    }
                }

            if (p.StreamLength != 0)
            {
                p.StreamCopyTo(ctx.Response.OutputStream);
            }
            ctx.Response.Close();
        }
Esempio n. 5
0
 public void SetSlotLock(SlotLock l)
 {
     slotLock = l;
 }
Esempio n. 6
0
 public DestructLockState(SlotLock lockReference)
 {
     slotLock = lockReference;
 }
Esempio n. 7
0
 public SwitchLockState(SlotLock lockReference)
 {
     slotLock = lockReference;
 }
Esempio n. 8
0
    private void DrawGameShapeOptions(GameSlot slot)
    {
        GameShape shapeData = slot.GetSlotShape();

        if (shapeData != null)
        {
            EditorGUILayout.LabelField($"Shape Info", EditorStyles.boldLabel);
            EditorGUILayout.LabelField($"Shape Color: {shapeData.colorType}");
            EditorGUILayout.LabelField($"Shape Type: {shapeData.GetShapeType()}");
        }
        else
        {
            EditorGUILayout.LabelField("Shape Info: No Shape Available");
        }

        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Lock Options", EditorStyles.boldLabel);

        desiredLockType  = (SlotLock.LockType)EditorGUILayout.EnumPopup("Lock Type", desiredLockType);
        desiredLockTimer = EditorGUILayout.IntField("Lock Timer", desiredLockTimer);
        desiredLockSize  = EditorGUILayout.FloatField("Lock Size", desiredLockSize);

        EditorGUILayout.BeginHorizontal();
        if (slot.GetSlotLock() != null)
        {
            if (GUILayout.Button("Edit Lock", GUILayout.MaxWidth(150f)))
            {
                GameSlotTools.EditSlotLock(slot.transform, desiredLockType, desiredLockTimer, desiredLockSize);
                EditorUtility.SetDirty(slot.GetComponent <GameSlot>().GetSlotLock());
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }
        else
        {
            if (GUILayout.Button("Create Lock", GUILayout.MaxWidth(150f)))
            {
                GameSlotTools.CreateSlotLock(slot.transform, desiredLockType, desiredLockTimer, desiredLockSize);
                EditorUtility.SetDirty(slot.GetComponent <GameSlot>().GetSlotLock());
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }

        SlotLock slotLock = slot.GetSlotLock();

        if (slotLock != null && GUILayout.Button("Destroy Lock", GUILayout.Width(150f)))
        {
            DestroyImmediate(slotLock.gameObject);
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Shape Options", EditorStyles.boldLabel);

        desiredShapeType  = (GameShape.ShapeType)EditorGUILayout.EnumPopup("Shape Type", desiredShapeType);
        desiredShapeColor = (GameShape.ColorType)EditorGUILayout.EnumPopup("Shape Color", desiredShapeColor);
        desiredShapeSize  = EditorGUILayout.FloatField("Shape Scale", desiredShapeSize);

        EditorGUILayout.BeginHorizontal();
        if (slot.GetSlotShape() != null)
        {
            if (GUILayout.Button("Edit Shape", GUILayout.MaxWidth(150f)))
            {
                GameSlotTools.EditSlotShape(slot.transform, desiredShapeType, desiredShapeColor, desiredShapeSize);
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }
        else
        {
            if (GUILayout.Button("Create Shape", GUILayout.MaxWidth(150f)))
            {
                GameSlotTools.CreateSlotShape(slot.transform, desiredShapeType, desiredShapeColor, desiredShapeSize);
                EditorUtility.SetDirty(slot.GetComponent <GameSlot>());
                EditorUtility.SetDirty(slot.GetComponent <GameSlot>().GetSlotShape());
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }

        if (shapeData != null && GUILayout.Button("Destroy Shape", GUILayout.Width(150f)))
        {
            DestroyImmediate(shapeData.gameObject);
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Separator();
    }