Exemple #1
0
        /// <summary>
        /// Build a network representation of the <see cref="ActionSetShortcut"/>'s in the <see cref="ActionSet"/>.
        /// </summary>
        public ServerActionSet BuildServerActionSet()
        {
            var serverActionSet = new ServerActionSet
            {
                Index    = Index,
                Unknown3 = 1,
                Result   = LimitedActionSetResult.Ok
            };

            for (UILocation i = 0; i < (UILocation)MaxActionCount; i++)
            {
                ActionSetShortcut action = GetShortcut(i);
                serverActionSet.Actions.Add(new ServerActionSet.Action
                {
                    ShortcutType = action?.ShortcutType ?? ShortcutType.None,
                    ObjectId     = action?.ObjectId ?? 0,
                    Location     = new ItemLocation
                    {
                        // TODO: this might not be correct, what about shortcuts that aren't spells?
                        Location = action != null ? InventoryLocation.Ability : (InventoryLocation)300, // no idea why 300, this is what retail did
                        BagIndex = (uint)(action?.Location ?? i)
                    }
                });
            }

            return(serverActionSet);
        }
Exemple #2
0
    public void SetUI(UILocation location)
    {
        switch (location)
        {
        case UILocation.UP:
            _up.SetActive(true);
            slider = _up.GetComponentInChildren <Slider>();
            break;

        case UILocation.DOWN:
            _down.SetActive(true);
            slider = _down.GetComponentInChildren <Slider>();
            break;

        case UILocation.LEFT:
            _left.SetActive(true);
            slider = _left.GetComponentInChildren <Slider>();
            break;

        case UILocation.RIGHT:
            _right.SetActive(true);
            slider = _right.GetComponentInChildren <Slider>();
            break;
        }
        slider.maxValue = 1;
        slider.minValue = 0;
    }
Exemple #3
0
        /// <summary>
        /// Add shortcut to <see cref="ActionSet"/> to supplied <see cref="UILocation"/>.
        /// </summary>
        public void AddShortcut(UILocation location, ShortcutType type, uint objectId, byte tier)
        {
            if (actions.TryGetValue(location, out ActionSetShortcut shortcut) && !shortcut.PendingDelete)
            {
                throw new InvalidOperationException($"Failed to add shortcut {type} {objectId} to {location}, location is occupied!");
            }

            if (type == ShortcutType.Spell)
            {
                checked
                {
                    TierPoints -= CalculateTierCost(tier);
                }
            }

            if (shortcut != null)
            {
                shortcut.EnqueueDelete(false);
                shortcut.ShortcutType = type;
                shortcut.ObjectId     = objectId;
                shortcut.Tier         = tier;
            }
            else
            {
                actions.Add(location, new ActionSetShortcut(this, location, type, objectId, tier));
            }

            saveMask |= ActionSetSaveMask.ActionSetActions;

            log.Trace($"Added shortcut {type} {objectId} at {location} to action set {Index}.");
        }
Exemple #4
0
        /// <summary>
        /// Remove shortcut from <see cref="ActionSet"/> at supplied <see cref="UILocation"/>.
        /// </summary>
        public void RemoveShortcut(UILocation location)
        {
            ActionSetShortcut shortcut = GetShortcut(location);

            if (shortcut == null)
            {
                throw new ArgumentException($"Failed to remove shortcut from {location}, location isn't occupied!");
            }

            if (shortcut.ShortcutType == ShortcutType.Spell)
            {
                checked
                {
                    TierPoints += CalculateTierCost(shortcut.Tier);
                }
            }

            if (shortcut.PendingCreate)
            {
                actions.Remove(location);
            }
            else
            {
                shortcut.EnqueueDelete(true);
                saveMask |= ActionSetSaveMask.ActionSetActions;
            }

            log.Trace($"Removed shortcut {shortcut.ShortcutType} {shortcut.ObjectId} at {location} from action set {Index}.");
        }
