Exemple #1
0
        public void GetVoltageTwoComponent4()
        {
            var test      = new NetList();
            var component = new SimTestComponent(3);

            test.Add(component);
            var component2 = new SimTestComponent(3);

            test.Add(component2);
            test.AddConnection(component.Bottom, component2.Top);
            test.Simulate();
            Assert.AreEqual(NetList.GetVoltageDrop(component.Top, component2.Bottom), 6);
        }
Exemple #2
0
        public void TestSingleResistors3()
        {
            var testResistComponent  = new Resistor(1);
            var testBatteryComponent = new Battery(2);
            var test = new NetList();

            test.Add(testResistComponent);
            test.Add(testBatteryComponent);
            test.AddConnection(testBatteryComponent.Bottom, testResistComponent.Top);
            test.AddConnection(testBatteryComponent.Top, testResistComponent.Bottom);
            test.Simulate();
            Assert.AreEqual(2, testResistComponent.GetVoltageDrop());
        }
Exemple #3
0
        public void AddComponent()
        {
            var test      = new NetList();
            var component = new SimTestComponent(1);

            test.Add(component);
        }
        protected override void WriteDelta(BinaryWriter writer)
        {
            NetCoreObject obj = new NetCoreObject(Value);

            obj.Write(writer);

            NetList <KeyValuePair <Vector2, MultiTileComponent>, NetKeyValuePair <Vector2, MultiTileComponent, NetVector2, NetMultiTileComponent> > netList = new NetList <KeyValuePair <Vector2, MultiTileComponent>, NetKeyValuePair <Vector2, MultiTileComponent, NetVector2, NetMultiTileComponent> >();

            if (Value.objects == null)
            {
                throw new Exception("Trying to write null object list!");
            }
            foreach (var v in Value.objects)
            {
                StardustCore.ModCore.ModMonitor.Log(v.Value.name);
                netList.Add(v);
            }
            netList.Write(writer);

            NetColor col = new NetColor(Value.categoryColor);

            col.Write(writer);

            NetString catName = new NetString(Value.categoryName);

            catName.Write(writer);
        }
Exemple #5
0
 public override void DayUpdate(int dayOfMonth)
 {
     base.DayUpdate(dayOfMonth);
     if (dayOfMonth % 7 % 5 == 0)
     {
         travelingMerchantDay = true;
         travelingMerchantBounds.Add(new Microsoft.Xna.Framework.Rectangle(1472, 640, 492, 116));
         travelingMerchantBounds.Add(new Microsoft.Xna.Framework.Rectangle(1652, 744, 76, 48));
         travelingMerchantBounds.Add(new Microsoft.Xna.Framework.Rectangle(1812, 744, 104, 48));
         foreach (Microsoft.Xna.Framework.Rectangle travelingMerchantBound in travelingMerchantBounds)
         {
             Utility.clearObjectsInArea(travelingMerchantBound, this);
         }
         if (Game1.IsMasterGame && Game1.netWorldState.Value.VisitsUntilY1Guarantee >= 0)
         {
             Game1.netWorldState.Value.VisitsUntilY1Guarantee--;
         }
     }
     else
     {
         travelingMerchantBounds.Clear();
         travelingMerchantDay = false;
     }
     if (Game1.currentSeason.Equals("spring"))
     {
         for (int i = 0; i < 7; i++)
         {
             Vector2 origin = new Vector2(Game1.random.Next(70, map.Layers[0].LayerWidth - 10), Game1.random.Next(68, map.Layers[0].LayerHeight - 15));
             if (!(origin.Y > 30f))
             {
                 continue;
             }
             foreach (Vector2 v in Utility.recursiveFindOpenTiles(this, origin, 16))
             {
                 string s = doesTileHaveProperty((int)v.X, (int)v.Y, "Diggable", "Back");
                 if (!terrainFeatures.ContainsKey(v) && s != null && Game1.random.NextDouble() < (double)(1f - Vector2.Distance(origin, v) * 0.15f))
                 {
                     terrainFeatures.Add(v, new HoeDirt(0, new Crop(forageCrop: true, 1, (int)v.X, (int)v.Y)));
                 }
             }
         }
     }
     if (Game1.year > 2 && getCharacterFromName("TrashBear") != null)
     {
         characters.Remove(getCharacterFromName("TrashBear"));
     }
 }
Exemple #6
0
 public IslandFieldOffice(string map, string name)
     : base(map, name)
 {
     while (piecesDonated.Count < 11)
     {
         piecesDonated.Add(item: false);
     }
 }
Exemple #7
0
        public void GetVoltage2()
        {
            var test      = new NetList();
            var component = new SimTestComponent(2);

            test.Add(component);
            test.Simulate();
            Assert.AreEqual(component.GetVoltageDrop(), 2);
        }
Exemple #8
0
 public SandDuggy(GameLocation location, Point[] points)
     : this()
 {
     locationRef.Value = location;
     foreach (Point point in points)
     {
         holeLocations.Add(point);
     }
     currentHoleIndex.Value = FindRandomFreePoint();
 }
Exemple #9
0
 public override void _GetOneFrom(Item source)
 {
     combinedRings.Clear();
     foreach (Ring combinedRing in (source as CombinedRing).combinedRings)
     {
         Ring ring = combinedRing.getOne() as Ring;
         combinedRings.Add(ring);
     }
     loadDisplayFields();
     base._GetOneFrom(source);
 }
