当前位置: 首页>>代码示例>>C#>>正文


C# Commands.GetType方法代码示例

本文整理汇总了C#中Commands.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Commands.GetType方法的具体用法?C# Commands.GetType怎么用?C# Commands.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Commands的用法示例。


在下文中一共展示了Commands.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PrioritizedCommand

 // Constructor
 public PrioritizedCommand(Commands.Command newCommand)
 {
     /*if (newCommand.GetType() == typeof(Tests.DynamicDamageCommand))
     {
         damage = ((Tests.DynamicDamageCommand)newCommand).Strength;
     }
     else*/ if (newCommand.GetType() == typeof(Commands.DamageCommand))
     {
         damage = ((Commands.DamageCommand)newCommand).Strength;
     }
     range = newCommand.Range;
     command = newCommand;
     next = null;
     targetOptions = new List<CommandInfo>();
 }
开发者ID:smartboyathome,项目名称:Haxxit,代码行数:16,代码来源:PrioritizedCommand.cs

示例2: RunMainAndEpilog

 private void RunMainAndEpilog(Commands.BaseCommand command)
 {
     Debug.Assert(command.Context == this);
     Debug.Assert(RunningCommand == null);
     RunningCommand = command;
     if (command.ValidateOnRun() && command.DefaultValidateOnRun(this))
     {
         command.ExecutionPhase = Commands.CommandPhase.Main;
         command.RunMain();
         if (!(command is Commands.ISilentCommand))
         {
             command.ExecutionPhase = Commands.CommandPhase.Epilog;
             GetCommandRunner(command.GetType()).RunEpilog(command);
         }
     }
     Game.Controller.OnCommandEnd(command);
     RunningCommand = null;
 }
开发者ID:galaxyyao,项目名称:TouhouGrave,代码行数:18,代码来源:ResolveContext.RunCommand.cs

示例3: RunPrerequisite

        private CommandResult RunPrerequisite(Commands.BaseCommand command, bool resolveConditions)
        {
            Debug.Assert(command.Context == this);
            Debug.Assert(RunningCommand == null);
            RunningCommand = command;
            command.ExecutionPhase = Commands.CommandPhase.Prerequisite;

            var runner = GetCommandRunner(command.GetType());
            var ret = runner.RunPrerequisite(command);
            if (!ret.Canceled)
            {
                command.ExecutionPhase = Commands.CommandPhase.Condition;
                ret = ResolveConditions(!resolveConditions);
            }

            RunningCommand = null;

            return ret;
        }
开发者ID:galaxyyao,项目名称:TouhouGrave,代码行数:19,代码来源:ResolveContext.RunCommand.cs

示例4: PerformCommand

        // This function accepts program, target, and intended command.  It first performs error checking to
        // ensure that the command is valid, then updates the associated AINodeData and program list to reflect
        // game changes as a result of this command, and finally submits the command to the turnActions queue for
        // sending during subsequent calls to HandleAITurn.
        private CommandCode PerformCommand(Haxxit.Maps.Point target, Haxxit.Maps.Point source, Commands.Command command)
        {
            if (command == null)
            {
                return CommandCode.NoCommandSpecified;
            }
            else if (!IsInBounds(target))
            {
                return CommandCode.TargetWasOutOfBounds;
            }
            else if (mapData[target.X, target.Y].OccupiedBy == null)
            {
                return CommandCode.NoProgramAtTarget;
            }
            else if (command.Range < Math.Abs(target.X - source.X) + Math.Abs(target.Y - source.Y))
            {
                return CommandCode.ProgramOutOfRange;
            }

            // Will hold all nodes touched by target program both before and after command
            List<Haxxit.Maps.Point> programPoints = new List<Haxxit.Maps.Point>();

            // Get all the nodes currently associated with the program
            Haxxit.Maps.ProgramHeadNode targetProgram = mapData[target.X, target.Y].OccupiedBy;
            foreach (Haxxit.Maps.MapNode node in targetProgram.GetAllNodes())
            {
                programPoints.Insert(0, node.coordinate);
            }

            Haxxit.Maps.CommandEventArgs commandArgs = new Haxxit.Maps.CommandEventArgs(target, source, command.Name);
            turnActions.Enqueue(new NotifyArgs("haxxit.map.command", this, commandArgs, NotifyArgs.ArgType.Command));
            if(command.GetType() == typeof(Commands.DamageCommand))
            {
                int damage = ((Commands.DamageCommand)command).Strength;
                int index = 0;
                foreach (Haxxit.Maps.Point point in programPoints)
                {
                    if (index < damage)
                    {
                        mapData[point.X, point.Y].IsAvailable = true;
                        mapData[point.X, point.Y].OccupiedBy = null;
                    }
                    index++;
                }
                if (index <= damage)
                {
                    enemyPrograms.Remove(targetProgram);
                }
            }
            else if (command.GetType() == typeof(Commands.DamageCommand))
            {
                int damage = ((Commands.DamageCommand)command).Strength;
                int index = 0;
                foreach (Haxxit.Maps.Point point in programPoints)
                {
                    if (index < damage)
                    {
                        mapData[point.X, point.Y].IsAvailable = true;
                        mapData[point.X, point.Y].OccupiedBy = null;
                    }
                    index++;
                }
                if (index <= damage)
                {
                    enemyPrograms.Remove(targetProgram);
                }
            }
            return CommandCode.Success;
        }
开发者ID:smartboyathome,项目名称:Haxxit,代码行数:73,代码来源:PlayerAI.cs

示例5: CommandRecieved

        /// <summary>
        /// Ein neuer Kommand ist über eine Kommunikationsschnittstelle angekommen
        /// kümmern wir uns darum!
        /// </summary>
        /// <param name="client"></param>
        /// <param name="Command"></param>
        public virtual void CommandRecieved(System.Net.Sockets.TcpClient client, Commands.BaseCommand recievedCommand)
        {
            Console.WriteLine(recievedCommand.GetType().ToString());
            try{
            if (recievedCommand.completed)
            {
                recievedCommand.ProcessResults(this);
                if (!recievedCommand.isAsync)
                {
                    lock (SynclockCommands)
                    {
                        SyncCommands.Add(recievedCommand.guid, recievedCommand);
                    }
                }
            }
            else
            {
                    Console.WriteLine("RemoteExec");
                recievedCommand.RemoteExecute(this);
                recievedCommand.completed = true;
                BinaryFormatter formatter = new BinaryFormatter();
                    MemoryStream memstr = new MemoryStream();
                formatter.Serialize(memstr, recievedCommand);
                    var outputstream = client.GetStream();
                        outputstream.Write(memstr.ToArray(),0,Convert.ToInt32(memstr.Length));
                    outputstream.Flush();

            }
            }catch (Exception ex){
                Console.WriteLine(ex.Message+ " "+ ex.StackTrace.ToString());

            }
        }
开发者ID:siegelpeter,项目名称:UAV-NET,代码行数:39,代码来源:UAVBase.cs


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