Exemple #5
0
    private int vidas = 3;  // Número de vidas do jogador

    // ativa e reseta a barra de tempo
    public void SetUI(UILocation location)
    {
        GameObject barra;

        switch (location)
        {
        case UILocation.DOWN:
            barra = _down;
            break;

        case UILocation.LEFT:
            barra = _left;
            break;

        case UILocation.RIGHT:
            barra = _right;
            break;

        default:     //case UILocation.UP:
            barra = _up;
            break;
        }

        barra.SetActive(true);
        barra.GetComponentInChildren <Text>().text = "Vidas\n" + GameData.lives;
        slider = barra.GetComponentInChildren <Slider>();

        slider.maxValue = 1;
        slider.minValue = 0;
        slider.gameObject.SetActive(false);
    }
Exemple #6
0
        private void positionUI(GameObject ui, UILocation location)
        {
            RectTransform rt = ui.GetComponent <RectTransform>();
            //float w = rectTransform.sizeDelta.x;
            float h = rectTransform.sizeDelta.y;
            //float uiWidth = rt.sizeDelta.x * rt.localScale.x;
            float uiHeight = rt.sizeDelta.y * rt.localScale.y;
            float pos;

            switch (location)
            {
            case UILocation.BOTTOM:
                pos = uiHeight / 2 - h / 2;
                rt.anchoredPosition = new Vector2(rt.anchoredPosition.x, pos);
                break;

            case UILocation.TOP:
                pos = h / 2 - uiHeight / 2;
                rt.anchoredPosition = new Vector2(rt.anchoredPosition.x, pos);
                break;

            default:
                break;
            }
        }
Exemple #7
0
        /// <summary>
        /// Return <see cref="ActionSetShortcut"/> at supplied <see cref="UILocation"/>.
        /// </summary>
        public ActionSetShortcut GetShortcut(UILocation location)
        {
            if (!actions.TryGetValue(location, out ActionSetShortcut shortcut))
            {
                return(null);
            }

            return(shortcut.PendingDelete ? null : shortcut);
        }
Exemple #8
0
        void Awake()
        {
            if (Instance != null)
            {
                Debug.LogError("Multiple UIManger instances in the scene: " + Instance.name + " and " + name);
                return;
            }

            Instance = this;

            #region Gather screens
            screens          = GetComponentsInChildren <UIScreen>(true);
            screenDictionary = new Dictionary <UILocation, UIScreen>();

            // Ensure each screen location is unique
            for (int i = 0; i < screens.Length; i++)
            {
                UILocation location = screens[i].Location;

                if (location == UILocation.None)
                {
                    Debug.LogWarning(screens[i].name + " has None Location");
                }
                else if (screenDictionary.ContainsKey(location))
                {
                    Debug.LogWarning("Multiple screens with the location: " + location + ": " + screens[i].name + " and " + screenDictionary[location]);
                }
                else
                {
                    screenDictionary[location] = screens[i];
                }
            }

            // Ensure no screen location is missing
            for (int i = 1; i < System.Enum.GetNames(typeof(UILocation)).Length; i++)
            {
                UILocation location = (UILocation)i;

                if (!screenDictionary.ContainsKey(location))
                {
                    Debug.LogWarning("Missing screen with UILocation: " + location);
                }
            }
            #endregion

            if (inputBlocker == null)
            {
                Debug.LogError(name + " UIManager has no input blocker");
            }
            else
            {
                inputBlocker.transform.SetAsLastSibling();
                inputBlocker.enabled = false;
            }
        }
Exemple #9
0
        protected override void Awake()
        {
            base.Awake();
            UILocation table = UILocationAsset.Get(m_ID);

            if (table == null)
            {
                return;
            }
            this.text = m_AddColon ? table.Text + ":" : table.Text;
        }
