Exemplo n.º 1
0
        public Color GetTintColor()
        {
            var   mymod     = TheLunaticMod.Instance;
            Color color     = Color.Black;
            float tintScale = MathHelper.Clamp(this.TintScale, 0f, 1f);
            float daySpike  = (float)Math.Abs(WorldStateHelpers.GetDayOrNightPercentDone() - 0.5d);

            if (Main.dayTime)
            {
                tintScale *= 1f - daySpike;
            }
            else
            {
                tintScale *= (daySpike * 0.6f) + 0.2f;
            }

            color.R = (byte)(255f * tintScale);
            color.G = (byte)(128f * tintScale);
            color.A = (byte)(255f * tintScale);

            if (mymod.Config.DebugModeInfo)
            {
                DebugHelpers.Print("Sky", color.ToString(), 20);
            }
            return(color);
        }
Exemplo n.º 2
0
        private void UpdateEndSigns()
        {
            var mymod = TheLunaticMod.Instance;

            if (this.HaveWeEndSigns())
            {
                int halfDaysLeft = (mymod.Config.DaysUntil * 2) - this.HalfDaysElapsed;
                int rand         = Main.rand.Next(halfDaysLeft * 60 * 54);

                if (Main.netMode != 1 && rand == 0)                     // Not client
                {
                    int duration = (int)(120 + (60 * 4 * Main.rand.NextFloat()));

                    if (Main.netMode == 2)                              // Server
                    {
                        ServerPacketHandlers.BroadcastEndSignFromServer(duration);
                    }
                    else if (Main.netMode == 0)                                 // Single-player
                    {
                        this.ApplyEndSignForMe(duration);
                    }
                }

                if (Main.netMode != 2)                      // Not server
                {
                    if (halfDaysLeft != 0)
                    {
                        double days = (double)this.HalfDaysElapsed + WorldStateHelpers.GetDayOrNightPercentDone();
                        days -= mymod.Config.DaysUntil;
                        mymod.Sky.TintScale = (float)days / (float)mymod.Config.DaysUntil;
                    }
                    else
                    {
                        mymod.Sky.TintScale = 0;
                    }
                }
            }
            else if (Main.netMode != 2)                         // Not server
            {
                mymod.Sky.TintScale = 0;
            }
        }
Exemplo n.º 3
0
        ////////////////

        public void RegisterReceiptOfMask(Player givingPlayer, int maskType, int bossNpcType)
        {
            var mymod = TheLunaticMod.Instance;

            if (maskType == ModContent.ItemType <CustomBossMaskItem>() && bossNpcType != 0 && bossNpcType != -1)                // -1 for legacy support
            {
                NPC npc = new NPC();
                npc.SetDefaults(bossNpcType);

                this.GivenCustomMasksByBossUid.Add(NPCID.GetUniqueKey(npc));
            }
            else
            {
                this.GivenVanillaMasksByType.Add(maskType);
            }

            if (mymod.Config.DebugModeInfo)
            {
                LogHelpers.Log("DEBUG Registering mask. " + givingPlayer.name + ", " + maskType);
            }

            // Buy time before the end comes
            if (this.GivenVanillaMasksByType.Count < (MaskLogic.AvailableMaskCount))
            {
                var modworld  = ModContent.GetInstance <TheLunaticWorld>();
                int recovered = mymod.Config.HalfDaysRecoveredPerMask;

                switch (maskType)
                {
                case ItemID.FleshMask:
                    recovered = (int)((float)recovered * mymod.Config.WallOfFleshMultiplier);
                    break;

                case ItemID.DestroyerMask:
                case ItemID.TwinMask:
                case ItemID.SkeletronPrimeMask:
                case ItemID.PlanteraMask:
                case ItemID.GolemMask:
                case ItemID.DukeFishronMask:
                case ItemID.BossMaskBetsy:
                case ItemID.BossMaskCultist:
                case ItemID.BossMaskMoonlord:
                    if (maskType == ItemID.BossMaskMoonlord && mymod.Config.MoonLordMaskWins)
                    {
                        this.GiveAllVanillaMasks();
                    }
                    recovered = (int)((float)recovered * mymod.Config.HardModeMultiplier);
                    break;
                }

                if (WorldStateHelpers.GetDayOrNightPercentDone() > 0.5f)
                {
                    recovered += 1;
                }

                modworld.GameLogic.SetTime(modworld.GameLogic.HalfDaysElapsed - recovered);
            }

            // Sky flash for all
            if (!Main.dedServ && Main.netMode != 2)                 // Not server
            {
                Player currentPlayer = Main.player[Main.myPlayer];
                var    modplayer     = currentPlayer.GetModPlayer <TheLunaticPlayer>();
                modplayer.FlashMe();
            }
        }