public virtual void Print(Stack<Printer> printers, List<KeyValuePair<string, int>>.Enumerator occurenceStepper)
        {
            occurenceStepper.MoveNext();
            Console.WriteLine(occurenceStepper.Current.Key + " => " + occurenceStepper.Current.Value);

            printers.Pop().Print(printers, occurenceStepper);
        }
Example #2
0
 public AnimatedTexture Add(Texture tex, double time)
 {
     Textures.Add(new Tuple<Texture, double>(tex, time));
     CurrentTexture = Textures.GetEnumerator();
     CurrentTexture.MoveNext();
     TotalTime += time;
     return this;
 }
Example #3
0
    // Use this for initialization
    public override void Awake()
    {
        base.Awake();
        TimeScaleList.Add(Game.GameTimeScale);

        NextTimeScale = TimeScaleList.GetEnumerator();
        NextTimeScale.MoveNext();
    }
Example #4
0
 // Use this for initialization
 public override void Awake()
 {
     base.Awake();
     Renderer = GetComponent<SpriteRenderer>();
     SpriteList.Add(Renderer.sprite);
     NextSprite = SpriteList.GetEnumerator();
     NextSprite.MoveNext();
     this.DelayedDispatch = true;
 }
Example #5
0
 public override void OnEventFunc(EventData data)
 {
     Game.GameTimeScale = NextTimeScale.Current;
     if (!NextTimeScale.MoveNext())
     {
         NextTimeScale = TimeScaleList.GetEnumerator();
         NextTimeScale.MoveNext();
     }
 }
Example #6
0
        //------------------------------------------------------------------
        public override void Reset()
        {
            AddNewActions ();

            enumerator = Actions.GetEnumerator ();
            enumerator.MoveNext ();

            Actions.ForEach (action => action.Reset());
        }
 static ScriptCompilers()
 {
   using (List<System.Type>.Enumerator enumerator = new List<System.Type>() { typeof (CSharpLanguage), typeof (BooLanguage), typeof (UnityScriptLanguage) }.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       System.Type current = enumerator.Current;
       ScriptCompilers._supportedLanguages.Add((SupportedLanguage) Activator.CreateInstance(current));
     }
   }
 }
Example #8
0
        public StatusBarPage()
        {
            InitializeComponent();

            UpdateControlsForCurrentPane();

            _imagesCollection.AddRange(
                new Image[]
                    {
                        Resources.RecordMacro,
                        Resources.reject_small,
                        Resources.research_small,
                        Resources.resetpicture_small,
                        Resources.reviewingpane_small,
                        Resources.reviewingpanevertical_small,
                        Resources.rotateleft_small,
                        Resources.setlanguage_small,
                        Resources.themes_small,
                        Resources.tight_small,
                        Resources.translationscreentip_small,
                        Resources.wordoptions_small
                    }
                );

            _imagesEnumerator = _imagesCollection.GetEnumerator();
            _imagesEnumerator.MoveNext();

            _highlightTimer = new Timer();
            _highlightTimer.Interval = 300;
            _highlightTimer.Tick += HighlightTimer_Tick;

            _progressBarTimer = new Timer();
            _progressBarTimer.Interval = 40;
            _progressBarTimer.Tick += ProgressBarTimer_Tick;
            _progressBarTimer.Start();

            CurrentPaneComboBox.SelectedIndexChanged += CurrentPaneComboBox_SelectedIndexChanged;

            AddButtonSplitButton.Command = AddButtonCommand;
            AddButtonButton.Command = AddButtonCommand;
            AddButtonWithTextButton.Command = AddButtonWithTextCommand;
            AddToggleButtonSplitButton.Command = AddToggleButtonCommand;
            AddToggleButtonButton.Command = AddToggleButtonCommand;
            AddToggleButtonWithTextButton.Command = AddToggleButtonWithTextCommand;
            AddSliderButton.Command = AddSliderCommand;

            AddButtonCommand.Executed += AddButtonCommand_Executed;
            AddButtonWithTextCommand.Executed += AddButtonWithTextCommand_Executed;
            AddToggleButtonCommand.Executed += AddToggleButtonCommand_Executed;
            AddToggleButtonWithTextCommand.Executed += AddToggleButtonWithTextCommand_Executed;
            AddSliderCommand.Executed += AddSliderCommand_Executed;
        }
    //VRPNAnalogRecording Constructor
    public VRPNAnalogRecording(string nName, float nTime, VRPNAnalog.AnalogReports nData)
    {
        name = nName;
        reportTime = nTime;
        data = nData;
        e = data.list.GetEnumerator();

        while (e.MoveNext())
        {
            VRPNAnalog.AnalogReportNew report = e.Current;
            channels = report.num_channel;
            lastTime = report.msg_time.tv_sec + (report.msg_time.tv_usec / 1000000f);
        }

        e = data.list.GetEnumerator();
    }
        public void LoggableEntity_CreatesPropertiesForModifiedEntity()
        {
            String title = model.Title;
            entry.State = EntityState.Modified;
            entry.CurrentValues["Title"] = "Role";
            entry.OriginalValues["Title"] = "Role";

            IEnumerator<LoggableProperty> expected = new List<LoggableProperty> { new LoggableProperty(entry.Property("Title"), title) }.GetEnumerator();
            IEnumerator<LoggableProperty> actual = new LoggableEntity(entry).Properties.GetEnumerator();

            while (expected.MoveNext() | actual.MoveNext())
            {
                Assert.Equal(expected.Current.IsModified, actual.Current.IsModified);
                Assert.Equal(expected.Current.ToString(), actual.Current.ToString());
            }
        }
Example #11
0
    public override void OnEventFunc(EventData data)
    {
        Renderer.sprite = NextSprite.Current;
        if(!NextSprite.MoveNext())
        {
            NextSprite = SpriteList.GetEnumerator();
            NextSprite.MoveNext();
        }

        if(DispatchOnFinish)
        {
            Dispatch = true;
        }
        else
        {
            DispatchEvent();
        }
    }
        private void textBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Tab)
            {
                TextBox textBox = (TextBox)sender;
                string text = textBox.Text;
                int caretIndex = textBox.CaretIndex;

                if (_enumerator.Current == null)
                {
                    string possibleNick = Utilities.TextUtil.GetWordFromBack(text, caretIndex);

                    _before = text.Substring(0, textBox.CaretIndex - possibleNick.Length);
                    _after = text.Substring(textBox.CaretIndex, text.Length - textBox.CaretIndex);

                    _possibleNicks = GetPossibleNicks(possibleNick);

                    _enumerator = _possibleNicks.GetEnumerator();
                }

                if (!_enumerator.MoveNext())
                {
                    _enumerator = _possibleNicks.GetEnumerator();
                    _enumerator.MoveNext();
                }

                if (_enumerator.Current != null)
                {
                    string delimiter = (_before == String.Empty) ? ": " : " ";

                    textBox.Text = string.Format("{0}{1}{2}{3}", _before, _enumerator.Current, delimiter, _after);
                    textBox.CaretIndex = _before.Length + _enumerator.Current.Length + delimiter.Length;
                }

                e.Handled = true;
            }
            else
            {
                _enumerator = new List<string>.Enumerator();
            }
        }
    //VRPNTrackerRecording Constructor
    public VRPNTrackerRecording(string nName, float nTime, VRPNTracker.TrackerReports nData)
    {
        name = nName;
        reportTime = nTime;
        data = nData;

        e = data.list.GetEnumerator();

        while (e.MoveNext())
        {
            VRPNTracker.TrackerReportNew report = e.Current;
            int test;
            if (!sensors.TryGetValue(report.sensor, out test))
            {
                sensors.Add(report.sensor, report.sensor);
            }
            lastTime = report.msg_time.tv_sec + (report.msg_time.tv_usec / 1000000f);
        }

        e = data.list.GetEnumerator();
    }
        public void LoggableEntity_CreatesPropertiesForAttachedEntity()
        {
            context.Dispose();
            String title = model.Title;
            context = new TestingContext();
            context.Set<Role>().Attach(model);

            entry = context.Entry<BaseModel>(model);
            entry.OriginalValues["Title"] = "Role";
            entry.CurrentValues["Title"] = "Role";
            entry.State = EntityState.Modified;

            IEnumerator<LoggableProperty> expected = new List<LoggableProperty> { new LoggableProperty(entry.Property("Title"), title) }.GetEnumerator();
            IEnumerator<LoggableProperty> actual = new LoggableEntity(entry).Properties.GetEnumerator();

            while (expected.MoveNext() | actual.MoveNext())
            {
                Assert.Equal(expected.Current.IsModified, actual.Current.IsModified);
                Assert.Equal(expected.Current.ToString(), actual.Current.ToString());
            }
        }
        protected static Token? SkipToNext(ref List<Token>.Enumerator enumerator)
        {
            Token? token;

            do {
                if (!enumerator.MoveNext())
                    return null;

                token = enumerator.Current;

                switch (token.Value.Type) {
                        // regardless where we are, skip over whitespace, etc.
                    case TokenType.WhiteSpace:
                    case TokenType.LineComment:
                    case TokenType.MultilineComment:
                        continue;
                }
                break;
            } while (true);
            return token;
        }
Example #16
0
 void Turn()
 {
     direction = currentRotation.Current;
     if (!currentRotation.MoveNext())
     {
         currentRotation = currentPOI.Current.directionPattern.GetEnumerator();
         currentRotation.MoveNext();
     }
     turnTimer = 0f;
 }
        private void RefreshNodeListAndTokenMap()
        {
            _logger.Info("Refreshing NodeList and TokenMap..");
            // Make sure we're up to date on nodes and tokens
            var tokenMap = new Dictionary<IPAddress, DictSet<string>>();
            string partitioner = null;

            var foundHosts = new List<IPAddress>();
            var dcs = new List<string>();
            var racks = new List<string>();
            var allTokens = new List<DictSet<string>>();
            IPAddress queriedHost;

            using (var rowset = _session.Query(SelectPeers, ConsistencyLevel.Quorum))
            {
                queriedHost = rowset.Info.QueriedHost;
                foreach (var row in rowset.GetRows())
                {
                    IPAddress hstip = null;
                    if(!row.IsNull("rpc_address"))
                         hstip = row.GetValue<IPEndPoint>("rpc_address").Address;
                    if (hstip == null)
                    {
                        if (!row.IsNull("peer"))
                            hstip = row.GetValue<IPEndPoint>("peer").Address;
                        _logger.Error("No rpc_address found for host in peers system table. ");
                    }
                    else if (hstip.Equals(bindAllAddress))
                    {
                        if (!row.IsNull("peer"))
                            hstip = row.GetValue<IPEndPoint>("peer").Address;
                    }

                    if (hstip != null)
                    {
                        foundHosts.Add(hstip);
                        dcs.Add(row.GetValue<string>("data_center"));
                        racks.Add(row.GetValue<string>("rack"));
                        var col = row.GetValue<IEnumerable<string>>("tokens");
                        if (col == null)
                            allTokens.Add(new DictSet<string>());
                        else
                            allTokens.Add(new DictSet<string>(col));
                    }
                }
            }

            var localhost = _cluster.Metadata.GetHost(queriedHost);
            var iterLiof = new List<Host>() { localhost }.GetEnumerator();
            iterLiof.MoveNext();
            List<IPAddress> tr = new List<IPAddress>();
            Dictionary<IPAddress, List<Exception>> exx = new Dictionary<IPAddress, List<Exception>>();
            var cn = _session.Connect(null, iterLiof, tr, exx);

            using (var outp = cn.Query(SelectLocal, ConsistencyLevel.Default,false))
            {
                if (outp is OutputRows)
                {
                    var rowset = new RowSet((outp as OutputRows), null, false);
                    // Update cluster name, DC and rack for the one node we are connected to
                    foreach (var localRow in rowset.GetRows())
                    {
                        var clusterName = localRow.GetValue<string>("cluster_name");
                        if (clusterName != null)
                            _cluster.Metadata.ClusterName = clusterName;

                        // In theory host can't be null. However there is no point in risking a NPE in case we
                        // have a race between a node removal and this.
                        if (localhost != null)
                        {
                            localhost.SetLocationInfo(localRow.GetValue<string>("data_center"), localRow.GetValue<string>("rack"));

                            partitioner = localRow.GetValue<string>("partitioner");
                            var tokens = localRow.GetValue<IList<string>>("tokens");
                            if (partitioner != null && tokens.Count > 0)
                            {
                                if (!tokenMap.ContainsKey(localhost.Address))
                                    tokenMap.Add(localhost.Address, new DictSet<string>());
                                tokenMap[localhost.Address].AddRange(tokens);
                            }
                        }

                        break; //fetch only one row
                    }
                }
            }

            for (int i = 0; i < foundHosts.Count; i++)
            {
                var host = _cluster.Metadata.GetHost(foundHosts[i]);
                if (host == null)
                {
                    // We don't know that node, add it.
                    host = _cluster.Metadata.AddHost(foundHosts[i]);
                }
                host.SetLocationInfo(dcs[i], racks[i]);

                if (partitioner != null && !allTokens[i].IsEmpty)
                    tokenMap.Add(host.Address, allTokens[i]);
            }

            // Removes all those that seems to have been removed (since we lost the control connection)
            var foundHostsSet = new DictSet<IPAddress>(foundHosts);
            foreach (var host in _cluster.Metadata.AllReplicas())
                if (!host.Equals(queriedHost) && !foundHostsSet.Contains(host))
                    _cluster.Metadata.RemoveHost(host);

            if (partitioner != null)
                _cluster.Metadata.RebuildTokenMap(partitioner, tokenMap);

            _logger.Info("NodeList and TokenMap have been successfully refreshed!");
        }
Example #18
0
 public bool MoveNext()
 {
     return(_enumerator.MoveNext());
 }
 public bool MoveNext()
 {
     return(_e.MoveNext());
 }
Example #20
0
        public async void joinQueue()
        {
            if (queueType == QueueTypes.CUSTOM)
            {
                CreatePracticeGame();
            }
            else
            {
                LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams matchParams = new LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams();
                if (queueType == QueueTypes.INTRO_BOT)
                {
                    matchParams.BotDifficulty = "INTRO";
                }
                else if (queueType == QueueTypes.BEGINNER_BOT)
                {
                    matchParams.BotDifficulty = "EASY";
                }
                else if (queueType == QueueTypes.MEDIUM_BOT)
                {
                    matchParams.BotDifficulty = "MEDIUM";
                }

                if (sumLevel == 3 && actualQueueType == QueueTypes.NORMAL_5x5)
                {
                    queueType = actualQueueType;
                }
                else if (sumLevel == 6 && actualQueueType == QueueTypes.ARAM)
                {
                    queueType = actualQueueType;
                }
                else if (sumLevel == 7 && actualQueueType == QueueTypes.NORMAL_3x3)
                {
                    queueType = actualQueueType;
                }

                matchParams.QueueIds = new Int32[1] {
                    (int)queueType
                };

                LoLLauncher.RiotObjects.Platform.Matchmaking.SearchingForMatchNotification m = await connection.AttachToQueue(matchParams);

                this.updateStatus("Trying to join queue", Accountname);
                if (m.PlayerJoinFailures == null)
                {
                    this.updateStatus("In queue for " + queueType.ToString(), Accountname);
                }
                else
                {
                    List <QueueDodger> .Enumerator enumerator = m.PlayerJoinFailures.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            QueueDodger current = enumerator.Current;
                            if (current.ReasonFailed == "LEAVER_BUSTED")
                            {
                                this.m_accessToken = current.AccessToken;
                                if (current.LeaverPenaltyMillisRemaining > this.m_leaverBustedPenalty)
                                {
                                    this.m_leaverBustedPenalty = current.LeaverPenaltyMillisRemaining;
                                }
                            }
                        }
                    }
                    finally
                    {
                        enumerator.Dispose();
                    }
                    if (string.IsNullOrEmpty(this.m_accessToken))
                    {
                        List <QueueDodger> .Enumerator enumerator2 = m.PlayerJoinFailures.GetEnumerator();
                        try
                        {
                            while (enumerator2.MoveNext())
                            {
                                QueueDodger dodger2 = enumerator2.Current;
                                this.updateStatus("Dodge Remaining Time: " + Convert.ToString((float)(((float)(dodger2.DodgePenaltyRemainingTime / 0x3e8)) / 60f)).Replace(",", ":") + "...", Accountname);

                                if (dodger2.DodgePenaltyRemainingTime == 0 || dodger2.LeaverPenaltyMillisRemaining == 0)
                                {
                                    this.updateStatus("You need login to your account using the game client and type 'I accept' to use HFL", Accountname);
                                    connection.Disconnect();
                                }
                            }
                            return;
                        }
                        finally
                        {
                            enumerator2.Dispose();
                        }
                    }
                    double minutes = ((float)(this.m_leaverBustedPenalty / 0x3e8)) / 60f;
                    this.updateStatus("Waiting out leaver buster: " + minutes + " minutes!", Accountname);
                    Thread.Sleep(TimeSpan.FromMilliseconds((double)this.m_leaverBustedPenalty));
                    m = await this.connection.AttachToLowPriorityQueue(matchParams, this.m_accessToken);

                    if (m.PlayerJoinFailures == null)
                    {
                        this.updateStatus("Succesfully joined lower priority queue!", Accountname);
                    }
                    else
                    {
                        this.updateStatus("There was an error in joining lower priority queue.Disconnecting...", Accountname);
                        this.connection.Disconnect();
                    }
                }
            }
        }
