/// <summary> /// This method is internally called by the engine. You must not call it! /// </summary> /// <param name="robotBase">Reference to robot core</param> public new void InternalSetCoreRobot(MarvinsArena.Robot.Core.RobotCore robotBase) { this.robotBase = robotBase; base.InternalSetCoreRobot(robotBase); this.robotBase.MessageReceivedFromTeammate += TeamRobot_MessageReceivedFromTeammate; }
/// <summary> /// This method is internally called by the engine. You must not call it! /// </summary> /// <param name="robotBase">Reference to robot core</param> public void InternalSetCoreRobot(MarvinsArena.Robot.Core.RobotCore robotBase) { this.robotBase = robotBase; this.robotBase.RoundStarted += RobotBase_RoundStarted; this.robotBase.HitBullet += RobotBase_HitBullet; this.robotBase.HitMissile += RobotBase_HitMissile; this.robotBase.HitRobot += RobotBase_HitRobot; this.robotBase.HitWall += RobotBase_HitWall; this.robotBase.ScannedRobot += RobotBase_ScannedRobot; }
public void LoadAssembly(string name, int squadNumber, int team, byte[][] map) { assembly = Assembly.Load(name); Name = AssemblyTitle; this.SquadNumber = squadNumber; this.Team = team; Type[] types = assembly.GetTypes(); foreach (Type t in types) { // This will get the first found MsgExchangeType - therefore no more than one MsgExchangeType should be in the plugin if (t.BaseType == typeof(MarvinsArena.Robot.BaseRobot) || t.BaseType == typeof(MarvinsArena.Robot.EnhancedRobot) || t.BaseType == typeof(MarvinsArena.Robot.TeamRobot)) { ConstructorInfo ci = t.GetConstructor(Type.EmptyTypes); object o = ci.Invoke(null); if (o == null) { throw new MarvinsArenaException("Error while constructing robot."); } irobot = ((MarvinsArena.Robot.IRobot)o); robot = ((MarvinsArena.Robot.BaseRobot)o); robotCore = new MarvinsArena.Robot.Core.RobotCore(Name, squadNumber, team); gameCore = new MarvinsArena.Robot.Core.GameCore(map); if (t.BaseType == typeof(MarvinsArena.Robot.EnhancedRobot)) { MarvinsArena.Robot.EnhancedRobot enhancedRobot = ((MarvinsArena.Robot.EnhancedRobot)o); enhancedRobot.InternalSetCoreRobot(robotCore); enhancedRobot.InternalSetCoreGame(gameCore); } else if (t.BaseType == typeof(MarvinsArena.Robot.TeamRobot)) { MarvinsArena.Robot.TeamRobot teamRobot = ((MarvinsArena.Robot.TeamRobot)o); teamRobot.InternalSetCoreRobot(robotCore); teamRobot.InternalSetCoreGame(gameCore); } else { robot.InternalSetCoreRobot(robotCore); robot.InternalSetCoreGame(gameCore); } irobot.Initialize(); if (t.BaseType == typeof(MarvinsArena.Robot.BaseRobot)) { RobotType = LoadedRobotType.Robot; } if (t.BaseType == typeof(MarvinsArena.Robot.EnhancedRobot)) { RobotType = LoadedRobotType.EnhancedRobot; } if (t.BaseType == typeof(MarvinsArena.Robot.TeamRobot)) { RobotType = LoadedRobotType.TeamRobot; } return; } } throw new MarvinsArenaException("No MsgExchangeType found!"); }
/// <summary> /// This method is internally called by the engine. You must not call it! /// </summary> /// <param name="robotBase">Reference to robot core</param> public new void InternalSetCoreRobot(MarvinsArena.Robot.Core.RobotCore robotBase) { this.robotBase = robotBase; base.InternalSetCoreRobot(robotBase); }