示例#1
0
 public Passenger(int destinationNodeId)
 {
     m_timeCreated       = Time.realtimeSinceStartup;
     m_destinationNodeId = destinationNodeId;
     name         = "herroh";
     passengerUid = UidGenerator.getNewUid();
 }
示例#2
0
        public ReqrepManager(string info, PType prefix)
        {
            lock ( _inst_tab_sync ) {
                _instance_table.Replace(info, this);
            }
            _info   = info;
            _prefix = prefix;
#if BRUNET_SIMULATOR
            Random r = Node.SimulatorRandom;
#else
            Random r = new Random();
#endif
            //Don't use negative numbers:
            _req_state_table = new UidGenerator <RequestState>(r, true);
            //Don't use negative numbers:
            _reply_id_table = new UidGenerator <ReplyState>(r, true);

            /**
             * We keep a list of the most recent 1000 replies until they
             * get too old.  If the reply gets older than reptimeout, we
             * remove it
             */
            _reply_cache = new Cache(1000);
            _reply_cache.EvictionEvent += HandleReplyCacheEviction;
            _to_mgr = new TimeOutManager();
        }
示例#3
0
        // Constructors
        public TaskAide(Database db, ISystemTime systemTime, ITimer timer)
        {
            this.systemTime = systemTime;
            this.timer      = timer;

            var taskTable = new TaskTable("Tasks", db);

            this.taskUidGenerator = new UidGenerator(
                ApplicationData.Current.RoamingSettings,
                "TaskUids",
                (uid) => { return(taskTable.Get(uid.ToString()) == null); });
            this.taskList = new TaskList(taskTable);

            //this.sessionTable = new SessionTable("Sessions", db);
            //this.sessionUidGenerator = new UidGenerator(
            //    ApplicationData.Current.RoamingSettings,
            //    "SessionUids",
            //    (uid) => { return this.sessionTable.Get(uid.ToString()) == null; });

            //this.intervalTable = new IntervalTable("Intervals", db);
            //this.intervalUidGenerator = new UidGenerator(
            //    ApplicationData.Current.RoamingSettings,
            //    "IntervalUids",
            //    (uid) => { return this.intervalTable.Get(uid.ToString()) == null; });
        }
示例#4
0
 void Awake()
 {
     m_isLoop       = false;
     m_addDirection = AddDir.Back;
     m_nodes        = new List <GameObject> ();
     m_trains       = new List <GameObject> ();
     m_lineUid      = UidGenerator.getNewUid();
 }
示例#5
0
 private Przejazd()
 {
     autobus         = null;
     nastepnaAkcja   = Akcja.PobieraniePasazerow;
     czasPrzejazdu   = TimeSpan.Zero;
     trasaZakonczona = false;
     uid             = UidGenerator.WygenerujUid();
 }
 public DanePasazera(Type typPasazera, int czasWsiadania, int czasWysiadania, string pPoczatkowy, string pKoncowy)
 {
     id = UidGenerator.WygenerujUid();
     this.typPasazera    = typPasazera;
     this.czasWsiadania  = czasWsiadania;
     this.czasWysiadania = czasWysiadania;
     this.pPoczatkowy    = pPoczatkowy;
     this.pKoncowy       = pKoncowy;
 }
示例#7
0
        public IdentifierTable(bool non_neg)
        {
#if BRUNET_SIMULATOR
            Random rand = Node.SimulatorRandom;
#else
            Random rand = new Random();
#endif
            _local_to_idpair = new UidGenerator <IIdentifierPair>(rand, non_neg);
        }
示例#8
0
 public Autobus(string modelAutobusu, int maksymalnaPojemnosc, int iloscDzwi, double dlugoscAutobusu, string sciezkaPlikuKonfiguracyjnego) : this()
 {
     idAutobusu                        = UidGenerator.WygenerujUid(5);
     this.modelAutobusu                = modelAutobusu;
     this.maksymalnaPojemnosc          = maksymalnaPojemnosc;
     this.iloscDzwi                    = iloscDzwi;
     this.sciezkaPlikuKonfiguracyjnego = sciezkaPlikuKonfiguracyjnego;
     this.dlugoscAutobusu              = dlugoscAutobusu;
 }
        public void Start()
        {
            AttackSpeed  = 1f; Random.Range(1f, 2f);
            AttackDamage = 2f; // Random.Range(1.7f,2.5f);
            if (Game.IsSinglePlayer())
            {
                uid = UidGenerator.GetNewUid();
            }

            PlayerData = Registry.Player [PlayerData.uid].GetComponent <PlayerData> ();

            GetComponentInChildren <Renderer>().material.color = PlayerData.color;
        }