Example #21
0
        public IEnumerable<DictionaryEntry> GetAutoCompleteSuggestions(string root)
        {
            Log.DebugFormat("GetAutoCompleteSuggestions called with root '{0}'", root);

            if (entriesForAutoComplete != null)
            {
                var simplifiedRoot = root.CreateAutoCompleteDictionaryEntryHash();

                if (!string.IsNullOrWhiteSpace(simplifiedRoot))
                {
                    var enumerator =
                        new List<DictionaryEntry> { new DictionaryEntry { Entry = root } } //Include the typed root as first result
                        .Union(entriesForAutoComplete
                                .Where(kvp => kvp.Key.StartsWith(simplifiedRoot))
                                .SelectMany(kvp => kvp.Value)
                                .Where(de => de.Entry.Length > root.Length)
                                .Distinct() //Phrases are stored in entriesForAutoComplete with multiple hashes (one the full version of the phrase and one the first letter of each word so you can look them up by either)
                                .OrderByDescending(de => de.UsageCount)
                                .ThenBy(de => de.Entry.Length))
                        .GetEnumerator();

                    while (enumerator.MoveNext())
                    {
                        yield return enumerator.Current;
                    }
                }

                yield break; //Not strictly necessary
            }
        }
Example #22
0
    private void CLProject(BaseEntity.RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (!this.VerifyClientAttack(player))
        {
            this.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
        }
        else
        {
            if (Object.op_Equality((Object)player, (Object)null) || player.IsHeadUnderwater())
            {
                return;
            }
            if (!this.canThrowAsProjectile)
            {
                AntiHack.Log(player, AntiHackType.ProjectileHack, "Not throwable (" + this.ShortPrefabName + ")");
                player.stats.combat.Log((AttackEntity)this, "not_throwable");
            }
            else
            {
                Item pickupItem = this.GetItem();
                if (pickupItem == null)
                {
                    AntiHack.Log(player, AntiHackType.ProjectileHack, "Item not found (" + this.ShortPrefabName + ")");
                    player.stats.combat.Log((AttackEntity)this, "item_missing");
                }
                else
                {
                    ItemModProjectile component1 = (ItemModProjectile)((Component)pickupItem.info).GetComponent <ItemModProjectile>();
                    if (Object.op_Equality((Object)component1, (Object)null))
                    {
                        AntiHack.Log(player, AntiHackType.ProjectileHack, "Item mod not found (" + this.ShortPrefabName + ")");
                        player.stats.combat.Log((AttackEntity)this, "mod_missing");
                    }
                    else
                    {
                        ProjectileShoot projectileShoot = ProjectileShoot.Deserialize((Stream)msg.read);
                        if (((List <ProjectileShoot.Projectile>)projectileShoot.projectiles).Count != 1)
                        {
                            AntiHack.Log(player, AntiHackType.ProjectileHack, "Projectile count mismatch (" + this.ShortPrefabName + ")");
                            player.stats.combat.Log((AttackEntity)this, "count_mismatch");
                        }
                        else
                        {
                            player.CleanupExpiredProjectiles();
                            using (List <ProjectileShoot.Projectile> .Enumerator enumerator = ((List <ProjectileShoot.Projectile>)projectileShoot.projectiles).GetEnumerator())
                            {
                                while (enumerator.MoveNext())
                                {
                                    ProjectileShoot.Projectile current = enumerator.Current;
                                    if (player.HasFiredProjectile((int)current.projectileID))
                                    {
                                        AntiHack.Log(player, AntiHackType.ProjectileHack, "Duplicate ID (" + (object)(int)current.projectileID + ")");
                                        player.stats.combat.Log((AttackEntity)this, "duplicate_id");
                                    }
                                    else if (this.ValidateEyePos(player, (Vector3)current.startPos))
                                    {
                                        player.NoteFiredProjectile((int)current.projectileID, (Vector3)current.startPos, (Vector3)current.startVel, (AttackEntity)this, pickupItem.info, pickupItem);
                                        Effect effect = new Effect();
                                        effect.Init(Effect.Type.Projectile, (Vector3)current.startPos, (Vector3)current.startVel, msg.connection);
                                        effect.scale        = (__Null)1.0;
                                        effect.pooledString = component1.projectileObject.resourcePath;
                                        effect.number       = current.seed;
                                        EffectNetwork.Send(effect);
                                    }
                                }
                            }
                            pickupItem.SetParent((ItemContainer)null);
                            Interface.CallHook("OnMeleeThrown", (object)player, (object)pickupItem);
                            if (!this.canAiHearIt)
                            {
                                return;
                            }
                            float num = 0.0f;
                            if (component1.projectileObject != null)
                            {
                                GameObject gameObject = component1.projectileObject.Get();
                                if (Object.op_Inequality((Object)gameObject, (Object)null))
                                {
                                    Projectile component2 = (Projectile)gameObject.GetComponent <Projectile>();
                                    if (Object.op_Inequality((Object)component2, (Object)null))
                                    {
                                        foreach (DamageTypeEntry damageType in component2.damageTypes)
                                        {
                                            num += damageType.amount;
                                        }
                                    }
                                }
                            }
                            if (!Object.op_Inequality((Object)player, (Object)null))
                            {
                                return;
                            }
                            Sense.Stimulate(new Sensation()
                            {
                                Type            = SensationType.ThrownWeapon,
                                Position        = ((Component)player).get_transform().get_position(),
                                Radius          = 50f,
                                DamagePotential = num,
                                InitiatorPlayer = player,
                                Initiator       = (BaseEntity)player
                            });
                        }
                    }
                }
            }
        }
    }
Example #23
0
 // Token: 0x06000D86 RID: 3462 RVA: 0x0011171C File Offset: 0x0010F91C
 public override void performHoverAction(int x, int y)
 {
     if (this.demolishing)
     {
         using (List <Building> .Enumerator enumerator = ((Farm)Game1.getLocationFromName("Farm")).buildings.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 enumerator.Current.color = Color.White;
             }
         }
         Building b = ((Farm)Game1.getLocationFromName("Farm")).getBuildingAt(new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize)));
         if (b != null)
         {
             b.color = Color.Red * 0.8f;
             return;
         }
     }
     else if (this.upgrading)
     {
         using (List <Building> .Enumerator enumerator = ((Farm)Game1.getLocationFromName("Farm")).buildings.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 enumerator.Current.color = Color.White;
             }
         }
         Building b2 = ((Farm)Game1.getLocationFromName("Farm")).getBuildingAt(new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize)));
         if (b2 != null && this.structureForPlacement.nameOfBuildingToUpgrade != null && this.structureForPlacement.nameOfBuildingToUpgrade.Equals(b2.buildingType))
         {
             b2.color = Color.Green * 0.8f;
             return;
         }
         if (b2 != null)
         {
             b2.color = Color.Red * 0.8f;
             return;
         }
     }
     else if (!this.placingStructure)
     {
         foreach (ClickableComponent c in this.tabs)
         {
             if (c.containsPoint(x, y))
             {
                 this.hoverText = c.name;
                 return;
             }
         }
         this.hoverText = "";
         bool overAnyButton = false;
         foreach (ClickableComponent c2 in this.blueprintButtons[this.currentTab].Keys)
         {
             if (c2.containsPoint(x, y))
             {
                 c2.scale         = Math.Min(c2.scale + 0.01f, 1.1f);
                 this.hoveredItem = this.blueprintButtons[this.currentTab][c2];
                 overAnyButton    = true;
             }
             else
             {
                 c2.scale = Math.Max(c2.scale - 0.01f, 1f);
             }
         }
         if (!overAnyButton)
         {
             this.hoveredItem = null;
         }
     }
 }
Example #24
0
 // Token: 0x06000D83 RID: 3459 RVA: 0x00110EC0 File Offset: 0x0010F0C0
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     if (this.currentAnimal != null)
     {
         this.currentAnimal    = null;
         this.placingStructure = true;
         this.queryingAnimals  = true;
     }
     if (!this.placingStructure)
     {
         Microsoft.Xna.Framework.Rectangle menuBounds = new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height);
         foreach (ClickableComponent c in this.blueprintButtons[this.currentTab].Keys)
         {
             if (c.containsPoint(x, y))
             {
                 if (c.name.Equals("Info Tool"))
                 {
                     this.placingStructure = true;
                     this.queryingAnimals  = true;
                     Game1.playSound("smallSelect");
                     return;
                 }
                 if (this.blueprintButtons[this.currentTab][c].doesFarmerHaveEnoughResourcesToBuild())
                 {
                     this.structureForPlacement = this.blueprintButtons[this.currentTab][c];
                     this.placingStructure      = true;
                     if (this.currentTab == 1)
                     {
                         this.upgrading = true;
                     }
                     Game1.playSound("smallSelect");
                     return;
                 }
                 Game1.addHUDMessage(new HUDMessage("Not Enough Resources", Color.Red, 3500f));
                 return;
             }
         }
         foreach (ClickableComponent c2 in this.tabs)
         {
             if (c2.containsPoint(x, y))
             {
                 this.currentTab = this.getTabNumberFromName(c2.name);
                 Game1.playSound("smallSelect");
                 if (this.currentTab == 3)
                 {
                     this.placingStructure = true;
                     this.demolishing      = true;
                 }
                 return;
             }
         }
         if (!menuBounds.Contains(x, y))
         {
             Game1.exitActiveMenu();
             return;
         }
     }
     else if (this.demolishing)
     {
         Building destroyed = ((Farm)Game1.getLocationFromName("Farm")).getBuildingAt(new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize)));
         if (destroyed != null && ((Farm)Game1.getLocationFromName("Farm")).destroyStructure(destroyed))
         {
             int groundYTile = destroyed.tileY + destroyed.tilesHigh;
             for (int i = 0; i < destroyed.texture.Bounds.Height / Game1.tileSize; i++)
             {
                 Game1.createRadialDebris(Game1.currentLocation, destroyed.texture, new Microsoft.Xna.Framework.Rectangle(destroyed.texture.Bounds.Center.X, destroyed.texture.Bounds.Center.Y, Game1.tileSize / 16, Game1.tileSize / 16), destroyed.tileX + Game1.random.Next(destroyed.tilesWide), destroyed.tileY + destroyed.tilesHigh - i, Game1.random.Next(20, 45), groundYTile);
             }
             Game1.playSound("explosion");
             Utility.spreadAnimalsAround(destroyed, (Farm)Game1.getLocationFromName("Farm"));
             return;
         }
         Game1.exitActiveMenu();
         return;
     }
     else if (this.upgrading && Game1.currentLocation.GetType() == typeof(Farm))
     {
         Building toUpgrade = ((Farm)Game1.getLocationFromName("Farm")).getBuildingAt(new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize)));
         if (toUpgrade != null && this.structureForPlacement.name != null && toUpgrade.buildingType.Equals(this.structureForPlacement.nameOfBuildingToUpgrade))
         {
             toUpgrade.indoors.map  = Game1.content.Load <Map>("Maps\\" + this.structureForPlacement.mapToWarpTo);
             toUpgrade.indoors.name = this.structureForPlacement.mapToWarpTo;
             toUpgrade.buildingType = this.structureForPlacement.name;
             toUpgrade.texture      = this.structureForPlacement.texture;
             if (toUpgrade.indoors.GetType() == typeof(AnimalHouse))
             {
                 ((AnimalHouse)toUpgrade.indoors).resetPositionsOfAllAnimals();
             }
             Game1.playSound("axe");
             this.structureForPlacement.consumeResources();
             toUpgrade.color = Color.White;
             Game1.exitActiveMenu();
             return;
         }
         if (toUpgrade != null)
         {
             Game1.addHUDMessage(new HUDMessage("Incorrect Building Type", Color.Red, 3500f));
             return;
         }
         Game1.exitActiveMenu();
         return;
     }
     else
     {
         if (this.queryingAnimals)
         {
             if (!(Game1.currentLocation.GetType() == typeof(Farm)) && !(Game1.currentLocation.GetType() == typeof(AnimalHouse)))
             {
                 return;
             }
             using (List <FarmAnimal> .Enumerator enumerator3 = ((Game1.currentLocation.GetType() == typeof(Farm)) ? ((Farm)Game1.currentLocation).animals.Values.ToList <FarmAnimal>() : ((AnimalHouse)Game1.currentLocation).animals.Values.ToList <FarmAnimal>()).GetEnumerator())
             {
                 while (enumerator3.MoveNext())
                 {
                     FarmAnimal animal = enumerator3.Current;
                     if (new Microsoft.Xna.Framework.Rectangle((int)animal.position.X, (int)animal.position.Y, animal.sprite.SourceRect.Width, animal.sprite.SourceRect.Height).Contains(Game1.viewport.X + Game1.getOldMouseX(), Game1.viewport.Y + Game1.getOldMouseY()))
                     {
                         this.positionOfAnimalWhenClicked = Game1.GlobalToLocal(Game1.viewport, animal.position);
                         this.currentAnimal    = animal;
                         this.queryingAnimals  = false;
                         this.placingStructure = false;
                         if (animal.sound != null && !animal.sound.Equals(""))
                         {
                             Game1.playSound(animal.sound);
                         }
                         break;
                     }
                 }
                 return;
             }
         }
         if (Game1.currentLocation.GetType() != typeof(Farm))
         {
             Game1.addHUDMessage(new HUDMessage("Can Only Place Outside On Farm", Color.Red, 3500f));
             return;
         }
         if (!this.structureForPlacement.doesFarmerHaveEnoughResourcesToBuild())
         {
             Game1.addHUDMessage(new HUDMessage("Not Enough Resources", Color.Red, 3500f));
             return;
         }
         if (this.tryToBuild())
         {
             this.structureForPlacement.consumeResources();
             if (!this.structureForPlacement.blueprintType.Equals("Animals"))
             {
                 Game1.playSound("axe");
                 return;
             }
         }
         else
         {
             Game1.addHUDMessage(new HUDMessage("Can't Build There", Color.Red, 3500f));
         }
     }
 }
