Exemplo n.º 1
0
    private void RefreshSelectedBox()
    {
        //toggle selected box
        if (Input.GetMouseButtonUp(0) && highLightedBox != null && !dragging &&
            !(GetComponent <WarpDialog>().WarpMenuEnabled &&             //make sure it not possible to change actor when there is a click inside warp menu
              RectTransformUtility.RectangleContainsScreenPoint(GetComponent <WarpDialog>().Panel, Input.mousePosition)))
        {
            if (highLightedBox.name == "Camera")
            {
                RefreshSelectedCamera();
            }
            else
            {
                if (selectedBox != highLightedBox)
                {
                    selectedBox   = highLightedBox;
                    selectedBoxId = highLightedBox.ID;
                }
                else
                {
                    selectedBox   = null;
                    selectedBoxId = -1;
                    defaultBoxSelectionTimer.Restart();
                }
            }
        }

        if (selectedBox == null && selectedBoxId != -1)
        {
            //if actor is no more available (eg : after room switch) search for it
            foreach (Box box in GetComponent <DosBox>().Boxes)
            {
                if (box != null && box.ID == selectedBoxId)
                {
                    selectedBox = box;
                    break;
                }
            }
        }

        if (selectedBox == null && speedRunMode && defaultBoxSelectionTimer.Elapsed > 1.0f)
        {
            //select player by default
            selectedBox = GetComponent <DosBox>().Player;
            if (selectedBox != null)
            {
                selectedBoxId = selectedBox.ID;
            }
        }

        if (selectedBox != null)
        {
            //display selected box info
            selectedBox.UpdateText(BottomText);
        }
        else
        {
            BottomText.Clear(true);
        }
    }
Exemplo n.º 2
0
    public void UpdateBoxInfo()
    {
        BoxInfo.Clear();
        if (Player != null)
        {
            float angle     = Player.Angles.y * 360.0f / 1024.0f;
            float sideAngle = (angle + 45.0f) % 90.0f - 45.0f;

            BoxInfo.Append("Position", Player.LocalPosition + Player.Mod);
            BoxInfo.Append("Angle", "{0:N1} {1:N1}", angle, sideAngle);
        }

        if (ShowAITD1Vars || ShowAdditionalInfo)
        {
            if (Player != null)
            {
                BoxInfo.AppendLine();
            }

            if (ShowAITD1Vars)
            {
                int      calculatedFps = previousFramesCount.Sum();
                TimeSpan totalDelayTS  = TimeSpan.FromSeconds(totalDelay.Elapsed);

                BoxInfo.Append("Timer 1", "{0}.{1:D2}", TimeSpan.FromSeconds(InternalTimer1 / 60), InternalTimer1 % 60);
                BoxInfo.Append("Timer 2", "{0}.{1:D2}", TimeSpan.FromSeconds(internalTimer2 / 60), internalTimer2 % 60);
                BoxInfo.Append("FPS/Frame/Delay", "{0}; {1}; {2} ms", calculatedFps, frameCounter, Mathf.FloorToInt(lastDelay * 1000));
                BoxInfo.Append("Total delay", "{0:D2}:{1:D2}:{2:D2}.{3:D3} ", totalDelayTS.Hours, totalDelayTS.Minutes, totalDelayTS.Seconds, totalDelayTS.Milliseconds);
            }

            Vector3 mousePosition = GetMousePosition(linkroom, linkfloor);
            BoxInfo.Append("Cursor position", "{0} {1}", Mathf.Clamp((int)(mousePosition.x), -32768, 32767), Mathf.Clamp((int)(mousePosition.z), -32768, 32767));
            if (Player != null)
            {
                BoxInfo.Append("Last offset/dist", "{0}; {1}", Player.LastOffset, Mathf.RoundToInt(Player.LastDistance));
            }

            if (ShowAITD1Vars)
            {
                BoxInfo.Append("Allow inventory", allowInventory ? "Yes" : "No");
                BoxInfo.Append("In hand", inHand);
            }
        }

        BoxInfo.UpdateText();
    }
