• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Robot类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Robot的典型用法代码示例。如果您正苦于以下问题:C# Robot类的具体用法?C# Robot怎么用?C# Robot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Robot类属于命名空间,在下文中一共展示了Robot类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Adapter

 protected Adapter(Robot robot, ILog logger, string adapterId)
 {
     Robot = robot;
     Logger = logger;
     Id = adapterId;
     Rooms = new Collection<string>();
 }
开发者ID:nardin,项目名称:mmbot,代码行数:7,代码来源:Adapter.cs


示例2: Register

        public void Register(Robot robot)
        {
            robot.Respond(@"spot me winning", msg =>
            {
                msg.Send("http://open.spotify.com/track/77NNZQSqzLNqh2A9JhLRkg");
                msg.Message.Done = true;
            });

            robot.Respond(@"spot me (.*)$", async msg =>
            {
                var q = msg.Match[1];
                var res = await msg.Http("http://ws.spotify.com/search/1/track.json")
                    .Query(new {q})
                    .GetJson();

                foreach(var t in res.tracks)
                {
                    try
                    {
                        if (t.album.availability.territories.ToString() == "worldwide" || t.album.availability.territories.ToString().IndexOf("NZ") > -1)
                        {
                            msg.Send(string.Format("http://open.spotify.com/track/{0}",
                                t.href.ToString().Replace("spotify:track:", string.Empty)));
                            msg.Message.Done = true;
                            return;
                        }
                    }
                    catch (Exception)
                    {

                    }
                }
            });
        }
开发者ID:nardin,项目名称:mmbot,代码行数:34,代码来源:Spot.cs


示例3: Initialize

        public override void Initialize(Robot robot)
        {
            base.Initialize(robot);

            _token = robot.GetConfigVariable("MMBOT_SLACK_TOKEN");
            _commandTokens = (robot.GetConfigVariable("MMBOT_SLACK_COMMANDTOKENS") ?? string.Empty)
                .Split(',')
                .Where(s => !string.IsNullOrWhiteSpace(s))
                .Select(s => s.Trim())
                .ToArray();
            _logRooms = (robot.GetConfigVariable("MMBOT_SLACK_LOGROOMS") ?? string.Empty)
                .Split(',')
                .Where(s => !string.IsNullOrWhiteSpace(s))
                .Select(s => s.Trim())
                .ToArray();

            if (string.IsNullOrWhiteSpace(_token))
            {
                var helpSb = new StringBuilder();
                helpSb.AppendLine("The Slack adapter is not configured correctly and hence will not be enabled.");
                helpSb.AppendLine("To configure the Slack adapter, please set the following configuration properties:");
                helpSb.AppendLine("  MMBOT_SLACK_TOKEN: This is the service token you are given when you add your Bot to your Team Services.");
                helpSb.AppendLine("  MMBOT_SLACK_COMMANDTOKENS: Optional. The comma delimited list of expected command tokens from the Slack commands hook. If none supplied then any token will be accepted.");
                helpSb.AppendLine("  MMBOT_SLACK_LOGROOMS: Optional. The comma delimited list of rooms to send log messages to.");
                helpSb.AppendLine("More info on these values and how to create the mmbot.ini file can be found at https://github.com/mmbot/mmbot/wiki/Configuring-mmbot");
                Logger.Warn(helpSb.ToString());
                _isConfigured = false;
                return;
            }

            _isConfigured = true;

            Logger.Info("The Slack adapter is connected");
        }
开发者ID:GhostTW,项目名称:mmbot,代码行数:34,代码来源:SlackAdapter.cs


示例4: Register

        public void Register(Robot robot)
        {
            robot.Respond(@"(calc|calculate|calculator|convert|math|maths)( me)? (.*)", async msg =>
            {
                dynamic res = await msg
                    .Http("https://www.google.com/ig/calculator")
                    .Query(new
                        {
                            hl = "en",
                            q = msg.Match[3]
                        })
                    .Headers(new Dictionary<string, string>
                        {
                            {"Accept-Language", "en-us,en;q=0.5"},
                            {"Accept-Charset", "utf-8"},
                            {"User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"}
                        })
                    .GetJson();

                try
                {
                    await msg.Send((string)res.rhs ?? "Could not compute");
                    return;
                }
                catch (Exception)
                { }
                await msg.Send("Could not compute");
            });
        }
