示例#1
0
 public void SetToolVal(PrintTool tool, ToolData val)
 {
     if (curTool == tool)
     {
         paintTool.SetToolVal(val);
     }
 }
示例#2
0
 void SetToolData(ToolData data, GameObject obj)
 {
     data          = new ToolData();
     data.position = obj.transform.position;
     data.rotation = obj.transform.rotation;
     data.scale    = obj.transform.localScale;
 }
示例#3
0
    // Changing of tool on certain tool data //
    public void UpdateData(ToolData newTool)
    {
        bg = GetComponent <Image>();

        if (newTool == null)
        {
            if (toolData != null)
            {
                gearImg.gameObject.SetActive(false);
            }

            toolData = null;
            return;
        }

        gearImg = transform.GetChild(0).GetComponent <Image>();
        gearImg.gameObject.SetActive(true);

        toolData = newTool;

        if (toolData != null)
        {
            gearImg.enabled = true;
            gearImg.sprite  = toolData.prefab.GetComponent <SpriteRenderer>().sprite;
        }
        else
        {
            gearImg.enabled = false;
        }
    }
        public Toolbox(ToolData toolData, Simulator simulator)
        {
            this.toolData  = toolData;
            this.simulator = simulator;

            availableToolUses   = new Dictionary <Tool, int>();
            shapeRewards        = new Dictionary <MatchShape, Tool>();
            requiredChainLength = new Dictionary <Tool, int>();
            awardedToolsForCurrentChainLength = new Dictionary <Tool, int>();

            foreach ((Tool tool, ToolData.SingleToolData data) in toolData.Map)
            {
                availableToolUses[tool] = data.InitialUses;

                if (data.AwardedFor != MatchShape.None)
                {
                    if (shapeRewards.ContainsKey(data.AwardedFor))
                    {
                        throw new ArgumentOutOfRangeException(nameof(toolData), "Multiple tools associated with the same shape");
                    }

                    shapeRewards[data.AwardedFor] = tool;
                }

                requiredChainLength[tool] = 1;
                awardedToolsForCurrentChainLength[tool] = 0;
            }
        }
示例#5
0
 public void AddToolData(ToolData toolData)
 {
     if (toolData is DumbbellDataValue)
     {
         this.dumbbellData.Add((DumbbellDataValue)toolData);
     }
 }
示例#6
0
 void AddToolToDeviceData(ToolData toolData, HashSet <InputDevice> devices)
 {
     foreach (var dev in devices)
     {
         AddToolToStack(dev, toolData);
     }
 }
示例#7
0
    public void PlaceStructure(ToolData tool, Vector3 position, Quaternion rotation)
    {
        var structure = GameObject.Instantiate(tool.Prefab.gameObject, position, rotation, _structuresParent.transform)
                        .GetComponent <PlaceableStructure>();

        structure.ViewMode = StructureViewMode.Ingame;
    }