Exemple #10
0
        public static void HandleRequestActionSetChanges(WorldSession session, ClientRequestActionSetChanges requestActionSetChanges)
        {
            // TODO: check for client validity, e.g. Level & Spell4TierRequirements

            ActionSet actionSet = session.Player.SpellManager.GetActionSet(requestActionSetChanges.ActionSetIndex);

            List <ActionSetShortcut> shortcuts = actionSet.Actions.ToList();

            for (UILocation i = 0; i < (UILocation)requestActionSetChanges.Actions.Count; i++)
            {
                ActionSetShortcut shortcut = actionSet.GetShortcut(i);
                if (shortcut != null)
                {
                    actionSet.RemoveShortcut(i);
                }

                uint spell4BaseId = requestActionSetChanges.Actions[(int)i];
                if (spell4BaseId != 0u)
                {
                    ActionSetShortcut existingShortcut = shortcuts.SingleOrDefault(s => s.ObjectId == spell4BaseId);
                    byte tier = existingShortcut?.Tier ?? 1;
                    actionSet.AddShortcut(i, ShortcutType.Spell, spell4BaseId, tier);
                }
            }

            foreach (ClientRequestActionSetChanges.ActionTier actionTier in requestActionSetChanges.ActionTiers)
            {
                session.Player.SpellManager.UpdateSpell(actionTier.Action, actionTier.Tier, requestActionSetChanges.ActionSetIndex);
            }

            session.EnqueueMessageEncrypted(actionSet.BuildServerActionSet());
            if (requestActionSetChanges.ActionTiers.Count > 0)
            {
                session.Player.SpellManager.SendServerAbilityPoints();
            }

            // only new AMP can be added with this packet, filter out existing ones
            List <ushort> newAmps = requestActionSetChanges.Amps
                                    .Except(actionSet.Amps
                                            .Select(a => (ushort)a.Entry.Id))
                                    .ToList();

            if (newAmps.Count > 0)
            {
                foreach (ushort id in newAmps)
                {
                    actionSet.AddAmp(id);
                }

                session.EnqueueMessageEncrypted(actionSet.BuildServerAmpList());
            }
        }
        public static void SendEvent(UIAction action, UILocation location)
        {
#if INCLUDE_DELTA_DNA
            if (!Application.isPlaying)
            {
                return;
            }

            DDNA.Instance.RecordEvent(AnalyticsUtils.GetGameEventWithProjectID(k_EventName)
                                      .AddParam(AnalyticsUtils.UserRoleParamName, AnalyticsUtils.CurrentUserRole)
                                      .AddParam(k_ActionParamName, action.ToString())
                                      .AddParam(k_LocationParamName, location.ToString()));
#endif
        }
Exemple #12
0
        /// <summary> Call to perform transition from current screen to location. Wait between screens for a time by setting waitTime. </summary>
        public static Coroutine Open(UILocation location, float waitTime = -1)
        {
            if (Instance == null)
            {
                Debug.LogError("Missing a UIManager instance in the scene.");
                return(null);
            }

            if (!IsInitialized)
            {
                IsInitialized = true;
            }
            return(Instance.OpenLocation(location, Mathf.Max(waitTime, Instance.baseWaitTime)));
        }
Exemple #13
0
        private Coroutine OpenLocation(UILocation location, float waitTime = 0)
        {
            UIScreen toOpen = screenDictionary.ContainsKey(location) ? screenDictionary[location] : null;

            if (toOpen == null)
            {
                Debug.LogWarning("Missing screen for UILocation: " + location);
            }

            if (!IsTransition)
            {
                return(StartCoroutine(SwitchToScreen(toOpen, waitTime)));
            }
            return(null);
        }
Exemple #14
0
        /// <summary>
        /// Add an existing spell to the specified action set.
        /// </summary>
        public void AddSpellToActionSet(byte actionSetIndex, uint spell4BaseId, UILocation location, byte tier = 1)
        {
            if (actionSetIndex >= ActionSet.MaxActionSets)
            {
                throw new ArgumentOutOfRangeException();
            }

            if (!spells.TryGetValue(spell4BaseId, out UnlockedSpell spell))
            {
                throw new ArgumentOutOfRangeException();
            }

            actionSets[actionSetIndex].AddSpell(spell, location, tier);
            spell.Tier = tier;
        }