Example #25
0
        private static void ShowMultiLoading()
        {
            CUIFormScript formScript = Singleton <CUIManager> .GetInstance().OpenForm(PVP_PATH_LOADING, false, false);

            if (formScript != null)
            {
                SLevelContext curLvelContext = Singleton <BattleLogic> .instance.GetCurLvelContext();

                GameObject widget = formScript.GetWidget(0);
                if (widget != null)
                {
                    if (MonoSingleton <Reconnection> .instance.isProcessingRelayRecover)
                    {
                        widget.CustomSetActive(true);
                    }
                    else
                    {
                        widget.CustomSetActive(false);
                    }
                }
                IGameActorDataProvider actorDataProvider = Singleton <ActorDataCenter> .instance.GetActorDataProvider(GameActorDataProviderType.StaticBattleDataProvider);

                IGameActorDataProvider provider2 = Singleton <ActorDataCenter> .instance.GetActorDataProvider(GameActorDataProviderType.ServerDataProvider);

                ActorStaticData actorData = new ActorStaticData();
                ActorMeta       actorMeta = new ActorMeta();
                ActorMeta       meta2     = new ActorMeta();
                ActorServerData data2     = new ActorServerData();
                actorMeta.ActorType = ActorTypeDef.Actor_Type_Hero;
                string name = null;
                for (int i = 1; i <= 2; i++)
                {
                    List <Player> allCampPlayers = Singleton <GamePlayerCenter> .GetInstance().GetAllCampPlayers((COM_PLAYERCAMP)i);

                    if (allCampPlayers != null)
                    {
                        Transform transform = (i != 1) ? formScript.transform.FindChild("DownPanel") : formScript.transform.FindChild("UpPanel");
                        for (int j = 1; j <= 5L; j++)
                        {
                            name = (i != 1) ? string.Format("Down_Player{0}", j) : string.Format("Up_Player{0}", j);
                            transform.FindChild(name).gameObject.CustomSetActive(false);
                        }
                        List <Player> .Enumerator enumerator = allCampPlayers.GetEnumerator();
                        COM_PLAYERCAMP            playerCamp = Singleton <GamePlayerCenter> .instance.GetHostPlayer().PlayerCamp;

                        while (enumerator.MoveNext())
                        {
                            Player current = enumerator.Current;
                            if (current != null)
                            {
                                name = (i != 1) ? string.Format("Down_Player{0}", current.CampPos + 1) : string.Format("Up_Player{0}", current.CampPos + 1);
                                GameObject gameObject = transform.FindChild(name).gameObject;
                                gameObject.CustomSetActive(true);
                                GameObject obj5 = gameObject.transform.Find("RankFrame").gameObject;
                                bool       flag = ((current.PlayerCamp == playerCamp) || Singleton <WatchController> .GetInstance().IsWatching) || Singleton <WatchController> .GetInstance().IsReplaying;

                                if (obj5 != null)
                                {
                                    if (flag)
                                    {
                                        string rankFrameIconPath = CLadderView.GetRankFrameIconPath((byte)current.GradeOfRank, current.ClassOfRank);
                                        if (string.IsNullOrEmpty(rankFrameIconPath))
                                        {
                                            obj5.CustomSetActive(false);
                                        }
                                        else
                                        {
                                            Image image = obj5.GetComponent <Image>();
                                            if (image != null)
                                            {
                                                image.SetSprite(rankFrameIconPath, formScript, true, false, false);
                                            }
                                            obj5.CustomSetActive(true);
                                        }
                                    }
                                    else
                                    {
                                        obj5.CustomSetActive(false);
                                    }
                                }
                                Transform transform2 = gameObject.transform.Find("RankClassText");
                                if (transform2 != null)
                                {
                                    GameObject obj6 = transform2.gameObject;
                                    if (flag && CLadderView.IsSuperKing((byte)current.GradeOfRank, current.ClassOfRank))
                                    {
                                        obj6.CustomSetActive(true);
                                        obj6.GetComponent <Text>().text = current.ClassOfRank.ToString();
                                    }
                                    else
                                    {
                                        obj6.CustomSetActive(false);
                                    }
                                }
                                Text component = gameObject.transform.Find("Txt_PlayerName/Name").gameObject.GetComponent <Text>();
                                component.text = current.Name;
                                Image image2 = gameObject.transform.Find("Txt_PlayerName/NobeIcon").gameObject.GetComponent <Image>();
                                if (image2 != null)
                                {
                                    MonoSingleton <NobeSys> .GetInstance().SetNobeIcon(image2, (int)current.VipLv, true);
                                }
                                Text text2 = gameObject.transform.Find("Txt_HeroName").gameObject.GetComponent <Text>();
                                actorMeta.ConfigId = (int)current.CaptainId;
                                text2.text         = !actorDataProvider.GetActorStaticData(ref actorMeta, ref actorData) ? null : actorData.TheResInfo.Name;
                                if ((Singleton <WatchController> .GetInstance().IsWatching&& (current.PlayerUId == Singleton <WatchController> .GetInstance().TargetUID)) || (!Singleton <WatchController> .GetInstance().IsWatching&& (current.PlayerId == Singleton <GamePlayerCenter> .instance.GetHostPlayer().PlayerId)))
                                {
                                    component.color = CUIUtility.s_Text_Color_Self;
                                }
                                else
                                {
                                    component.color = CUIUtility.s_Text_Color_CommonGray;
                                }
                                GameObject obj7 = gameObject.transform.Find("Txt_LoadingPct").gameObject;
                                if (obj7 != null)
                                {
                                    Text text3 = obj7.GetComponent <Text>();
                                    if (current.Computer)
                                    {
                                        text3.text = !curLvelContext.m_isWarmBattle ? "100%" : "1%";
                                    }
                                    else
                                    {
                                        text3.text = (!MonoSingleton <Reconnection> .instance.isProcessingRelayRecover && !Singleton <WatchController> .GetInstance().IsWatching) ? "1%" : "100%";
                                    }
                                }
                                ResHeroCfgInfo dataByKey = GameDataMgr.heroDatabin.GetDataByKey(current.CaptainId);
                                if (dataByKey != null)
                                {
                                    meta2.PlayerId  = current.PlayerId;
                                    meta2.ActorCamp = (COM_PLAYERCAMP)i;
                                    meta2.ConfigId  = (int)dataByKey.dwCfgID;
                                    meta2.ActorType = ActorTypeDef.Actor_Type_Hero;
                                    Image image3 = gameObject.transform.Find("Hero").gameObject.GetComponent <Image>();
                                    if (provider2.GetActorServerData(ref meta2, ref data2))
                                    {
                                        ResHeroSkin heroSkin = CSkinInfo.GetHeroSkin((uint)data2.TheActorMeta.ConfigId, data2.SkinId);
                                        if (heroSkin != null)
                                        {
                                            image3.SetSprite(CUIUtility.s_Sprite_Dynamic_BustHero_Dir + StringHelper.UTF8BytesToString(ref heroSkin.szSkinPicID), formScript, true, false, false);
                                            if (heroSkin.dwSkinID > 0)
                                            {
                                                text2.text = string.Format(Singleton <CTextManager> .GetInstance().GetText("LoadingSkinNameTxt"), heroSkin.szSkinName, heroSkin.szHeroName);
                                            }
                                        }
                                        bool      bActive    = (((current.PlayerCamp == playerCamp) || Singleton <WatchController> .GetInstance().IsWatching) || Singleton <WatchController> .GetInstance().IsReplaying) && (curLvelContext.m_isWarmBattle || !current.Computer);
                                        Transform transform3 = gameObject.transform.Find("heroProficiencyBgImg");
                                        if (transform3 != null)
                                        {
                                            transform3.gameObject.CustomSetActive(bActive);
                                            if (bActive)
                                            {
                                                CUICommonSystem.SetHeroProficiencyBgImage(formScript, transform3.gameObject, (int)data2.TheProficiencyInfo.Level, true);
                                            }
                                        }
                                        Transform transform4 = gameObject.transform.Find("heroProficiencyImg");
                                        if (transform4 != null)
                                        {
                                            transform4.gameObject.CustomSetActive(bActive);
                                            if (bActive)
                                            {
                                                CUICommonSystem.SetHeroProficiencyIconImage(formScript, transform4.gameObject, (int)data2.TheProficiencyInfo.Level);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        image3.SetSprite(CUIUtility.s_Sprite_Dynamic_BustHero_Dir + StringHelper.UTF8BytesToString(ref dataByKey.szImagePath), formScript, true, false, false);
                                    }
                                    uint skillID = 0;
                                    if (provider2.GetActorServerCommonSkillData(ref meta2, out skillID) && (skillID != 0))
                                    {
                                        ResSkillCfgInfo info2 = GameDataMgr.skillDatabin.GetDataByKey(skillID);
                                        if (info2 != null)
                                        {
                                            gameObject.transform.Find("SelSkill").gameObject.CustomSetActive(true);
                                            string prefabPath = string.Format("{0}{1}", CUIUtility.s_Sprite_Dynamic_Skill_Dir, Utility.UTF8Convert(info2.szIconPath));
                                            gameObject.transform.Find("SelSkill/Icon").GetComponent <Image>().SetSprite(prefabPath, formScript.GetComponent <CUIFormScript>(), true, false, false);
                                        }
                                        else
                                        {
                                            gameObject.transform.Find("SelSkill").gameObject.CustomSetActive(false);
                                        }
                                    }
                                    else
                                    {
                                        gameObject.transform.Find("SelSkill").gameObject.CustomSetActive(false);
                                    }
                                    Transform transform5 = gameObject.transform.Find("skinLabelImage");
                                    if (transform5 != null)
                                    {
                                        CUICommonSystem.SetHeroSkinLabelPic(formScript, transform5.gameObject, dataByKey.dwCfgID, data2.SkinId);
                                    }
                                }
                            }
                        }
                    }
                }
                formScript.gameObject.transform.FindChild("Img_Tiao").FindChild("Tips").gameObject.GetComponent <Text>().text = GenerateRandomPvpLoadingTips(GenerateMultiRandomNum());
            }
        }
Example #26
0
 public bool MoveNext() => enumerator.MoveNext();
Example #27
0
        public static void Drive()
        {
            List <long> list  = new List <long>();
            List <long> list2 = new List <long>();

            using (Dictionary <long, TCPSocketContext> .Enumerator enumerator = NetLib.dictSocketContext.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyValuePair <long, TCPSocketContext> current = enumerator.get_Current();
                    list.Add(current.get_Key());
                }
            }
            using (List <long> .Enumerator enumerator2 = list.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    long current2 = enumerator2.get_Current();
                    if (NetLib.dictSocketContext.ContainsKey(current2))
                    {
                        long             num = current2;
                        TCPSocketContext tCPSocketContext = NetLib.dictSocketContext.get_Item(num);
                        int num2 = NetLib.PandoraNet_DoSelect(num);
                        if (num2 != 0)
                        {
                            if (num2 == 1)
                            {
                                int num3 = tCPSocketContext.HandleInputEvent();
                                if (num3 < 0)
                                {
                                    int num4 = 0;
                                    tCPSocketContext.HandleClose(out num4);
                                    NetLib.pendingPacketsLength -= (long)num4;
                                    list2.Add(num);
                                }
                            }
                            else if (num2 == 2)
                            {
                                int num5 = 0;
                                int num6 = tCPSocketContext.HandleOutputEvent(out num5);
                                NetLib.pendingPacketsLength -= (long)num5;
                                if (num6 < 0)
                                {
                                    int num7 = 0;
                                    tCPSocketContext.HandleClose(out num7);
                                    NetLib.pendingPacketsLength -= (long)num7;
                                    list2.Add(num);
                                }
                            }
                            else
                            {
                                int num8 = 0;
                                tCPSocketContext.HandleClose(out num8);
                                NetLib.pendingPacketsLength -= (long)num8;
                                list2.Add(num);
                            }
                        }
                    }
                }
            }
            using (List <long> .Enumerator enumerator3 = list2.GetEnumerator())
            {
                while (enumerator3.MoveNext())
                {
                    long current3 = enumerator3.get_Current();
                    NetLib.dictSocketContext.Remove(current3);
                    NetLib.PandoraNet_Close(current3);
                }
            }
        }
Example #28
0
 public override void Init()
 {
     currentChild = children.GetEnumerator();
     currentChild.MoveNext();
 }
Example #29
0
        static void Postfix(ref List <CharacterObject> __result, Settlement settlement, int maxParticipantCount, bool includePlayer = true, bool includeHeroes = true)
        {
            if (!includePlayer)
            {
                return;
            }

            if (ModState.TournamentRecords.ForCurrentSettlement().tournamentType == TournamentType.Highborn)
            {
                IEnumerable <Hero> list = settlement.OwnerClan.MapFaction.Heroes;
                for (int i = 0; i < 15; i++)
                {
                    CharacterObject potentialParticipant = list.GetRandomElementInefficiently().CharacterObject;
                    bool            exists = false;
                    for (int t = 0; t < __result.Count; t++)
                    {
                        if (__result[t].Name.Equals(potentialParticipant.Name) || potentialParticipant.IsPlayerCharacter || potentialParticipant.HeroObject.IsDead || potentialParticipant.Age < 18.00)
                        {
                            exists = true;
                            break;
                        }
                    }
                    if (!exists)
                    {
                        __result[__result.Count - 1 - i] = potentialParticipant;
                    }
                }
            }
            else if (includePlayer)
            {
                int numAddedHeroes      = MBRandom.RandomInt(4, Settings.UpperBoundHeroesAdded);
                IEnumerable <Hero> list = settlement.OwnerClan.MapFaction.Heroes;
                for (int i = 0; i <= numAddedHeroes; i++)
                {
                    CharacterObject potentialParticipant = list.GetRandomElementInefficiently().CharacterObject;
                    bool            exists = false;
                    for (int t = 0; t < __result.Count; t++)
                    {
                        if (__result[t].Name.Equals(potentialParticipant.Name) || potentialParticipant.IsPlayerCharacter || potentialParticipant.HeroObject.IsDead || potentialParticipant.Age < 18.00)
                        {
                            exists = true;
                            break;
                        }
                    }
                    if (!exists)
                    {
                        __result[__result.Count - 1 - i] = potentialParticipant;
                    }
                }
            }

            if (includePlayer && Settings.BringCompanions)
            {
                IEnumerable <Hero> companions    = Hero.MainHero.CompanionsInParty;
                List <Hero>        companionList = companions.ToList();
                if (Hero.MainHero.Spouse != null && Hero.MainHero.Spouse.CurrentSettlement != null && Hero.MainHero.Spouse.IsAlive && Hero.MainHero.Spouse.CurrentSettlement.Name.Equals(settlement.Name))
                {
                    companionList.Add(Hero.MainHero.Spouse);
                }
                List <Hero> .Enumerator companionEnumerator = companionList.GetEnumerator();

                int i = 1;
                while (companionEnumerator.MoveNext())
                {
                    bool exists = false;
                    for (int t = 0; t < __result.Count; t++)
                    {
                        if (__result[t].Name.Equals(companionEnumerator.Current.CharacterObject.Name) || companionEnumerator.Current.CharacterObject.IsPlayerCharacter || companionEnumerator.Current.CharacterObject.HeroObject.IsDead || companionEnumerator.Current.CharacterObject.Age < 18.00)
                        {
                            exists = true;
                            break;
                        }
                    }
                    if (!exists)
                    {
                        Hero[] companionArray = companionList.ToArray();
                        for (int y = 0; y < __result.Count - 1; y++)
                        {
                            if (__result[i].Name.Equals(companionArray[y].CharacterObject.Name))
                            {
                                i++;
                            }
                            else
                            {
                                break;
                            }
                        }
                        __result[i] = companionEnumerator.Current.CharacterObject;
                        i++;
                    }

                    if (i >= 10)
                    {
                        break;
                    }
                }
            }
        }
Example #30
0
        internal static bool CanKerbalsBeXferred(List <Part> selectedPartsSource, List <Part> selectedPartsTarget)
        {
            bool results = true;

            WindowTransfer.XferToolTip = "";
            try
            {
                if (IsTransferInProgress())
                {
                    //WindowTransfer.XferToolTip = "Transfer in progress.  Xfers disabled.";
                    WindowTransfer.XferToolTip = SmUtils.SmTags["#smloc_conditions_tt_001"];
                    return(false);
                }
                if (selectedPartsSource.Count == 0 || selectedPartsTarget.Count == 0)
                {
                    WindowTransfer.XferToolTip = SmUtils.SmTags["#smloc_conditions_tt_002"];
                    //  "Source or Target Part is not selected.\r\nPlease Select a Source AND a Target part.";
                    return(false);
                }
                if (selectedPartsSource.Count == 1 && selectedPartsTarget.Count == 1)
                {
                    if (selectedPartsSource[0] == selectedPartsTarget[0])
                    {
                        WindowTransfer.XferToolTip = SmUtils.SmTags["#smloc_conditions_tt_003"];
                        // "Source and Target Parts are the same.\r\nUse Move Kerbal (>>) instead.";
                        return(false);
                    }
                }
                else if (selectedPartsSource.Count > 1 || selectedPartsTarget.Count > 1)
                {
                    if (selectedPartsSource == selectedPartsTarget)
                    {
                        WindowTransfer.XferToolTip = SmUtils.SmTags["#smloc_conditions_tt_003"];
                        // "Source and Target Parts are the same.\r\nUse Move individual Kerbals (>>) instead.";
                        return(false);
                    }
                }
                // If one of the parts is a DeepFreeze part and no crew are showing in protoModuleCrew, check it isn't full of frozen Kerbals.
                // This is to prevent SM from Transferring crew into a DeepFreeze part that is full of frozen kerbals.
                // If there is just one spare seat or seat taken by a Thawed Kerbal that is OK because SM will just transfer them into the empty
                // seat or swap them with a thawed Kerbal.
                DfWrapper.DeepFreezer sourcepartFrzr = null; // selectedPartsSource[0].FindModuleImplementing<DFWrapper.DeepFreezer>();
                DfWrapper.DeepFreezer targetpartFrzr = null; // selectedPartsTarget[0].FindModuleImplementing<DFWrapper.DeepFreezer>();

                List <Part> .Enumerator srcPart = selectedPartsSource.GetEnumerator();
                while (srcPart.MoveNext())
                {
                    if (srcPart.Current == null)
                    {
                        continue;
                    }
                    PartModule sourcedeepFreezer = GetFreezerModule(srcPart.Current);
                    if (sourcedeepFreezer != null)
                    {
                        sourcepartFrzr = new DfWrapper.DeepFreezer(sourcedeepFreezer);
                    }
                    if (sourcepartFrzr?.FreezerSpace != 0)
                    {
                        continue;
                    }
                    WindowTransfer.XferToolTip = SmUtils.SmTags["#smloc_conditions_tt_004"];
                    // "DeepFreeze Part is full of frozen kerbals.\r\nCannot Xfer until some are thawed.";
                    return(false);
                }

                List <Part> .Enumerator tgtPart = selectedPartsSource.GetEnumerator();
                while (tgtPart.MoveNext())
                {
                    if (tgtPart.Current == null)
                    {
                        continue;
                    }
                    PartModule targetdeepFreezer = GetFreezerModule(tgtPart.Current);
                    if (targetdeepFreezer != null)
                    {
                        targetpartFrzr = new DfWrapper.DeepFreezer(targetdeepFreezer);
                    }
                    if (targetpartFrzr?.FreezerSpace != 0)
                    {
                        continue;
                    }
                    WindowTransfer.XferToolTip = SmUtils.SmTags["#smloc_conditions_tt_004"];
                    // "DeepFreeze Part is full of frozen kerbals.\r\nCannot Xfer until some are thawed.";
                    return(false);
                }

                // Are there kerbals to move?
                if (SmUtils.GetPartsCrewCount(selectedPartsSource) == 0)
                {
                    //WindowTransfer.XferToolTip = "No Kerbals to Move.";
                    WindowTransfer.XferToolTip = SmUtils.SmTags["#smloc_conditions_tt_005"];
                    return(false);
                }
                // now if realistic xfers is enabled, are the parts connected to each other in the same living space?
                results = IsClsInSameSpace(selectedPartsSource, selectedPartsTarget);
                if (!results)
                {
                    WindowTransfer.EvaToolTip = SmUtils.SmTags["#smloc_conditions_tt_006"];
                }
                // "CLS is preventing internal Crew Transfer.  Click to initiate EVA operation.";
                else
                {
                    WindowTransfer.XferToolTip = SmUtils.SmTags["#smloc_conditions_tt_007"];
                }
                // "Kerbal can be Transfered.";
            }
            catch (Exception ex)
            {
                SmUtils.LogMessage($" in CanBeXferred.  Error:  {ex.Message} \r\n\r\n{ex.StackTrace}",
                                   SmUtils.LogType.Error, true);
            }
            return(results);
        }