Exemplo n.º 3
0
    public void UpdateText(BoxInfo info)
    {
        info.Clear();
        info.Append("TYPE", name.ToUpperInvariant());
        info.Append("ID", ID);

        if (name == "Collider" || name == "Trigger")
        {
            info.Append("FLAGS", "0x{0:X4}", Flags);
        }

        if (name == "Camera" && DosBox != null && DosBox.ShowAdditionalInfo)
        {
            Vector3 position = Camera.transform.localPosition * 1000.0f;
            Vector3 rotation = Camera.transform.rotation.eulerAngles;
            info.Append("POSITION", "{0:F0} {1:F0} {2:F0}", position.x, -position.y, position.z);
            info.Append("ANGLE", "{0:N1} {1:N1} {2:N1}",
                        rotation.x > 180.0f ? (rotation.x - 360.0f) : rotation.x,
                        (-rotation.y + 540.0f) % 360.0f,
                        rotation.z > 180.0f ? (rotation.z - 360.0f) : rotation.z);
        }

        if (name == "Actor")
        {
            if (DosBox.ShowAdditionalInfo)
            {
                info.Append("FLAGS/COL", "0x{0:X4} 0x{1:X4}", Flags, ColFlags);
            }
            else
            {
                info.Append("FLAGS", "0x{0:X4}", Flags);
            }

            if (DosBox.ShowAdditionalInfo)
            {
                info.Append("ROOM", "E{0}R{1}", Floor, Room);
                info.Append("ROOM_POS", LocalPosition + Mod);
                info.Append("WORLD_POS", WorldPosition + Mod);
                info.Append("ZV_POS", BoundingPos);
                info.Append("ZV_SIZE", BoundingSize);
                info.Append("MOD", Mod);
                info.Append("OFFSET", LastOffset);
                info.Append("DISTANCE", Mathf.RoundToInt(LastDistance));
                if (Angles.x == 0.0f && Angles.z == 0.0f)
                {
                    info.Append("ANGLE", "{0:N1} {1}",
                                Angles.y * 360.0f / 1024.0f,
                                RotateDir);
                }
                else
                {
                    info.Append("ANGLE", "{0:N1} {1:N1} {2:N1}",
                                Angles.x * 360.0f / 1024.0f,
                                Angles.y * 360.0f / 1024.0f,
                                Angles.z * 360.0f / 1024.0f);
                }
            }

            if (Life != -1)
            {
                if (DosBox.ShowAdditionalInfo && LifeMode >= 0 && LifeMode <= 2)
                {
                    info.Append("LIFE/LIFEMODE", "{0}; {1}", Life, lifeModeInfo[LifeMode]);
                }
                else
                {
                    info.Append("LIFE", Life);
                }
            }

            if (Body != -1)
            {
                if (Anim != -1)
                {
                    if (DosBox.ShowAITD1Vars && NextAnim != -1)
                    {
                        info.Append("BODY/ANIM", "{0}; {1}; {2}", Body, Anim, NextAnim);
                    }
                    else
                    {
                        info.Append("BODY/ANIM", "{0}; {1}", Body, Anim);
                    }

                    if (DosBox.ShowAITD1Vars && AnimType >= 0 && AnimType <= 2)
                    {
                        info.Append("ANIMTYPE", animTypeInfo[AnimType]);
                    }
                }
                else
                {
                    info.Append("BODY", Body);
                }
            }

            if (DosBox.ShowAITD1Vars && Anim != -1)
            {
                if (Keyframe != -1)
                {
                    info.Append("KEYFRAME", "{0}/{1}; {2} {3}", Keyframe, TotalFrames - 1, EndFrame, EndAnim);
                    info.Append("FRAME", Mathf.FloorToInt(lastKeyFrameChange.Elapsed * 60.0f));
                }

                info.Append("SPEED", Speed);
            }

            if (DosBox.ShowAITD1Vars && Chrono != 0)
            {
                info.Append("CHRONO", "{0}.{1:D2}", TimeSpan.FromSeconds((DosBox.InternalTimer1 - Chrono) / 60), (DosBox.InternalTimer1 - Chrono) % 60);
            }
            if (DosBox.ShowAITD1Vars && RoomChrono != 0)
            {
                info.Append("ROOM_CHRONO", "{0}.{1:D2}", TimeSpan.FromSeconds((DosBox.InternalTimer1 - RoomChrono) / 60), (DosBox.InternalTimer1 - RoomChrono) % 60);
            }
            if (DosBox.ShowAdditionalInfo && TrackMode >= 0 && TrackMode <= 3)
            {
                info.Append("TRACKMODE", trackModeInfo[TrackMode]);
            }
            if (DosBox.ShowAITD1Vars && TrackNumber != -1)
            {
                info.Append("TRACKNUM/POS", "{0} {1}", DashIfEmpty(TrackNumber), DashIfEmpty(PositionInTrack));
            }
            if (DosBox.ShowAITD1Vars && ActionType >= 0 && ActionType <= 10)
            {
                info.Append("ACTIONTYPE", actionTypeInfo[ActionType]);
            }
            if (DosBox.ShowAITD1Vars)
            {
                info.Append("2DBOX", "{0} {1}; {2} {3}", Box2DLower.x, Box2DLower.y, Box2DUpper.x, Box2DUpper.y);
            }
            if (DosBox.ShowAITD1Vars)
            {
                info.Append("HITFORCE", HitForce);
            }
            if (DosBox.ShowAITD1Vars)
            {
                info.Append("HIT/BY COL/BY", "{0} {1}  {2} {3} {4} {5}", GetActorID(Hit), GetActorID(HitBy), GetActorID((int)Col.x), GetActorID((int)Col.y), GetActorID((int)Col.z), GetActorID(ColBy));
            }
            if (DosBox.ShowAITD1Vars)
            {
                info.Append("HARDCOL/TRIG", "{0} {1}", DashIfEmpty(HardCol), DashIfEmpty(HardTrigger));
            }
            if (DosBox.ShowAdditionalInfo)
            {
                info.Append("SLOT", Slot);
            }
        }

        info.UpdateText();
    }