开发者ID:dcr25568,项目名称:mmbot,代码行数:29,代码来源:Math.cs


示例5: Main

        static void Main(string[] args)
        {
            // Read the count of the commands that will follow.
            int commandCount = int.Parse(Console.ReadLine());
            
            // Get the start position of the robot.
            Vector2 startPosition = Vector2.PositionFromString(Console.ReadLine());

            // Create the robot and the tracker.
            Robot robot = new Robot(startPosition);
            PositionTracker tracker = new PositionTracker(robot);

            // Loop until we have read all commands.
            for (int i = 0; i < commandCount; i++)
            {
                // Read the line and create a movement vector.
                var line = Console.ReadLine();
                Vector2 movement = Vector2.MoveDirectionFromString(line);

                // Move the robot.
                robot.Move(movement);
            }

            // Calculate and display the unique positions visited by the robot.
            Console.WriteLine($"=> Cleaned: {tracker.CalculatePositionsVisited()}");
        }
开发者ID:jacob-ebey,项目名称:RobotCleaner,代码行数:26,代码来源:Program.cs


示例6: RobotTest

        public void RobotTest()
        {
            var commands = new[]
            {
                "Move 2",
                "Turn right",
                "Move 4",
                "Turn left",
                "Move -5",
                "Turn right",
                "Move 10",
                "Turn left",
                "Move -2",
                "Turn left",
                "Turn left",
                "Move 5",
                "Move -2",
                "Turn right",
                "Move 1",
                "Move 0"
            };

            const int expectedX = 13;
            const int expectedY = -8;

            var grid = new Grid();
            var robot = new Robot(grid);
            commands.ToList().ForEach(robot.Command);

            var actualX = robot.PositionX;
            var actualY = robot.PositionY;

            Assert.AreEqual(expectedX, actualX);
            Assert.AreEqual(expectedY, actualY);
        }
开发者ID:ryanerdmann,项目名称:programming-puzzles,代码行数:35,代码来源:RobotTests.cs


示例7: Response

 internal Response(Robot robot, ResponseCode code, Byte seqNum, Byte[] data)
 {
     Robot = robot;
     RspCode = code;
     SeqNum = seqNum;
     Data = data;
 }
开发者ID:xesf,项目名称:Sphero-WinPhone8-SDK,代码行数:7,代码来源:Response.cs


示例8: CreateProgramRobot

 public void CreateProgramRobot(Robot robot, Program program) =>
     data.ProgramRobots.Add(new ProgramRobot
     {
         Program = program,
         Robot = robot,
         CurrentVersion = program.ActualVersion
     });
开发者ID:qreal,项目名称:robostore.net,代码行数:7,代码来源:ProgramManager.cs


示例9: Hit

 public override void Hit(Robot robot)
 {
     Debug.Log("StraightLight hit " + robot.name);
     Assert.IsNotNull<Robot>(robot);
     Assert.IsTrue(robot.teamColor != teamColor);
     robot.RecieveDamage(damage);
 }
开发者ID:AtwoodDeng,项目名称:miniRTS,代码行数:7,代码来源:StraightLight.cs


示例10: ExecuteAction

        public override void ExecuteAction(Robot.hexapod hexy)
        {
            var deg = -30;
            // pickup and put all the feet centered on the floor
            hexy.LeftFront.replantFoot(-deg, 0.3f);
            hexy.RightMiddle.replantFoot(1, 0.3f);
            hexy.LeftBack.replantFoot(deg, 0.3f);

            Thread.Sleep(1000);

            Console.WriteLine(hexy.LeftFront.GetStatus());
            Console.WriteLine(hexy.RightMiddle.GetStatus());
            Console.WriteLine(hexy.LeftBack.GetStatus());

            hexy.RightFront.replantFoot(deg, 0.3f);
            hexy.LeftMiddle.replantFoot(1, 0.3f);
            hexy.RightBack.replantFoot(-deg, 0.3f);

            Thread.Sleep(1000);

            // set all the hip angle to what they should be while standing
            hexy.LeftFront.hip(-deg);
            hexy.RightMiddle.hip(1);
            hexy.LeftBack.hip(deg);
            hexy.RightFront.hip(deg);
            hexy.LeftMiddle.hip(1);
            hexy.RightBack.hip(-deg);
        }