示例#10
0
        public ReqrepManager(object info, PType prefix)
        {
            ReqrepManager existing;

            lock ( _inst_tab_sync ) {
                if (_instance_table.TryGetValue(info, out existing))
                {
                    throw new Exception("Already an existing ReqrepManager for: " + info.ToString());
                }
                else
                {
                    _instance_table[info] = this;
                }
            }
            _info = info.ToString();

            _prefix            = prefix;
            _req_handler_table = new Hashtable();
            Random r = new Random();

            //Don't use negative numbers:
            _req_state_table = new UidGenerator <RequestState>(r, true);
            //Don't use negative numbers:
            _reply_id_table    = new UidGenerator <ReplyState>(r, true);
            _rep_handler_table = new Hashtable();

            /**
             * We keep a list of the most recent 1000 replies until they
             * get too old.  If the reply gets older than reptimeout, we
             * remove it
             */
            _reply_cache = new Cache(1000);
            _reply_cache.EvictionEvent += HandleReplyCacheEviction;

            /*
             * Here we set the timeout mechanisms.  There is a default
             * value, but this is now dynamic based on the observed
             * RTT of the network
             */
            //resend the request after 5 seconds.
            _edge_reqtimeout    = new TimeSpan(0, 0, 0, 0, 5000);
            _nonedge_reqtimeout = new TimeSpan(0, 0, 0, 0, 5000);
            //Start with 50 sec timeout
            _acked_reqtimeout = new TimeSpan(0, 0, 0, 0, 50000);
            //Here we track the statistics to improve the timeouts:
            _nonedge_rtt_stats = new TimeStats(_nonedge_reqtimeout.TotalMilliseconds, 0.98);
            _edge_rtt_stats    = new TimeStats(_edge_reqtimeout.TotalMilliseconds, 0.98);
            _acked_rtt_stats   = new TimeStats(_acked_reqtimeout.TotalMilliseconds, 0.98);
            _last_check        = DateTime.UtcNow;
        }
示例#11
0
文件: Windows.cs 项目: radtek/HinxCor
        private static string io_cmd(string cmd, string io = null)
        {
            string tmpp = "_tmp_f_" + UidGenerator.GetShortId();

            if (File.Exists(tmpp))
            {
                File.Delete(tmpp);
            }
            string argument = string.Format("{0}@{1}#{2}", cmd, tmpp, io);

            System.Diagnostics.Process.Start("FolderBrowserDialog.exe", argument);
            while (File.Exists(tmpp) == false)
            {
                Thread.Sleep(200);
            }
            var reader = new StreamReader(tmpp);
            var result = reader.ReadLine();

            reader.Dispose();
            reader.Close();
            File.Delete(tmpp);
            return(result);
        }
        public virtual void Spawn()
        {
            var shipUid    = UidGenerator.GetNewUid();
            var island     = Registry.Islands[gameObject.GetComponent <IslandData>().Uid];
            var islandData = island.GetComponent <IslandData>();

            // 1) create ship by type
            var go = GameObjectFactory.CreateShip(shipUid, islandData.ShipType, islandData.PlayerData.playerType);

            // 2) append ship at island
            go.transform.Translate(island.transform.position);
            go.transform.parent = island.transform;

            // 3) set ship data
            var shipData = go.AddComponent <ShipData>();

            shipData.shipType   = islandData.ShipType;
            shipData.uid        = shipUid;
            shipData.PlayerData = islandData.PlayerData;

            // 4) colorize @see http://answers.unity3d.com/questions/483419/changing-color-of-children-of-instantiated-prefab.html
            //go.GetComponentInChildren<Renderer>().material.color = Island.PlayerData.color - new Color(0.5f,0.5f,0.5f);

            // 5) life data
            var lifeData = go.AddComponent <LifeData>();

            lifeData.CurrentHp = lifeData.MaxHp = 10;

            // 6) host fires attacks
            go.AddComponent <Assault>();
            go.AddComponent <Defence>();

            // 7) reset spawn timer
            ResetSpawnTimer();

            // Debug.Log("spawn [uid=" + shipUid + "|type=" + shipData.shipType + "] at [uid=" + islandData.uid + "|type=" + islandData.islandType  + "] for player [" + shipData.playerUid + "]");
        }