示例#8
0
            internal static void SpawnDefaultTools(IProxy proxy)
            {
                var vacuumables  = evr.GetNestedModule <Vacuumables>();
                var lockModule   = evr.GetModule <LockModule>();
                var defaultTools = evr.m_DefaultTools;

                foreach (var deviceData in evr.m_DeviceData)
                {
                    var      inputDevice       = deviceData.inputDevice;
                    ToolData selectionToolData = null;

                    if (deviceData.proxy != proxy)
                    {
                        continue;
                    }

                    foreach (var toolType in defaultTools)
                    {
                        HashSet <InputDevice> devices;
                        var toolData = SpawnTool(toolType, out devices, inputDevice);
                        AddToolToDeviceData(toolData, devices);

                        var tool          = toolData.tool;
                        var selectionTool = tool as SelectionTool;
                        if (selectionTool)
                        {
                            selectionToolData      = toolData;
                            selectionTool.hovered += lockModule.OnHovered;
                        }

                        var vacuumTool = tool as VacuumTool;
                        if (vacuumTool)
                        {
                            vacuumTool.defaultOffset = WorkspaceModule.DefaultWorkspaceOffset;
                            vacuumTool.defaultTilt   = WorkspaceModule.DefaultWorkspaceTilt;
                            vacuumTool.vacuumables   = vacuumables.vacuumables;
                        }
                    }

                    var menuHideData = deviceData.menuHideData;
                    var mainMenu     = Menus.SpawnMainMenu(typeof(MainMenu), inputDevice, false, out deviceData.mainMenuInput);
                    deviceData.mainMenu    = mainMenu;
                    menuHideData[mainMenu] = new Menus.MenuHideData();

                    var alternateMenu = Menus.SpawnAlternateMenu(typeof(RadialMenu), inputDevice, out deviceData.alternateMenuInput);
                    deviceData.alternateMenu       = alternateMenu;
                    menuHideData[alternateMenu]    = new Menus.MenuHideData();
                    alternateMenu.itemWasSelected += Menus.UpdateAlternateMenuOnSelectionChanged;

                    // Setup ToolsMenu
                    var toolsMenu = Menus.SpawnToolsMenu(typeof(Experimental.EditorVR.Menus.ToolsMenu), inputDevice, out deviceData.toolsMenuInput);
                    deviceData.ToolsMenu = toolsMenu;
                    toolsMenu.rayOrigin  = deviceData.rayOrigin;
                    toolsMenu.setButtonForType(typeof(IMainMenu), null);
                    toolsMenu.setButtonForType(typeof(SelectionTool), selectionToolData != null ? selectionToolData.icon : null);
                }

                evr.GetModule <DeviceInputModule>().UpdatePlayerHandleMaps();
            }
示例#9
0
    //TODO: Create reference to player's fishing spear
    public override void Initialize(UseItemStateMachine parent, ToolData tool, Transform location, ToolComponentReferences references)
    {
        Debug.Log("Let's go!");
        parentStateMachine = parent;
        PlayerTool         = tool;

        CreateAssets();
    }
示例#10
0
        public IToolData MapToolData(ToolData source)
        {
            var acct   = Session.Get <AccountInfo>(source.AccountID);
            var result = MapFrom <ToolDataItem>(source);

            result.OrgID = acct.OrgID;
            return(result);
        }
示例#11
0
    public bool CorrectTool(ToolData tool)
    {
        //Grabs the resource the player is trying to hit
        //And checks if the resource isnt null and the tool is in the source object
        var resource = GetResource();

        return(resource != null && tool.resourceType.Contains(resource.resourceObject));
    }
    private void InitToolList()
    {
        ToolData axe        = new ToolData(TYPE.Axe);
        ToolData springkler = new ToolData(TYPE.Springkler);

        toolDic.Add(0, axe);
        toolDic.Add(1, springkler);
    }
示例#13
0
 public void ToolDataReceived(ToolData data)
 {
     if (data is DumbellDataValue dumbell)
         Collection.Add(dumbell.WeightValue);
     // OR
     if (!(data is DumbellDataValue dumbell))
         return;
     Collection.Add(dumbell.WeightValue);
 }
示例#14
0
 public dataMonitor()
 {
     InitializeComponent();
     tool1      = Form1.tool;
     w1         = Form1.w;
     toolData   = Form1.toolData;
     wobjData   = Form1.wobjData;
     controller = Form1.controller;
 }
示例#15
0
 static void AddToolToDeviceData(ToolData toolData, HashSet <InputDevice> devices)
 {
     foreach (var dd in evr.m_DeviceData)
     {
         if (devices.Contains(dd.inputDevice))
         {
             AddToolToStack(dd, toolData);
         }
     }
 }
示例#16
0
    public void UpdateTool(string letter)
    {
        ToolData tool = toolMap[letter];

        tool.Time       = currentToolTime;
        tool.Count     += 1;
        toolMap[letter] = tool;
        currentToolTime = 0;
        toolListString += letter;
    }
示例#17
0
 public bool CanBeCollectedBy(ToolData toolData)
 {
     if (!itemData)
     {
         return(false);
     }
     return(itemData.requiredTier.quality == 0 ||
            toolData.tier.quality >= itemData.requiredTier.quality &&
            itemData.requiredToolType == toolData.type);
 }
