Example #1
0
    public void GetPlaytime()
    {
        TimeSpan time = TimeSpan.FromMilliseconds(GameState.CurrentTick * GameState.GameSpeed);

        if (time.TotalHours > 1)
        {
            MessageManager.AddMessage("You've been in this world for " + time.TotalHours + " hours.");
        }
        else if (time.TotalMinutes > 1)
        {
            MessageManager.AddMessage("You've been in this world for " + time.TotalMinutes + " minutes.");
        }
        else if (time.TotalSeconds > 1)
        {
            MessageManager.AddMessage("You've been in this world for " + time.TotalSeconds + " seconds.");
        }
        else
        {
            MessageManager.AddMessage("You've only been in this world for " + time.TotalMilliseconds + " milliseconds!");
        }
    }
Example #2
0
 public bool PlayerGatherItem(GameItem item)
 {
     if (Inventory.AddItem(item.Copy()) == false)
     {
         if (CurrentFollower != null && CurrentFollower.IsBanking)
         {
             MessageManager.AddMessage("Your inventory is full. You wait for your follower to return from banking.");
         }
         else
         {
             MessageManager.AddMessage("Your inventory is full.");
         }
         return(false);
     }
     else
     {
         GainExperience(item.ExperienceGained);
         MessageManager.AddMessage(item.GatherString);
     }
     return(true);
 }
Example #3
0
 private void Update()
 {
     if (!rescueTimerStarted)
     {
         var comms = GameObject.Find("CommunicationsDevice(Clone)");
         if (comms)
         {
             var rigid = comms.GetComponentInChildren <Rigidbody>();
             if (!rigid.isKinematic)
             {
                 StartRescueTimer();
                 NotificationManager.AddNotification(new NotificationEvent(EventName.FirstMissionControlMessage, "New Message - Press M to view"));
                 MessageManager.AddMessage(new Message()
                 {
                     Title     = "Mission Control - You're alive?",
                     Body      = "Wow you're alive?! We were worried then for a few minutes, that was quite the crash! We're working on sending a rescue mission but it's looking like it'll be about 10 days until we can get to you. Hang tight until then, we'll be in touch with more instructions.",
                     EventName = EventName.FirstMissionControlMessage
                 });
             }
         }
     }
 }
Example #4
0
 public void Eat(GameItem item)
 {
     if (item.FoodInfo != null)
     {
         CurrentFood  = item;
         HealingTicks = CurrentFood.FoodInfo.HealDuration;
         Player.Instance.Inventory.RemoveItems(item, 1);
         if (CurrentFood.FoodInfo.BuffedSkill != null)
         {
             Player.Instance.Skills.Find(x => x.Name == item.FoodInfo.BuffedSkill).Boost = CurrentFood.FoodInfo.BuffAmount;
             MessageManager.AddMessage("You eat a " + CurrentFood + "." + " It somehow makes you feel better at " + CurrentFood.FoodInfo.BuffedSkill + ".");
         }
         else
         {
             MessageManager.AddMessage("You eat a " + CurrentFood + ".");
         }
     }
     else
     {
         Console.WriteLine("Item has no food info:" + item.Name);
     }
 }
 public static bool GetAutoSmeltingMaterials(Recipe CurrentSmeltingRecipe)
 {
     if (Player.Instance.CurrentFollower != null && Player.Instance.CurrentFollower.AutoCollectSkill == "Smithing")
     {
         if (Player.Instance.CurrentFollower.TicksToNextAction <= 0)
         {
             if (Player.Instance.CurrentFollower.Inventory.GetUsedSpaces() == 0)
             {
                 int amtToWithdraw = Player.Instance.CurrentFollower.InventorySize / CurrentSmeltingRecipe.GetNumberOfIngredients();
                 foreach (Ingredient i in CurrentSmeltingRecipe.Ingredients)
                 {
                     int actualAmt = Math.Min(amtToWithdraw * i.Amount, Bank.Instance.Inventory.GetNumberOfItem(i.Item));
                     if (actualAmt == 0)
                     {
                         return(false);
                     }
                     if (Bank.Instance.Inventory.RemoveItems(i.Item, actualAmt) == actualAmt)
                     {
                         Player.Instance.CurrentFollower.Inventory.AddMultipleOfItem(i.Item, actualAmt);
                         Player.Instance.CurrentFollower.TicksToNextAction = Player.Instance.CurrentFollower.AutoCollectSpeed;
                     }
                     else
                     {
                         return(false);
                     }
                 }
                 MessageManager.AddMessage(Player.Instance.CurrentFollower.Name + " goes to the bank and gathers the resources to smith.");
                 SmithingStage++;
                 return(true);
             }
         }
         else
         {
             Player.Instance.CurrentFollower.TicksToNextAction--;
             return(true);
         }
     }
     return(false);
 }
