コード例 #1
0
 public void SetPokemonSprite(
     string spritePath,
     BTLSCN_Pokemon scnPokemon     = null,
     BTLSCN_PokemonBW scnPokemonBW = null,
     PBS.Battle.View.Scene.Entities.Pokemon scnPokemonNew = null,
     Image imagePokemon = null)
 {
     if (scnPokemon != null)
     {
         scnPokemon.spriteRenderer.sprite = loadedPokemonSprites[spritePath];
     }
     if (scnPokemonBW != null)
     {
         scnPokemonBW.spriteRenderer.sprite = loadedPokemonSprites[spritePath];
         scnPokemonBW.shadowRenderer.sprite = loadedPokemonSprites[spritePath];
     }
     if (scnPokemonNew != null)
     {
         scnPokemonNew.spriteRenderer.sprite = loadedPokemonSprites[spritePath];
         scnPokemonNew.shadowRenderer.sprite = loadedPokemonSprites[spritePath];
     }
     if (imagePokemon != null)
     {
         imagePokemon.sprite = loadedPokemonSprites[spritePath];
     }
 }
コード例 #2
0
 /// <summary>
 /// Removes the given pokemon from the canvas.
 /// </summary>
 /// <param name="pokemonUniqueID">The ID of the pokemon to remove.</param>
 /// <returns></returns>
 public bool UndrawPokemon(string pokemonUniqueID)
 {
     Entities.Pokemon oldScnPokemon = GetSCNPokemon(pokemonUniqueID);
     if (oldScnPokemon != null)
     {
         scnPokemon.Remove(oldScnPokemon);
         Destroy(oldScnPokemon.gameObject);
         return(true);
     }
     return(false);
 }
コード例 #3
0
        /// <summary>
        /// Draws the given pokemon on the canvas.
        /// </summary>
        /// <param name="pokemon">The pokemon to be drawn.</param>
        /// <param name="teamMode">The pokemon's team's battle type for reference.</param>
        /// <param name="isNear">If true, this pokemon is drawn as being part of the ally team.</param>
        /// <returns></returns>
        public Entities.Pokemon DrawPokemon(
            Battle.View.WifiFriendly.Pokemon pokemon,
            TeamMode teamMode,
            bool isNear)
        {
            // get spawn position
            Transform spawnPos = this.transform;

            switch (teamMode)
            {
            case TeamMode.Single:
                spawnPos = (isNear) ? spawnNearSingle : spawnFarSingle;
                break;

            case TeamMode.Double:
                spawnPos = (pokemon.battlePos == 0) ? (isNear ? spawnNearDouble0 : spawnFarDouble0)
                        : isNear ? spawnNearDouble1 : spawnFarDouble1;
                break;

            case TeamMode.Triple:
                spawnPos = (pokemon.battlePos == 0) ? (isNear ? spawnNearTriple0 : spawnFarTriple0)
                        : (pokemon.battlePos == 1) ? (isNear ? spawnNearTriple1 : spawnFarTriple1)
                        : isNear ? spawnNearTriple2 : spawnFarTriple2;
                break;
            }

            // draw pokemon
            PokemonData pokemonData = PokemonDatabase.instance.GetPokemonData(pokemon.pokemonID);
            string      drawPath    = "pokemonSprites/" + (isNear ? "back/" : "front/") + pokemonData.displayID;

            Entities.Pokemon newScnPokemon = Instantiate(pokemonPrefab, spawnPos.position, Quaternion.identity, spawnPos);
            newScnPokemon.spriteRenderer.sprite = BattleAssetLoader.instance.nullSprite;
            newScnPokemon.shadowRenderer.sprite = BattleAssetLoader.instance.nullSprite;
            newScnPokemon.pokemonUniqueID       = pokemon.uniqueID;

            // positioning
            float xOffset = isNear ? pokemonData.xOffset2DNear : pokemonData.xOffset2DFar;
            float yOffset = isNear ? pokemonData.yOffset2DNear : pokemonData.yOffset2DFar;

            newScnPokemon.transform.localPosition = new Vector3(xOffset, yOffset);

            // load model
            newScnPokemon.pokemonID = pokemon.pokemonID;
            StartCoroutine(BattleAssetLoader.instance.LoadPokemon(
                               pokemon: pokemon,
                               useFront: !isNear,
                               useBack: isNear,
                               scnPokemonNew: newScnPokemon
                               ));

            scnPokemon.Add(newScnPokemon);
            return(newScnPokemon);
        }