示例#18
0
 public void InitializeTest()
 {
     toolData = ScriptableObject.CreateInstance <ToolData>();
     toolData.Map[Tool.ToggleMarked].InitialUses  = -1;
     toolData.Map[Tool.RemoveTile].AwardedFor     = MatchShape.Row3;
     toolData.Map[Tool.RemoveRow].AwardedFor      = MatchShape.Row4;
     toolData.Map[Tool.CreateWildcard].AwardedFor = MatchShape.Row5;
     toolData.Map[Tool.PlusBomb].AwardedFor       = MatchShape.Plus;
     toolData.Map[Tool.RemoveColor].AwardedFor    = MatchShape.T;
     toolData.Map[Tool.Rotate3x3].AwardedFor      = MatchShape.L;
     toolData.Map[Tool.SwapTiles].AwardedFor      = MatchShape.H;
     toolData.Map[Tool.SwapLines].AwardedFor      = MatchShape.U;
 }
示例#19
0
    //TODO: Create reference to player's fishing rod
    public override void Initialize(UseItemStateMachine parent, ToolData tool, Transform location, ToolComponentReferences references)
    {
        //Debug.Log("Let's go!");
        _fishingLocation = location;

        toolReferences = references;

        parentStateMachine = parent;
        PlayerTool         = tool;
        playerRod          = (ToolRodData)PlayerTool;
        CreateAssets();
        _rodFishingState = 1;
    }
示例#20
0
            static void AddToolToStack(DeviceData deviceData, ToolData toolData)
            {
                if (toolData != null)
                {
                    // Exclusive tools render other tools disabled while they are on the stack
                    if (toolData.tool is IExclusiveMode)
                    {
                        SetToolsEnabled(deviceData, false);
                    }

                    deviceData.toolData.Push(toolData);
                    deviceData.currentTool = toolData.tool;
                }
            }
示例#21
0
        private void OnItemPressDown(GameObject obj_)
        {
            EngineCoreEvents.AudioEvents.PlayAudio.SafeInvoke(Audio.AudioType.UISound, EngineCommonAudioKey.Button_Click_Common.ToString());
            int index = int.Parse(obj_.name);

            ToolData t_d = m_item_datas[index];

            m_tool_tip.Refresh(t_d.m_tool_id, t_d.m_tool_count, t_d.m_tool_max_count);

            m_tool_tip.gameObject.transform.position = obj_.transform.position;
            m_tool_tip.Widget.anchoredPosition       = m_tool_tip.Widget.anchoredPosition - new Vector2(m_tool_tip.Widget.sizeDelta.x * 0.5f + 30.0f, index * -30.0f);
            //RectTransform rect = obj_.GetComponent<RectTransform>();
            //m_tool_tip.Widget.anchoredPosition = rect.anchoredPosition - new Vector2(m_tool_tip.Widget.sizeDelta.x * 0.5f, -20.0f);
            m_tool_tip.Visible = true;
        }
示例#22
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         // 转化为工具坐标和坐标系
         toolData        = (ToolData)tool1.Data; // 拆箱操作
         wobjData        = (WobjData)w1.Data;
         label_tool.Text = "当前Tool:" + tool1.Name + "  " + "坐标:" + toolData.ToString();
         label_wobj.Text = "工具坐标系:" + w1.Name + "  " + "工具坐标:" + wobjData.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "获取失败");
     }
 }