示例#13
0
        public override void Spawn()
        {
            // check if spawning event already triggered
            if (_fsm.ActiveStateName.Equals("Spawning Ship"))
            {
                return;
            }

            // 1) block spawnings until network event did actually spawn the ship
            _fsm.SendEvent("Spawn");

            // 2) broadcast spawn event
            var json = PackageFactory.CreateSpawnMessage(
                new[] { new JObject
                        {
                            { "island_uid", Island.Uid },
                            { "uid", UidGenerator.GetNewUid() }
                        } });

            SocketHandler.EmitNow("spawn-unit", json);

            // 3 schedule event
            Spawn(json);
        }
示例#14
0
  public ReqrepManager(string info, PType prefix) {
    lock( _inst_tab_sync ) {
      _instance_table.Replace(info, this);
    }
    _info = info;

    _prefix = prefix;
    _req_handler_table = new Hashtable();
    Random r = new Random();
    //Don't use negative numbers:
    _req_state_table = new UidGenerator<RequestState>(r, true);
    //Don't use negative numbers:
    _reply_id_table = new UidGenerator<ReplyState>(r, true);
    _rep_handler_table = new Hashtable();

    /**
     * We keep a list of the most recent 1000 replies until they
     * get too old.  If the reply gets older than reptimeout, we
     * remove it
     */
    _reply_cache = new Cache(1000);
    _reply_cache.EvictionEvent += HandleReplyCacheEviction;
    /*
     * Here we set the timeout mechanisms.  There is a default
     * value, but this is now dynamic based on the observed
     * RTT of the network
     */
    //resend the request after 5 seconds.
    _edge_reqtimeout = new TimeSpan(0,0,0,0,5000);
    _nonedge_reqtimeout = new TimeSpan(0,0,0,0,5000);
    //Start with 50 sec timeout
    _acked_reqtimeout = new TimeSpan(0,0,0,0,50000);
    //Here we track the statistics to improve the timeouts:
    _nonedge_rtt_stats = new TimeStats(_nonedge_reqtimeout.TotalMilliseconds, 0.98);
    _edge_rtt_stats = new TimeStats(_edge_reqtimeout.TotalMilliseconds, 0.98);
    _acked_rtt_stats = new TimeStats(_acked_reqtimeout.TotalMilliseconds, 0.98);
    _last_check = DateTime.UtcNow;
  }
示例#15
0
 public IdentifierTable(bool non_neg)
 {
     _local_to_idpair = new UidGenerator <IIdentifierPair>(new Random(), non_neg);
 }
示例#16
0
  public ReqrepManager(string info, PType prefix) {
    lock( _inst_tab_sync ) {
      _instance_table.Replace(info, this);
    }
    _info = info;
    _prefix = prefix;
#if BRUNET_SIMULATOR
    Random r = Node.SimulatorRandom;
#else
    Random r = new Random();
#endif
    //Don't use negative numbers:
    _req_state_table = new UidGenerator<RequestState>(r, true);
    //Don't use negative numbers:
    _reply_id_table = new UidGenerator<ReplyState>(r, true);

    /**
     * We keep a list of the most recent 1000 replies until they
     * get too old.  If the reply gets older than reptimeout, we
     * remove it
     */
    _reply_cache = new Cache(1000);
    _reply_cache.EvictionEvent += HandleReplyCacheEviction;
    _to_mgr = new TimeOutManager();
  }
示例#17
0
  /**
   * Protected constructor, we want to control ReqrepManager instances
   * running on a node. 
   * @param info some context that we work for
   */
  public ReqrepManager(object info) {
    ReqrepManager existing;
    lock( _inst_tab_sync ) {
      if(_instance_table.TryGetValue(info, out existing) ) {
        throw new Exception("Already an existing ReqrepManager for: " + info.ToString());
      }
      else {
        _instance_table[info] = this;
      }
    }
    _info = info.ToString();

    Random r = new Random();
    //Don't use negative numbers:
    _req_state_table = new UidGenerator<RequestState>(r, true);
    //Don't use negative numbers:
    _reply_id_table = new UidGenerator<ReplyState>(r, true);

    /**
     * We keep a list of the most recent 1000 replies until they
     * get too old.  If the reply gets older than reptimeout, we
     * remove it
     */
    _reply_cache = new Cache(1000);
    _reply_cache.EvictionEvent += HandleReplyCacheEviction;
    _to_mgr = new TimeOutManager();
  }