Example #31
0
 public bool MoveNext()
 {
     return(headerCurrent.MoveNext() && payloadCurrent.MoveNext());
 }
        /// <summary>
        /// Parses hyperlink if the current Range in the enumerator e
        /// is part of a hyperlink and moves the enumerator to the next
        /// Range not part of current hyperlink
        /// </summary>
        /// <param name="e"></param>
        /// <param name="currentElement"></param>
        /// <param name="hyperlink"></param>
        private bool ParseHyperlink(ref List <Range> .Enumerator e, XElement currentElement, out Hyperlink hyperlink)
        {
            var cur = e.Current;

            hyperlink = null;
            if (cur == null)
            {
                return(false);
            }
            IEnumerable <Hyperlink> hs = cur.Hyperlinks.Cast <Hyperlink>().ToList();

            if (hs.Any())
            {
                Hyperlink currentHyperlink      = hs.First();
                Range     currentHyperlinkRange = currentHyperlink.Range;
                if (currentHyperlinkRange != null)
                {
                    while (e.Current != null && (e.Current.End < currentHyperlinkRange.End && e.MoveNext()))
                    {
                    }
                }
                if (!ShouldNotTransformHyperlink(currentHyperlink))
                {
                    XElement toAdd = SupDocs.GetHtmlHyperlink(currentHyperlink);
                    currentElement.Add(toAdd ?? GetExternalHyperlink(currentHyperlink));
                    hyperlink = currentHyperlink;

                    return(true);
                }
            }
            return(false);
        }
Example #33
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            if (HighLogic.LoadedSceneIsFlight)
            {
                myVesselID = vessel.id.ToString();
                RadarUtils.SetupResources();

                if (string.IsNullOrEmpty(radarName))
                {
                    radarName = part.partInfo.title;
                }

                linkedToVessels = new List <VesselRadarData>();

                signalPersistTime = omnidirectional
                    ? 360 / (scanRotationSpeed + 5)
                    : directionalFieldOfView / (scanRotationSpeed + 5);

                rwrType = (RadarWarningReceiver.RWRThreatTypes)rwrThreatType;
                if (rwrType == RadarWarningReceiver.RWRThreatTypes.Sonar)
                {
                    signalPersistTimeForRwr = RadarUtils.ACTIVE_MISSILE_PING_PERISTS_TIME;
                }
                else
                {
                    signalPersistTimeForRwr = signalPersistTime / 2;
                }


                if (rotationTransformName != string.Empty)
                {
                    rotationTransform = part.FindModelTransform(rotationTransformName);
                }

                attemptedLocks = new TargetSignatureData[3];
                TargetSignatureData.ResetTSDArray(ref attemptedLocks);
                lockedTargets = new List <TargetSignatureData>();

                referenceTransform               = (new GameObject()).transform;
                referenceTransform.parent        = transform;
                referenceTransform.localPosition = Vector3.zero;

                List <ModuleTurret> .Enumerator turr = part.FindModulesImplementing <ModuleTurret>().GetEnumerator();
                while (turr.MoveNext())
                {
                    if (turr.Current == null)
                    {
                        continue;
                    }
                    if (turr.Current.turretID != turretID)
                    {
                        continue;
                    }
                    lockingTurret = turr.Current;
                    break;
                }
                turr.Dispose();

                //GameEvents.onVesselGoOnRails.Add(OnGoOnRails);    //not needed
                EnsureVesselRadarData();
                StartCoroutine(StartUpRoutine());
            }
            else if (HighLogic.LoadedSceneIsEditor)
            {
                //Editor only:
                List <ModuleTurret> .Enumerator tur = part.FindModulesImplementing <ModuleTurret>().GetEnumerator();
                while (tur.MoveNext())
                {
                    if (tur.Current == null)
                    {
                        continue;
                    }
                    if (tur.Current.turretID != turretID)
                    {
                        continue;
                    }
                    lockingTurret = tur.Current;
                    break;
                }
                tur.Dispose();
                if (lockingTurret)
                {
                    lockingTurret.Fields["minPitch"].guiActiveEditor = false;
                    lockingTurret.Fields["maxPitch"].guiActiveEditor = false;
                    lockingTurret.Fields["yawRange"].guiActiveEditor = false;
                }
            }

            // check for not updated legacy part:
            if ((canScan && (radarMinDistanceDetect == float.MaxValue)) || (canLock && (radarMinDistanceLockTrack == float.MaxValue)))
            {
                Debug.Log("[BDArmory]: WARNING: " + part.name + " has legacy definition, missing new radarDetectionCurve and radarLockTrackCurve definitions! Please update for the part to be usable!");
            }
        }
Example #34
0
    private void checkTags()
    {
        if (!this.avatar.enabled)
        {
            return;
        }
        if (!this.rootTr.gameObject.activeSelf)
        {
            return;
        }
        if (Scene.SceneTracker.graphsBeingUpdated)
        {
            return;
        }
        if (this.setup.search.fsmInCave.Value)
        {
            if (this.setup.pmBrain)
            {
                this.fsmBrainGroundWalkable.Value = true;
            }
            return;
        }
        if (this.creepy || this.creepy_male || this.creepy_baby || this.creepy_fat)
        {
            return;
        }
        float num = this.thisTr.position.y - this.setup.animControl.terrainPosY;

        if (num < -2f || num > 25f)
        {
            if (this.setup.pmBrain)
            {
                this.fsmBrainGroundWalkable.Value = true;
            }
            return;
        }
        if (!AstarPath.active)
        {
            return;
        }
        this.groundNode = this.rg.GetNearest(this.thisTr.position).node;
        this.ugroundTag = this.groundNode.Tag;
        this.groundTag  = (int)this.ugroundTag;
        if (this.groundNode != null)
        {
            if (this.groundNode.Walkable)
            {
                this.lastWalkablePos = new Vector3((float)(this.groundNode.position[0] / 1000), (float)(this.groundNode.position[1] / 1000), (float)(this.groundNode.position[2] / 1000));
            }
            if (this.setup.pmBrain)
            {
                this.fsmBrainGroundTag.Value = this.groundTag;
            }
            if (!this.groundNode.Walkable)
            {
                this.stuckCount++;
                if (this.stuckCount > 10 && this.allPlayers.Count > 0 && this.allPlayers[0] && this.mainPlayerDist > 250f)
                {
                    Vector2   vector   = this.randomCircle(50f);
                    Vector3   position = new Vector3(this.thisTr.position.x + vector.x, this.thisTr.position.y, this.thisTr.position.z + vector.y);
                    GraphNode node     = this.rg.GetNearest(position, NNConstraint.Default).node;
                    bool      flag     = false;
                    using (List <uint> .Enumerator enumerator = Scene.MutantControler.mostCommonArea.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            int num2 = (int)enumerator.Current;
                            if ((long)num2 == (long)((ulong)node.Area))
                            {
                                flag = true;
                            }
                        }
                    }
                    if (node.Walkable && flag)
                    {
                        this.setup.search.worldPositionTr.position = new Vector3((float)(node.position[0] / 1000), (float)(node.position[1] / 1000), (float)(node.position[2] / 1000));
                        this.rootTr.position = this.setup.search.worldPositionTr.position;
                        this.stuckCount      = 0;
                    }
                }
            }
            else
            {
                this.stuckCount = 0;
            }
        }
        else if (this.setup.pmBrain)
        {
            this.fsmBrainGroundWalkable.Value = false;
        }
    }
Example #35
0
 public static void HandleSpriteSceneDrag(SceneView sceneView, IEvent evt, UnityEngine.Object[] objectReferences, string[] paths, SpriteUtility.ShowFileDialogDelegate saveFileDialog)
 {
     if (evt.type == EventType.DragUpdated || evt.type == EventType.DragPerform || evt.type == EventType.DragExited)
     {
         if (objectReferences.Length == 1 && objectReferences[0] as UnityEngine.Texture2D != null)
         {
             GameObject gameObject = HandleUtility.PickGameObject(evt.mousePosition, true);
             if (gameObject != null)
             {
                 Renderer component = gameObject.GetComponent <Renderer>();
                 if (component != null && !(component is SpriteRenderer))
                 {
                     SpriteUtility.CleanUp(true);
                     return;
                 }
             }
         }
         EventType type = evt.type;
         if (type != EventType.DragUpdated)
         {
             if (type != EventType.DragPerform)
             {
                 if (type == EventType.DragExited)
                 {
                     if (SpriteUtility.s_SceneDragObjects != null)
                     {
                         SpriteUtility.CleanUp(true);
                         evt.Use();
                     }
                 }
             }
             else
             {
                 List <Sprite> spriteFromPathsOrObjects = SpriteUtility.GetSpriteFromPathsOrObjects(objectReferences, paths, evt.type);
                 if (spriteFromPathsOrObjects.Count > 0 && SpriteUtility.s_SceneDragObjects != null)
                 {
                     if (SpriteUtility.s_SceneDragObjects.Count == 0)
                     {
                         SpriteUtility.CreateSceneDragObjects(spriteFromPathsOrObjects);
                         SpriteUtility.PositionSceneDragObjects(SpriteUtility.s_SceneDragObjects, sceneView, evt.mousePosition);
                     }
                     bool flag = true;
                     if (SpriteUtility.s_DragType == SpriteUtility.DragType.SpriteAnimation && spriteFromPathsOrObjects.Count > 1)
                     {
                         UsabilityAnalytics.Event("Sprite Drag and Drop", "Drop multiple sprites to scene", "null", 1);
                         flag = SpriteUtility.AddAnimationToGO((GameObject)SpriteUtility.s_SceneDragObjects[0], spriteFromPathsOrObjects.ToArray(), saveFileDialog);
                     }
                     else
                     {
                         UsabilityAnalytics.Event("Sprite Drag and Drop", "Drop single sprite to scene", "null", 1);
                     }
                     if (flag)
                     {
                         using (List <UnityEngine.Object> .Enumerator enumerator = SpriteUtility.s_SceneDragObjects.GetEnumerator())
                         {
                             while (enumerator.MoveNext())
                             {
                                 GameObject gameObject2 = (GameObject)enumerator.Current;
                                 Undo.RegisterCreatedObjectUndo(gameObject2, "Create Sprite");
                                 gameObject2.hideFlags = HideFlags.None;
                             }
                         }
                         Selection.objects = SpriteUtility.s_SceneDragObjects.ToArray();
                     }
                     SpriteUtility.CleanUp(!flag);
                     evt.Use();
                 }
             }
         }
         else
         {
             SpriteUtility.DragType dragType = (!evt.alt) ? SpriteUtility.DragType.SpriteAnimation : SpriteUtility.DragType.CreateMultiple;
             if (SpriteUtility.s_DragType != dragType || SpriteUtility.s_SceneDragObjects == null)
             {
                 if (!SpriteUtility.ExistingAssets(objectReferences) && SpriteUtility.PathsAreValidTextures(paths))
                 {
                     DragAndDrop.visualMode           = DragAndDropVisualMode.Copy;
                     SpriteUtility.s_SceneDragObjects = new List <UnityEngine.Object>();
                     SpriteUtility.s_DragType         = dragType;
                 }
                 else
                 {
                     List <Sprite> spriteFromPathsOrObjects2 = SpriteUtility.GetSpriteFromPathsOrObjects(objectReferences, paths, evt.type);
                     if (spriteFromPathsOrObjects2.Count == 0)
                     {
                         return;
                     }
                     if (SpriteUtility.s_DragType != SpriteUtility.DragType.NotInitialized)
                     {
                         SpriteUtility.CleanUp(true);
                     }
                     SpriteUtility.s_DragType = dragType;
                     SpriteUtility.CreateSceneDragObjects(spriteFromPathsOrObjects2);
                     SpriteUtility.IgnoreForRaycasts(SpriteUtility.s_SceneDragObjects);
                 }
             }
             SpriteUtility.PositionSceneDragObjects(SpriteUtility.s_SceneDragObjects, sceneView, evt.mousePosition);
             DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
             evt.Use();
         }
     }
 }
        /// <summary>
        ///   <para>This sends the set of peers in the game to all the peers in the game.</para>
        /// </summary>
        public void SendPeerInfo()
        {
            if (!this.m_HostMigration)
            {
                return;
            }
            PeerListMessage        peerListMessage     = new PeerListMessage();
            List <PeerInfoMessage> peerInfoMessageList = new List <PeerInfoMessage>();

            for (int index = 0; index < NetworkServer.connections.Count; ++index)
            {
                NetworkConnection connection = NetworkServer.connections[index];
                if (connection != null)
                {
                    PeerInfoMessage peerInfoMessage = new PeerInfoMessage();
                    string          address;
                    int             port;
                    NetworkID       network;
                    NodeID          dstNode;
                    byte            error;
                    NetworkTransport.GetConnectionInfo(NetworkServer.serverHostId, connection.connectionId, out address, out port, out network, out dstNode, out error);
                    peerInfoMessage.connectionId = connection.connectionId;
                    peerInfoMessage.port         = port;
                    if (index == 0)
                    {
                        peerInfoMessage.port    = NetworkServer.listenPort;
                        peerInfoMessage.isHost  = true;
                        peerInfoMessage.address = "<host>";
                    }
                    else
                    {
                        peerInfoMessage.address = address;
                        peerInfoMessage.isHost  = false;
                    }
                    List <PeerInfoPlayer> peerInfoPlayerList = new List <PeerInfoPlayer>();
                    using (List <PlayerController> .Enumerator enumerator = connection.playerControllers.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            PlayerController current = enumerator.Current;
                            if (current != null && (Object)current.unetView != (Object)null)
                            {
                                PeerInfoPlayer peerInfoPlayer;
                                peerInfoPlayer.netId = current.unetView.netId;
                                peerInfoPlayer.playerControllerId = current.unetView.playerControllerId;
                                peerInfoPlayerList.Add(peerInfoPlayer);
                            }
                        }
                    }
                    if (connection.clientOwnedObjects != null)
                    {
                        using (HashSet <NetworkInstanceId> .Enumerator enumerator = connection.clientOwnedObjects.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                NetworkInstanceId current     = enumerator.Current;
                                GameObject        localObject = NetworkServer.FindLocalObject(current);
                                if (!((Object)localObject == (Object)null) && (int)localObject.GetComponent <NetworkIdentity>().playerControllerId == -1)
                                {
                                    PeerInfoPlayer peerInfoPlayer;
                                    peerInfoPlayer.netId = current;
                                    peerInfoPlayer.playerControllerId = (short)-1;
                                    peerInfoPlayerList.Add(peerInfoPlayer);
                                }
                            }
                        }
                    }
                    if (peerInfoPlayerList.Count > 0)
                    {
                        peerInfoMessage.playerIds = peerInfoPlayerList.ToArray();
                    }
                    peerInfoMessageList.Add(peerInfoMessage);
                }
            }
            peerListMessage.peers = peerInfoMessageList.ToArray();
            for (int index = 0; index < NetworkServer.connections.Count; ++index)
            {
                NetworkConnection connection = NetworkServer.connections[index];
                if (connection != null)
                {
                    peerListMessage.oldServerConnectionId = connection.connectionId;
                    connection.Send((short)11, (MessageBase)peerListMessage);
                }
            }
        }
 // Token: 0x06000EFC RID: 3836 RVA: 0x00055B28 File Offset: 0x00053D28
 private void ProcessGet()
 {
     using (this.user.Context.Tracker.Start(TimeId.RMSProcessGet))
     {
         AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Processing RightsManagementInformationSetting - Get");
         XmlNode xmlNode  = base.Response.OwnerDocument.CreateElement("Get", "Settings:");
         XmlNode xmlNode2 = base.Response.OwnerDocument.CreateElement("RightsManagementTemplates", "RightsManagement:");
         try
         {
             if (this.user.IrmEnabled)
             {
                 List <RmsTemplate>      list     = new List <RmsTemplate>(RmsTemplateReaderCache.GetRmsTemplates(this.user.OrganizationId));
                 IComparer <RmsTemplate> comparer = new RightsManagementInformationSetting.RmsTemplateNameComparer(this.cultureInfo);
                 list.Sort(comparer);
                 int count           = list.Count;
                 int maxRmsTemplates = GlobalSettings.MaxRmsTemplates;
                 if (count > maxRmsTemplates)
                 {
                     list.RemoveRange(maxRmsTemplates, count - maxRmsTemplates);
                 }
                 using (List <RmsTemplate> .Enumerator enumerator = list.GetEnumerator())
                 {
                     while (enumerator.MoveNext())
                     {
                         RmsTemplate rmsTemplate = enumerator.Current;
                         AirSyncDiagnostics.TraceInfo <Guid>(ExTraceGlobals.RequestsTracer, this, "Found RMS template {0}", rmsTemplate.Id);
                         XmlNode xmlNode3 = base.Response.OwnerDocument.CreateElement("RightsManagementTemplate", "RightsManagement:");
                         XmlNode xmlNode4 = base.Response.OwnerDocument.CreateElement("TemplateID", "RightsManagement:");
                         xmlNode4.InnerText = rmsTemplate.Id.ToString();
                         xmlNode3.AppendChild(xmlNode4);
                         XmlNode xmlNode5 = base.Response.OwnerDocument.CreateElement("TemplateName", "RightsManagement:");
                         xmlNode5.InnerText = rmsTemplate.GetName(this.cultureInfo);
                         xmlNode3.AppendChild(xmlNode5);
                         XmlNode xmlNode6 = base.Response.OwnerDocument.CreateElement("TemplateDescription", "RightsManagement:");
                         xmlNode6.InnerText = rmsTemplate.GetDescription(this.cultureInfo);
                         xmlNode3.AppendChild(xmlNode6);
                         xmlNode2.AppendChild(xmlNode3);
                     }
                     goto IL_205;
                 }
             }
             AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, this, "IRM feature disabled for user {0}", this.user.DisplayName);
             this.status = StatusCode.IRM_FeatureDisabled;
             IL_205 :;
         }
         catch (AirSyncPermanentException ex)
         {
             AirSyncDiagnostics.TraceError <AirSyncPermanentException>(ExTraceGlobals.RequestsTracer, this, "AirSyncPermanentException encountered while processing RightsManagementInformationSetting->Get {0}", ex);
             if (base.ProtocolLogger != null && !string.IsNullOrEmpty(ex.ErrorStringForProtocolLogger))
             {
                 base.ProtocolLogger.SetValueIfNotSet(ProtocolLoggerData.Error, ex.ErrorStringForProtocolLogger);
             }
             this.ProcessException(ex);
             this.status = ex.AirSyncStatusCode;
         }
         XmlNode xmlNode7 = base.Response.OwnerDocument.CreateElement("Status", "Settings:");
         XmlNode xmlNode8 = xmlNode7;
         int     num      = (int)this.status;
         xmlNode8.InnerText = num.ToString(CultureInfo.InvariantCulture);
         base.Response.AppendChild(xmlNode7);
         xmlNode.AppendChild(xmlNode2);
         base.Response.AppendChild(xmlNode);
         AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Done processing RightsManagementInformationSetting - Get.");
     }
 }