示例#23
0
        public void Initialize(UnitData unitData, OwnerType assignedOwner)
        {
            _name         = unitData.name;
            Health        = unitData.health;
            MovementSpeed = unitData.movementSpeed;
            UnitType      = unitData.type;
            if (assignedOwner == OwnerType.NONE)
            {
                assignedOwner = OwnerType.PLAYER;
            }
            string targetLayerName = "Default";

            switch (assignedOwner)
            {
            case OwnerType.NONE:
                break;

            case OwnerType.NEUTRAL:
                targetLayerName = "NeutralUnits";
                break;

            case OwnerType.PLAYER:
                targetLayerName = "PlayerUnits";
                break;

            case OwnerType.AI:
                targetLayerName = "AIUnits";
                break;
            }
            gameObject.layer = LayerMask.NameToLayer(targetLayerName);
            owner            = assignedOwner;
            _unitId          = ids++;
            _toolData        = unitData.toolData;
            _weaponData      = unitData.weaponData;
            InitializeWeapon(unitData.weaponData);
            InitializeCommands(unitData);
            if (UnitType == UnitType.CHARACTER)
            {
                _unitService.UnitAppeared    += AddVisibleUnit;
                _unitService.UnitDisappeared += RemoveVisibleUnit;
                _unitService.UnitDying       += RemoveVisibleUnit;
            }
            _beatInputService.BeatLost           += BeatLost;
            _beatInputService.ExecutionFinishing += ExecutionFinishing;
            _gameStateService.GameFinishing      += OnGameFinishing;
        }
示例#24
0
        /*
         * [STAThread]
         * public static void robotListener(string[] controllerData, int port)
         * {
         *  IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(controllerData[1]), port);
         *  TcpListener listener = new TcpListener(endPoint);
         *  Socket socket = null;
         *
         *  listener.Start();
         *  Console.WriteLine("Local end point: {0}", listener.LocalEndpoint);
         *  socket = listener.AcceptSocket();
         *  Console.WriteLine("Connection accepted from " + socket.RemoteEndPoint);
         *
         *  byte[] data = new byte[256];
         *  int len = socket.Receive(data);
         *  Console.WriteLine("Received...");
         *
         *
         *
         *
         *  TcpClient client = listener.AcceptTcpClient();
         *  Console.WriteLine("Connection accepted");
         *
         *  NetworkStream stream = client.GetStream();
         *  String response = "Connection has been accepted";
         *  Byte[] sendTheseBytes = Encoding.ASCII.GetBytes(response);
         *
         *  stream.Write(sendTheseBytes, 0, sendTheseBytes.Length);
         *
         *
         *  client.Close();
         *  listener.Stop();
         * }
         *
         *
         * public static RobTarget RobTargetAtPoint(Point point, double q1, double q2, double q3, double q4)
         * {
         *  var target = new RobTarget();
         *  if (point != null)
         *  {
         *      target.FillFromString2(
         *          string.Format(
         *              "[[{0},{1},{2}],[{3},{4},{5},{6}],[0,0,0,0],[9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09]];",
         *              point.X, point.Y, point.Z, q1, q2, q3, q4));
         *  }
         *  return target;
         * }
         */



        public static ToolData toolData(float x, float y, float z, float q1, float q2, float q3, float q4, float load, float cog_x, float cog_y, float cog_z)
        {
            var t = new ToolData();

            t.Tframe.Trans.X = x;
            t.Tframe.Trans.Y = y;
            t.Tframe.Trans.Z = z;
            t.Tframe.Rot.Q1  = q1;
            t.Tframe.Rot.Q2  = q2;
            t.Tframe.Rot.Q3  = q3;
            t.Tframe.Rot.Q4  = q4;
            t.Tload.Mass     = load;
            t.Tload.Cog.X    = cog_x;
            t.Tload.Cog.Y    = cog_y;
            t.Tload.Cog.Z    = cog_z;
            return(t);
        }
示例#25
0
        public virtual void Setup()
        {
            ToolData toolData = resourceService.GetTool(toolId);

            button.SetListener(() => {
                if (playerService.GetItemCount(toolData) > 0)
                {
                    if (IsValid(toolData))
                    {
                        playerService.UseItem(toolData, OnUse);
                    }
                }
                else
                {
                    viewService.ShowView(RavenhillViewType.buy_item_view, toolData);
                }
            }, engine.GetService <IAudioService>());
        }
示例#26
0
    public void SetNewCustomTool(ToolData data)
    {
        DestroyCustomTool();
        Hotbar.Instance.AddNewToolData(2, data);

        Tool newTool = Instantiate(data.prefab, handTrans.transform.position, Quaternion.identity, handTrans).GetComponent <Tool>();

        newTool.transform.localRotation = Quaternion.Euler(Vector3.forward * data.zOffset);

        tools[2] = newTool;

        if (nowTool == null)
        {
            nowTool = newTool;
            ChangeTool(2);
        }

        CheckForRanged();
    }
