Esempio n. 1
0
        private bool spawnOne()
        {
            GameObject       prefab = ps.prefabs[Random.Range(0, ps.prefabs.Length)];
            PokemonCatchable poke   = prefab.GetComponent <PokemonCatchable>();
            Vector2          circleRan;
            Vector3          pos = new Vector3();
            int i = 0;

            do
            {
                if (i > 1000)
                {
                    Debug.Log("Stopped spawning pokemons at " + ps.amount + ". not enough space!");
                    return(false);
                }
                circleRan = ps.spawnRadius * Random.insideUnitCircle;
                pos       = new Vector3(circleRan.x + ps.transform.position.x, ps.transform.position.y,
                                        circleRan.y + ps.transform.position.z);
                i++;
            } while (Physics.CheckSphere(pos, poke.radius + ps.distanceRadius, (1 << 8) + (1 << 9)));
            GameObject one = PrefabUtility.InstantiatePrefab(prefab, ps.parent) as GameObject;

            one.transform.position = pos;
            one.transform.rotation = Quaternion.Euler(Vector3.up * Random.Range(0f, 360f));
            instanciated.Add(new PokemonSpawner.InstanceDetails(prefab, pos, one.transform.rotation));
            return(true);
        }
Esempio n. 2
0
 public void NoneCatching()
 {
     if (!ReferenceEquals(previousBeingCaught, null))
     {
         previousBeingCaught.ExitCatch();
     }
     previousBeingCaught = null;
 }
Esempio n. 3
0
    public void CatchPokemon(PokemonCatchable pokemon)
    {
        caughtPokemons.Enqueue(pokemon);
        smoke.gameObject.transform.position = pokemon.gameObject.transform.position;
        smoke.Play();

        previousBeingCaught = null;
        UIManager.Instance.SetScore(++caughtNumber);
    }
Esempio n. 4
0
    public void TryToCatchPokemon(GameObject pokemon, bool isBeingCaught)
    {
        if (!isBeingCaught)
        {
            NoneCatching();
            return;
        }

        var currentPoke = pokemon.GetComponent <PokemonCatchable>();

        if (previousBeingCaught != null)
        {
            Assert.IsTrue(previousBeingCaught.Equals(currentPoke));
        }
        else
        {
            currentPoke.TryToCatch();
        }

        previousBeingCaught = currentPoke;
    }
Esempio n. 5
0
 private void OnEnable()
 {
     poke = (PokemonCatchable)target;
 }