Example #38
0
        public void RunAreaLuaFile(GameMap gameMap, RunAreaLuaType runAreaLuaType, List <int> areaLuaIDList, string functionName, int taskId = 0)
        {
            List <GAreaLua> GAreaLuaList = null;

            if (RunAreaLuaType.SelfPoint == runAreaLuaType)
            {
                int newGridX = this._ClientData.PosX / gameMap.MapGridWidth;
                int newGridY = this._ClientData.PosY / gameMap.MapGridHeight;
                GAreaLuaList = gameMap.GetAreaLuaListByPoint(new Point((double)newGridX, (double)newGridY));
            }
            else if (RunAreaLuaType.AreaLuaIDList == runAreaLuaType)
            {
                if (areaLuaIDList == null || areaLuaIDList.Count == 0)
                {
                    return;
                }
                foreach (int areaLuaID in areaLuaIDList)
                {
                    GAreaLua areaLua = gameMap.GetAreaLuaByID(areaLuaID);
                    if (areaLua != null)
                    {
                        if (GAreaLuaList == null)
                        {
                            GAreaLuaList = new List <GAreaLua>();
                        }
                        GAreaLuaList.Add(areaLua);
                    }
                }
            }
            if (GAreaLuaList != null)
            {
                using (List <GAreaLua> .Enumerator enumerator2 = GAreaLuaList.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        GAreaLua areaLuaEv = enumerator2.Current;
                        bool     isTrigger = false;
                        if (areaLuaEv.AddtionType != AddtionType.NowTrigger)
                        {
                            switch (areaLuaEv.AddtionType)
                            {
                            case AddtionType.AccessTask:
                            {
                                TaskData taskData;
                                lock (this.ClientData.TaskDataList)
                                {
                                    taskData = this.ClientData.TaskDataList.Find((TaskData x) => x.DoingTaskID == areaLuaEv.TaskId);
                                    if (taskData == null)
                                    {
                                        break;
                                    }
                                }
                                SystemXmlItem systemTask = null;
                                if (GameManager.SystemTasksMgr.SystemXmlItemDict.TryGetValue(areaLuaEv.TaskId, out systemTask))
                                {
                                    if (taskData.DoingTaskVal1 < systemTask.GetIntValue(string.Format("TargetNum1", new object[0]), -1) || taskData.DoingTaskVal2 < systemTask.GetIntValue(string.Format("TargetNum2", new object[0]), -1))
                                    {
                                        isTrigger = true;
                                    }
                                }
                                break;
                            }

                            case AddtionType.FinishTask:
                            {
                                TaskData taskData;
                                lock (this.ClientData.TaskDataList)
                                {
                                    taskData = this.ClientData.TaskDataList.Find((TaskData x) => x.DoingTaskID == areaLuaEv.TaskId);
                                    if (taskData == null)
                                    {
                                        break;
                                    }
                                }
                                if (Global.JugeTaskComplete(this, areaLuaEv.TaskId, taskData.DoingTaskVal1, taskData.DoingTaskVal2))
                                {
                                    isTrigger = true;
                                }
                                break;
                            }

                            case AddtionType.BackTask:
                                if (taskId != 0)
                                {
                                    if (areaLuaEv.TaskId == taskId)
                                    {
                                        isTrigger = true;
                                    }
                                }
                                break;

                            case AddtionType.NewMainTask:
                                if (functionName == "takeNewMainTask" && taskId == areaLuaEv.TaskId)
                                {
                                    isTrigger = true;
                                }
                                break;
                            }
                            if (!isTrigger)
                            {
                                continue;
                            }
                        }
                        foreach (KeyValuePair <AreaEventType, List <int> > areaEvent in areaLuaEv.AreaEventDict)
                        {
                            if (areaEvent.Key == AreaEventType.FinishTask)
                            {
                                int           eventTaskId = areaEvent.Value[0];
                                TaskData      taskData    = this.ClientData.TaskDataList.Find((TaskData x) => x.DoingTaskID == eventTaskId);
                                SystemXmlItem systemTask  = null;
                                if (GameManager.SystemTasksMgr.SystemXmlItemDict.TryGetValue(eventTaskId, out systemTask))
                                {
                                    if (taskData.DoingTaskVal1 < systemTask.GetIntValue("TargetNum1", -1))
                                    {
                                        taskData.DoingTaskVal1 = systemTask.GetIntValue("TargetNum1", -1);
                                    }
                                    if (taskData.DoingTaskVal2 < systemTask.GetIntValue("TargetNum2", -1))
                                    {
                                        taskData.DoingTaskVal2 = systemTask.GetIntValue("TargetNum2", -1);
                                    }
                                    GameManager.DBCmdMgr.AddDBCmd(10007, string.Format("{0}:{1}:{2}:{3}:{4}:{5}", new object[]
                                    {
                                        this.ClientData.RoleID,
                                        taskData.DoingTaskID,
                                        taskData.DbID,
                                        taskData.DoingTaskFocus,
                                        taskData.DoingTaskVal1,
                                        taskData.DoingTaskVal2
                                    }), null, this.ServerId);
                                    GameManager.ClientMgr.NotifyUpdateTask(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, this, taskData.DbID, taskData.DoingTaskID, taskData.DoingTaskVal1, taskData.DoingTaskVal2, taskData.DoingTaskFocus, taskData.ChengJiuVal);
                                    int destNPC = systemTask.GetIntValue("DestNPC", -1);
                                    if (-1 != destNPC)
                                    {
                                        int state = Global.ComputeNPCTaskState(this, this.ClientData.TaskDataList, destNPC, 0);
                                        GameManager.ClientMgr.NotifyUpdateNPCTaskSate(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, this, destNPC + 2130706432, state);
                                    }
                                    ProcessTask.CheckAutoCompleteTask(this);
                                }
                            }
                            else if (areaEvent.Key == AreaEventType.CallMonsters && functionName == "enterArea")
                            {
                                int monsterID = areaEvent.Value[0];
                                Global.SystemKillSummonMonster(this, MonsterTypes.AreaCallMonster);
                                GameManager.LuaMgr.CallMonstersForGameClient(this, monsterID, 1, 0, 1002, 1);
                            }
                            else if (areaEvent.Key == AreaEventType.RemoveMonsters && functionName == "enterArea")
                            {
                                int monsterid = areaEvent.Value[0];
                                Global.SystemKillSummonMonster(this, monsterid);
                            }
                            else
                            {
                                string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                                {
                                    (int)areaEvent.Key,
                                    areaEvent.Value[0],
                                    areaLuaEv.CenterPoint.X,
                                    areaLuaEv.CenterPoint.Y
                                });
                                this.sendCmd(3000, strCmd, false);
                            }
                        }
                        string fileName = areaLuaEv.LuaScriptFileName;
                        if (!string.IsNullOrEmpty(fileName))
                        {
                            ProcessAreaScripts.ProcessScripts(this, fileName, functionName, areaLuaEv.ID);
                        }
                    }
                }
            }
        }
        internal bool WaitForSchemaAgreement(IPAddress forHost = null)
        {
            var start = DateTimeOffset.Now;
            long elapsed = 0;
            while (elapsed < MaxSchemaAgreementWaitMs)
            {
                var versions = new DictSet<Guid>();

                IPAddress queriedHost;

                if (forHost == null)
                {
                    using (var rowset = _session.Query(SelectSchemaPeers, ConsistencyLevel.Default))
                    {
                        queriedHost = rowset.Info.QueriedHost;
                        foreach (var row in rowset.GetRows())
                        {
                            if (row.IsNull("rpc_address") || row.IsNull("schema_version"))
                                continue;

                            var rpc = row.GetValue<IPEndPoint>("rpc_address").Address;
                            if (rpc.Equals(bindAllAddress))
                                if (!row.IsNull("peer"))
                                    rpc = row.GetValue<IPEndPoint>("peer").Address;

                            Host peer = _cluster.Metadata.GetHost(rpc);
                            if (peer != null && peer.IsConsiderablyUp)
                                versions.Add(row.GetValue<Guid>("schema_version"));
                        }
                    }
                }
                else
                {
                    queriedHost = forHost;
                    var localhost = _cluster.Metadata.GetHost(queriedHost);
                    var iterLiof = new List<Host>() { localhost }.GetEnumerator();
                    iterLiof.MoveNext();
                    List<IPAddress> tr = new List<IPAddress>();
                    Dictionary<IPAddress, List<Exception>> exx = new Dictionary<IPAddress, List<Exception>>();
                    var cn = _session.Connect(null, iterLiof, tr, exx);

                    using (var outp = cn.Query(SelectSchemaPeers, ConsistencyLevel.Default, false))
                    {
                        if (outp is OutputRows)
                        {
                            var rowset = new RowSet((outp as OutputRows), null, false);
                            foreach (var row in rowset.GetRows())
                            {
                                if (row.IsNull("rpc_address") || row.IsNull("schema_version"))
                                    continue;

                                var rpc = row.GetValue<IPEndPoint>("rpc_address").Address;
                                if (rpc.Equals(bindAllAddress))
                                {
                                    if (!row.IsNull("peer"))
                                        rpc = row.GetValue<IPEndPoint>("peer").Address;
                                }

                                Host peer = _cluster.Metadata.GetHost(rpc);
                                if (peer != null && peer.IsConsiderablyUp)
                                    versions.Add(row.GetValue<Guid>("schema_version"));
                            }
                        }
                    }
                }

                {
                    var localhost = _cluster.Metadata.GetHost(queriedHost);
                    var iterLiof = new List<Host>() { localhost }.GetEnumerator();
                    iterLiof.MoveNext();
                    List<IPAddress> tr = new List<IPAddress>();
                    Dictionary<IPAddress, List<Exception>> exx = new Dictionary<IPAddress, List<Exception>>();
                    var cn = _session.Connect(null, iterLiof, tr, exx);

                    using (var outp = cn.Query(SelectSchemaLocal, ConsistencyLevel.Default, false))
                    {
                        if (outp is OutputRows)
                        {
                            var rowset = new RowSet((outp as OutputRows), null, false);
                            // Update cluster name, DC and rack for the one node we are connected to
                            foreach (var localRow in rowset.GetRows())
                                if (!localRow.IsNull("schema_version"))
                                {
                                    versions.Add(localRow.GetValue<Guid>("schema_version"));
                                    break;
                                }
                        }
                    }
                }

                if (versions.Count <= 1)
                    return true;

                // let's not flood the node too much
                Thread.Sleep(200);
                elapsed = (long)(DateTimeOffset.Now - start).TotalMilliseconds;
            }

            return false;
        }
Example #40
0
        private void DoHeapshotObjects(List <HeapshotWindow.HeapshotUIObject> objects, SplitterState splitter, int indent, HeapshotWindow.OnSelect onSelect)
        {
            if (objects == null)
            {
                return;
            }
            Event current1 = Event.current;

            using (List <HeapshotWindow.HeapshotUIObject> .Enumerator enumerator = objects.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    HeapshotWindow.HeapshotUIObject current2 = enumerator.Current;
                    Rect   position  = new Rect(14f * (float)indent, this.guiRect.y, 14f, this.guiRect.height);
                    Rect[] rectArray = new Rect[this.titleNames.Length];
                    float  x         = 14f * (float)(indent + 1);
                    for (int index = 0; index < rectArray.Length; ++index)
                    {
                        float width = index != 0 ? (float)splitter.realSizes[index] : (float)splitter.realSizes[index] - x;
                        rectArray[index] = new Rect(x, this.guiRect.y, width, this.guiRect.height);
                        x += width;
                    }
                    if (current1.type == EventType.Repaint)
                    {
                        ((this.itemIndex & 1) != 0 ? HeapshotWindow.Styles.entryOdd : HeapshotWindow.Styles.entryEven).Draw(new Rect(0.0f, 16f * (float)this.itemIndex, this.position.width, 16f), GUIContent.none, false, false, this.itemIndex == this.selectedItem, false);
                    }
                    if (current2.HasChildren)
                    {
                        GUI.changed = false;
                        bool flag = GUI.Toggle(position, current2.IsExpanded, GUIContent.none, HeapshotWindow.Styles.foldout);
                        if (GUI.changed)
                        {
                            if (flag)
                            {
                                current2.Expand();
                            }
                            else
                            {
                                current2.Collapse();
                            }
                        }
                    }
                    GUI.changed = false;
                    bool flag1 = GUI.Toggle(rectArray[0], this.itemIndex == this.selectedItem, current2.Name, HeapshotWindow.Styles.numberLabel);
                    if (!current2.IsDummyObject)
                    {
                        GUI.Toggle(rectArray[1], this.itemIndex == this.selectedItem, current2.TypeName, HeapshotWindow.Styles.numberLabel);
                        GUI.Toggle(rectArray[2], this.itemIndex == this.selectedItem, "0x" + current2.Code.ToString("X"), HeapshotWindow.Styles.numberLabel);
                        GUI.Toggle(rectArray[3], this.itemIndex == this.selectedItem, current2.Size.ToString(), HeapshotWindow.Styles.numberLabel);
                        GUI.Toggle(rectArray[4], this.itemIndex == this.selectedItem, string.Format("{0} / {1}", (object)current2.ReferenceCount, (object)current2.InverseReferenceCount), HeapshotWindow.Styles.numberLabel);
                        if (GUI.changed && flag1 && onSelect != null)
                        {
                            this.selectedItem = this.itemIndex;
                            onSelect(current2);
                        }
                    }
                    ++this.itemIndex;
                    this.guiRect.y += 16f;
                    this.DoHeapshotObjects(current2.Children, splitter, indent + 1, onSelect);
                }
            }
        }
Example #41
0
    void FixedUpdate()
    {
        // if we haven't set up the enumerator, do so
        if (currentPOI.Current == null)
        {
            currentPOI = points.GetEnumerator();
            currentPOI.MoveNext(); //set the enumerator to the first element (Why microsoft?)
            currentRotation = currentPOI.Current.directionPattern.GetEnumerator();
            currentRotation.MoveNext(); //why
        }

        // get the player's direction relative to the enemy if they're within range
        if (alerted)
        {
            Vector3 playerVector = player.transform.position - transform.position;
            playerVector.z = 0f;
            if (Mathf.Abs(playerVector.y) >= Mathf.Abs(playerVector.x))
            {
                if (playerVector.y <= 0)
                    playerDirection = FacingDirection.Front;
                else playerDirection = FacingDirection.Back;
            }
            else
            {
                if (playerVector.x <= 0)
                    playerDirection = FacingDirection.Left;
                else playerDirection = FacingDirection.Right;
            }
        }

        attackTimer += Time.deltaTime;

        //attack update
        if (playerScript.currentHealth <= 0)
        {
            alerted = false;
            playerInRange = false;
        }

        if (attackTimer >= timeBetweenAttacks && playerInRange && alerted && playerDirection == direction && currentHealth > 0)
        {
            attackTimer = 0f;
            attackScript.Attack(player);
        }

        //movement update
        if (!alerted)
        {
            if (destinationReached)
            { //if you are waiting at a POI
                poiTimer += Time.deltaTime;
                turnTimer += Time.deltaTime;
                if (turnTimer >= currentPOI.Current.rotationSpeed)
                    Turn();
                if (poiTimer >= currentPOI.Current.restTime)
                {
                    if (!currentPOI.MoveNext())
                    { //if you reached the end of the list, restart.
                        currentPOI = points.GetEnumerator();
                        currentPOI.MoveNext(); // y
                        currentRotation = currentPOI.Current.directionPattern.GetEnumerator();
                        currentRotation.MoveNext(); // whyyy
                    }
                    Patrol();
                }
            }
            else // or travelling to a new POI
                Patrol();
        }
        else
        {
            if (!ranged && direction == playerDirection) // chase player
                Move(player.transform.position.x - transform.position.x, player.transform.position.y - transform.position.y);

            Vector3 facing = player.transform.position - transform.position;
            facing.z = 0f;
            if (Mathf.Abs(facing.y) >= Mathf.Abs(facing.x))
            {
                if (facing.y <= 0)
                    direction = FacingDirection.Front;
                else direction = FacingDirection.Back;
            }
            else
            {
                if (facing.x <= 0)
                    direction = FacingDirection.Left;
                else direction = FacingDirection.Right;
            }
        }
        Animating();
    }