示例#27
0
        public override void Setup()
        {
            base.Setup();
            ToolData toolData = resourceService.GetTool(toolId);

            button.SetListener(() => {
                if (playerService.GetItemCount(toolData) > 0)
                {
                    if (IsValid(toolData))
                    {
                        //playerService.UseItem(toolData, OnUse);
                        MessageBoxView.Data msgBoxData = new MessageBoxView.Data {
                            content       = "[Do you want to complete the room instantly?]",
                            textPanColor  = ControlColor.white,
                            buttonConfigs = new ButtonConfig[] {
                                new ButtonConfig {
                                    buttonName = "[Yes]",
                                    color      = ControlColor.green,
                                    action     = () => {
                                        playerService.UseItem(toolData, OnUse);
                                    }
                                },
                                new ButtonConfig {
                                    buttonName = "[No]",
                                    color      = ControlColor.red,
                                    action     = () => { }
                                }
                            }
                        };
                        viewService.ShowView(RavenhillViewType.message_box_view, msgBoxData);
                    }
                }
                else
                {
                    viewService.ShowView(RavenhillViewType.buy_item_view, toolData);
                }
            }, engine.GetService <IAudioService>());
        }
    private void UpdatePreviewObject(ToolData tool)
    {
        if (_previewTool == tool)
        {
            return;
        }

        if (_previewObject != null)
        {
            Destroy(_previewObject.gameObject);
            _previewObject = null;
        }

        _previewTool = tool;

        if (_previewTool == null)
        {
            return;
        }

        _previewObject = Instantiate(_previewTool.Prefab, transform)
                         .GetComponent <PlaceableStructure>();
        _previewObject.ViewMode = StructureViewMode.Preview;
    }
示例#29
0
 public abstract void SetToolVal(ToolData val);
示例#30
0
            internal void SpawnDefaultTools(IProxy proxy)
            {
                var vacuumables  = evr.GetNestedModule <Vacuumables>();
                var lockModule   = evr.GetModule <LockModule>();
                var defaultTools = evr.m_DefaultTools;

                foreach (var deviceData in evr.m_DeviceData)
                {
                    var      inputDevice       = deviceData.inputDevice;
                    ToolData selectionToolData = null;

                    if (deviceData.proxy != proxy)
                    {
                        continue;
                    }

                    var rayOrigin = deviceData.rayOrigin;
                    foreach (var toolType in defaultTools)
                    {
                        HashSet <InputDevice> devices;
                        var toolData = SpawnTool(toolType, out devices, inputDevice, rayOrigin);
                        AddToolToDeviceData(toolData, devices);

                        var tool          = toolData.tool;
                        var selectionTool = tool as SelectionTool;
                        if (selectionTool)
                        {
                            selectionToolData      = toolData;
                            selectionTool.hovered += lockModule.OnHovered;
                        }

                        var vacuumTool = tool as VacuumTool;
                        if (vacuumTool)
                        {
                            vacuumTool.defaultOffset = WorkspaceModule.DefaultWorkspaceOffset;
                            vacuumTool.defaultTilt   = WorkspaceModule.DefaultWorkspaceTilt;
                            vacuumTool.vacuumables   = vacuumables.vacuumables;
                        }
                    }

                    IMainMenu mainMenu     = null;
                    var       menus        = evr.GetNestedModule <Menus>();
                    var       menuHideData = deviceData.menuHideData;
                    if (DefaultMenu != null)
                    {
                        mainMenu               = (IMainMenu)menus.SpawnMenu(DefaultMenu, rayOrigin);
                        deviceData.mainMenu    = mainMenu;
                        menuHideData[mainMenu] = new Menus.MenuHideData();
                    }

                    if (DefaultAlternateMenu != null)
                    {
                        var alternateMenu = (IAlternateMenu)menus.SpawnMenu(DefaultAlternateMenu, rayOrigin);
                        menuHideData[alternateMenu] = new Menus.MenuHideData();
                        var radialMenu = alternateMenu as RadialMenu;
                        if (radialMenu)
                        {
                            radialMenu.itemWasSelected += Menus.UpdateAlternateMenuOnSelectionChanged;
                        }
                    }

                    var undoMenu = menus.SpawnMenu <UndoMenu>(rayOrigin);
                    var hideData = new Menus.MenuHideData();
                    menuHideData[undoMenu] = hideData;
                    hideData.hideFlags     = 0;

                    // Setup ToolsMenu
                    Experimental.EditorVR.Menus.ToolsMenu toolsMenu = null;
                    var toolsMenus = evr.gameObject.GetComponents <Experimental.EditorVR.Menus.ToolsMenu>();
                    foreach (var m in toolsMenus)
                    {
                        if (!m.enabled)
                        {
                            toolsMenu = m;
                            break;
                        }
                    }

                    if (!toolsMenu)
                    {
                        toolsMenu = ObjectUtils.AddComponent <Experimental.EditorVR.Menus.ToolsMenu>(evr.gameObject);
                    }

                    toolsMenu.enabled = true;
                    this.ConnectInterfaces(toolsMenu, rayOrigin);
                    deviceData.toolsMenu = toolsMenu;
                    toolsMenu.rayOrigin  = rayOrigin;
                    toolsMenu.setButtonForType(typeof(IMainMenu), null);
                    toolsMenu.setButtonForType(typeof(SelectionTool), selectionToolData != null ? selectionToolData.icon : null);

                    var spatialMenu = ObjectUtils.AddComponent <SpatialMenu>(evr.gameObject);
                    this.ConnectInterfaces(spatialMenu, rayOrigin);
                    spatialMenu.Setup();
                }

                evr.GetModule <DeviceInputModule>().UpdatePlayerHandleMaps();
            }