Exemple #15
0
        /// <summary>
        /// Add <see cref="UnlockedSpell"/> to supplied <see cref="UILocation"/>.
        /// </summary>
        public void AddSpell(UnlockedSpell spell, UILocation location, byte tier)
        {
            byte tierPointCost = 0;

            for (byte i = spell.Tier; i <= tier; i++)
            {
                tierPointCost += (byte)(i == 5 || i == 9 ? 5 : 1);
            }

            TierPoints -= tierPointCost;

            if (tierPointCost > TierPoints)
            {
                throw new InvalidOperationException();
            }

            actions.Add(new ActionSetAction(4, spell.Entry.Id, location));
        }
Exemple #16
0
        public override void Init()
        {
            if (Instance == null)
            {
                Instance = this;
            }

            // we initialize to invalid
            CurrentLocation = UILocation.Invalid;

            // we grab the UI Root and we set it not to destroy so when we load different scenes
            // we can change objects and such :P
            UIRootGameObject = GameObject.FindGameObjectWithTag("UIRoot");
            UnityEngine.Object.DontDestroyOnLoad(UIRootGameObject);

            UIController[] controllers = UIRootGameObject.GetComponentsInChildren <UIController>(true);
            foreach (UIController item in controllers)
            {
                _controllers.Add(item);
            }
        }