Exemplo n.º 4
0
    private void RefreshHighLightedBox()
    {
        Vector3 mousePosition = Input.mousePosition;

        RaycastHit[] hitInfos = null;

        //check screen boundaries
        if (mousePosition.x > 0 && mousePosition.x < Screen.width &&
            mousePosition.y > 0 && mousePosition.y < Screen.height)
        {
            hitInfos = Physics.RaycastAll(Camera.main.ScreenPointToRay(mousePosition));
        }

        if (hitInfos != null && hitInfos.Length > 0 &&
            !menuEnabled && !GetComponent <WarpDialog>().WarpMenuEnabled)
        {
            //sort colliders by priority
            boxComparer.Room = room;
            Array.Sort(hitInfos, boxComparer);

            Box box = hitInfos[0].collider.GetComponent <Box>();
            if (box != highLightedBox)
            {
                if (highLightedBox != null)
                {
                    highLightedBox.HighLight = false;
                    if (highLightedBox.name == "Camera")
                    {
                        highLightedBox.GetComponent <Renderer>().sharedMaterial.renderQueue = 3000;
                    }
                }

                box.HighLight = true;

                if (box.name == "Camera")
                {
                    box.GetComponent <Renderer>().sharedMaterial.renderQueue = 3500;
                }

                highLightedBox = box;
            }

            //display info
            Vector3 position = Camera.main.WorldToScreenPoint(box.GetComponent <Renderer>().bounds.center);
            Vector2 size     = BoxInfo.GetComponent <RectTransform>().sizeDelta;

            //make sure box fit in viewport
            position.x = Mathf.Clamp(position.x, size.x / 2.0f, Screen.width - size.x / 2.0f);
            position.y = Mathf.Clamp(position.y, size.y / 2.0f, Screen.height - size.y / 2.0f);
            BoxInfo.transform.position = new Vector3(position.x, position.y, 0.0f);

            //text
            box.UpdateText(BoxInfo);
        }
        else
        {
            if (highLightedBox != null)
            {
                highLightedBox.HighLight = false;
                highLightedBox           = null;
            }

            BoxInfo.Clear(true);
        }
    }