private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Beispiel #2
0
        public void SetSpecies(PokemonSpecies species)
        {
            currSpeciesId = species.id;

            //Name

            textName.text = species.name;

            //Sprites

            imageType1.gameObject.SetActive(true);
            imageType2.gameObject.SetActive(true);

            imageType1.sprite = SpriteStorage.GetTypeSymbolSprite(species.type1);

            if (species.type2 != null)
            {
                imageType2.gameObject.SetActive(true);
                imageType2.sprite = SpriteStorage.GetTypeSymbolSprite((Pokemon.Type)species.type2);
            }
            else
            {
                imageType2.gameObject.SetActive(false);
            }

            //Seen/Caught

            textSeenCount.text   = playerPokedex.GetSeenCount(currSpeciesId).ToString();
            textCaughtCount.text = playerPokedex.GetCaughtCount(currSpeciesId).ToString();

            //Cry button
            buttonCry.interactable = true;
        }
Beispiel #3
0
        public bool CreateEmpty(Core.Version version, ClientFeatures features)
        {
            if (version == null)
            {
                throw new ArgumentNullException(nameof(version));
            }

            this.Things = ThingTypeStorage.Create(version, features);
            if (this.Things == null)
            {
                return(false);
            }

            this.Sprites = SpriteStorage.Create(version, features);
            if (this.Sprites == null)
            {
                return(false);
            }

            this.Things.ProgressChanged  += new ProgressHandler(this.StorageProgressChanged_Handler);
            this.Things.StorageChanged   += new ThingListChangedHandler(this.ThingListChanged_Handler);
            this.Things.StorageCompiled  += new StorageHandler(this.StorageCompiled_Handler);
            this.Things.StorageDisposed  += new StorageHandler(this.StorageDisposed_Handler);
            this.Sprites.StorageChanged  += new SpriteListChangedHandler(this.SpriteListChanged_Handler);
            this.Sprites.ProgressChanged += new ProgressHandler(this.StorageProgressChanged_Handler);
            this.Sprites.StorageCompiled += new StorageHandler(this.StorageCompiled_Handler);
            this.Sprites.StorageDisposed += new StorageHandler(this.StorageDisposed_Handler);

            if (this.Loaded && this.ClientLoaded != null)
            {
                this.ClientLoaded(this, new EventArgs());
            }

            return(this.Loaded);
        }
Beispiel #4
0
        public void SetValues(string name,
                              Sprite icon,
                              float healthBarValue,
                              PokemonInstance.NonVolatileStatusCondition statusCondition,
                              bool hasHeldItem)
        {
            if (healthBarValue < 0 || healthBarValue > 1)
            {
                Debug.LogError("Health bar value provided out of range");
            }

            textName.text    = name;
            imageIcon.sprite = icon;
            healthBar.UpdateBar(healthBarValue);

            if (statusCondition == PokemonInstance.NonVolatileStatusCondition.None)
            {
                imageStatusCondition.gameObject.SetActive(false);
            }
            else
            {
                imageStatusCondition.gameObject.SetActive(true);
                imageStatusCondition.sprite = SpriteStorage.GetNonVolatileStatusConditionSprite(statusCondition);
            }

            imageHeldItem.enabled = hasHeldItem;
        }
Beispiel #5
0
 public override void RefreshImage()
 {
     image.sprite = SpriteStorage.GetPokemonSprite(
         PokemonSpecies.GetPokemonSpeciesById(instanceId).resourceName,
         PokemonSpecies.SpriteType.Front1,
         false);
 }
        public void UpdateValues(PokemonInstance pokemon)
        {
            imageIcon.sprite = pokemon.LoadSprite(PokemonSpecies.SpriteType.Icon);
            textName.text    = pokemon.GetDisplayName();
            healthBar.UpdateBar(pokemon.HealthProportion);

            if (pokemon.nonVolatileStatusCondition == PokemonInstance.NonVolatileStatusCondition.None)
            {
                imageStatusCondition.gameObject.SetActive(false);
            }
            else
            {
                imageStatusCondition.gameObject.SetActive(true);
                imageStatusCondition.sprite = SpriteStorage.GetNonVolatileStatusConditionSprite(pokemon.nonVolatileStatusCondition);
            }

            if (pokemon.heldItem == null)
            {
                imageHeldItem.enabled = false;
            }
            else
            {
                imageHeldItem.enabled = true;
            }
        }
Beispiel #7
0
 public Sprite LoadSprite(SpriteType spriteType,
                          bool?gender,
                          bool shiny = false)
 => SpriteStorage.GetPokemonSprite(
     resourceName == "" || resourceName == null ? id.ToString() : resourceName,
     spriteType,
     gender,
     shiny
     );
        /// <summary>
        /// Sets up the background and circles of the battle layout
        /// </summary>
        /// <param name="settingResourceName">The resource name of the background and the circles (eg. "mountain", "snow", "forest" etc.)</param>
        public void SetUpBackground(string settingResourceName)
        {
            Sprite backgroundSprite = SpriteStorage.GetBattleBackgroundSprite(settingResourceName);
            Sprite circleSprite     = SpriteStorage.GetBattleCircleSprite(settingResourceName);

            backgroundSpriteRenderer.sprite = backgroundSprite;
            foreach (SpriteRenderer sr in battleCircleSpriteRenderers)
            {
                sr.sprite = circleSprite;
            }
        }
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
 private static Sprite GetStateSprite(BallState state)
 {
     if (state == BallState.None)
     {
         Debug.LogWarning("Ball state sprite requested for None");
         return(null);
     }
     else
     {
         return(SpriteStorage.GetBattlePokeBallLineBallSprite(state));
     }
 }
Beispiel #11
0
 public void UpdateNonVolatileStatsCondition(PokemonInstance.NonVolatileStatusCondition nvsc)
 {
     if (nvsc == PokemonInstance.NonVolatileStatusCondition.None)
     {
         imageNonVolatileStatusCondition.gameObject.SetActive(false);
     }
     else
     {
         imageNonVolatileStatusCondition.gameObject.SetActive(true);
         imageNonVolatileStatusCondition.sprite = SpriteStorage.GetNonVolatileStatusConditionSprite(nvsc);
     }
 }
Beispiel #12
0
        public override void SetPokemon(PokemonInstance pokemon)
        {
            if (pokemon != null)
            {
                imagePokeBall.gameObject.SetActive(true);
                imagePokeBall.sprite = SpriteStorage.GetItemSprite(
                    PokeBall.GetPokeBallById(pokemon.pokeBallId)
                    .resourceName
                    );

                textName.text = pokemon.GetDisplayName();
                imageGender.gameObject.SetActive(true);
                imageGender.sprite = SpriteStorage.GetGenderSprite(pokemon.gender);

                imageFront.gameObject.SetActive(true);
                imageFront.sprite = pokemon.LoadSprite(PokemonSpecies.SpriteType.Front1);

                imageType1.gameObject.SetActive(true);
                imageType2.gameObject.SetActive(true);
                imageType1.sprite = SpriteStorage.GetTypeSymbolSprite(pokemon.species.type1);

                Type?pokemonType2 = pokemon.species.type2;
                if (pokemonType2 == null)
                {
                    imageType2.gameObject.SetActive(false);
                }
                else
                {
                    imageType2.gameObject.SetActive(true);
                    imageType2.sprite = SpriteStorage.GetTypeSymbolSprite((Type)pokemonType2);
                }

                imageCheatPokemon.gameObject.SetActive(pokemon.cheatPokemon);
                imageShinyPokemon.gameObject.SetActive(pokemon.IsShiny);
            }
            else
            {
                imageFront.gameObject.SetActive(false);

                imageType1.gameObject.SetActive(false);
                imageType2.gameObject.SetActive(false);

                imagePokeBall.gameObject.SetActive(false);

                textName.text = noPokemonPromptMessage;
                imageGender.gameObject.SetActive(false);

                imageCheatPokemon.gameObject.SetActive(false);
                imageShinyPokemon.gameObject.SetActive(false);
            }
        }
Beispiel #13
0
        protected virtual void OnValidate()
        {
            if (!string.IsNullOrEmpty(spriteGroupName))
            {
                SpriteStorage.TryLoadAll();

                spriteRenderer.sprite = SpriteStorage.GetCharacterSprite(out bool flipSprite,
                                                                         spriteGroupName,
                                                                         "idle",
                                                                         initialDirectionFacing);

                spriteRenderer.flipX = flipSprite;
            }
        }
Beispiel #14
0
        public override void RefreshImage()
        {
            bool flipSprite;

            image.sprite = SpriteStorage.GetCharacterSprite(out flipSprite, instanceId, "idle", FreeRoaming.GameCharacterController.FacingDirection.Down);

            int flipMultiplier = flipSprite ? -1 : 1;

            //If needing to flip sprite, make x-scale negative
            image.rectTransform.localScale = new Vector3(
                Mathf.Abs(image.rectTransform.localScale.x) * flipMultiplier,
                image.rectTransform.localScale.y,
                image.rectTransform.localScale.z
                );
        }
        protected void SetMovePaneDetails(int moveId, byte remainingPP)
        {
            PokemonMove move = PokemonMove.GetPokemonMoveById(moveId);

            textName.text          = move.name;
            textPPValue.text       = remainingPP + "/" + move.maxPP;
            textDescription.text   = move.description;
            textPowerValue.text    = move.power != 0 ? move.power.ToString() : "-";
            textAccuracyValue.text = move.accuracy != 0 ? move.accuracy.ToString() : "-";

            imageCategory.sprite = SpriteStorage.GetMoveTypeSprite(move.moveType);
            imageType.sprite     = SpriteStorage.GetTypeSymbolSprite(move.type);

            ShowMovePane();
        }
Beispiel #16
0
        public void SetMove(PokemonMove move)
        {
            if (move == null)
            {
                textName.text = "";

                imageType.enabled = false;
            }
            else
            {
                textName.text = move.name;

                imageType.enabled = true;
                imageType.sprite  = SpriteStorage.GetTypeSymbolSprite(move.type);
            }
        }
Beispiel #17
0
        public static void Load()
        {
            SceneArea.TryLoadRegistry();
            Gym.TryLoadRegistry();
            Weather.CreateWeathers();
            PokemonSpeciesData.LoadData();
            PokemonMoveData.LoadData();
            Nature.LoadRegistry();
            SpriteStorage.TryLoadAll();
            WildPokemonAreaData.LoadData();
            TrainersData.LoadData();

            Item.TrySetRegistry();         //TMs must be loaded after moves

            GenericNPCData.LoadData();     //Generic NPCs must be loaded after items

            DroppedItem.TryLoadRegistry(); //Dropped items must be loaded after items

            PokeMartData.LoadData();       //This must be loaded after all items
        }
Beispiel #18
0
        public void SetMoveById(int id, byte currentPP)
        {
            if (PokemonMove.MoveIdIsUnset(id))
            {
                SetShowState(false);
                return;
            }

            SetShowState(true);

            PokemonMove move = PokemonMove.GetPokemonMoveById(id);

            textName.text          = move.name;
            textPP.text            = currentPP.ToString() + "/" + move.maxPP.ToString();
            textDescription.text   = move.description;
            textPowerValue.text    = move.power != 0 ? move.power.ToString() : "-";
            textAccuracyValue.text = move.accuracy != 0 ? move.accuracy.ToString() : "-";
            imageType.sprite       = SpriteStorage.GetTypeSymbolSprite(move.type);
            imageCategory.sprite   = SpriteStorage.GetMoveTypeSprite(move.moveType);
        }
Beispiel #19
0
        public void LoadSprites()
        {
            LoadCatalogJson();
            catalog.Sort((x, y) => x.FirstSpriteid.CompareTo(y.FirstSpriteid));
            var options = new ParallelOptions()
            {
                MaxDegreeOfParallelism = Environment.ProcessorCount * 5
            };

            if (ToSpr.Checked)
            {
                version  = new OpenTibia.Core.Version(1000, "Client 10.00", DatSignature, SprSignature, 0);
                Features = OpenTibia.Client.ClientFeatures.Extended;
                sprites  = SpriteStorage.Create(version, Features);
            }

            progress = 0;
            Directory.CreateDirectory(_dumpToPath + @"//slices//");
            Parallel.ForEach(catalog, options, (sheet, state) =>
            {
                progress++;
                if (sheet.Type == "sprite")
                {
                    DumpSpriteSheet(sheet);
                }

                worker.ReportProgress((int)(progress * 100 / catalog.Count));
            });

            if (ToSpr.Checked)
            {
                foreach (var tile in concurrentDictionary.OrderBy(tile => tile.Key))
                {
                    sprites.AddSprites(tile.Value);
                }

                sprites.Save(String.Format("{0}//Clients//Tibia.spr", _dumpToPath), version);
            }
        }
Beispiel #20
0
        public override void RefreshDetails(PokemonInstance pokemon)
        {
            imagePokeBall.sprite = SpriteStorage.GetItemSprite(
                PokeBall.GetPokeBallById(pokemon.pokeBallId)
                .resourceName
                );

            textName.text      = pokemon.GetDisplayName();
            imageGender.sprite = SpriteStorage.GetGenderSprite(pokemon.gender);

            textSpeciesName.text   = pokemon.species.name;
            textSpeciesNumber.text = pokemon.species.id.ToString();
            imageType1.sprite      = SpriteStorage.GetTypeSymbolSprite(pokemon.species.type1);

            imageFront.sprite = pokemon.LoadSprite(PokemonSpecies.SpriteType.Front1);

            Type?pokemonType2 = pokemon.species.type2;

            if (pokemonType2 == null)
            {
                imageType2.gameObject.SetActive(false);
            }
            else
            {
                imageType2.gameObject.SetActive(true);
                imageType2.sprite = SpriteStorage.GetTypeSymbolSprite((Type)pokemonType2);
            }

            textLevel.text = pokemon.GetLevel().ToString();

            textOriginalTrainer.text = pokemon.originalTrainerName;

            //TODO - once abilities made, set ability Text texts
            textAbilityName.text        = "";
            textAbilityDescription.text = "";

            imageCheatPokemon.gameObject.SetActive(pokemon.cheatPokemon);
            imageShinyPokemon.gameObject.SetActive(pokemon.IsShiny);
        }
        public void SetPokemon(PokemonInstance pokemon)
        {
            if (pokemon == null)
            {
                SetInteractable(false);
                return;
            }
            else
            {
                SetInteractable(true);
            }

            textName.text    = pokemon.GetDisplayName();
            textLevel.text   = levelTextPrefix + pokemon.GetLevel().ToString();
            imageIcon.sprite = pokemon.LoadSprite(PokemonSpecies.SpriteType.Icon);

            if (pokemon.nonVolatileStatusCondition == PokemonInstance.NonVolatileStatusCondition.None)
            {
                nvscImage.enabled = false;
            }
            else
            {
                nvscImage.enabled = true;
                nvscImage.sprite  = SpriteStorage.GetNonVolatileStatusConditionSprite(pokemon.nonVolatileStatusCondition);
            }

            if (pokemon.heldItem == null)
            {
                imageHeldItem.enabled = false;
            }
            else
            {
                imageHeldItem.enabled = true;
            }

            healthBar.UpdateBar(pokemon.HealthProportion);
        }
Beispiel #22
0
        private void SetMovePaneDetails(int moveIndex)
        {
            PokemonMove move = GetMoves()[moveIndex];

            if (move == null)
            {
                HideMovePane();
                return;
            }

            byte[] remainingPPs = PlayerData
                                  .singleton
                                  .partyPokemon[currentPokemonIndex]
                                  .movePPs;

            textPPValue.text       = remainingPPs[moveIndex] + "/" + move.maxPP;
            textPowerValue.text    = move.power != 0 ? move.power.ToString() : "-";
            textAccuracyValue.text = move.accuracy != 0 ? move.accuracy.ToString() : "-";

            imageCategory.sprite = SpriteStorage.GetMoveTypeSprite(move.moveType);
            imageType.sprite     = SpriteStorage.GetTypeSymbolSprite(move.type);

            ShowMovePane();
        }
Beispiel #23
0
 public Sprite LoadSprite() => SpriteStorage.GetItemSprite(resourceName);
Beispiel #24
0
 public void UpdateGender(bool?gender) => imageGender.sprite = SpriteStorage.GetGenderSprite(gender);
 public Sprite LoadGenderSprite()
 {
     return(SpriteStorage.GetGenderSprite(gender));
 }
Beispiel #26
0
        public void SetPokemonDetails(PokemonInstance pokemon)
        {
            #region Images

            imageIcon.sprite  = pokemon.LoadSprite(PokemonSpecies.SpriteType.Icon);
            imageFront.sprite = pokemon.LoadSprite(PokemonSpecies.SpriteType.Front1);
            imageBack.sprite  = pokemon.LoadSprite(PokemonSpecies.SpriteType.Back);

            #endregion

            #region General Details

            imageType1.sprite = SpriteStorage.GetTypeSymbolSprite(pokemon.species.type1);

            Pokemon.Type?pokemonType2 = pokemon.species.type2;
            if (pokemonType2 == null)
            {
                imageType2.gameObject.SetActive(false);
            }
            else
            {
                imageType2.gameObject.SetActive(true);
                imageType2.sprite = SpriteStorage.GetTypeSymbolSprite((Pokemon.Type)pokemon.species.type2);
            }

            textName.text = pokemon.GetDisplayName();

            imageGender.sprite = pokemon.LoadGenderSprite();

            textLevelValue.text = pokemon.GetLevel().ToString();

            if (pokemon.heldItem != null)
            {
                textItemName.text     = pokemon.heldItem.itemName;
                imageItemIcon.enabled = true;
                imageItemIcon.sprite  = pokemon.heldItem.LoadSprite();
            }
            else
            {
                textItemName.text     = "No held item";
                imageItemIcon.enabled = false;
            }

            //TODO - set values for ability when and if implemented
            textAbilityName.text        = "";
            textAbilityDescription.text = "";

            if (pokemon.nonVolatileStatusCondition != PokemonInstance.NonVolatileStatusCondition.None)
            {
                imageStatusCondition.gameObject.SetActive(true);

                Sprite statusConditionSprite = SpriteStorage.GetNonVolatileStatusConditionSprite(pokemon.nonVolatileStatusCondition);
                if (statusConditionSprite != null)
                {
                    imageStatusCondition.gameObject.SetActive(true);
                    imageStatusCondition.sprite = statusConditionSprite;
                }
                else
                {
                    imageStatusCondition.gameObject.SetActive(false);
                }
            }
            else
            {
                imageStatusCondition.gameObject.SetActive(false);
            }

            imageCheatPokemon.gameObject.SetActive(pokemon.cheatPokemon);
            imageShinyPokemon.gameObject.SetActive(pokemon.IsShiny);

            #endregion

            #region Stats

            Pokemon.Stats <int> stats = pokemon.GetStats();

            textAttackValue.text         = stats.attack.ToString();
            textDefenseValue.text        = stats.defense.ToString();
            textSpecialAttackValue.text  = stats.specialAttack.ToString();
            textSpecialDefenseValue.text = stats.specialDefense.ToString();
            textSpeedValue.text          = stats.speed.ToString();
            healthBar.UpdateBar(pokemon.HealthProportion);

            #endregion
        }
Beispiel #27
0
        public void SetPokemon(PokemonInstance pokemon)
        {
            if (pokemon == null)
            {
                SetPokemonShownState(false);
            }
            else
            {
                SetPokemonShownState(true);

                textDisplayName.text = pokemon.GetDisplayName();
                imageGender.sprite   = pokemon.LoadGenderSprite();
                textLevel.text       = levelPrefix + pokemon.GetLevel().ToString();
                imageSprite.sprite   = pokemon.LoadSprite(PokemonSpecies.SpriteType.Front1);

                textSpeciesName.text   = pokemon.species.name;
                textSpeciesNumber.text = pokemon.species.id.ToString();
                imageType1.sprite      = SpriteStorage.GetTypeSymbolSprite(pokemon.species.type1);
                if (pokemon.species.type2 != null)
                {
                    imageType2.sprite = SpriteStorage.GetTypeSymbolSprite((Type)pokemon.species.type2);
                }
                else
                {
                    imageType2.enabled = false;
                }

                //This capitalises first letter of the nature's name
                textNature.text   = pokemon.nature.name[0].ToString().ToUpper() + pokemon.nature.name.Substring(1);
                textItemName.text = pokemon.heldItem != null ? pokemon.heldItem.itemName : "";

                textStatAttackValue.text         = pokemon.GetStats().attack.ToString();
                textStatDefenseValue.text        = pokemon.GetStats().defense.ToString();
                textStatSpecialAttackValue.text  = pokemon.GetStats().specialAttack.ToString();
                textStatSpecialDefenseValue.text = pokemon.GetStats().specialDefense.ToString();
                textStatSpeedValue.text          = pokemon.GetStats().speed.ToString();
                textStatHealthValue.text         = pokemon.GetStats().health.ToString();

                statHexEV.values = new float[]
                {
                    (float)pokemon.effortValues.attack / PokemonInstance.maximumEffortValue,
                    (float)pokemon.effortValues.defense / PokemonInstance.maximumEffortValue,
                    (float)pokemon.effortValues.specialAttack / PokemonInstance.maximumEffortValue,
                    (float)pokemon.effortValues.specialDefense / PokemonInstance.maximumEffortValue,
                    (float)pokemon.effortValues.speed / PokemonInstance.maximumEffortValue,
                    (float)pokemon.effortValues.health / PokemonInstance.maximumEffortValue
                };

                statHexIV.values = new float[]
                {
                    (float)pokemon.individualValues.attack / PokemonInstance.maximumIndividualValue,
                    (float)pokemon.individualValues.defense / PokemonInstance.maximumIndividualValue,
                    (float)pokemon.individualValues.specialAttack / PokemonInstance.maximumIndividualValue,
                    (float)pokemon.individualValues.specialDefense / PokemonInstance.maximumIndividualValue,
                    (float)pokemon.individualValues.speed / PokemonInstance.maximumIndividualValue,
                    (float)pokemon.individualValues.health / PokemonInstance.maximumIndividualValue
                };

                imageCheatPokemon.enabled = pokemon.cheatPokemon;
            }
        }
Beispiel #28
0
 public Sprite GetSprite(SpriteType spriteType)
 => SpriteStorage.GetPokeBallSprite(id, spriteType);