コード例 #1
0
ファイル: TeamRobot.cs プロジェクト: spech66/marvinsarena
        /// <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;
        }
コード例 #2
0
ファイル: BaseRobot.cs プロジェクト: spech66/marvinsarena
        /// <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;
        }
コード例 #3
0
        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!");
        }
コード例 #4
0
 /// <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);
 }