コード例 #4
0
    public IEnumerator LegacyLoadPokemon(Pokemon pokemon,
                                         bool useicon                  = false,
                                         bool useFront                 = false,
                                         bool useBack                  = false,
                                         BTLSCN_Pokemon scnPokemon     = null,
                                         BTLSCN_PokemonBW scnPokemonBW = null,
                                         PBS.Battle.View.Scene.Entities.Pokemon scnPokemonNew = null,
                                         Image imagePokemon = null)
    {
        PokemonData pokemonData = (pokemon.bProps.illusion != null) ?
                                  PokemonDatabase.instance.GetPokemonIllusionData(pokemon.bProps.illusion) : pokemon.data;

        yield return(StartCoroutine(LegacyLoadPokemon(
                                        data: pokemonData,
                                        useicon: useicon, useFront: useFront, useBack: useBack,
                                        scnPokemon: scnPokemon, scnPokemonBW: scnPokemonBW, scnPokemonNew: scnPokemonNew,
                                        imagePokemon: imagePokemon
                                        )));
    }
コード例 #5
0
    public IEnumerator LegacyLoadPokemon(PokemonData data,
                                         bool useicon                  = false,
                                         bool useFront                 = false,
                                         bool useBack                  = false,
                                         BTLSCN_Pokemon scnPokemon     = null,
                                         BTLSCN_PokemonBW scnPokemonBW = null,
                                         PBS.Battle.View.Scene.Entities.Pokemon scnPokemonNew = null,
                                         Image imagePokemon = null)
    {
        // sprite loading
        string iconSprite  = "pokemonSprites/icon/" + data.displayID;
        string frontSprite = "pokemonSprites/front/" + data.displayID;
        string backSprite  = "pokemonSprites/back/" + data.displayID;

        // icon
        if (!loadedPokemonSprites.ContainsKey(iconSprite))
        {
            loadedPokemonSprites[iconSprite] = null;
            var op = Addressables.LoadAssetAsync <Sprite>(iconSprite);
            yield return(op);

            if (op.Status == AsyncOperationStatus.Succeeded)
            {
                loadedPokemonSprites[iconSprite] = op.Result;
                if (useicon)
                {
                    SetPokemonSprite(
                        spritePath: iconSprite,
                        scnPokemon: scnPokemon,
                        scnPokemonBW: scnPokemonBW,
                        scnPokemonNew: scnPokemonNew,
                        imagePokemon: imagePokemon
                        );
                }
            }
        }
        else if (useicon)
        {
            SetPokemonSprite(
                spritePath: iconSprite,
                scnPokemon: scnPokemon,
                scnPokemonBW: scnPokemonBW,
                scnPokemonNew: scnPokemonNew,
                imagePokemon: imagePokemon
                );
        }

        // front
        if (!loadedPokemonSprites.ContainsKey(frontSprite))
        {
            loadedPokemonSprites[frontSprite] = null;
            var op = Addressables.LoadAssetAsync <Sprite>(frontSprite);
            yield return(op);

            if (op.Status == AsyncOperationStatus.Succeeded)
            {
                loadedPokemonSprites[frontSprite] = op.Result;
                if (useFront)
                {
                    SetPokemonSprite(
                        spritePath: frontSprite,
                        scnPokemon: scnPokemon,
                        scnPokemonBW: scnPokemonBW,
                        scnPokemonNew: scnPokemonNew,
                        imagePokemon: imagePokemon
                        );
                }
            }
        }
        else if (useFront)
        {
            SetPokemonSprite(
                spritePath: frontSprite,
                scnPokemon: scnPokemon,
                scnPokemonBW: scnPokemonBW,
                scnPokemonNew: scnPokemonNew,
                imagePokemon: imagePokemon
                );
        }

        // back
        if (!loadedPokemonSprites.ContainsKey(backSprite))
        {
            loadedPokemonSprites[backSprite] = null;
            var op = Addressables.LoadAssetAsync <Sprite>(backSprite);
            yield return(op);

            if (op.Status == AsyncOperationStatus.Succeeded)
            {
                loadedPokemonSprites[backSprite] = op.Result;
                if (useBack)
                {
                    SetPokemonSprite(
                        spritePath: backSprite,
                        scnPokemon: scnPokemon,
                        scnPokemonBW: scnPokemonBW,
                        scnPokemonNew: scnPokemonNew,
                        imagePokemon: imagePokemon
                        );
                }
            }
        }
        else if (useBack)
        {
            SetPokemonSprite(
                spritePath: backSprite,
                scnPokemon: scnPokemon,
                scnPokemonBW: scnPokemonBW,
                scnPokemonNew: scnPokemonNew,
                imagePokemon: imagePokemon
                );
        }
    }