Facebook
From code, 8 Years ago, written in C.
Embed
Download Paste or View Raw
Hits: 465
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System;
  5.  
  6. namespace Commands
  7. {
  8.     public class CommandChecker : MonoBehaviour
  9.     {
  10.         public List<Command> commands = new List<Command>();
  11.  
  12.         void Update()
  13.         {
  14.             foreach (Command command in commands)
  15.             {
  16.                 if (command.isActualy)
  17.                 {
  18.                     Application.LoadLevel(1);
  19.                     //Run(command.value);
  20.                 }
  21.             }
  22.             commands.RemoveAll(delegate(Command c)
  23.             {
  24.                 if (!c.isActualy)
  25.                 {
  26.                     return true;
  27.                 }
  28.                 return false;
  29.             });
  30.         }
  31.  
  32.         void Run(string value)
  33.         {
  34.             string[] valueSplit = value.Split(new Char[] { ':' });
  35.             switch (valueSplit[0])
  36.             {
  37.                 case "0":
  38.                     Application.LoadLevel((int.Parse(valueSplit[1])));
  39.                     break;
  40.                 default:
  41.                     Debug.Log("Неизвестный ответ от сервера");
  42.                     break;
  43.             }
  44.         }
  45.  
  46.         public void AddCommand(string value)
  47.         {
  48.             Debug.Log("Тест");
  49.             commands.Add(new Command(value));
  50.         }
  51.     }
  52.  
  53.     public class Command
  54.     {
  55.         public string value;
  56.         public bool isActualy;
  57.  
  58.         public Command(string value)
  59.         {
  60.             this.value = value;
  61.             this.isActualy = true;
  62.         }
  63.     }
  64. }