开发者ID:Togusa09,项目名称:Hexy,代码行数:28,代码来源:Reset.cs


示例11: Shoot

 public override void Shoot(Robot _robot)
 {
     if ( _robot.UsePower(_robot.GetWeaponPowerCost(weaponParameter.PowerCost)) )
         MagicShoot(_robot);
     else
         NormalShoot(_robot);
 }
开发者ID:AtwoodDeng,项目名称:miniRTS,代码行数:7,代码来源:MagicBallGun.cs


示例12: PickUp

 public void PickUp(Robot robot)
 {
     coin.PickUp(robot);
     FindObjectOfType<UIManagerScript>().OnCoinAmountChanged();
     SoundEffectsHelper.Instance.MakeCoinPickedUpSound(transform.position);
     Destroy(this.gameObject);
 }
开发者ID:lutrampal,项目名称:ProjetVR,代码行数:7,代码来源:CoinScript.cs


示例13: Update

 //Update timer and return if end effect
 public bool Update(Robot _robot)
 {
     duration += Time.deltaTime;
     if (duration > parameter.PTime)
         return true;
     return false;
 }
开发者ID:AtwoodDeng,项目名称:miniRTS,代码行数:8,代码来源:Effect.cs


示例14: doMove

 public void doMove(Robot player, string theMove)
 {
     if (theMove == "block")
         player.Block ();
     else if (theMove == "unblock")
         player.UnBlock ();
     else if (theMove == "leftPunch")
         player.LeftPunch ();
     else if (theMove == "rightPunch")
         player.RightPunch ();
     else if (theMove == "leftKick")
         player.LeftKick ();
     else if (theMove == "rightKick")
         player.RightKick ();
     else if (theMove == "RocketLeftArm")
         player.RocketLeftArm ();
     else if (theMove == "RocketRightArm")
         player.RocketRightArm ();
     else if (theMove == "RocketLeftLeg")
         player.RocketLeftLeg ();
     else if (theMove == "RocketRightLeg")
         player.RocketRightLeg ();
     else if (theMove == "pickUp")
         player.Pickup ();
 }
开发者ID:atymisk,项目名称:Boulder,代码行数:25,代码来源:StageSelect.cs


示例15: Start

	// Use this for initialization
	void Start () {
        observedRobot = FindObjectOfType<RobotScript>().ScriptRobot;
        hearts = new GameObject[observedRobot.MaxHealth];
        RectTransform rt = (RectTransform) heartPrefab.transform;
        float heartWidth = rt.rect.width;
        float heartHeight = rt.rect.height;

        int i = 0;
        for (; i<observedRobot.MaxHealth; ++i)
        {
            Vector2 position = new Vector2(heartWidth/2 + heartMargin + (heartWidth + heartMargin)*i , Screen.height - heartHeight/2 - heartMargin);
            hearts[i] = Instantiate(heartPrefab, position, Quaternion.identity) as GameObject;
            hearts[i].transform.parent = UICanvas.transform;
        }

        RectTransform rtCoin = (RectTransform)coinUIPrefab.transform;
        float coinUIHeight = rt.rect.height;

        Vector2 coinUIPosition = new Vector2((heartWidth + heartMargin*2)*(i+1), Screen.height - coinUIHeight/2 - heartMargin);
        coinUI = Instantiate(coinUIPrefab, coinUIPosition, Quaternion.identity) as GameObject;
        coinUI.transform.parent = UICanvas.transform;
        coinAmountText = coinUI.GetComponentInChildren<Text>();
        coinAmountText.text = observedRobot.Coins.ToString();

        Vector2 sliderPosition = new Vector2(Screen.width - sliderRightMargin, Screen.height - sliderTopMargin);
        timeSlider = Instantiate(timeSliderPrefab, sliderPosition, Quaternion.identity) as GameObject;
        timeSlider.transform.parent = UICanvas.transform;
	}