Exemple #10
0
 public bool donatePiece(int which)
 {
     piecesDonated[which] = true;
     if (!centerSkeletonRestored && isRangeAllTrue(0, 6))
     {
         centerSkeletonRestored.Value = true;
         uncollectedRewards.Add(new Object(73, 6));
         uncollectedRewards.Add(new Object(69, 1));
         Game1.player.team.MarkCollectedNut("IslandCenterSkeletonRestored");
         return(true);
     }
     if (!snakeRestored && isRangeAllTrue(6, 9))
     {
         snakeRestored.Value = true;
         uncollectedRewards.Add(new Object(73, 3));
         uncollectedRewards.Add(new Object(835, 1));
         Game1.player.team.MarkCollectedNut("IslandSnakeRestored");
         return(true);
     }
     if (!batRestored && piecesDonated[9])
     {
         batRestored.Value = true;
         uncollectedRewards.Add(new Object(73, 1));
         Game1.player.team.MarkCollectedNut("IslandBatRestored");
         return(true);
     }
     if (!frogRestored && piecesDonated[10])
     {
         frogRestored.Value = true;
         uncollectedRewards.Add(new Object(73, 1));
         Game1.player.team.MarkCollectedNut("IslandFrogRestored");
         return(true);
     }
     return(false);
 }
Exemple #11
0
        public override void UpdateWhenCurrentLocation(GameTime time)
        {
            enterValueEvent.Poll();
            if ((localPhase != 1 || currentPlaybackCrystalSequenceIndex < 0 || currentPlaybackCrystalSequenceIndex >= currentCrystalSequence.Count) && localPhase != netPhase.Value)
            {
                localPhaseTimer = netPhaseTimer.Value;
                localPhase      = netPhase.Value;
                if (localPhase != 1)
                {
                    currentPlaybackCrystalSequenceIndex = -1;
                }
                else
                {
                    currentPlaybackCrystalSequenceIndex = 0;
                }
            }
            base.UpdateWhenCurrentLocation(time);
            foreach (CaveCrystal crystal in crystals)
            {
                crystal.update();
            }
            if (localPhaseTimer > 0f)
            {
                localPhaseTimer -= (float)time.ElapsedGameTime.TotalMilliseconds;
                if (localPhaseTimer <= 0f)
                {
                    switch (localPhase)
                    {
                    case 0:
                    case 4:
                        currentPlaybackCrystalSequenceIndex = 0;
                        if (Game1.IsMasterGame)
                        {
                            currentDifficulty.Value++;
                            currentCrystalSequence.Clear();
                            currentCrystalSequenceIndex.Value = 0;
                            if ((int)currentDifficulty > (((int)timesFailed < 8) ? 7 : 6))
                            {
                                netPhaseTimer.Value = 10f;
                                netPhase.Value      = 5;
                                break;
                            }
                            for (int i = 0; i < (int)currentDifficulty; i++)
                            {
                                currentCrystalSequence.Add(Game1.random.Next(5));
                            }
                            netPhase.Value = 1;
                        }
                        betweenNotesTimer = 600f;
                        break;

                    case 5:
                        if (Game1.currentLocation == this)
                        {
                            Game1.playSound("fireball");
                            Utility.addSmokePuff(this, new Vector2(5f, 1f) * 64f);
                            Utility.addSmokePuff(this, new Vector2(7f, 1f) * 64f);
                        }
                        if (Game1.IsMasterGame)
                        {
                            Game1.player.team.MarkCollectedNut("IslandWestCavePuzzle");
                            Game1.createObjectDebris(73, 5, 1, this);
                            Game1.createObjectDebris(73, 7, 1, this);
                            Game1.createObjectDebris(73, 6, 1, this);
                        }
                        completed.Value = true;
                        if (Game1.currentLocation == this)
                        {
                            addCompletionTorches();
                        }
                        break;
                    }
                }
            }
            int num = localPhase;

            if (num != 1)
            {
                _ = 5;
                return;
            }
            betweenNotesTimer -= (float)time.ElapsedGameTime.TotalMilliseconds;
            if (!(betweenNotesTimer <= 0f) || currentCrystalSequence.Count <= 0 || currentPlaybackCrystalSequenceIndex < 0)
            {
                return;
            }
            int which = currentCrystalSequence[currentPlaybackCrystalSequenceIndex];

            if (which < crystals.Count)
            {
                crystals[which].activate();
            }
            currentPlaybackCrystalSequenceIndex++;
            int betweenNotesDivisor = currentDifficulty;

            if ((int)currentDifficulty > 5)
            {
                betweenNotesDivisor--;
                if ((int)timesFailed >= 4)
                {
                    betweenNotesDivisor--;
                }
                if ((int)timesFailed >= 6)
                {
                    betweenNotesDivisor--;
                }
                if ((int)timesFailed >= 8)
                {
                    betweenNotesDivisor = 3;
                }
            }
            else if ((int)timesFailed >= 4 && (int)currentDifficulty > 4)
            {
                betweenNotesDivisor--;
            }
            betweenNotesTimer = 1500f / (float)betweenNotesDivisor;
            if ((int)currentDifficulty > (((int)timesFailed < 8) ? 7 : 6))
            {
                betweenNotesTimer = 100f;
            }
            if (currentPlaybackCrystalSequenceIndex < currentCrystalSequence.Count)
            {
                return;
            }
            currentPlaybackCrystalSequenceIndex = -1;
            if ((int)currentDifficulty > (((int)timesFailed < 8) ? 7 : 6))
            {
                if (Game1.IsMasterGame)
                {
                    netPhaseTimer.Value = 1000f;
                    netPhase.Value      = 5;
                }
            }
            else if (Game1.IsMasterGame)
            {
                netPhase.Value = 2;
                currentCrystalSequenceIndex.Value = 0;
            }
        }
Exemple #12
0
 public virtual void AddObjective(OrderObjective objective)
 {
     objectives.Add(objective);
 }