Beispiel #1
0
    private void Swap(List <WaveCommand> list, int i, int j)
    {
        WaveCommand tmp = list[i];

        list[i] = list[j];
        list[j] = tmp;
    }
Beispiel #2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        Wave wave = (Wave)target;

        if (wave.commandQueue.Count > 0)
        {
            if (wave.commandQueue.First().type == WaveCommand.CommandType.Utility)// || wave.commandQueue.Last().type == WaveCommand.CommandType.Utility)
            {
                EditorGUILayout.HelpBox("Utility commands at the beginning of the command queue will be ignored by the spawner.", MessageType.Warning);
            }
        }
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.Space();
        if (GUILayout.Button("Add Command"))
        {
            wave.commandQueue.Add(new WaveCommand());
        }
        EditorGUILayout.Space();
        EditorGUILayout.EndHorizontal();

        for (int i = 0; i < wave.commandQueue.Count; i++)
        {
            WaveCommand command = wave.commandQueue[i];
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Command " + (i + 1));
            if (GUILayout.Button("Delete"))
            {
                wave.commandQueue.RemoveAt(i);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.BeginVertical();
            if (i > 0)
            {
                if (GUILayout.Button("Move Up"))
                {
                    Swap(wave.commandQueue, i, i - 1);
                }
            }
            if (i < wave.commandQueue.Count - 1)
            {
                if (GUILayout.Button("Move Down"))
                {
                    Swap(wave.commandQueue, i, i + 1);
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical();
            command.type = (WaveCommand.CommandType)EditorGUILayout.EnumPopup(command.type);

            EditorGUILayout.BeginHorizontal();
            command.SetNFromEditorScript(EditorGUILayout.IntField(command.N));

            if (command.type == WaveCommand.CommandType.Spawning)
            {
                command.enemyIndex = EditorGUILayout.Popup(command.enemyIndex, wave.Enemies.Select(x => x.name).ToArray());
            }
            else
            {
                command.utility = (WaveCommand.UtilityCommand)EditorGUILayout.EnumPopup(command.utility);
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
        }
    }
 public void Before_Each_Test()
 {
     mock = MockRepository.GenerateMock<IConsoleFacade>();
     cmd = new WaveCommand(mock);
 }
 public void Before_Each_Test()
 {
     mock = MockRepository.GenerateMock <IConsoleFacade>();
     cmd  = new WaveCommand(mock);
 }
Beispiel #5
0
        /// <summary>
        /// Requests the device to start a waving pattern.
        /// Waving pattern involves each leds blinking to the same color in an out-of-phase manner, giving a waving effect that starts from the first leds and propagates to the last one and then the first again.
        /// </summary>
        /// <param name="waveType">Specify how the wave is formed</param>
        /// <param name="color">Specify the color to which leds should be switched</param>
        /// <param name="speed">Abstract duration for the wave effect. The higher, the longer each wave will take.</param>
        /// <param name="repeatCount">Number of time the wave should be repeated, ie. the number of times the wave should pass each led</param>
        /// <param name="timeout">Time, in milliseconds, after which the application should stop waiting for the acknowledgment of this message</param>
        /// <returns>Task representing the operation. Result is true if the message has been acknowledged, false otherwise</returns>
        public Task <bool> Wave(WaveType waveType, Color color, byte speed, byte repeatCount, int timeout = 0)
        {
            var command = new WaveCommand(waveType, color, speed, repeatCount);

            return(SendCommand(command, timeout));
        }
Beispiel #6
0
 /// <summary>
 /// Proper Constructor.
 /// </summary>
 /// <param name="command">Processor for this wave.</param>
 /// <param name="isInitiator">True on the node initiating the wave.</param>
 public Wave(WaveCommand command, bool isInitiator)
 {
     this.command     = command;
     this.isInitiator = isInitiator;
     this.identity    = Guid.NewGuid().ToString("N");
 }