本文整理汇总了C#中Robot类的典型用法代码示例。如果您正苦于以下问题:C# Robot类的具体用法?C# Robot怎么用?C# Robot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Robot类属于命名空间,在下文中一共展示了Robot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Adapter
protected Adapter(Robot robot, ILog logger, string adapterId)
{
Robot = robot;
Logger = logger;
Id = adapterId;
Rooms = new Collection<string>();
}
示例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)
{
}
}
});
}
示例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");
}
示例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");
});
}
示例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()}");
}
示例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);
}
示例7: Response
internal Response(Robot robot, ResponseCode code, Byte seqNum, Byte[] data)
{
Robot = robot;
RspCode = code;
SeqNum = seqNum;
Data = data;
}
示例8: CreateProgramRobot
public void CreateProgramRobot(Robot robot, Program program) =>
data.ProgramRobots.Add(new ProgramRobot
{
Program = program,
Robot = robot,
CurrentVersion = program.ActualVersion
});
示例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);
}
示例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);
}
示例11: Shoot
public override void Shoot(Robot _robot)
{
if ( _robot.UsePower(_robot.GetWeaponPowerCost(weaponParameter.PowerCost)) )
MagicShoot(_robot);
else
NormalShoot(_robot);
}
示例12: PickUp
public void PickUp(Robot robot)
{
coin.PickUp(robot);
FindObjectOfType<UIManagerScript>().OnCoinAmountChanged();
SoundEffectsHelper.Instance.MakeCoinPickedUpSound(transform.position);
Destroy(this.gameObject);
}
示例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;
}
示例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 ();
}
示例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;
}