Example #6
0
 /// <summary>
 /// Returns true if the item was sucessfully created. Outputs the number created for the message manager.
 /// </summary>
 /// <param name="created"></param>
 /// <returns></returns>
 public bool Create(out int created)
 {
     created = 0;
     if (CanCreate())
     {
         int maxOutput = GetMaxOutput();
         foreach (Ingredient ingredient in Ingredients)
         {
             if (ingredient.DestroyOnUse)
             {
                 Player.Instance.Inventory.RemoveItems(ingredient.Item, ingredient.Amount * maxOutput);
                 //Console.WriteLine("Removing " + (ingredient.Amount * maxOutput) + " " + ingredient.Item);
             }
         }
         Player.Instance.GainExperienceMultipleTimes(ExperienceGained, OutputAmount * maxOutput);
         Player.Instance.Inventory.AddMultipleOfItem(Output, OutputAmount * maxOutput);
         if (SecondaryOutputItemName != null)
         {
             Player.Instance.Inventory.AddMultipleOfItem(SecondaryOutput, OutputAmount * maxOutput);
         }
         if (TertiaryOutputItemName != null)
         {
             Player.Instance.Inventory.AddMultipleOfItem(TertiaryOutput, OutputAmount * maxOutput);
         }
         created = maxOutput;
         return(true);
     }
     else if ((Output.IsStackable && (Player.Instance.Inventory.GetAvailableSpaces() == 0 && Player.Instance.Inventory.HasItem(Output) == false)) ||
              Player.Instance.Inventory.GetAvailableSpaces() < OutputAmount * GetRequiredSpaces())
     {
         MessageManager.AddMessage("You don't have enough inventory space to do this.");
         return(false);
     }
     else
     {
         return(false);
     }
 }
    public double CalculateTypeBonus(Monster m)
    {
        double bonus = 1;

        if (Player.Instance.GetWeapon() != null)
        {
            foreach (string s in Player.Instance.GetWeapon().GetRequiredSkills())
            {
                if (m.Weaknesses.Contains(s))
                {
                    MessageManager.AddMessage("Your opponent seems weak to your weapon!");
                    bonus += 0.4;
                }
                else if (m.Strengths.Contains(s))
                {
                    MessageManager.AddMessage("Your opponent seems to be resistant to your weapon...");
                    bonus -= 0.4;
                }
            }
        }

        return(Math.Min(Math.Max(bonus, 0.1), 10));
    }
Example #8
0
    public async void Save(string data)
    {
        if (IsConnected == false || data == null)
        {
            return;
        }
        string dataPart2 = "";

        if (data.Length > 4500)
        {
            dataPart2 = data.Substring(4500, data.Length - 4500);
            data      = data.Substring(0, 4500);
        }
        PlayFabResult <UpdateUserDataResult> result = await PlayFabClientAPI.UpdateUserDataAsync(new UpdateUserDataRequest()
        {
            Data = new Dictionary <string, string>()
            {
                { "Save Data", data },
                { "Save Data2", dataPart2 }
            }
        });

        if (result.Error != null)
        {
            Console.WriteLine(result.Error.GenerateErrorReport());
            if (result.Error.HttpCode == 401)
            {
                IsConnected = false;
                Console.WriteLine("Player has been logged out. Attempting to log in...");
                await TryLogin(gameState.userID, gameState.token);
            }
        }
        else
        {
            messageManager.AddMessage("Cloud save was successful.");
        }
    }
Example #9
0
    public void IdentifyGems()
    {
        List <KeyValuePair <GameItem, int> > items         = Player.Instance.Inventory.GetItems();
        List <KeyValuePair <GameItem, int> > itemsToRemove = new List <KeyValuePair <GameItem, int> >();
        int amt        = 0;
        int coinsToPay = 0;

        foreach (KeyValuePair <GameItem, int> pair in items)
        {
            if (pair.Key.Name == "Unidentified Gem")
            {
                if (Player.Instance.Inventory.GetNumberOfItem(ItemManager.Instance.GetItemByName("Coins")) - coinsToPay >= 300)
                {
                    coinsToPay += 300;
                    itemsToRemove.Add(new KeyValuePair <GameItem, int>(pair.Key, 1));
                }
            }
        }
        Player.Instance.Inventory.RemoveItems(ItemManager.Instance.GetItemByName("Coins"), coinsToPay);
        foreach (KeyValuePair <GameItem, int> pair in itemsToRemove)
        {
            if (Player.Instance.Inventory.RemoveItems(pair.Key, 1) == 1)
            {
                GameItem i = ItemManager.Instance.GetCopyOfItem(pair.Key.Parameter);
                Player.Instance.Inventory.AddItem(i);
                amt++;
            }
        }
        if (amt == 0)
        {
            MessageManager.AddMessage("You'll need both money and gems to have me identify them...");
        }
        else
        {
            MessageManager.AddMessage("Tochtei correctly identifies your gems.");
        }
    }
Example #10
0
    // Update is called once per frame
    void UpdateDaysUntilRescue()
    {
        if (daysUntilRescue > 0)
        {
            daysUntilRescue--;

            if (NotificationManager.Notifications.Any(a => a.EventName == EventName.Explore) && daysUntilRescue == 9)
            {
                NotificationManager.CompleteNotification(EventName.Explore, false);
                NotificationManager.AddNotification(new NotificationEvent(EventName.SecondMissionControlMessage, "New Message - Press M to view"));
                MessageManager.AddMessage(new Message()
                {
                    Title     = "Mission Control - Rescue Plan Stage 1",
                    Body      = "Okay we have a plan. We need you to craft and place a drill to start mining resources. You may need to clean your solar panel to get enough electricity to drill. Also be careful of your oxygen, it'll refill in the hab but outside it will go down. Await further instructions.",
                    EventName = EventName.SecondMissionControlMessage
                });
            }

            if (daysUntilRescue == 1)
            {
                NotificationManager.RemoveAllNotification();
                NotificationManager.AddNotification(new NotificationEvent(EventName.FinalMissionControlMessage, "New Message - Press M to view"));
                MessageManager.AddMessage(new Message()
                {
                    Title     = "Mission Control - Last Message",
                    Body      = "Rescue mission is nearly with you. Just a little bit longer to wait. See you soon!",
                    EventName = EventName.FinalMissionControlMessage
                });
            }
        }
        else
        {
            SceneManager.LoadScene(4);
        }

        rescueText.text = daysUntilRescue.ToString();
    }