示例#31
0
        /*
        [STAThread]
        public static void robotListener(string[] controllerData, int port)
        {
            IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(controllerData[1]), port);
            TcpListener listener = new TcpListener(endPoint);
            Socket socket = null;

            listener.Start();
            Console.WriteLine("Local end point: {0}", listener.LocalEndpoint);
            socket = listener.AcceptSocket();
            Console.WriteLine("Connection accepted from " + socket.RemoteEndPoint);

            byte[] data = new byte[256];
            int len = socket.Receive(data);
            Console.WriteLine("Received...");

            TcpClient client = listener.AcceptTcpClient();
            Console.WriteLine("Connection accepted");

            NetworkStream stream = client.GetStream();
            String response = "Connection has been accepted";
            Byte[] sendTheseBytes = Encoding.ASCII.GetBytes(response);

            stream.Write(sendTheseBytes, 0, sendTheseBytes.Length);

            client.Close();
            listener.Stop();
        }

        public static RobTarget RobTargetAtPoint(Point point, double q1, double q2, double q3, double q4)
        {
            var target = new RobTarget();
            if (point != null)
            {
                target.FillFromString2(
                    string.Format(
                        "[[{0},{1},{2}],[{3},{4},{5},{6}],[0,0,0,0],[9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09]];",
                        point.X, point.Y, point.Z, q1, q2, q3, q4));
            }
            return target;
        }
        */
        public static ToolData toolData(float x, float y, float z, float q1, float q2, float q3, float q4, float load, float cog_x, float cog_y, float cog_z)
        {
            var t = new ToolData();
            t.Tframe.Trans.X = x;
            t.Tframe.Trans.Y = y;
            t.Tframe.Trans.Z = z;
            t.Tframe.Rot.Q1 = q1;
            t.Tframe.Rot.Q2 = q2;
            t.Tframe.Rot.Q3 = q3;
            t.Tframe.Rot.Q4 = q4;
            t.Tload.Mass = load;
            t.Tload.Cog.X = cog_x;
            t.Tload.Cog.Y = cog_y;
            t.Tload.Cog.Z = cog_z;
            return t;
        }