Example #42
0
 public CardPresenter(List<ICardable> cardObjects)
 {
     _cardObjects = cardObjects;
     _cardEnumerator = _cardObjects.GetEnumerator();
     _cardEnumerator.MoveNext();
 }
Example #43
0
 public Parser(List<Token> theList)
 {
     tokenList = theList;
     tokenEnumerator = tokenList.GetEnumerator();
     tokenEnumerator.MoveNext();
 }
Example #44
0
 public void Update(double dt)
 {
     Timer += dt;
     if (Textures.Count < 2)
         return;
     CurrentTime += dt;
     if (CurrentTime > CurrentTexture.Current.Item2)
     {
         CurrentTime = 0;
         if (!CurrentTexture.MoveNext())
         {
             CurrentTexture.Dispose();
             CurrentTexture = Textures.GetEnumerator();
             CurrentTexture.MoveNext();
         }
     }
 }
Example #45
0
        public void testMultipleTermEqualitiesInBothClausesExample()
        {
            FOLDomain domain = new FOLDomain();

            domain.addConstant("A");
            domain.addConstant("B");
            domain.addConstant("C");
            domain.addConstant("D");
            domain.addPredicate("P");
            domain.addPredicate("Q");
            domain.addPredicate("R");
            domain.addFunction("F");

            FOLParser parser = new FOLParser(domain);

            List <Literal> lits = new List <Literal>();
            AtomicSentence a1   = (AtomicSentence)parser.parse("F(C,x) = D");
            AtomicSentence a2   = (AtomicSentence)parser.parse("A = D");
            AtomicSentence a3   = (AtomicSentence)parser.parse("P(F(x,B),x)");
            AtomicSentence a4   = (AtomicSentence)parser.parse("Q(x)");
            AtomicSentence a5   = (AtomicSentence)parser.parse("R(C)");

            lits.Add(new Literal(a1));
            lits.Add(new Literal(a2));
            lits.Add(new Literal(a3));
            lits.Add(new Literal(a4));
            lits.Add(new Literal(a5));

            Clause c1 = new Clause(lits);

            lits.Clear();
            a1 = (AtomicSentence)parser.parse("F(A,y) = y");
            a2 = (AtomicSentence)parser.parse("F(B,y) = C");
            a3 = (AtomicSentence)parser.parse("R(y)");
            a4 = (AtomicSentence)parser.parse("R(A)");
            lits.Add(new Literal(a1));
            lits.Add(new Literal(a2));
            lits.Add(new Literal(a3));
            lits.Add(new Literal(a4));

            Clause c2 = new Clause(lits);

            List <Clause> paras = paramodulation.apply(c1, c2);

            Assert.AreEqual(5, paras.Count);

            List <Clause> .Enumerator it = paras.GetEnumerator();
            it.MoveNext();
            Assert
            .AreEqual(
                "[F(B,B) = C, F(C,A) = D, A = D, P(B,A), Q(A), R(A), R(B), R(C)]",
                it.Current.ToString());
            it.MoveNext();
            Assert
            .AreEqual(
                "[F(A,F(C,x)) = D, F(B,F(C,x)) = C, A = D, P(F(x,B),x), Q(x), R(F(C,x)), R(A), R(C)]",
                it.Current.ToString());
            it.MoveNext();
            Assert
            .AreEqual(
                "[F(A,B) = B, F(C,B) = D, A = D, P(C,B), Q(B), R(A), R(B), R(C)]",
                it.Current.ToString());
            it.MoveNext();
            Assert
            .AreEqual(
                "[F(F(B,y),x) = D, F(A,y) = y, A = D, P(F(x,B),x), Q(x), R(y), R(A), R(C)]",
                it.Current.ToString());
            it.MoveNext();
            Assert
            .AreEqual(
                "[F(B,y) = C, F(C,x) = D, F(D,y) = y, P(F(x,B),x), Q(x), R(y), R(A), R(C)]",
                it.Current.ToString());
        }
        public override IEnumerator Play()
        {
            // "Reveal cards from the top of the villain deck until you reveal 1 Terrain, 1 Hazard, and 1 One-Shot."
            List <RevealCardsAction> revealed = new List <RevealCardsAction>();
            Card          firstTerrain        = null;
            Card          firstHazard         = null;
            Card          firstOneShot        = null;
            List <Card>   allMatches          = new List <Card>();
            List <String> searchKeywords      = new List <String>();

            searchKeywords.Add(TERRAIN);
            searchKeywords.Add(HAZARD);
            searchKeywords.Add(ONESHOT);
            IEnumerator revealCoroutine;

            while (searchKeywords.Count() > 0 && base.TurnTaker.Deck.HasCards)
            {
                // Reveal cards from the villain deck until you find one that has a keyword in searchKeywords (or the deck runs out of cards)
                revealCoroutine = base.GameController.RevealCards(base.TurnTakerController, base.TurnTaker.Deck, (Card c) => c.DoKeywordsContain(searchKeywords), 1, revealed, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(revealCoroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(revealCoroutine);
                }

                List <Card> newMatches = GetRevealedCards(revealed).Where((Card c) => c.DoKeywordsContain(searchKeywords)).Take(1).ToList();
                if (newMatches.Any())
                {
                    // If the card you found has a keyword that's still in searchKeywords, add that card to allMatches and remove that keyword from searchKeywords
                    Card firstMatch = newMatches.First();
                    if (firstMatch != null)
                    {
                        if (firstMatch.DoKeywordsContain(TERRAIN) && searchKeywords.Contains(TERRAIN))
                        {
                            firstTerrain = firstMatch;
                            allMatches.Add(firstMatch);
                            searchKeywords.Remove(TERRAIN);
                        }
                        else if (firstMatch.DoKeywordsContain(HAZARD) && searchKeywords.Contains(HAZARD))
                        {
                            firstHazard = firstMatch;
                            allMatches.Add(firstMatch);
                            searchKeywords.Remove(HAZARD);
                        }
                        else if (firstMatch.DoKeywordsContain(ONESHOT) && searchKeywords.Contains(ONESHOT))
                        {
                            firstOneShot = firstMatch;
                            allMatches.Add(firstMatch);
                            searchKeywords.Remove(ONESHOT);
                        }
                    }
                }
            }

            // "Shuffle the other revealed cards into the villain deck..."
            List <Card> otherRevealed = GetRevealedCards(revealed).Where((Card c) => !allMatches.Contains(c)).ToList();

            if (otherRevealed.Any())
            {
                IEnumerator replaceCoroutine = base.GameController.MoveCards(this.DecisionMaker, otherRevealed, this.TurnTaker.Deck, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(replaceCoroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(replaceCoroutine);
                }

                IEnumerator shuffleCoroutine = base.ShuffleDeck(this.DecisionMaker, this.TurnTaker.Deck);
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(shuffleCoroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(shuffleCoroutine);
                }
            }

            // "... then put the first revealed Terrain, the first revealed Hazard, and the first revealed One-Shot into play in that order."
            List <PlayCardAction> cardsPlayed = new List <PlayCardAction>();
            List <Card>           cardsToPlay = new List <Card>();

            cardsToPlay.Add(firstTerrain);
            cardsToPlay.Add(firstHazard);
            cardsToPlay.Add(firstOneShot);
            foreach (Card c in cardsToPlay)
            {
                if (c != null)
                {
                    IEnumerator playCoroutine = base.GameController.PlayCard(this.DecisionMaker, c, isPutIntoPlay: true, responsibleTurnTaker: base.TurnTaker, storedResults: cardsPlayed, cardSource: GetCardSource());
                    if (base.UseUnityCoroutines)
                    {
                        yield return(base.GameController.StartCoroutine(playCoroutine));
                    }
                    else
                    {
                        base.GameController.ExhaustCoroutine(playCoroutine);
                    }
                }
            }

            List <PlayCardAction> playSuccesses = new List <PlayCardAction>();

            if (cardsPlayed.Count() > 0)
            {
                using (List <PlayCardAction> .Enumerator enumerator = cardsPlayed.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        PlayCardAction pca = enumerator.Current;
                        if (pca.WasCardPlayed)
                        {
                            playSuccesses.Add(pca);
                        }
                    }
                }
            }
            int numEnteredPlay = playSuccesses.Count();

            // "If fewer than 3 cards entered play this way, {Breakaway} regains 3 HP."
            if (numEnteredPlay < 3)
            {
                IEnumerator hpGainCoroutine = base.GameController.GainHP(this.TurnTaker.FindCard("BreakawayCharacter"), 3, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(this.GameController.StartCoroutine(hpGainCoroutine));
                }
                else
                {
                    this.GameController.ExhaustCoroutine(hpGainCoroutine);
                }
            }

            yield break;
        }
		public void GetEnumeratorWorks() {
			var e = new List<string> { "x", "y" }.GetEnumerator();
			Assert.IsTrue(e.MoveNext());
			Assert.AreEqual(e.Current, "x");
			Assert.IsTrue(e.MoveNext());
			Assert.AreEqual(e.Current, "y");
			Assert.IsFalse(e.MoveNext());
		}
        protected override void LocalParse(ref List<Match>.Enumerator tokens, string sNum)
        {
            if (!tokens.MoveNext())
                return;

            string name, value;
            if (!string.IsNullOrEmpty(tokens.Current.Groups["lparen"].Value))
            {
                tokens.MoveNext();

                while (tokens.Current != null &&
                       string.IsNullOrEmpty(tokens.Current.Groups["rparen"].Value))
                {
                    if (
                        string.IsNullOrEmpty(
                            name = tokens.Current.Groups["name"].Value.Split(new[] { ':' })[0]))
                    {
                        tokens.MoveNext();
                        continue;
                    }

                    if (!tokens.MoveNext())
                        continue;

                    if (string.IsNullOrEmpty(value = tokens.Current.Groups["word"].Value) &&
                        string.IsNullOrEmpty(sNum = tokens.Current.Groups["float"].Value))
                    {
                        tokens.MoveNext();
                        continue;
                    }

                    _dimensions[name] = new Dimension { Name = name, Value = string.IsNullOrEmpty(sNum) ? value : sNum };
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(tokens.Current.Groups["lparen"].Value))
                    tokens.MoveNext();

                if (
                    string.IsNullOrEmpty(
                        name = tokens.Current.Groups["name"].Value.Split(new[] { ':' })[0]))
                {
                    tokens.MoveNext();
                    return;
                }

                if (!tokens.MoveNext())
                    return;

                if (string.IsNullOrEmpty(value = tokens.Current.Groups["word"].Value))
                {
                    tokens.MoveNext();
                    return;
                }

                _dimensions[name] = new Dimension { Name = name, Value = string.IsNullOrEmpty(sNum) ? value : sNum };
            }
        }
Example #49
0
        /// <summary>
        /// 確認excel表格內定義的Type是否和給予的基本資料結構有對應
        /// </summary>
        /// <param name="checkType">給予的type定義</param>
        /// <param name="checkObject">對應的物件</param>
        /// <param name="tableTypeEnumerator">table內文</param>
        /// <returns>是否有對應</returns>
        bool CheckBaseTypeCorrect(Type checkType, object checkObject, ref List<string>.Enumerator tableTypeEnumerator)
        {
            if (!tableTypeEnumerator.MoveNext()) { return false; } // 沒有下一個,表示沒有對應
            // 由於可能有nullable型態,取得對應的非nullable型態再比較
            bool isNullabelType = checkType.IsGenericType && checkType.GetGenericTypeDefinition() == typeof(Nullable<>);
            Type realType = (isNullabelType) ? Nullable.GetUnderlyingType(checkType) : checkType;

            string compareStr;
            if (_baseTypeString.TryGetValue(realType, out compareStr)) // 是基本四型態之一
            {
                if (tableTypeEnumerator.Current.ToUpper().Equals(compareStr.ToUpper()))
                {
                    return true;
                }
                else  // 沒對應到正確的基本型態
                {
                    CommonFunction.DebugMsgFormat("base error : Type = {1} excelType = {2}", _debugMessage, realType, tableTypeEnumerator.Current);
                    _debugMessage = string.Format("{0} base error : Type = {1} excelType = {2}", _debugMessage, realType, tableTypeEnumerator.Current);
                    return false;
                }
            }
            else  // 不是基本四型態之一的話直接跳沒對應
            {
                CommonFunction.DebugMsgFormat("not base error : Type = {1}", _debugMessage, realType);
                _debugMessage = string.Format("{0} not base error : Type = {1}", _debugMessage, realType);
                return false;
            }
        }
Example #50
0
        void RebuildObjList()
        {
            // add the basic types to Intelisense
            ObjDecl _A;

            for (int i = 0; i < BASIC_TYPES.Count; i++)
            {
                _A = new ObjDecl(BASIC_TYPES[i], ObjDecl.TClassType.tCTType, "", "", "", "", 0, 0);
                UpdateObjDecl(_A);
            }
            DateTime _start = DateTime.Now;
            //Log.getInstance().Add("collecting files ", Log.EnuSeverity.Info, "");
            Tokenizer _tokenizer = new Tokenizer();
            LinkedList <Tokenizer.Token> _Tokens = new LinkedList <Tokenizer.Token>();
            List <String> Dirs = new List <String>(); //stack of directories relative to _path
            int           k    = 0;

            try {
                String[] _SubProj = getSubProj();
                for (int i = 0; i < _SubProj.Length; i++)
                {
                    Dirs.Add(Path.Combine(m_ProjectDir, getSeqDir(_SubProj[i])));
                }

                while (k < Dirs.Count)
                {
                    FileInfo[] _files = new DirectoryInfo(Dirs[k]).GetFiles();
                    for (int i = 0; i < _files.Length; i++)
                    {
                        if (_files[i].Extension.Equals(".seq", StringComparison.OrdinalIgnoreCase))
                        {
                            _Tokens.AddLast(_tokenizer.TokenizeFile(_files[i].FullName));
                            NPP.SetFoldLevel(1, 1, true); //Todo !!
                            NPP.SetFoldLevel(2, 2, false);
                            NPP.SetFoldLevel(3, 2, false);
                            NPP.SetFoldLevel(4, 1, false);
                        }
                    }
                    DirectoryInfo[] _Dirs = new DirectoryInfo(Dirs[k]).GetDirectories();
                    for (int i = 0; i < _Dirs.Length; i++)
                    {
                        // If the file is a directory (or is in some way invalid) we'll skip it
                        Dirs.Insert(k + 1, _Dirs[i].FullName);
                    }
                    k++;
                }
                //Log.getInstance().Add("Tokenized all" , Log.EnuSeverity.Info, "");
                Parser2 _parser2 = new Parser2(this, m_ProjectDir);
                _parser2.ParseTokens(_Tokens);
                LinkedList <Parser2.Context.Log> .Enumerator _l = _parser2.GetLogs().GetEnumerator();
                while (_l.MoveNext())
                {
                    Log.getInstance().Add(_l.Current.m_Text, Log.EnuSeverity.Warn, _l.Current.m_Cmd.AsText());
                }
                //update database with parserresult
                LinkedList <Parser2.CmdBase> .Enumerator _Cmds;
                List <String> .Enumerator _Scopes = _parser2.GetScopes().GetEnumerator();
                while (_Scopes.MoveNext())
                {
                    //Log.getInstance().Add("write DB " + _Scopes.Current, Log.EnuSeverity.Info, "");
                    // if(!m_IsClassDef) {
                    { //each SEQ includes itself
                        this.UpdateObjList(new Obj(_Scopes.Current, "", _Scopes.Current, "", 0, 0));
                    }
                    _Cmds = _parser2.GetCmds(_Scopes.Current).GetEnumerator();
                    while (_Cmds.MoveNext())
                    {
                        PublishCmdToDB(_Scopes.Current, _Cmds.Current);
                    }
                }
                Log.getInstance().Add("Parsing done ", Log.EnuSeverity.Info, "");
            } catch (Exception ex) {
                Log.getInstance().Add(ex.Message, Log.EnuSeverity.Error, "");
            }
            finally {
            }
        }
Example #51
0
 public AnimatedTexture(Texture tex)
 {
     Textures.Add(new Tuple<Texture, double>(tex, 0));
     CurrentTexture = Textures.GetEnumerator();
     CurrentTexture.MoveNext();
 }
        internal bool WaitForSchemaAgreement(IPAddress forHost = null)
        {
            var  start   = DateTimeOffset.Now;
            long elapsed = 0;

            while (elapsed < MaxSchemaAgreementWaitMs)
            {
                var versions = new DictSet <Guid>();


                IPAddress queriedHost;

                if (forHost == null)
                {
                    using (var rowset = _session.Query(SelectSchemaPeers, ConsistencyLevel.Default))
                    {
                        queriedHost = rowset.QueriedHost;
                        foreach (var row in rowset.GetRows())
                        {
                            if (row.IsNull("peer") || row.IsNull("schema_version"))
                            {
                                continue;
                            }

                            Host peer = _cluster.Metadata.GetHost(row.GetValue <IPEndPoint>("peer").Address);
                            if (peer != null && peer.IsConsiderablyUp)
                            {
                                versions.Add(row.GetValue <Guid>("schema_version"));
                            }
                        }
                    }
                }
                else
                {
                    queriedHost = forHost;
                    var localhost = _cluster.Metadata.GetHost(queriedHost);
                    var iterLiof  = new List <Host>()
                    {
                        localhost
                    }.GetEnumerator();
                    iterLiof.MoveNext();
                    List <IPAddress> tr = new List <IPAddress>();
                    Dictionary <IPAddress, Exception> exx = new Dictionary <IPAddress, Exception>();
                    var cn = _session.Connect(null, iterLiof, tr, exx);

                    using (var outp = cn.Query(SelectSchemaPeers, ConsistencyLevel.Default, false))
                    {
                        if (outp is OutputRows)
                        {
                            var rowset = new CqlRowSet((outp as OutputRows), null, false);
                            foreach (var row in rowset.GetRows())
                            {
                                if (row.IsNull("peer") || row.IsNull("schema_version"))
                                {
                                    continue;
                                }

                                Host peer = _cluster.Metadata.GetHost(row.GetValue <IPEndPoint>("peer").Address);
                                if (peer != null && peer.IsConsiderablyUp)
                                {
                                    versions.Add(row.GetValue <Guid>("schema_version"));
                                }
                            }
                        }
                    }
                }

                {
                    var localhost = _cluster.Metadata.GetHost(queriedHost);
                    var iterLiof  = new List <Host>()
                    {
                        localhost
                    }.GetEnumerator();
                    iterLiof.MoveNext();
                    List <IPAddress> tr = new List <IPAddress>();
                    Dictionary <IPAddress, Exception> exx = new Dictionary <IPAddress, Exception>();
                    var cn = _session.Connect(null, iterLiof, tr, exx);

                    using (var outp = cn.Query(SelectSchemaLocal, ConsistencyLevel.Default, false))
                    {
                        if (outp is OutputRows)
                        {
                            var rowset = new CqlRowSet((outp as OutputRows), null, false);
                            // Update cluster name, DC and rack for the one node we are connected to
                            foreach (var localRow in rowset.GetRows())
                            {
                                if (!localRow.IsNull("schema_version"))
                                {
                                    versions.Add(localRow.GetValue <Guid>("schema_version"));
                                    break;
                                }
                            }
                        }
                    }
                }


                if (versions.Count <= 1)
                {
                    return(true);
                }

                // let's not flood the node too much
                Thread.Sleep(200);
                elapsed = (long)(DateTimeOffset.Now - start).TotalMilliseconds;
            }

            return(false);
        }
Example #53
0
 public AnimatedTexture Reset()
 {
     Timer = 0;
     CurrentTime = 0;
     CurrentTexture = Textures.GetEnumerator();
     CurrentTexture.MoveNext();
     return this;
 }
Example #54
0
 private void btnRefresh_Click(object sender, EventArgs e)
 {
     try
     {
         btnRefresh.Enabled = false;
         btnRefresh.Cursor  = Cursors.WaitCursor;
         List <Device> device = UsbDevice.GetDevice();
         ListView.ListViewItemCollection items = devicelist.Items;
         foreach (string str in FlashingDevice.flashDeviceList.Where(d => d.IsDone.Value).Select(d => d.Name).ToList())
         {
             foreach (Device flashDevice in FlashingDevice.flashDeviceList)
             {
                 if (flashDevice.Name == str.ToString())
                 {
                     FlashingDevice.flashDeviceList.Remove(flashDevice);
                     break;
                 }
             }
             foreach (ListViewItem listViewItem in items)
             {
                 if (listViewItem.SubItems[1].Text == str.ToString())
                 {
                     items.Remove(listViewItem);
                     break;
                 }
             }
             foreach (Control control in (ArrangedElementCollection)devicelist.Controls)
             {
                 if (control.Name == str.ToString() + "progressbar")
                 {
                     devicelist.Controls.Remove(control);
                     break;
                 }
             }
         }
         using (List <Device> .Enumerator enumerator = device.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 Device d = enumerator.Current;
                 if (FlashingDevice.flashDeviceList.Where(fd => fd.Name == d.Name).Select(fd => fd.Name).Count() == 0)
                 {
                     int          num1         = devicelist.Items.Count + 1;
                     ListViewItem listViewItem = new ListViewItem(new string[6]
                     {
                         num1.ToString(),
                         d.Name,
                         "",
                         "0s",
                         "",
                         ""
                     });
                     devicelist.Items.Add(listViewItem);
                     d.ID       = num1;
                     d.Progress = 0.0f;
                     d.IsDone   = new bool?();
                     FlashingDevice.flashDeviceList.Add(d);
                     float       num2        = 0.0f;
                     Rectangle   rectangle   = new Rectangle();
                     ProgressBar progressBar = new ProgressBar();
                     rectangle          = listViewItem.SubItems[2].Bounds;
                     rectangle.Width    = devicelist.Columns[2].Width;
                     progressBar.Parent = devicelist;
                     progressBar.SetBounds(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                     progressBar.Value   = (int)num2;
                     progressBar.Visible = true;
                     progressBar.Name    = d.Name + "progressbar";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.w(ex.Message);
         int num = (int)MessageBox.Show(ex.Message);
     }
     finally
     {
         btnRefresh.Enabled = true;
         btnRefresh.Cursor  = Cursors.Default;
     }
 }
Example #55
0
    public void Load(GridPool Grid, string loadpath)
    {
        List <BuildPartsPool>[] baseParts = Singleton <CraftCommandListBaseObject> .Instance.BaseParts;
        FileStream   fileStream           = new FileStream(loadpath, FileMode.Open, FileAccess.Read);
        Encoding     utF8 = Encoding.UTF8;
        BinaryReader br   = new BinaryReader((Stream)fileStream, utF8);

        if (br != null)
        {
            PngFile.SkipPng(br);
            int  num1 = (int)br.ReadChar();
            char ch   = br.ReadChar();
            if (!ch.Equals('P'))
            {
                fileStream.Seek(-2L, SeekOrigin.Current);
            }
            this.data.MaxFloorNum  = br.ReadInt32();
            this.data.nPutPartsNum = br.ReadInt32();
            Vector3 vector3;
            while (!ch.Equals('P'))
            {
                vector3.x = (__Null)br.ReadDouble();
                vector3.y = (__Null)br.ReadDouble();
                vector3.z = (__Null)br.ReadDouble();
                this.data.GridPos.Add(vector3);
                int num2 = (int)br.ReadChar();
                ch = br.ReadChar();
                if (!ch.Equals('P'))
                {
                    fileStream.Seek(-2L, SeekOrigin.Current);
                }
            }
            int num3 = (int)br.ReadChar();
            ch = br.ReadChar();
            if (!ch.Equals('U'))
            {
                fileStream.Seek(-2L, SeekOrigin.Current);
            }
            while (!ch.Equals('U'))
            {
                this.data.GridUseState.Add(br.ReadBoolean());
                int num2 = (int)br.ReadChar();
                ch = br.ReadChar();
                if (!ch.Equals('U'))
                {
                    fileStream.Seek(-2L, SeekOrigin.Current);
                }
            }
            int num4 = (int)br.ReadChar();
            ch = br.ReadChar();
            if (!ch.Equals('F'))
            {
                fileStream.Seek(-2L, SeekOrigin.Current);
            }
            while (!ch.Equals('F'))
            {
                this.data.nFloorPartsHeight.Add(br.ReadInt32());
                int num2 = (int)br.ReadChar();
                ch = br.ReadChar();
                if (!ch.Equals('F'))
                {
                    fileStream.Seek(-2L, SeekOrigin.Current);
                }
            }
            int num5 = (int)br.ReadChar();
            ch = br.ReadChar();
            if (!ch.Equals('S'))
            {
                fileStream.Seek(-2L, SeekOrigin.Current);
            }
            int index1 = 0;
            int index2 = 0;
            int num6   = 0;
            this.data.SmallGridState.Add(new List <List <int> >());
            this.data.SmallGridOnParts.Add(new List <List <int[]> >());
            this.data.SmallGridOnStackWall.Add(new List <List <int[]> >());
            this.data.SmallGridCanRoofState.Add(new List <List <int> >());
            this.data.SmallGridInRoomState.Add(new List <List <bool> >());
            this.data.SmallGridState[index1].Add(new List <int>());
            this.data.SmallGridOnParts[index1].Add(new List <int[]>());
            this.data.SmallGridOnStackWall[index1].Add(new List <int[]>());
            this.data.SmallGridCanRoofState[index1].Add(new List <int>());
            this.data.SmallGridInRoomState[index1].Add(new List <bool>());
            while (!ch.Equals('S'))
            {
                this.data.SmallGridState[index1][index2].Add(br.ReadInt32());
                int[] numArray1 = new int[7];
                for (int index3 = 0; index3 < numArray1.Length; ++index3)
                {
                    numArray1[index3] = br.ReadInt32();
                }
                this.data.SmallGridOnParts[index1][index2].Add(numArray1);
                int[] numArray2 = new int[9];
                for (int index3 = 0; index3 < numArray2.Length; ++index3)
                {
                    numArray2[index3] = br.ReadInt32();
                }
                this.data.SmallGridOnStackWall[index1][index2].Add(numArray2);
                this.data.SmallGridCanRoofState[index1][index2].Add(br.ReadInt32());
                this.data.SmallGridInRoomState[index1][index2].Add(br.ReadBoolean());
                int num2 = (int)br.ReadChar();
                ch = br.ReadChar();
                if (!ch.Equals('S'))
                {
                    fileStream.Seek(-2L, SeekOrigin.Current);
                }
                ++num6;
                if (num6 == 4)
                {
                    num6 = 0;
                    ++index2;
                    if (index2 != this.data.MaxFloorNum)
                    {
                        this.data.SmallGridState[index1].Add(new List <int>());
                        this.data.SmallGridOnParts[index1].Add(new List <int[]>());
                        this.data.SmallGridOnStackWall[index1].Add(new List <int[]>());
                        this.data.SmallGridCanRoofState[index1].Add(new List <int>());
                        this.data.SmallGridInRoomState[index1].Add(new List <bool>());
                    }
                    if (index2 == this.data.MaxFloorNum)
                    {
                        index2 = 0;
                        ++index1;
                        this.data.SmallGridState.Add(new List <List <int> >());
                        this.data.SmallGridOnParts.Add(new List <List <int[]> >());
                        this.data.SmallGridOnStackWall.Add(new List <List <int[]> >());
                        this.data.SmallGridCanRoofState.Add(new List <List <int> >());
                        this.data.SmallGridInRoomState.Add(new List <List <bool> >());
                        this.data.SmallGridState[index1].Add(new List <int>());
                        this.data.SmallGridOnParts[index1].Add(new List <int[]>());
                        this.data.SmallGridOnStackWall[index1].Add(new List <int[]>());
                        this.data.SmallGridCanRoofState[index1].Add(new List <int>());
                        this.data.SmallGridInRoomState[index1].Add(new List <bool>());
                    }
                }
            }
            int num7 = (int)br.ReadChar();
            ch = br.ReadChar();
            if (!ch.Equals('B'))
            {
                fileStream.Seek(-2L, SeekOrigin.Current);
            }
            List <int> intList1 = new List <int>();
            List <int> intList2 = new List <int>();
            while (!ch.Equals('B'))
            {
                this.data.BuildPartsGridKind.Add(br.ReadInt32());
                this.data.BuildPartsKind.Add(br.ReadInt32());
                this.data.BuildPartsFloor.Add(br.ReadInt32());
                vector3.x = (__Null)br.ReadDouble();
                vector3.y = (__Null)br.ReadDouble();
                vector3.z = (__Null)br.ReadDouble();
                this.data.BuildPartsPos.Add(vector3);
                Quaternion quaternion;
                quaternion.x = (__Null)br.ReadDouble();
                quaternion.y = (__Null)br.ReadDouble();
                quaternion.z = (__Null)br.ReadDouble();
                quaternion.w = (__Null)br.ReadDouble();
                this.data.BuildPartsRot.Add(quaternion);
                this.data.BuildPartsPutGridInfosNum.Add(br.ReadInt32());
                intList1.Clear();
                intList2.Clear();
                for (int index3 = 0; index3 < this.data.BuildPartsPutGridInfosNum[this.data.BuildPartsPutGridInfosNum.Count - 1]; ++index3)
                {
                    intList1.Add(br.ReadInt32());
                    intList2.Add(br.ReadInt32());
                }
                this.data.BuildPartsPutGridInfos.Add(intList1);
                this.data.BuildPartsPutSmallGridInfos.Add(intList2);
                int num2 = (int)br.ReadChar();
                ch = br.ReadChar();
                if (!ch.Equals('B'))
                {
                    fileStream.Seek(-2L, SeekOrigin.Current);
                }
            }
            int num8 = (int)br.ReadChar();
            ch = br.ReadChar();
            if (!ch.Equals('A'))
            {
                fileStream.Seek(-2L, SeekOrigin.Current);
            }
            bool[] flagArray = new bool[this.data.GridPos.Count];
            while (!ch.Equals('A'))
            {
                for (int index3 = 0; index3 < flagArray.Length; ++index3)
                {
                    flagArray[index3] = br.ReadBoolean();
                }
                this.data.tmpGridActiveList.Add(flagArray);
                this.data.tmpGridActiveListUpdate.Add(br.ReadBoolean());
                this.data.MaxPutHeight.Add(br.ReadInt32());
                int num2 = (int)br.ReadChar();
                ch = br.ReadChar();
                if (!ch.Equals('A'))
                {
                    fileStream.Seek(-2L, SeekOrigin.Current);
                }
            }
            br.Close();
        }
        if (this.data.SmallGridState[this.data.SmallGridState.Count - 1][this.data.SmallGridState[this.data.SmallGridState.Count - 1].Count - 1].Count == 0)
        {
            this.data.SmallGridState.RemoveAt(this.data.SmallGridState.Count - 1);
            this.data.SmallGridOnParts.RemoveAt(this.data.SmallGridOnParts.Count - 1);
            this.data.SmallGridOnStackWall.RemoveAt(this.data.SmallGridOnStackWall.Count - 1);
            this.data.SmallGridCanRoofState.RemoveAt(this.data.SmallGridCanRoofState.Count - 1);
            this.data.SmallGridInRoomState.RemoveAt(this.data.SmallGridInRoomState.Count - 1);
        }
        Singleton <CraftCommandListBaseObject> .Instance.nMaxFloorCnt = this.data.MaxFloorNum;
        Singleton <CraftCommandListBaseObject> .Instance.nPutPartsNum = this.data.nPutPartsNum;
        List <GameObject> list1 = Grid.GetList();
        List <GridInfo>   Grid1 = new List <GridInfo>();

        using (List <GameObject> .Enumerator enumerator = list1.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                GameObject current = enumerator.Current;
                Grid1.Add((GridInfo)current.GetComponent <GridInfo>());
            }
        }
        int num = this.data.GridPos.Count - list1.Count;

        if (num > 0)
        {
            for (int index = 0; index < num; ++index)
            {
                Grid.Get();
            }
        }
        for (int index1 = 0; index1 < list1.Count; ++index1)
        {
            list1[index1].SetActive(true);
            list1[index1].get_transform().set_localPosition(this.data.GridPos[index1]);
            Grid1[index1].DelFloor(0);
            for (int floorNum = Grid1[index1].GetFloorNum(); floorNum < this.data.MaxFloorNum; ++floorNum)
            {
                Grid1[index1].AddFloor();
            }
            for (int index2 = 0; index2 < this.data.MaxFloorNum; ++index2)
            {
                Grid1[index1].SetUseState(index2, this.data.GridUseState[index2 + Grid1[index1].GetFloorNum() * index1]);
                Grid1[index1].nFloorPartsHeight[index2] = this.data.nFloorPartsHeight[index2];
                for (int index3 = 0; index3 < 4; ++index3)
                {
                    for (int index4 = 0; index4 < 7; ++index4)
                    {
                        Grid1[index1].ChangeSmallGrid(index3, this.data.SmallGridState[index1][index2][index3], this.data.SmallGridOnParts[index1][index2][index3][index4], index2, false);
                    }
                    for (int index4 = 0; index4 < 5; ++index4)
                    {
                        Grid1[index1].ChangeSmallGrid(index3, this.data.SmallGridState[index1][index2][index3], this.data.SmallGridOnStackWall[index1][index2][index3][index4], index2, false);
                    }
                    if (index2 == 0)
                    {
                        Grid1[index1].ChangeSmallGridColor(index2, index3);
                    }
                    Grid1[index1].SetCanRoofSmallGrid(index3, index2, this.data.SmallGridCanRoofState[index1][index2][index3]);
                    Grid1[index1].SetInRoomSmallGrid(index3, this.data.SmallGridInRoomState[index1][index2][index3], index2);
                }
            }
        }
        for (int floorcnt = 0; floorcnt < this.data.MaxFloorNum; ++floorcnt)
        {
            GridInfo.ChangeGridInfo(Grid1, floorcnt);
        }
        List <GameObject> gameObjectList = new List <GameObject>();

        for (int index1 = 0; index1 < baseParts.Length; ++index1)
        {
            for (int index2 = 0; index2 < baseParts[index1].Count; ++index2)
            {
                List <GameObject> list2 = baseParts[index1][index2].GetList();
                for (int index3 = 0; index3 < list2.Count; ++index3)
                {
                    if (list2[index3].get_activeSelf())
                    {
                        list2[index3].SetActive(false);
                    }
                    if (((BuildPartsInfo)list2[index3].GetComponent <BuildPartsInfo>()).nPutFloor != -1)
                    {
                        ((BuildPartsInfo)list2[index3].GetComponent <BuildPartsInfo>()).nPutFloor = -1;
                    }
                }
                baseParts[index1][index2].ReserveListDel(0, 1);
            }
        }
        for (int index1 = 0; index1 < this.data.BuildPartsPos.Count; ++index1)
        {
            if (gameObjectList != baseParts[this.data.BuildPartsGridKind[index1]][this.data.BuildPartsKind[index1]].GetList())
            {
                gameObjectList = baseParts[this.data.BuildPartsGridKind[index1]][this.data.BuildPartsKind[index1]].GetList();
            }
            int ID = -1;
            baseParts[this.data.BuildPartsGridKind[index1]][this.data.BuildPartsKind[index1]].Get(ref ID);
            BuildPartsInfo component = (BuildPartsInfo)gameObjectList[ID].GetComponent <BuildPartsInfo>();
            gameObjectList[ID].SetActive(true);
            gameObjectList[ID].get_transform().set_localPosition(this.data.BuildPartsPos[index1]);
            gameObjectList[ID].get_transform().set_localRotation(this.data.BuildPartsRot[index1]);
            component.nPutFloor = this.data.BuildPartsFloor[index1];
            component.putGridInfos.Clear();
            component.putSmallGridInfos.Clear();
            for (int index2 = 0; index2 < this.data.BuildPartsPutGridInfos.Count; ++index2)
            {
                component.putGridInfos.Add(Singleton <CraftCommandListBaseObject> .Instance.BaseGridInfo[this.data.BuildPartsPutGridInfos[index1][index2]]);
                component.putSmallGridInfos.Add(this.data.BuildPartsPutSmallGridInfos[index1][index2]);
            }
        }
        Singleton <CraftCommandListBaseObject> .Instance.tmpGridActiveList       = this.data.tmpGridActiveList;
        Singleton <CraftCommandListBaseObject> .Instance.tmpGridActiveListUpdate = this.data.tmpGridActiveListUpdate;
        Singleton <CraftCommandListBaseObject> .Instance.MaxPutHeight            = this.data.MaxPutHeight;
        this.data.MaxFloorNum  = 0;
        this.data.nPutPartsNum = 0;
        this.data.GridPos.Clear();
        this.data.GridUseState.Clear();
        this.data.nFloorPartsHeight.Clear();
        this.data.SmallGridState.Clear();
        this.data.SmallGridOnParts.Clear();
        this.data.SmallGridOnStackWall.Clear();
        this.data.SmallGridCanRoofState.Clear();
        this.data.SmallGridInRoomState.Clear();
        this.data.BuildPartsGridKind.Clear();
        this.data.BuildPartsKind.Clear();
        this.data.BuildPartsFloor.Clear();
        this.data.BuildPartsPos.Clear();
        this.data.BuildPartsRot.Clear();
        this.data.BuildPartsPutGridInfos.Clear();
        this.data.BuildPartsPutSmallGridInfos.Clear();
        this.data.BuildPartsPutGridInfosNum.Clear();
        this.data.tmpGridActiveList.Clear();
        this.data.tmpGridActiveListUpdate.Clear();
        this.data.MaxPutHeight.Clear();
    }
        public override void Update()
        {
            RadarOverlay.< > c__DisplayClass30_0 CS$ < > 8__locals1 = new RadarOverlay.< > c__DisplayClass30_0();
            this._tickEngine.Pulse();
            if (base.OverlayWindow == null || !base.OverlayWindow.IsVisible)
            {
                return;
            }
            if (!this.MouseDown)
            {
                this.FollowTargetWindow();
            }
            RadarOverlay.< > c__DisplayClass30_0 CS$ < > 8__locals2 = CS$ < > 8__locals1;
            FFXIVMemory mem = Program.mem;

            CS$ < > 8__locals2.self = ((mem != null) ? mem.GetSelfCombatant() : null);
            FFXIVMemory   mem2  = Program.mem;
            List <Entity> clist = (mem2 != null) ? mem2.GetCombatantList() : null;

            if (CS$ < > 8__locals1.self != null && clist != null)
            {
                clist.RemoveAll((Entity c) => c.OwnerID == CS$ < > 8__locals1.self.ID);
                using (List <uint> .Enumerator enumerator = (from x in clist.OfType <PC>()
                                                             select x.ID).ToList <uint>().GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        uint ID = enumerator.Current;
                        clist.RemoveAll((Entity c) => c.OwnerID == ID);
                    }
                }
                this.RemoveUnvantedCombatants(CS$ < > 8__locals1.self, clist);
                double centerY = base.OverlayWindow.Height / 2.0;
                double centerX = base.OverlayWindow.Width / 2.0;
                foreach (Entity c2 in clist)
                {
                    if (c2.ID == 3758096384u && !this.miscDrawMap.ContainsKey(c2.PosX + c2.PosY))
                    {
                        this.miscDrawMap.Add(c2.PosX + c2.PosY, new EntityOverlayControl(c2, false));
                        base.OverlayWindow.Add(this.miscDrawMap[c2.PosX + c2.PosY]);
                    }
                    else if (!this.drawMap.ContainsKey(c2.ID))
                    {
                        this.drawMap.Add(c2.ID, new EntityOverlayControl(c2, c2.ID == CS$ < > 8__locals1.self.ID));
                        base.OverlayWindow.Add(this.drawMap[c2.ID]);
                    }
                    double Top  = (double)(c2.PosY - CS$ < > 8__locals1.self.PosY);
                    double Left = (double)(c2.PosX - CS$ < > 8__locals1.self.PosX);
                    Top  += centerY + Top * base.OverlayWindow.Height * 0.003 * (double)Settings.Default.RadarZoom;
                    Left += centerX + Left * base.OverlayWindow.Width * 0.003 * (double)Settings.Default.RadarZoom;
                    if (this.drawMap.ContainsKey(c2.ID))
                    {
                        this.drawMap[c2.ID].Update(c2);
                        Top  -= this.drawMap[c2.ID].ActualHeight / 2.0;
                        Left -= this.drawMap[c2.ID].ActualWidth / 2.0;
                        if (Top < 0.0)
                        {
                            Canvas.SetTop(this.drawMap[c2.ID], 0.0);
                        }
                        else if (Top > base.OverlayWindow.Height - this.drawMap[c2.ID].ActualHeight)
                        {
                            Canvas.SetTop(this.drawMap[c2.ID], base.OverlayWindow.Height - this.drawMap[c2.ID].ActualHeight);
                        }
                        else
                        {
                            Canvas.SetTop(this.drawMap[c2.ID], Top);
                        }
                        if (Left < 0.0)
                        {
                            Canvas.SetLeft(this.drawMap[c2.ID], 0.0);
                        }
                        else if (Left > base.OverlayWindow.Width - this.drawMap[c2.ID].ActualWidth)
                        {
                            Canvas.SetLeft(this.drawMap[c2.ID], base.OverlayWindow.Width - this.drawMap[c2.ID].ActualWidth);
                        }
                        else
                        {
                            Canvas.SetLeft(this.drawMap[c2.ID], Left);
                        }
                    }
                    else if (this.miscDrawMap.ContainsKey(c2.PosX + c2.PosY))
                    {
                        this.miscDrawMap[c2.PosX + c2.PosY].Update(c2);
                        Top  -= this.miscDrawMap[c2.ID].ActualHeight / 2.0;
                        Left -= this.miscDrawMap[c2.ID].ActualWidth / 2.0;
                        Canvas.SetTop(this.miscDrawMap[c2.PosX + c2.PosY], Top);
                        Canvas.SetLeft(this.miscDrawMap[c2.PosX + c2.PosY], Left);
                    }
                }
            }
            KeyValuePair <uint, EntityOverlayControl>[] array = this.drawMap.ToArray <KeyValuePair <uint, EntityOverlayControl> >();
            int i = 0;

            while (i < array.Length)
            {
                KeyValuePair <uint, EntityOverlayControl> entry = array[i];
                if (!entry.Value.GetEntityName().Equals("Hoard!", StringComparison.Ordinal) || clist == null)
                {
                    goto IL_626;
                }
                if (!clist.OfType <EObject>().Any((EObject c) => c.SubType == EObjType.Banded))
                {
                    goto IL_626;
                }
                entry.Value.Visibility = Visibility.Collapsed;
                if (!this.hoardsDiscovered.Contains(entry.Key))
                {
                    this.hoardsDiscovered.Add(entry.Key);
                }
IL_668:
                i++;
                continue;
IL_626:
                if (clist == null || !clist.Exists((Entity c) => c.ID == entry.Key))
                {
                    entry.Value.Visibility = Visibility.Collapsed;
                    this.drawMap.Remove(entry.Key);
                    goto IL_668;
                }
                goto IL_668;
            }
            KeyValuePair <float, EntityOverlayControl>[] array2 = this.miscDrawMap.ToArray <KeyValuePair <float, EntityOverlayControl> >();
            for (i = 0; i < array2.Length; i++)
            {
                KeyValuePair <float, EntityOverlayControl> entry = array2[i];
                if (clist == null || !clist.Exists((Entity c) => c.PosX + c.PosY == entry.Key))
                {
                    entry.Value.Visibility = Visibility.Collapsed;
                    this.miscDrawMap.Remove(entry.Key);
                }
            }
        }
Example #57
0
 protected void ResetEnumerator()
 {
     _cardEnumerator = _cardObjects.GetEnumerator();
     _cardEnumerator.MoveNext();
 }
Example #58
0
        private void TemplateBatch_Load(object sender, EventArgs e)
        {
            string b = "master";
            string dbType;

            switch (dbType = this.dbobj.DbType)
            {
            case "SQL2000":
            case "SQL2005":
            case "SQL2008":
            case "SQL2012":
                b = "master";
                break;

            case "Oracle":
            case "OleDb":
                b = "";
                this.label3.Visible = false;
                this.cmbDB.Visible  = false;
                break;

            case "MySQL":
                b = "mysql";
                break;

            case "SQLite":
                b = "sqlite_master";
                break;
            }
            if (this.dbset.DbName == "" || this.dbset.DbName == b)
            {
                List <string> dBList = this.dbobj.GetDBList();
                if (dBList == null || dBList.Count <= 0)
                {
                    goto IL_19B;
                }
                using (List <string> .Enumerator enumerator = dBList.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        string current = enumerator.Current;
                        this.cmbDB.Items.Add(current);
                    }
                    goto IL_19B;
                }
            }
            this.cmbDB.Items.Add(this.dbset.DbName);
IL_19B:
            if (this.cmbDB.Items.Count > 0)
            {
                this.cmbDB.SelectedIndex = 0;
            }
            else
            {
                this.listTable1.Items.Clear();
                this.listTable2.Items.Clear();
                List <string> list;
                if (this.isProc)
                {
                    list = this.dbobj.GetProcs("");
                }
                else
                {
                    list = this.dbobj.GetTableViews("");
                }
                if (list.Count > 0)
                {
                    foreach (string current2 in list)
                    {
                        this.listTable1.Items.Add(current2);
                    }
                }
            }
            this.btn_Export.Enabled = false;
            if (File.Exists(this.cmcfgfile))
            {
                this.cfgfile = new INIFile(this.cmcfgfile);
                string text = this.cfgfile.IniReadValue("Project", "lastpath");
                if (text.Trim() != "")
                {
                    this.txtTargetFolder.Text = text;
                }
            }
            this.settings = AppConfig.GetSettings();
            if (this.settings.TemplateFolder == "Template" || this.settings.TemplateFolder == "Template\\TemplateFile" || this.settings.TemplateFolder.Length == 0)
            {
                this.TemplateFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template\\TemplateFile");
            }
            else
            {
                DirectoryInfo directoryInfo = new DirectoryInfo(this.settings.TemplateFolder);
                if (directoryInfo.Exists)
                {
                    this.TemplateFolder = this.settings.TemplateFolder;
                }
                else
                {
                    this.TemplateFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template\\TemplateFile");
                }
            }
            this.CreateFolderTree(this.TemplateFolder);
            this.CheckTemplate();
            this.IsHasItem();
        }
Example #59
0
        /// <summary>
        /// 從excel檔案中取得基本型別的資料
        /// </summary>
        /// <param name="type">基本型別的type</param>
        /// <param name="retObj">存放取得的資料</param>
        /// <param name="rowDataEnumerator">由excel來的row Data</param>
        /// <returns>可能的錯誤</returns>
        ReadExcelToJsonStringError GetBaseTypeDataFromExcel(Type type, ref object retObj, ref List<string>.Enumerator rowDataEnumerator)
        {
            if (!rowDataEnumerator.MoveNext())
            {
                retObj = null;
                return ReadExcelToJsonStringError.DATA_COL_NUM_IS_NOT_ENOUGH;
            }

            bool isNull = string.IsNullOrEmpty(rowDataEnumerator.Current);
            if (type == typeof(string))
            {
                retObj = (isNull) ? null : rowDataEnumerator.Current;
                return ReadExcelToJsonStringError.NONE;
            }
            else
            {
                bool isNullableType = type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
                if (isNull) // 資料是空的
                {
                    retObj = null;
                    return (isNullableType) ? ReadExcelToJsonStringError.NONE : ReadExcelToJsonStringError.DATA_CANT_BE_NULL; // type可為null,則資料為空沒問題
                }
                else // 資料非空
                {
                    string[] para = new string[1] { rowDataEnumerator.Current };
                    Type[] transferType = new Type[1] { typeof(string) };
                    Type realType = (isNullableType) ? Nullable.GetUnderlyingType(type) : type;
                    try
                    {
                        retObj = realType.GetMethod("Parse", transferType).Invoke(null, para);
                        return ReadExcelToJsonStringError.NONE;
                    }
                    catch (Exception e)
                    {
                        CommonFunction.DebugMsgFormat("取得基本型別時出錯\n{0}\n{1}", e.Message, e.StackTrace);
                        retObj = null;
                        return ReadExcelToJsonStringError.GET_BASE_TYPE_ERROR;
                    }
                }
            }
        }
        private void RefreshNodeListAndTokenMap()
        {
            _logger.Info("Refreshing NodeList and TokenMap..");
            // Make sure we're up to date on nodes and tokens
            var    tokenMap    = new Dictionary <IPAddress, DictSet <string> >();
            string partitioner = null;

            var       foundHosts = new List <IPAddress>();
            var       dcs        = new List <string>();
            var       racks      = new List <string>();
            var       allTokens  = new List <DictSet <string> >();
            IPAddress queriedHost;

            using (var rowset = _session.Query(SelectPeers, ConsistencyLevel.Quorum))
            {
                queriedHost = rowset.QueriedHost;
                foreach (var row in rowset.GetRows())
                {
                    var hstip = row.GetValue <IPEndPoint>("peer").Address;
                    if (hstip != null)
                    {
                        foundHosts.Add(hstip);
                        dcs.Add(row.GetValue <string>("data_center"));
                        racks.Add(row.GetValue <string>("rack"));
                        var col = row.GetValue <IEnumerable <string> >("tokens");
                        if (col == null)
                        {
                            allTokens.Add(new DictSet <string>());
                        }
                        else
                        {
                            allTokens.Add(new DictSet <string>(col));
                        }
                    }
                }
            }

            var localhost = _cluster.Metadata.GetHost(queriedHost);
            var iterLiof  = new List <Host>()
            {
                localhost
            }.GetEnumerator();

            iterLiof.MoveNext();
            List <IPAddress> tr = new List <IPAddress>();
            Dictionary <IPAddress, Exception> exx = new Dictionary <IPAddress, Exception>();
            var cn = _session.Connect(null, iterLiof, tr, exx);

            using (var outp = cn.Query(SelectLocal, ConsistencyLevel.Default, false))
            {
                if (outp is OutputRows)
                {
                    var rowset = new CqlRowSet((outp as OutputRows), null, false);
                    // Update cluster name, DC and rack for the one node we are connected to
                    foreach (var localRow in rowset.GetRows())
                    {
                        var clusterName = localRow.GetValue <string>("cluster_name");
                        if (clusterName != null)
                        {
                            _cluster.Metadata.ClusterName = clusterName;
                        }



                        // In theory host can't be null. However there is no point in risking a NPE in case we
                        // have a race between a node removal and this.
                        if (localhost != null)
                        {
                            localhost.SetLocationInfo(localRow.GetValue <string>("data_center"), localRow.GetValue <string>("rack"));

                            partitioner = localRow.GetValue <string>("partitioner");
                            var tokens = localRow.GetValue <IList <string> >("tokens");
                            if (partitioner != null && tokens.Count > 0)
                            {
                                if (!tokenMap.ContainsKey(localhost.Address))
                                {
                                    tokenMap.Add(localhost.Address, new DictSet <string>());
                                }
                                tokenMap[localhost.Address].AddRange(tokens);
                            }
                        }

                        break; //fetch only one row
                    }
                }
            }

            for (int i = 0; i < foundHosts.Count; i++)
            {
                var host = _cluster.Metadata.GetHost(foundHosts[i]);
                if (host == null)
                {
                    // We don't know that node, add it.
                    host = _cluster.Metadata.AddHost(foundHosts[i]);
                }
                host.SetLocationInfo(dcs[i], racks[i]);

                if (partitioner != null && !allTokens[i].IsEmpty)
                {
                    tokenMap.Add(host.Address, allTokens[i]);
                }
            }

            // Removes all those that seems to have been removed (since we lost the control connection)
            var foundHostsSet = new DictSet <IPAddress>(foundHosts);

            foreach (var host in _cluster.Metadata.AllReplicas())
            {
                if (!host.Equals(queriedHost) && !foundHostsSet.Contains(host))
                {
                    _cluster.Metadata.RemoveHost(host);
                }
            }

            if (partitioner != null)
            {
                _cluster.Metadata.RebuildTokenMap(partitioner, tokenMap);
            }

            _logger.Info("NodeList and TokenMap have been successfully refreshed!");
        }