Example #11
0
    public void LevelUp(Skill skill)
    {
        skill.SetSkillLevel(skill.GetSkillLevelUnboosted() + 1);
        MessageManager.AddMessage("You leveled up! Your " + skill.Name + " level is now " + skill.GetSkillLevelUnboosted() + ".");
        if (skill.Name == "Strength")
        {
            Inventory.IncreaseMaxSizeBy(1);

            if (skill.GetSkillLevelUnboosted() % 10 == 0)
            {
                Inventory.IncreaseMaxSizeBy(4);
                MessageManager.AddMessage("You feel stronger. You can now carry 5 more items in your inventory.");
            }
            else
            {
                MessageManager.AddMessage("You feel stronger. You can now carry 1 more item in your inventory.");
            }
        }
        else if (skill.Name == "HP")
        {
            IncreaseMaxHPBy(5);
            if (skill.GetSkillLevelUnboosted() % 5 == 0)
            {
                IncreaseMaxHPBy(10);
                MessageManager.AddMessage("You feel much healthier. Your maximum HP has increased by 15!");
            }
            else
            {
                MessageManager.AddMessage("You feel healthier. Your maximum HP has increased by 5.");
            }
        }

        if (skill.Experience >= Skill.GetExperienceRequired(skill.GetSkillLevelUnboosted()))
        {
            LevelUp(skill);
        }
    }
Example #12
0
    public void BeAttacked(Monster opponent)
    {
        RollForMonsterAttackEffects(opponent);
        int total = (int)Math.Max(1, (opponent.Damage.ToRandomDamage()));

        if (Player.Instance.CurrentStatusEffects.OfType <CleaveEffect>().Any())
        {
        }
        else
        {
            total = (int)Math.Max(total * Extensions.CalculateArmorDamageReduction(), 1);
        }

        Player.Instance.CurrentHP -= total;
        Player.Instance.GainExperience("HP", total);
        if (CurrentDojo != null)
        {
            MessageManager.AddMessage(opponent.Name + " hit you for " + total + " damage!");
        }
        else
        {
            MessageManager.AddMessage("The " + opponent.Name + " hit you for " + total + " damage!");
        }
    }
 public static void DoAutoWithdrawal(Recipe CurrentSmithingRecipe)
 {
     if (Player.Instance.CurrentFollower != null && Player.Instance.CurrentFollower.AutoCollectSkill == "Smithing")
     {
         if (Player.Instance.CurrentFollower.TicksToNextAction <= 0)
         {
             Player.Instance.CurrentFollower.Inventory.AddMultipleOfItem(CurrentSmithingRecipe.Output, CurrentSmithingRecipe.OutputAmount);
             AutoSmithedItemCount -= CurrentSmithingRecipe.OutputAmount;
             MessageManager.AddMessage(Player.Instance.CurrentFollower.Name + " gathers up a cooled " + CurrentSmithingRecipe.OutputItemName + ".");
             Player.Instance.GainExperience(CurrentSmithingRecipe.ExperienceGained);
             if (GameState.CurrentArtisanTask != null)
             {
                 if (GameState.CurrentArtisanTask.ItemName == CurrentSmithingRecipe.OutputItemName)
                 {
                     if (long.TryParse(CurrentSmithingRecipe.ExperienceGained.Split(':')[1], out long xp))
                     {
                         Player.Instance.GainExperience("Artisan", xp / 5);
                     }
                     else
                     {
                         Player.Instance.GainExperience("Artisan", 15);
                     }
                 }
             }
             Player.Instance.CurrentFollower.TicksToNextAction = Player.Instance.CurrentFollower.AutoCollectSpeed;
             if (AutoSmithedItemCount <= 0)
             {
                 SmithingStage = 4;
             }
         }
         else
         {
             Player.Instance.CurrentFollower.TicksToNextAction--;
         }
     }
 }
Example #14
0
 public void Tick()
 {
     if (HasFallen)
     {
         CurrentTick++;
         if (CurrentTick >= TicksToRise)
         {
             HasFallen = false;
         }
     }
     else
     {
         if (Fall)
         {
             CurrentTick--;
             if (CurrentTick <= 0)
             {
                 MessageManager.AddMessage("The " + Position + " lilypad falls under the water!", "red");
                 HasFallen = true;
                 Fall      = false;
             }
         }
     }
 }
Example #15
0
    public void LevelUp()
    {
        if (Banking.GetSkillLevelUnboosted() >= AutoCollectLevel)
        {
            return;
        }
        if (Banking.GetSkillLevelUnboosted() % 2 == 0)
        {
            MessageManager.AddMessage(Name + " leveled up! Their banking level is now " + Banking.GetSkillLevelUnboosted() + ".");
            InventorySize++;
            Inventory.IncreaseMaxSizeBy(1);
        }
        else
        {
            MessageManager.AddMessage(Name + " leveled up!");
        }

        Banking.SetSkillLevel(Banking.GetSkillLevelUnboosted() + 1);

        if (Banking.Experience >= Skill.GetExperienceRequired(Banking.GetSkillLevelUnboosted()))
        {
            LevelUp();
        }
    }
Example #16
0
    public static async Task LoadSaveGame(string mode)
    {
        var serializerSettings = new JsonSerializerSettings {
            ObjectCreationHandling = ObjectCreationHandling.Replace
        };
        int errorcode = 0;

        try
        {
            if (await ContainsKeyAsync("NewSaveCompression"))
            {
                GameState.UseNewSaveCompression = true;
            }
            if (mode == "Normal")
            {
                GameState.CurrentGameMode = GameState.GameType.Normal;
            }
            else if (mode == "Hardcore")
            {
                GameState.CurrentGameMode = GameState.GameType.Hardcore;
            }
            else if (mode == "Ultimate")
            {
                GameState.CurrentGameMode = GameState.GameType.Ultimate;
            }

            if (await ContainsKeyAsync("Playtime:" + mode))
            {
                GameState.CurrentTick = int.Parse(Decompress(await GetItemAsync <string>("Playtime:" + mode)));
            }
            errorcode++; //1
            if (await ContainsKeyAsync("LastSave:" + mode))
            {
                LastSave = DateTime.Parse(await GetItemAsync <string>("LastSave:" + mode), System.Globalization.CultureInfo.InvariantCulture);
            }
            errorcode++; //2
            if (await ContainsKeyAsync("Skills:" + mode))
            {
                string[] data = Decompress(await GetItemAsync <string>("Skills:" + mode)).Split(',');
                foreach (string d in data)
                {
                    if (d.Length > 1)
                    {
                        Player.Instance.Skills.Find(x => x.Name == d.Split(':')[0]).LoadExperience(long.Parse(d.Split(':')[1]));
                    }
                }
            }
            errorcode++; //3
            if (await ContainsKeyAsync("Inventory:" + mode))
            {
                Player.Instance.Inventory.Clear();
                Player.Instance.Inventory.LoadData(Decompress(await GetItemAsync <string>("Inventory:" + mode)));
            }
            errorcode++; //4
            if (await ContainsKeyAsync("Bank:" + mode))
            {
                Bank.Instance.Inventory.Clear();
                Bank.Instance.Inventory.LoadData(Decompress(await GetItemAsync <string>("Bank:" + mode)));
            }
            errorcode++; //5
            if (await ContainsKeyAsync("BankTabs:" + mode))
            {
                Bank.Instance.LoadTabs(DeserializeToList(Decompress(await GetItemAsync <string>("BankTabs:" + mode))));
            }
            errorcode++; //6
            if (await ContainsKeyAsync("Areas:" + mode))
            {
                AreaManager.Instance.LoadAreaSave(JsonConvert.DeserializeObject <List <AreaSaveData> >(Decompress(await GetItemAsync <string>("Areas:" + mode))));
            }
            errorcode++; //7
            if (await ContainsKeyAsync("Regions:" + mode))
            {
                AreaManager.Instance.LoadRegionSave(JsonConvert.DeserializeObject <List <RegionSaveData> >(Decompress(await GetItemAsync <string>("Regions:" + mode))));
            }
            errorcode++; //8
            if (await ContainsKeyAsync("Dungeons:" + mode))
            {
                AreaManager.Instance.LoadDungeonSaveData(JsonConvert.DeserializeObject <List <DungeonSaveData> >(Decompress(await GetItemAsync <string>("Dungeons:" + mode))));
            }
            errorcode++; //9
            if (await ContainsKeyAsync("Quests:" + mode))
            {
                QuestManager.Instance.LoadQuestSave(JsonConvert.DeserializeObject <List <QuestSaveData> >(Decompress(await GetItemAsync <string>("Quests:" + mode))));
            }
            errorcode++; //10
            if (await ContainsKeyAsync("GameState:" + mode))
            {
                GameState.LoadSaveData(JsonConvert.DeserializeObject <GameStateSaveData>(Decompress(await GetItemAsync <string>("GameState:" + mode))));
            }
            errorcode++; //11
            if (await ContainsKeyAsync("Followers:" + mode))
            {
                FollowerManager.Instance.LoadSaveData(Decompress2(await GetItemAsync <string>("Followers:" + mode)));
            }
            errorcode++; //12
            if (await ContainsKeyAsync("Player:" + mode))
            {
                Player.Instance.LoadSaveData(JsonConvert.DeserializeObject <PlayerSaveData>(Decompress(await GetItemAsync <string>("Player:" + mode))));
            }
            errorcode++; //13
            if (await ContainsKeyAsync("TanningInfo:" + mode))
            {
                AreaManager.Instance.LoadTanningSave(JsonConvert.DeserializeObject <List <TanningSaveData> >(Decompress(await GetItemAsync <string>("TanningInfo:" + mode))));
            }
            errorcode++; //14
            if (await ContainsKeyAsync("Dojos:" + mode))
            {
                AreaManager.Instance.LoadDojoSaveData(JsonConvert.DeserializeObject <List <DojoSaveData> >(Decompress(await GetItemAsync <string>("Dojos:" + mode))));
            }
            errorcode++; //15
            if (await ContainsKeyAsync("AFKAction:" + mode))
            {
                GameState.LoadAFKActionData(JsonConvert.DeserializeObject <AFKAction>(Decompress(await GetItemAsync <string>("AFKAction:" + mode))));
            }
            errorcode++; //16
            if (await ContainsKeyAsync("Tomes:" + mode))
            {
                ItemManager.Instance.Tomes = JsonConvert.DeserializeObject <List <TomeData> >(Decompress(await GetItemAsync <string>("Tomes:" + mode)));
            }
            errorcode++; //17
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
            Console.WriteLine(e.StackTrace);
            MessageManager.AddMessage("Failed to load save. Error code:" + errorcode);
        }

        //Console.WriteLine(Compress("This is a test of what I can do"));
    }
Example #17
0
 public void DoEffect(Monster m)
 {
     MessageManager.AddMessage("An enemy Chill Chicken has come to protect its egg!");
 }
Example #18
0
 private void SmithItem()
 {
     if (CurrentSmeltingRecipe == null || CurrentSmithingRecipe == null)
     {
         Console.WriteLine("Failed to start smithing, Smelting Item is null:" + (CurrentSmeltingRecipe == null) + " and Smithing Item is null:" + (CurrentSmithingRecipe == null));
         return;
     }
     if (SmithingManager.SmithingStage == 0)
     {
         if (Player.Instance.CurrentFollower != null && Player.Instance.CurrentFollower.AutoCollectSkill == "Smithing")
         {
             SmithingManager.AutoSmithedItemCount = 0;
             SmithingManager.GetAutoSmeltingMaterials(CurrentSmeltingRecipe);
         }
         else if (SmithingManager.DoSmelting(CurrentSmeltingRecipe))
         {
             TicksToNextAction = CurrentSmeltingRecipe.CraftingSpeed;
         }
         else
         {
             if (SmithingComponent != null)
             {
                 SmithingComponent.UpdateSmeltables();
             }
             MessageManager.AddMessage("You have run out of ores.");
             StopActions();
             SmithingManager.SmithingStage = 0;
         }
     }
     else if (SmithingManager.SmithingStage == 1)
     {
         if (Player.Instance.CurrentFollower != null && Player.Instance.CurrentFollower.AutoCollectSkill == "Smithing")
         {
             SmithingManager.DoAutoSmelting(CurrentSmeltingRecipe, CurrentSmithingRecipe);
         }
         else if (SmithingManager.DoSmithing(CurrentSmeltingRecipe, CurrentSmithingRecipe))
         {
             TicksToNextAction = CurrentSmithingRecipe.CraftingSpeed;
         }
         else
         {
             if (SmithingComponent != null)
             {
                 SmithingComponent.UpdateSmeltables();
             }
             StopActions();
         }
     }
     else if (SmithingManager.SmithingStage == 2)
     {
         if (Player.Instance.CurrentFollower != null && Player.Instance.CurrentFollower.AutoCollectSkill == "Smithing")
         {
             SmithingManager.DoAutoSmithing(CurrentSmithingRecipe);
         }
         else if (Player.Instance.Inventory.AddMultipleOfItem(CurrentSmithingRecipe.Output, CurrentSmithingRecipe.OutputAmount))
         {
             MessageManager.AddMessage("You withdraw " + CurrentSmithingRecipe.OutputAmount + " " + CurrentSmithingRecipe.Output.Name);
             Player.Instance.GainExperience(CurrentSmithingRecipe.ExperienceGained);
             if (CurrentArtisanTask != null)
             {
                 if (CurrentArtisanTask.ItemName == CurrentSmithingRecipe.OutputItemName)
                 {
                     if (long.TryParse(CurrentSmithingRecipe.ExperienceGained.Split(':')[1], out long xp))
                     {
                         Player.Instance.GainExperience("Artisan", xp / 5);
                     }
                     else
                     {
                         Player.Instance.GainExperience("Artisan", 15);
                     }
                 }
             }
             TicksToNextAction             = 12;
             SmithingManager.SmithingStage = 0;
         }
     }
     else if (SmithingManager.SmithingStage == 3)
     {
         if (Player.Instance.CurrentFollower != null && Player.Instance.CurrentFollower.AutoCollectSkill == "Smithing")
         {
             SmithingManager.DoAutoWithdrawal(CurrentSmithingRecipe);
         }
     }
     else if (SmithingManager.SmithingStage == 4)
     {
         if (Player.Instance.CurrentFollower != null && Player.Instance.CurrentFollower.AutoCollectSkill == "Smithing")
         {
             SmithingManager.DepositOutputs();
         }
     }
 }
Example #19
0
 private void AlchItem()
 {
     if (AlchemyStage == 0)
     {
         if (Player.Instance.Inventory.HasItem(CurrentAlchemyFormula.InputMetal))
         {
             Player.Instance.Inventory.RemoveItems(CurrentAlchemyFormula.InputMetal, 1);
             AlchemyStage      = 1;
             TicksToNextAction = 10;
             MessageManager.AddMessage("You place the " + CurrentAlchemyFormula.InputMetal.Name + " into the pool.");
         }
         else
         {
             if (AlchemicalHallComponent != null)
             {
                 AlchemicalHallComponent.UpdateLists();
             }
             MessageManager.AddMessage("You don't have any " + CurrentAlchemyFormula.InputMetal.Name + "s.");
             CurrentAlchemyFormula = null;
             AlchemyStage          = 0;
         }
     }
     else if (AlchemyStage == 1)
     {
         if (Player.Instance.Inventory.HasItem(CurrentAlchemyFormula.Element))
         {
             Player.Instance.Inventory.RemoveItems(CurrentAlchemyFormula.Element, 1);
             AlchemyStage      = 2;
             TicksToNextAction = 10;
             MessageManager.AddMessage("You apply the " + CurrentAlchemyFormula.Element.Name + " to the metal mixture in the pool.");
         }
         else
         {
             if (AlchemicalHallComponent != null)
             {
                 AlchemicalHallComponent.UpdateLists();
             }
             MessageManager.AddMessage("You don't have any " + CurrentAlchemyFormula.Element.Name + ".");
             CurrentAlchemyFormula = null;
             AlchemyStage          = 0;
         }
     }
     else if (AlchemyStage == 2)
     {
         MessageManager.AddMessage("You " + CurrentAlchemyFormula.ActionString + " the combined element and metal.");
         AlchemyStage      = 3;
         TicksToNextAction = 10;
         if (AlchemicalHallComponent != null)
         {
             AlchemicalHallComponent.UpdateLists();
         }
     }
     else if (AlchemyStage == 3)
     {
         GameItem reward = ItemManager.Instance.GetItemFromFormula(CurrentAlchemyFormula).Copy();
         if (reward == null)
         {
             reward = ItemManager.Instance.GetItemByName("Alchemical Dust");
         }
         MessageManager.AddMessage("You withdraw the " + reward.Name + " from the release valve.");
         Player.Instance.Inventory.AddItem(reward);
         if (reward.Name == "Alchemical Dust")
         {
             StopActions();
         }
         AlchemyStage      = 0;
         TicksToNextAction = 10;
         if (AlchemicalHallComponent != null)
         {
             AlchemicalHallComponent.UpdateLists();
         }
     }
 }
Example #20
0
 private void CraftItem()
 {
     if (CurrentRecipe == null)
     {
         return;
     }
     else if (BattleManager.Instance.BattleHasEnded == false)
     {
         MessageManager.AddMessage("You can't make that while fighting!");
         CurrentRecipe = null;
         return;
     }
     if (CurrentRecipe.Create(out int created))
     {
         TicksToNextAction = CurrentRecipe.CraftingSpeed;
         MessageManager.AddMessage(CurrentRecipe.GetOutputsString().Replace("$", (created * CurrentRecipe.OutputAmount).ToString()));
         if (CurrentRecipe.CanCreate() == false)
         {
             if (CurrentRecipe.HasSpace())
             {
                 CurrentRecipe.Output.Rerender = true;
                 MessageManager.AddMessage("You have run out of materials.");
                 if (OvenComponent != null)
                 {
                     OvenComponent.Source = "";
                 }
             }
             else
             {
                 MessageManager.AddMessage("You don't have enough inventory space to do it again.");
             }
             if (CurrentRecipe != null)
             {
                 foreach (Ingredient i in CurrentRecipe.Ingredients)
                 {
                     i.Item.Rerender = true;
                 }
             }
             CurrentRecipe = null;
             itemViewer.ClearItem();
         }
         if (CurrentRecipe != null)
         {
             foreach (Ingredient i in CurrentRecipe.Ingredients)
             {
                 i.Item.Rerender = true;
             }
         }
     }
     else
     {
         if (CurrentRecipe.Ingredients.Count == 1 && CurrentRecipe.Ingredients[0].Item.Name == itemViewer.Item.Name && CurrentRecipe.HasSpace())
         {
             itemViewer.ClearItem();
             MessageManager.AddMessage("You have run out of materials.");
             CurrentRecipe.Output.Rerender = true;
             if (OvenComponent != null)
             {
                 OvenComponent.Source = "";
             }
         }
         foreach (Ingredient i in CurrentRecipe.Ingredients)
         {
             i.Item.Rerender = true;
         }
         CurrentRecipe = null;
     }
     if (CraftingComponent != null)
     {
         CraftingComponent.ReloadRecipes();
     }
 }
Example #21
0
 private void RollForDrops(Monster opponent)
 {
     if (opponent.DropTable != null && (opponent.DropTable.Drops.Count > 0 || opponent.DropTable.AlwaysDrops.Count > 0))
     {
         Drop drop = opponent.DropTable.GetDrop();
         if (drop != null)
         {
             if (LootTracker.Instance.TrackLoot)
             {
                 foreach (Drop d in opponent.DropTable.AlwaysDrops)
                 {
                     LootTracker.Instance.Inventory.AddDrop(d);
                 }
                 LootTracker.Instance.Inventory.AddDrop(drop);
             }
             else
             {
                 if (drop.Amount > 1)
                 {
                     MessageManager.AddMessage("You defeated the " + opponent.Name + ". It dropped " + drop.Amount + " " + drop.Item.GetPlural() + ".", "white", "Loot");
                 }
                 else
                 {
                     MessageManager.AddMessage("You defeated the " + opponent.Name + ". It dropped 1 " + drop.ToString() + ".", "white", "Loot");
                 }
                 if (drop.Item != null && drop.Item.Category == "QuestItems" && (Player.Instance.Inventory.HasItem(drop.Item) || Bank.Instance.Inventory.HasItem(drop.Item)))
                 {
                 }
                 else
                 {
                     Player.Instance.Inventory.AddDrop(drop);
                 }
             }
         }
         foreach (Drop d in opponent.DropTable.AlwaysDrops)
         {
             if (d.Amount > 1)
             {
                 if (drop != null)
                 {
                     MessageManager.AddMessage("You also got " + d.Amount + " " + d.Item.GetPlural() + ".", "white", "Loot");
                 }
                 else
                 {
                     MessageManager.AddMessage("You got " + d.Amount + " " + d.Item.GetPlural() + ".", "white", "Loot");
                 }
             }
             else
             {
                 if (drop != null)
                 {
                     MessageManager.AddMessage("You also got 1 " + d.ToString() + ".", "white", "Loot");
                 }
                 else
                 {
                     MessageManager.AddMessage("You got 1 " + d.ToString() + ".", "white", "Loot");
                 }
             }
             Player.Instance.Inventory.AddDrop(d);
         }
     }
     else
     {
         MessageManager.AddMessage("You defeated the " + opponent.Name + ".");
     }
 }
Example #22
0
    /// <summary>
    /// “保存”按钮
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["MessageId"] != null)
        {
            //修改
            int messageId = Convert.ToInt32(Request.QueryString["MessageId"]);

            Message message = MessageManager.GetMessageById(messageId);
            message.Title     = txtTitle.Text.ToString();
            message.Content   = txtContent.Text.ToString();
            message.BeginTime = Convert.ToDateTime(txtBeginTime.Text);
            message.EndTime   = Convert.ToDateTime(txtEndTime.Text);
            int typeId = Convert.ToInt32(ddlMessageType.SelectedValue);
            message.Type = MessageTypeManager.GetMessageTypeById(typeId);
            MessageManager.UpdateMessage(message);
            Response.Redirect("MessageManage.aspx");
        }
        else
        {
            try
            {
                //添加
                User    user = (User)Session["Login"];
                Message item = new Message();
                item.Title              = txtTitle.Text;
                item.BeginTime          = Convert.ToDateTime(txtBeginTime.Text);
                item.EndTime            = Convert.ToDateTime(txtEndTime.Text);
                item.Type.MessageTypeId = Convert.ToInt32(ddlMessageType.SelectedValue);
                item.Content            = txtContent.Text;
                item.FromUser.UserId    = user.UserId;
                item.RecordTime         = DateTime.Now;
                item.IfPublish          = 0;
                item.IfDelete           = 0;
                item.IfDeleteTo         = 0;
                int messageId = MessageManager.AddMessage(item);
                if (messageId > 0)
                {
                    if (rdoSendObj.SelectedValue == "0") //公共消息
                    {
                        MessageToUser messageToUser = new MessageToUser();
                        messageToUser.Message.MessageId = messageId;
                        messageToUser.ToUser.UserId     = "0";
                        messageToUser.IfRead            = 0;
                        bool result = MessageToUserManager.AddMessageToUser(messageToUser);
                        if (result)
                        {
                            Response.Redirect("MessageManage.aspx");
                        }
                    }
                    else if (rdoSendObj.SelectedValue == "1")           //添加特定对象消息
                    {
                        foreach (ListItem li in chklstSelectUser.Items) //循环特定的对象
                        {
                            if (li.Selected)
                            {
                                MessageToUser messageToUser = new MessageToUser();
                                messageToUser.Message.MessageId = messageId;
                                messageToUser.IfRead            = 0;
                                messageToUser.ToUser.UserId     = li.Value;
                                bool result = MessageToUserManager.AddMessageToUser(messageToUser);
                            }
                        }
                        Response.Redirect("MessageManage.aspx");
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
    }
Example #23
0
 public void StartAutoFighting()
 {
     autoFight            = true;
     gameState.isFighting = true;
     if (gameState.autoFightTimer != null)
     {
         gameState.autoFightTimer.Dispose();
         gameState.autoFightTimer = null;
     }
     messageManager.AddMessage(gameState.GetPlayer().activeFollower.Name + " looks for an enemy for you to fight.");
     gameState.autoFightTimer = new Timer(new TimerCallback(_ =>
     {
         AutoBattle();
     }), null, gameState.GetPlayer().activeFollower.AutoCollectSpeed, gameState.GetPlayer().activeFollower.AutoCollectSpeed);
     gameState.UpdateState();
 }
Example #24
0
    public void Talk()
    {
        if (NPCManager.Instance.CustomDialogFunctions.TryGetValue(ResponseWithParameter, out Action a))
        {
            a.Invoke();
            if (Quest != "None" && NewQuestProgressValue != -1)
            {
                if (NewQuestProgressValue == 1 && QuestManager.Instance.GetQuestByName(Quest).Progress == 0 && HasStartedQuest == false)
                {
                    HasStartedQuest = true;
                    MessageManager.AddMessage("You've started the quest " + Quest + ".", "#00ff00");
                }
                QuestManager.Instance.GetQuestByName(Quest).Progress = NewQuestProgressValue;
                if (CompleteQuest)
                {
                    QuestManager.Instance.GetQuestByName(Quest).Complete();
                }
            }
            return;
        }
        if (ItemOnTalk != "None")
        {
            if (Player.Instance.Inventory.AddItem(ItemManager.Instance.GetItemByName(ItemOnTalk).Copy()) == false)
            {
                MessageManager.AddMessage("Your inventory is full! Come back after you store something in your bank.", "red");
                return;
            }
        }
        if (ConsumeRequiredItems)
        {
            foreach (Requirement r in Requirements)
            {
                if (r.Item != "None")
                {
                    if (Player.Instance.Inventory.GetNumberOfItem(ItemManager.Instance.GetItemByName(r.Item)) < r.ItemAmount)
                    {
                        if (r.ItemAmount == 1)
                        {
                            MessageManager.AddMessage("You need a " + r.Item + ".", "red");
                        }
                        else
                        {
                            MessageManager.AddMessage("You don't have enough " + r.Item + ".(" + r.ItemAmount + ")", "red");
                        }

                        return;
                    }
                }
            }
            foreach (Requirement r in Requirements)
            {
                if (r.Item != "None")
                {
                    Player.Instance.Inventory.RemoveItems(ItemManager.Instance.GetItemByName(r.Item), r.ItemAmount);
                }
            }
        }
        if (UnlockedFollower != "None")
        {
            FollowerManager.Instance.GetFollowerByName(UnlockedFollower).IsUnlocked = true;
        }
        MessageManager.AddMessage(ResponseText);
        if (Quest != "None" && NewQuestProgressValue != -1)
        {
            if (NewQuestProgressValue == 1 && QuestManager.Instance.GetQuestByName(Quest).Progress == 0 && HasStartedQuest == false)
            {
                HasStartedQuest = true;
                MessageManager.AddMessage("You've started the quest " + Quest + ".", "#00ff00");
            }
            QuestManager.Instance.GetQuestByName(Quest).Progress = NewQuestProgressValue;
            if (CompleteQuest)
            {
                QuestManager.Instance.GetQuestByName(Quest).Complete();
            }
        }
    }
Example #25
0
    public void Attack()
    {
        if (Target == null || Target.IsDefeated)
        {
            if (CurrentOpponents == null || CurrentOpponents.Count == 0)
            {
                return;
            }
            Target = GetNextTarget();
        }
        RollForPlayerAttackEffects();
        int total = (int)Math.Max(1, Player.Instance.GetTotalDamage().ToRandomDamage() * CalculateTypeBonus(Target));

        if (Target.CurrentStatusEffects.OfType <CleaveEffect>().Any())
        {
        }
        else
        {
            total = (int)Math.Max(total * Extensions.CalculateArmorDamageReduction(Target), 1);
        }
        total             = (int)Math.Min(Target.CurrentHP, total);
        Target.CurrentHP -= total;

        if (Player.Instance.GetWeapon() == null)
        {
            Player.Instance.GainExperience("Strength", total);
            Player.Instance.GainExperience("Deftness", total / 3);
            MessageManager.AddMessage("You punch the " + Target.Name + " for " + total + " damage!");
        }
        else
        {
            if (Player.Instance.GetWeapon().EnabledActions == "Archery")
            {
                if (Player.Instance.GetWeapon().Name == "Spine Shooter")
                {
                    if (Player.Instance.Inventory.HasItem("Cactus Spines"))
                    {
                        Player.Instance.GainExperienceFromWeapon(Player.Instance.GetWeapon(), total);
                        MessageManager.AddMessage("You shoot the " + Target.Name + " for " + total + " damage!");
                        Player.Instance.Inventory.RemoveItems(ItemManager.Instance.GetItemByName("Cactus Spines"), 1);
                    }
                    else
                    {
                        Player.Instance.GainExperience("Strength", total);
                        MessageManager.AddMessage("You whack the " + Target.Name + " with your spine shooter for " + total + " damage!");
                    }
                }
                else
                {
                    if (Player.Instance.Inventory.HasArrows())
                    {
                        Player.Instance.GainExperienceFromWeapon(Player.Instance.GetWeapon(), total);
                        MessageManager.AddMessage("You hit the " + Target.Name + " for " + total + " damage!");
                        Player.Instance.Inventory.RemoveItems(Player.Instance.Inventory.GetStrongestArrow(), 1);
                    }
                    else
                    {
                        Player.Instance.GainExperience("Strength", total);
                        MessageManager.AddMessage("You whack the " + Target.Name + " with your bow for " + total + " damage!");
                    }
                }
            }
            else
            {
                Player.Instance.GainExperienceFromWeapon(Player.Instance.GetWeapon(), total);
                MessageManager.AddMessage("You hit the " + Target.Name + " for " + total + " damage!");
            }
        }


        if (Target.IsDefeated)
        {
            Target = GetNextTarget();
        }
    }
Example #26
0
 public void ChangeWorldColor(string color)
 {
     GameState.BGColor = color;
     MessageManager.AddMessage("The world changes colors as the man disappears in a puff of smoke.");
 }
Example #27
0
 public void AddMessagesToMessageManager(MessageManager msgMgr, String language, int locale)
 {
     msgMgr.AddLanguage(language, locale);
     msgMgr.AddMessage("pur_badsku", "One or more items were removed from the basket", language);
     msgMgr.AddMessage("pur_noitems", "No items were found in the basket", language);
     msgMgr.AddMessage("pur_badplacedprice", "Placed price was not correct", language);
     msgMgr.AddMessage("pur_discount_changed", "One or more discounts have changed", language);
     msgMgr.AddMessage("pur_discount_removed", "One or more discounts no longer apply", language);
     msgMgr.AddMessage("pur_badshipping", "Unable to complete order: cannot compute shipping cost", language);
     msgMgr.AddMessage("pur_badhandling", "Unable to complete order: cannot compute handling cost", language);
     msgMgr.AddMessage("pur_badtax", "Unable to complete order: cannot compute tax", language);
     msgMgr.AddMessage("pur_badcc", "The credit-card number you provided is not valid. Please verify your payment information or use a different card", language);
     msgMgr.AddMessage("pur_badpayment", "There was a problem authorizing your credit. Please verify your payment information or use a different card", language);
     msgMgr.AddMessage("pur_badverify", "Changes to the data require your review. Please review and re-submit", language);
     msgMgr.AddMessage("pur_out_of_stock", "At least one item is out of stock", language);
     msgMgr.AddMessage("unknown_shipping_method", "The selected shipping method is not currently available.  Please choose another shipping method", language);
 }
Example #28
0
 public void OnSpecialAttack()
 {
     Player.Instance.TicksToNextAttack = Player.Instance.GetWeaponAttackSpeed();
     MessageManager.AddMessage("The Gashadokuro slams the bridge, you lose your balance and need to recover before attacking!", "red");
     TicksToNextSpecialAttack = SpecialAttackSpeed;
 }
Example #29
0
    public void DoBattle()
    {
        if (BattleHasEnded == false)
        {
            foreach (Monster opponent in CurrentOpponents)
            {
                if (opponent.IsDefeated)
                {
                    opponent.TicksToNextAttack = opponent.AttackSpeed;
                }
                else
                {
                    opponent.TicksToNextAttack--;
                }
            }
            Player.Instance.TicksToNextAttack--;
            if (Player.Instance.TicksToNextAttack < 0)
            {
                Attack();
                if (CurrentBoss != null)
                {
                    CurrentBoss.OnBeAttacked(Target);
                }
                Player.Instance.TicksToNextAttack = Player.Instance.GetWeaponAttackSpeed();
            }
            foreach (Monster opponent in CurrentOpponents)
            {
                if (opponent.CurrentHP <= 0 && opponent.IsDefeated == false)
                {
                    opponent.CurrentHP = 0;
                    Drop drop = opponent.DropTable.GetDrop();

                    if (LootTracker.Instance.TrackLoot)
                    {
                        foreach (Drop d in opponent.DropTable.AlwaysDrops)
                        {
                            LootTracker.Instance.Inventory.AddDrop(d);
                        }
                        LootTracker.Instance.Inventory.AddDrop(drop);
                    }
                    else
                    {
                        MessageManager.AddMessage("You defeated the " + opponent.Name + ".");
                        foreach (Drop d in opponent.DropTable.AlwaysDrops)
                        {
                            Player.Instance.Inventory.AddDrop(d);
                        }
                        Player.Instance.Inventory.AddDrop(drop);
                    }

                    opponent.IsDefeated = true;
                    if (CurrentBoss != null)
                    {
                        CurrentBoss.OnDie(opponent);
                    }
                }
                else if (opponent.TicksToNextAttack < 0 && opponent.IsDefeated == false)
                {
                    if (CurrentBoss != null && CurrentBoss.CustomAttacks)
                    {
                        CurrentBoss.OnAttack();
                    }
                    else if (CurrentBoss != null)
                    {
                        CurrentBoss.OnAttack();
                        BeAttacked(opponent);
                    }
                    else
                    {
                        BeAttacked(opponent);
                    }
                    opponent.TicksToNextAttack = opponent.AttackSpeed;
                }
            }
            if (AllOpponentsDefeated())
            {
                if (CurrentDojo != null)
                {
                    CurrentDojo.CurrentOpponent++;
                    if (CurrentDojo.CurrentOpponent >= CurrentDojo.Opponents.Count)
                    {
                        CurrentDojo.LastWinTime = DateTime.Now;
                    }
                }
                WonLastBattle = true;
                EndBattle();
            }
            if (CurrentBoss != null)
            {
                CurrentBoss.TicksToNextSpecialAttack--;
                if (CurrentBoss.TicksToNextSpecialAttack <= 0)
                {
                    CurrentBoss.OnSpecialAttack();
                }
            }

            if (Player.Instance.CurrentHP <= 0)
            {
                Player.Instance.Die();
                WonLastBattle = false;
            }
        }
    }
Example #30
0
 public void AddMessage(string message)
 {
     _MessageMan.AddMessage(message);
 }