public void LinkMessageController(MessageOverlayController controller) { foreach (Quest q in Quests) { q.LinkMessageController(controller); } }
public void ProcessBonusCode(string code) { //Get bonus from code. If the function returns null, the code wasn't found List <string> rewards = _networkManager.BonusGetBonus(code); if (rewards == null) { return; } string bonusCodeDetails = null; switch (rewards[0]) { //int id, int count case "ITEM": { int id = int.Parse(rewards[1]); int count = int.Parse(rewards[2]); _inventory.QueueItemForAddition(id, count); if (count == 1) { bonusCodeDetails = "Item received!"; } else { bonusCodeDetails = "Items received!"; } break; } //int count case "SKILLPOINTS": { int count = int.Parse(rewards[1]); _stats.AddSkillPoints(count); bonusCodeDetails = count.ToString() + " skill points received!"; break; } //int count case "STATPOINTS": { int count = int.Parse(rewards[1]); _stats.AddStatPoints(count); bonusCodeDetails = count.ToString() + " stat points received!"; break; } } //Save that code has been redeemed _networkManager.BonusCodeActivate(code); //Lastly, notify the player that the bonus code has been redeemed MessageOverlayController messageController = GameObject.FindGameObjectWithTag("MessageOverlay").GetComponent <MessageOverlayController>(); messageController.EnqueueMessage("Bonus code redeemed!"); messageController.EnqueueMessage(bonusCodeDetails); }
// Clears the values currently on the HUD public static void ResetHUD() { if (SettingsMenu.settingsData.hudEnabled == 1) { EnableHUD(); if (BurnPercentageMeter) { BurnPercentageMeter.Clear(); TargetOverlayController.Clear(); ThrowingAmmoMeter.Clear(); MetalReserveMeters.Clear(); MessageOverlayController.Clear(); ZincMeterController.Clear(); } } }
//Quality player up public void LevelUp() { //Increase level by 1 PlayerLevel++; //Add two skill point AddSkillPoints(2); //Add four stat points AddStatPoints(4); //Save all this _network.DBGainLevel(); _network.UpdatePlayerStat("Level", PlayerLevel.ToString()); //Notify user if (_messageOverlay == null) { _messageOverlay = GameObject.FindGameObjectWithTag("MessageOverlay").GetComponent <MessageOverlayController>(); } _messageOverlay.EnqueueMessage("Level up!"); }
/* This would be called when the user has logged in. First, it loads all the quests from a local database into the QuestManager. * Then, it loads the current quest status from the server, and adjusts the quest state for each of the quests. All this relies * on features that the game doesn't currently have, so for now it just creates a sample quest and activates it */ void Start() { Quests = new List <Quest>(); //Get link to player controller and inventory player = GetComponentInParent <PlayerController>(); inventory = GetComponentInParent <Inventory>(); em = GetComponent <EventManager>(); //Get link to database - guaranteed to exist before this is created db = GameObject.Find("DatabaseManager").GetComponent <NetworkManager>(); mc = GameObject.FindGameObjectWithTag("MessageOverlay").GetComponent <MessageOverlayController>(); InitializeAllQuests(); db.RetrievePlayerQuestProgress(this); //GetQuest(10).RestartQuest(); //Unlock any quests if content lock has updated UnlockContentLockedQuests(); }
// Use this for initialization void Start() { _messageOverlay = null; _network = GameObject.Find("DatabaseManager").GetComponent <NetworkManager>(); PlayerLevel = 1; XP = 0; SkillPoints = 0; StatPoints = 0; PhysicalAttack = 10; MagicalAttack = 10; PhysicalDefense = 10; MagicalDefense = 10; BaseHealth = 400; Speed = 10f; IsEnemy = false; TauntTarget = null; StartCoroutine(SecondTick()); }
//Initializer, accepts arguments for the above public variables public Quest(double id, string name, string description, List <QuestObjective> objectives, List <FallbackObjective> fallbackObjectives, List <GameReward> questRewards, PlayerController linkToPlayerController, Inventory linkToPlayerInventory, NetworkManager linkToDatabaseManager, MessageOverlayController linkToMessageController, EventManager linkToEventManager) { //Initialize variables ID = id; Name = name; Description = description; _state = QuestState.INACTIVE; _numberOfCompletions = 0; QuestRewards = questRewards; _inactive = objectives; _active = new List <QuestObjective>(); _completed = new List <QuestObjective>(); _inactiveFallback = fallbackObjectives ?? new List <FallbackObjective>(); //Creates empty list if passed parameter is null _activeFallback = new List <FallbackObjective>(); _playerController = linkToPlayerController; _playerInventory = linkToPlayerInventory; _databaseManager = linkToDatabaseManager; _eventManager = linkToEventManager; _messageController = linkToMessageController; _messagesToDisplay = new List <string>(); }
public void UpdateAchievements(List <object> worldEvent) { //Get the achievement stat that matches this event AchievementStat stat = null; GameAction? action = worldEvent[0] as GameAction?; if (action == null) { return; //Just in case } foreach (AchievementStat s in _achievementStats) { if (action == s.Stat) { stat = s; break; } } //If nothing matches the event, return if (stat == null) { return; } //Update this stat's value, depending on the message type switch (action) { //Format: <ACTION> <ID> <QUANTITY>. We want quantity case GameAction.CRAFTED: case GameAction.CONSUMED: case GameAction.DISCARDED: case GameAction.DROPPED: //Not implemented case GameAction.LOOTED: //Not implemented case GameAction.NPC_GIVE: case GameAction.NPC_RECEIVE: case GameAction.PICKED_UP: case GameAction.QUEST_CONSUMED: //Not implemented case GameAction.TRADE_GIVE: //Not implemented case GameAction.TRADE_RECEIVED: //Not implemented if (worldEvent[2] is int) //Just in case { stat.AddToValue((int)worldEvent[2]); } break; //Format: <ACTION>. Just increment stat by one case GameAction.ATTACK_MAGIC: case GameAction.ATTACK_MELEE: case GameAction.ATTACK_RANGED: case GameAction.ATTACK_HEAL: case GameAction.MONSTER_KILLED: case GameAction.MOUSE_CLICK: case GameAction.SECRET_AREA: default: stat.AddToValue(1); break; //Many action types are not included - these only send strings and thus can't be used here } //Save this update on the server _networkManager.UpdateAchievementStat(stat.ID, stat.Value); //Update all achievements that subscribe to this stat foreach (Achievement a in stat.Subscribers) { //Ignore completed achievements if (a.IsCompleted()) { continue; } //If this latest stat update completed the achievement, notify the user and save this to the server if (a.JustCompleted()) { //Notify user if (_messageOverlayController == null) { _messageOverlayController = GameObject.FindGameObjectWithTag("MessageOverlay").GetComponent <MessageOverlayController>(); } _messageOverlayController.EnqueueMessage("Achievement \"" + a.Name + "\" completed!"); //Save this to the server _networkManager.UpdateAchievement(a.ID, a.State); //Check for milestone completion int completedInGroup = a.Group.NumberCompleted(); foreach (AchievementMilestone m in a.Group.Milestones) { //Skip completed milestones if (m.IsCompleted()) { continue; } //If milestone has been completed, notify user and save to server if (m.Required <= completedInGroup) { m.Complete(); //Notify user _messageOverlayController.EnqueueMessage("\"" + a.Group.Name + "\" milestone completed!"); //Save to server _networkManager.UpdateMilestone(m.ID, m.State); } } } //Lastly, set that the achievement group has been modified a.Group.AnyChanges = true; } }
// Use this for initialization void Start() { _networkManager = GameObject.Find("DatabaseManager").GetComponent <NetworkManager>(); _messageOverlayController = GameObject.FindGameObjectWithTag("MessageOverlay").GetComponent <MessageOverlayController>(); Initialize(); }
//Links quest to message overlay controller public void LinkMessageController(MessageOverlayController controller) { _messageController = controller; }
// walk in octagonal pattern void Start() { npc = this.GetComponentInParent <NPC_Controller>(); messageController = GameObject.Find("Message Overlay").GetComponent <MessageOverlayController>(); ExecuteTestWalk(); }