Exemple #17
0
        public static void HandleCharacterCreate(WorldSession session, ClientCharacterCreate characterCreate)
        {
            try
            {
                // TODO: validate name and path
                if (DatabaseManager.Instance.CharacterDatabase.CharacterNameExists(characterCreate.Name))
                {
                    session.EnqueueMessageEncrypted(new ServerCharacterCreate
                    {
                        Result = CharacterModifyResult.CreateFailed_UniqueName
                    });

                    return;
                }

                CharacterCreationEntry creationEntry = GameTableManager.Instance.CharacterCreation.GetEntry(characterCreate.CharacterCreationId);
                if (creationEntry == null)
                {
                    throw new InvalidPacketValueException();
                }

                if (creationEntry.EntitlementIdRequired != 0u)
                {
                    // TODO: Aurin engineer has this
                }

                var character = new CharacterModel
                {
                    AccountId  = session.Account.Id,
                    Id         = AssetManager.Instance.NextCharacterId,
                    Name       = characterCreate.Name,
                    Race       = (byte)creationEntry.RaceId,
                    Sex        = (byte)creationEntry.Sex,
                    Class      = (byte)creationEntry.ClassId,
                    FactionId  = (ushort)creationEntry.FactionId,
                    ActivePath = characterCreate.Path
                };

                for (Path path = Path.Soldier; path <= Path.Explorer; path++)
                {
                    character.Path.Add(new CharacterPathModel
                    {
                        Path     = (byte)path,
                        Unlocked = Convert.ToByte(characterCreate.Path == (byte)path)
                    });
                }

                // merge seperate label and value lists into a single dictonary
                Dictionary <uint, uint> customisations = characterCreate.Labels
                                                         .Zip(characterCreate.Values, (l, v) => new { l, v })
                                                         .ToDictionary(p => p.l, p => p.v);

                foreach ((uint label, uint value) in customisations)
                {
                    character.Customisation.Add(new CharacterCustomisationModel
                    {
                        Label = label,
                        Value = value
                    });

                    CharacterCustomizationEntry entry = GetCharacterCustomisation(customisations, creationEntry.RaceId, creationEntry.Sex, label, value);
                    if (entry == null)
                    {
                        continue;
                    }

                    character.Appearance.Add(new CharacterAppearanceModel
                    {
                        Slot      = (byte)entry.ItemSlotId,
                        DisplayId = (ushort)entry.ItemDisplayId
                    });
                }

                for (int i = 0; i < characterCreate.Bones.Count; ++i)
                {
                    character.Bone.Add(new CharacterBoneModel
                    {
                        BoneIndex = (byte)(i),
                        Bone      = characterCreate.Bones[i]
                    });
                }

                //TODO: handle starting locations per race
                character.LocationX = -7683.809f;
                character.LocationY = -942.5914f;
                character.LocationZ = -666.6343f;
                character.WorldId   = 870;

                character.ActiveSpec = 0;

                // create initial LAS abilities
                UILocation location = 0;
                foreach (SpellLevelEntry spellLevelEntry in GameTableManager.Instance.SpellLevel.Entries
                         .Where(s => s.ClassId == character.Class && s.CharacterLevel == 1))
                {
                    Spell4Entry spell4Entry = GameTableManager.Instance.Spell4.GetEntry(spellLevelEntry.Spell4Id);
                    if (spell4Entry == null)
                    {
                        continue;
                    }

                    character.Spell.Add(new CharacterSpellModel
                    {
                        Id           = character.Id,
                        Spell4BaseId = spell4Entry.Spell4BaseIdBaseSpell,
                        Tier         = 1
                    });

                    character.ActionSetShortcut.Add(new CharacterActionSetShortcutModel
                    {
                        Id           = character.Id,
                        SpecIndex    = 0,
                        Location     = (ushort)location,
                        ShortcutType = (byte)ShortcutType.Spell,
                        ObjectId     = spell4Entry.Spell4BaseIdBaseSpell,
                        Tier         = 1
                    });

                    location++;
                }

                // create a temporary inventory to create starting gear
                var inventory            = new Inventory(character.Id, creationEntry);
                IEnumerable <Item> items = inventory
                                           .SelectMany(b => b)
                                           .Select(i => i);

                //TODO: handle starting stats per class/race
                character.Stat.Add(new CharacterStatModel
                {
                    Id    = character.Id,
                    Stat  = (byte)Stat.Health,
                    Value = 800
                });
                character.Stat.Add(new CharacterStatModel
                {
                    Id    = character.Id,
                    Stat  = (byte)Stat.Shield,
                    Value = 450
                });
                character.Stat.Add(new CharacterStatModel
                {
                    Id    = character.Id,
                    Stat  = (byte)Stat.Dash,
                    Value = 200
                });
                character.Stat.Add(new CharacterStatModel
                {
                    Id    = character.Id,
                    Stat  = (byte)Stat.Level,
                    Value = 1
                });
                character.Stat.Add(new CharacterStatModel
                {
                    Id    = character.Id,
                    Stat  = (byte)Stat.StandState,
                    Value = 3
                });

                // TODO: actually error check this
                session.EnqueueEvent(new TaskEvent(DatabaseManager.Instance.CharacterDatabase.Save(c =>
                {
                    c.Character.Add(character);
                    foreach (Item item in items)
                    {
                        item.Save(c);
                    }
                }),
                                                   () =>
                {
                    session.Characters.Add(character);
                    session.EnqueueMessageEncrypted(new ServerCharacterCreate
                    {
                        CharacterId = character.Id,
                        WorldId     = character.WorldId,
                        Result      = CharacterModifyResult.CreateOk
                    });
                }));
            }
            catch
            {
                session.EnqueueMessageEncrypted(new ServerCharacterCreate
                {
                    Result = CharacterModifyResult.CreateFailed
                });

                throw;
            }

            CharacterCustomizationEntry GetCharacterCustomisation(Dictionary <uint, uint> customisations, uint race, uint sex, uint primaryLabel, uint primaryValue)
            {
                ImmutableList <CharacterCustomizationEntry> entries = AssetManager.Instance.GetPrimaryCharacterCustomisation(race, sex, primaryLabel, primaryValue);

                if (entries == null)
                {
                    return(null);
                }
                if (entries.Count == 1)
                {
                    return(entries[0]);
                }

                // customisation has multiple results, filter with secondary label and value
                uint secondaryLabel = entries.First(e => e.CharacterCustomizationLabelId01 != 0).CharacterCustomizationLabelId01;
                uint secondaryValue = customisations[secondaryLabel];

                CharacterCustomizationEntry entry = entries.SingleOrDefault(e => e.CharacterCustomizationLabelId01 == secondaryLabel && e.Value01 == secondaryValue);

                return(entry ?? entries.Single(e => e.CharacterCustomizationLabelId01 == 0 && e.Value01 == 0));
            }
        }
Exemple #18
0
 /// <summary>
 /// Create a new <see cref="ActionSetAction"/>.
 /// </summary>
 public ActionSetAction(byte shortcutType, uint objectId, UILocation location)
 {
     ShortcutType = shortcutType;
     ObjectId     = objectId;
     Location     = location;
 }