开发者ID:lutrampal,项目名称:ProjetVR,代码行数:29,代码来源:UIManagerScript.cs


示例16: robot_line_charges_robots_upon_attachment

 public void robot_line_charges_robots_upon_attachment()
 {
     var recharger = new Mock<IRobotRecharger>();
     var robot = new Robot(recharger.Object);
     new RobotAssemblyLine().Attach(robot);
     recharger.Verify(x => x.Recharge(robot));
 }
开发者ID:bradygaster,项目名称:NDecision,代码行数:7,代码来源:RobotDomainTests.cs


示例17: Register

        public void Register(Robot robot)
        {
            robot.Respond(@"(cat|cats)( gif)( \d+)?$", async msg =>
            {
                int number = 1;
                try
                {
                    number = Int32.Parse(msg.Match[3]);
                }
                catch (Exception) { }
                if (number == 0)
                {
                    number = 1;
                }

                await CatMeGifCore(msg, number);
            });
            
            robot.Respond(@"(cat|cats)( me)?( \d+)?$", async msg =>
            {
                int number = 1;
                try
                {
                    number = Int32.Parse(msg.Match[3]);
                }
                catch (Exception) { }
                if (number == 0)
                {
                    number = 1;
                }

                await CatMeCore(msg, number);
            });
        }
开发者ID:holytshirt,项目名称:mmbot,代码行数:34,代码来源:Cats.cs


示例18: robot_recharger_automatically_recharges_robot_when_needed_to_perform_work

 public void robot_recharger_automatically_recharges_robot_when_needed_to_perform_work()
 {
     var recharger = new Mock<IRobotRecharger>();
     var robot = new Robot(recharger.Object);
     robot.Work();
     recharger.Verify(x => x.Recharge(robot));
 }
开发者ID:bradygaster,项目名称:NDecision,代码行数:7,代码来源:RobotDomainTests.cs


示例19: ExecuteAction

        public override void ExecuteAction(Robot.hexapod hexy)
        {
            var deg = -30;
            hexy.LeftFront.hip(-deg);
            hexy.RightMiddle.hip(1);
            hexy.LeftBack.hip(deg);

            hexy.RightFront.hip(deg);
            hexy.LeftMiddle.hip(1);
            hexy.RightBack.hip(-deg);

            Thread.Sleep(500);

            foreach (var leg in hexy.Legs)
            {
                leg.knee(-30);
            }

            Thread.Sleep(500);

            for (var angle = 0; angle <= 45; angle += 3)
            {
                foreach (var leg in hexy.Legs)
                {
                    leg.knee(angle);
                    leg.ankle(-90 + angle);
                }
                Thread.Sleep(100);
            }

            hexy.Move("Reset");
        }
开发者ID:Togusa09,项目名称:Hexy,代码行数:32,代码来源:GetUp.cs


示例20: TestRobot

        public void TestRobot()
        {
            Robot testRobot = new Robot();
            Position position = null;
            Assert.IsFalse(testRobot.initialized);

            testRobot.initialize(2, 2, Orientation.NORTH);
            Assert.IsTrue(testRobot.initialized);

            testRobot.TurnLeft();
            position = testRobot.GetCurrentPosition();
            Assert.AreEqual(2, position.x);
            Assert.AreEqual(2, position.y);
            Assert.AreEqual(Orientation.WEST, position.orientation);

            testRobot.Place(3, 3, Orientation.SOUTH);
            Assert.AreEqual(3, position.x);
            Assert.AreEqual(3, position.y);
            Assert.AreEqual(Orientation.SOUTH, position.orientation);

            testRobot.TurnRight();
            Assert.AreEqual(3, position.x);
            Assert.AreEqual(3, position.y);
            Assert.AreEqual(Orientation.WEST, position.orientation);
        }
开发者ID:allenzhang83,项目名称:RobotSimulator,代码行数:25,代码来源:ToyRobotSimulatorTests.cs



注:本文中的Robot类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Rock类代码示例发布时间:2022-05-24
下一篇:
C# Roar类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap