示例#1
0
 // HUD Activity
 public void SetPokemonHUDActive(PBS.Battle.View.WifiFriendly.Pokemon pokemon, bool active)
 {
     HUD.PokemonHUD pokemonHUD = GetPokemonHUD(pokemon);
     if (pokemonHUD != null)
     {
         pokemonHUD.gameObject.SetActive(active);
     }
 }
示例#2
0
 public bool UndrawPokemonHUD(PBS.Battle.View.WifiFriendly.Pokemon pokemon)
 {
     HUD.PokemonHUD pokemonHUD = GetPokemonHUD(pokemon);
     if (pokemonHUD != null)
     {
         pokemonHUDs.Remove(pokemonHUD);
         Destroy(pokemonHUD.gameObject);
         return(true);
     }
     return(false);
 }
示例#3
0
        // Animation
        public IEnumerator AnimatePokemonHUDHPChange(
            PBS.Battle.View.WifiFriendly.Pokemon pokemon,
            int preHP,
            int postHP,
            int maxHP,
            float timeSpan = 1f)
        {
            HUD.PokemonHUD pokemonHUD = GetPokemonHUD(pokemon);
            if (pokemonHUD != null)
            {
                float preValue  = pokemonHUD.hpBar.fillAmount;
                float postValue = ((float)postHP / maxHP);

                float difference = postValue - preValue;
                float increment  = (timeSpan == 0) ? 1f : 0f;
                while (increment < 1)
                {
                    increment += (1 / timeSpan) * Time.deltaTime;
                    if (increment > 1)
                    {
                        increment = 1;
                    }
                    float curFillAmount = preValue + difference * increment;
                    int   displayHP     = Mathf.FloorToInt(curFillAmount * maxHP);
                    if (displayHP == 0 && curFillAmount > 0)
                    {
                        displayHP = 1;
                    }

                    // display changes
                    pokemonHUD.hpTxt.text       = displayHP + " / " + maxHP;
                    pokemonHUD.hpBar.fillAmount = curFillAmount;
                    pokemonHUD.hpBar.color      = (curFillAmount > 0.5f) ? pokemonHUD.hpHigh
                        : (curFillAmount > 0.25f) ? pokemonHUD.hpMed
                        : pokemonHUD.hpLow;

                    yield return(null);
                }

                pokemonHUD.hpTxt.text       = postHP + " / " + maxHP;
                pokemonHUD.hpBar.fillAmount = postValue;
                pokemonHUD.hpBar.color      = (postValue > 0.5f) ? pokemonHUD.hpHigh
                    : (postValue > 0.25f) ? pokemonHUD.hpMed
                    : pokemonHUD.hpLow;
                yield return(null);
            }
        }
示例#4
0
        // Drawing HUD
        public HUD.PokemonHUD DrawPokemonHUD(
            PBS.Battle.View.WifiFriendly.Pokemon pokemon,
            TeamMode teamMode,
            bool isNear)
        {
            // get spawn position
            Transform spawnPos = GetPokemonHUDSpawnPosition(pokemon, teamMode, isNear);

            if (spawnPos == null)
            {
                Debug.LogWarning("Could not find HUD Spawn Position for " + pokemon.nickname);
                return(null);
            }
            else
            {
                // draw pokemon HUD
                HUD.PokemonHUD pokemonHUD = Instantiate(pokemonHUDPrefab, spawnPos.position, Quaternion.identity, spawnPos);
                pokemonHUD.pokemonUniqueID = pokemon.uniqueID;
                pokemonHUD.hpObj.gameObject.SetActive(isNear &&
                                                      (teamMode == TeamMode.Single ||
                                                       teamMode == TeamMode.Double));
                // set EXP bar
                pokemonHUD.expObj.SetActive(isNear &&
                                            (teamMode == TeamMode.Single ||
                                             teamMode == TeamMode.Double));
                pokemonHUDs.Add(pokemonHUD);

                UpdatePokemonHUD(
                    pokemon: pokemon,
                    nickname: pokemon.nickname,
                    gender: pokemon.gender,
                    level: pokemon.level,
                    nonVolatileStatusID: pokemon.nonVolatileStatus,
                    currentHP: pokemon.currentHP,
                    maxHP: pokemon.maxHP);
                return(pokemonHUD);
            }
        }
示例#5
0
        public void UpdatePokemonHUD(
            PBS.Battle.View.WifiFriendly.Pokemon pokemon,
            string nickname            = "",
            PokemonGender gender       = PokemonGender.Genderless,
            int level                  = 1,
            string nonVolatileStatusID = null,
            int currentHP              = 1,
            int maxHP                  = 1)
        {
            HUD.PokemonHUD pokemonHUD = GetPokemonHUD(pokemon);
            if (pokemonHUD != null)
            {
                pokemonHUD.nameTxt.text = nickname;
                if (gender != PokemonGender.Genderless)
                {
                    pokemonHUD.nameTxt.text += (gender == PokemonGender.Male) ? " <color=#8080FF>♂</color>"
                        : " <color=#FF8080>♀</color>";
                }

                pokemonHUD.lvlTxt.text    = "<color=yellow>Lv</color>" + level;
                pokemonHUD.statusTxt.text = "";
                if (!string.IsNullOrEmpty(nonVolatileStatusID))
                {
                    StatusPKData statusData = StatusPKDatabase.instance.GetStatusData(nonVolatileStatusID);
                    pokemonHUD.statusTxt.text = statusData.shortName;
                }

                pokemonHUD.hpTxt.text = currentHP + " / " + maxHP;

                float hpPercent = ((float)currentHP) / maxHP;
                pokemonHUD.hpBar.fillAmount = hpPercent;

                pokemonHUD.hpBar.color = (hpPercent > 0.5f) ? pokemonHUD.hpHigh
                    : (hpPercent > 0.25f) ? pokemonHUD.hpMed
                    : pokemonHUD.hpLow;
            }
        }