Ejemplo n.º 1
0
    public void SetLearnSkillsMenu(System.Action <int> confirmFunc, System.Action refuseFunc)
    {
        //set refuse skill button
        refuseSkillButton.onClick.RemoveAllListeners();
        refuseSkillButton.onClick.AddListener(() => refuseFunc());

        //deactive every button in the pooling and add if there are not enough buttons in pool
        skillsToReplacePooling.DeactiveAll();
        skillsToReplacePooling.InitCycle(prefabSimpleButton, GameManager.instance.MaxSkillForPokemon);

        //get current skills of the pokemon
        List <SkillModel> currentSkills = fightManager.currentPlayerPokemon.CurrentSkills;
        int quantity = Mathf.Min(currentSkills.Count + 1, GameManager.instance.MaxSkillForPokemon);

        for (int i = 0; i < quantity; i++)
        {
            //instantiate button from pool and set parent
            Button button = skillsToReplacePooling.Instantiate(prefabSimpleButton, contentLearnSkillMenu, false);

            //be sure to not have listeners
            button.onClick.RemoveAllListeners();

            //add new listener to button
            int indexForLambda = i;                                         //for some reason, need to make a copy of anything you want to access for the lambda
            button.onClick.AddListener(() => confirmFunc(indexForLambda));

            //set text (name of the skill or empty)
            button.GetComponentInChildren <Text>().text = i < currentSkills.Count ? currentSkills[i].GetObjectName() : "-";
        }

        skillsToReplacePooling.EndCycle(quantity);
    }
Ejemplo n.º 2
0
    protected virtual void Attack()
    {
        //create shot (pool, position, rotation, scale, init)
        TurretShot shot = shots.Instantiate(shotPrefab, shotSpawns[indexSpawn].position, shotSpawns[indexSpawn].rotation);
        float      size = GameManager.instance.world.worldConfig.CellsSize;

        shot.transform.localScale = new Vector3(size, size, size);
        shot.Init(this, EnemyToAttack);

        //call event
        onShoot?.Invoke(shotSpawns[indexSpawn]);

        //cycle between spawns
        indexSpawn = indexSpawn < shotSpawns.Length - 1 ? indexSpawn + 1 : 0;
    }
Ejemplo n.º 3
0
    protected void SuperHit(Collision collision)
    {
        //pooling particles on the bat
        if (batParticles != null)
        {
            ParticleSystem go = poolingParticles.Instantiate(batParticles, collision.GetContact(0).point, Quaternion.identity);
            go.Play(true);
        }

        //if hit a carp, call his super hit
        Carp carp = collision.gameObject.GetComponent <Carp>();

        if (carp != null)
        {
            carp.SuperHit();
        }
    }
Ejemplo n.º 4
0
    public void SetCatchPokemonMenu(System.Action <int> confirmFunc, System.Action refuseFunc)
    {
        //set refuse pokemon button
        refuseCatchPokemonButton.onClick.RemoveAllListeners();
        refuseCatchPokemonButton.onClick.AddListener(() => refuseFunc());

        //deactive every button in the pooling and add if there are not enough buttons in pool
        pokemonCatchPooling.DeactiveAll();
        pokemonCatchPooling.InitCycle(prefabSimpleButton, GameManager.instance.MaxPokemonInTeam);

        //get current player pokemons
        List <PokemonModel> playerPokemons = GameManager.instance.Player.PlayerPokemons;
        int quantity = Mathf.Min(playerPokemons.Count + 1, GameManager.instance.MaxPokemonInTeam);

        for (int i = 0; i < quantity; i++)
        {
            //instantiate button from pool and set parent
            Button button = pokemonCatchPooling.Instantiate(prefabSimpleButton, contentCatchPokemonMenu, false);

            //be sure to not have listeners
            button.onClick.RemoveAllListeners();

            //add new listener to button
            int indexForLambda = i;                                         //for some reason, need to make a copy of anything you want to access for the lambda
            button.onClick.AddListener(() => confirmFunc(indexForLambda));

            //set text (name of the pokemon or empty)
            button.GetComponentInChildren <Text>().text = i < playerPokemons.Count ? playerPokemons[i].GetObjectName() : "-";

            //set not interactable button of pokemon in arena
            if (i < playerPokemons.Count && playerPokemons[i] == fightManager.currentPlayerPokemon)
            {
                button.interactable = false;
            }
            //be sure other buttons are interactable, or when start another fight can be a button not interactable from previous battle
            else if (button.interactable == false)
            {
                button.interactable = true;
            }
        }

        pokemonCatchPooling.EndCycle(quantity);
    }
Ejemplo n.º 5
0
    void SetList <T>(Pooling <Button> poolingList, List <T> valueArray, Transform parent, System.Action <Button, T> function) where T : IGetName
    {
        //deactive every button
        poolingList.DeactiveAll();

        //add if there are not enough buttons in pool
        poolingList.InitCycle(prefabSimpleButton, valueArray.Count);

        //foreach value
        foreach (T value in valueArray)
        {
            //instantiate button from pool and set parent
            Button button = poolingList.Instantiate(prefabSimpleButton, parent, false);

            //and set it
            SetButton(button, value, function);
        }

        poolingList.EndCycle(valueArray.Count);
    }
Ejemplo n.º 6
0
    IEnumerator HitRoutine(HitInfo hit)
    {
        //WeaverLog.Log("NAIL TINK ATTACK DIRECTION = " + hit.Direction);
        WeaverGameManager.FreezeGameTime(WeaverGameManager.TimeFreezePreset.Preset3);
        Player.Player1.EnterParryState();
        CameraShaker.Instance.Shake(WeaverCore.Enums.ShakeType.EnemyKillShake);

        //PLAY AUDIO
        WeaverAudio.PlayAtPoint(TinkSound, transform.position);

        var attackDirection = hit.Direction;

        CardinalDirection direction = CardinalDirection.Right;

        if (attackDirection < 360f && attackDirection > 225f)
        {
            direction = CardinalDirection.Down;
        }
        else if (attackDirection <= 225f && attackDirection > 135f)
        {
            direction = CardinalDirection.Left;
        }
        else if (attackDirection <= 135 && attackDirection > 45f)
        {
            direction = CardinalDirection.Up;
        }
        else
        {
            direction = CardinalDirection.Right;
        }

        //WeaverLog.Log("TINK DIRECTION = " + direction);

        switch (direction)
        {
        case CardinalDirection.Up:
            Player.Player1.Recoil(CardinalDirection.Down);
            Pooling.Instantiate(TinkEffectPrefab, Player.Player1.transform.position + new Vector3(0f, 1.5f, 0f), Quaternion.identity);
            break;

        case CardinalDirection.Down:
            Player.Player1.Recoil(CardinalDirection.Up);
            Pooling.Instantiate(TinkEffectPrefab, Player.Player1.transform.position + new Vector3(0f, -1.5f, 0f), Quaternion.identity);
            break;

        case CardinalDirection.Left:
            Player.Player1.Recoil(CardinalDirection.Right);
            Pooling.Instantiate(TinkEffectPrefab, Player.Player1.transform.position + new Vector3(-1.5f, 0f, 0f), Quaternion.identity);
            break;

        case CardinalDirection.Right:
            Player.Player1.Recoil(CardinalDirection.Left);
            Pooling.Instantiate(TinkEffectPrefab, Player.Player1.transform.position + new Vector3(1.5f, 0f, 0f), Quaternion.identity);
            break;
        }

        yield return(null);


        Player.Player1.RecoverFromParry();


        if (enemy != null)
        {
            enemy.OnParry(this, hit);
        }


        yield return(null);

        yield return(new WaitForSeconds(0.15f));
    }
Ejemplo n.º 7
0
        public void PlayHitEffect(HitInfo hit, Vector3 effectsOffset = default(Vector3))
        {
            if (!firedOnCurrentFrame)
            {
                firedOnCurrentFrame = true;

                var audio = WeaverAudio.PlayAtPoint(DamageSound, transform.position, channel: AudioChannel.Sound);
                audio.AudioSource.pitch = UnityEngine.Random.Range(audioPitchMin, audioPitchMax);

                //DamageFlashPool.Instantiate(transform.position + effectsOffset, Quaternion.identity);
                Pooling.Instantiate(DamageFlash, transform.position + effectsOffset, Quaternion.identity);

                if (doFlashEffects)
                {
                    flasher.flashInfected();
                }

                switch (DirectionUtilities.DegreesToDirection(hit.Direction))
                {
                case CardinalDirection.Up:
                    if (doBlood)
                    {
                        Blood.SpawnDirectionalBlood(transform.position + effectsOffset, CardinalDirection.Up);
                    }
                    //HitPuffPool.Instantiate(transform.position, Quaternion.Euler(270f, 90f, 270f));
                    Pooling.Instantiate(HitPuff, transform.position, Quaternion.Euler(270f, 90f, 270f));
                    break;

                case CardinalDirection.Down:
                    if (doBlood)
                    {
                        Blood.SpawnDirectionalBlood(transform.position + effectsOffset, CardinalDirection.Down);
                    }
                    Pooling.Instantiate(HitPuff, transform.position, Quaternion.Euler(-72.5f, -180f, -180f));
                    break;

                case CardinalDirection.Left:
                    if (doBlood)
                    {
                        Blood.SpawnDirectionalBlood(transform.position + effectsOffset, CardinalDirection.Left);
                    }
                    Pooling.Instantiate(HitPuff, transform.position, Quaternion.Euler(180f, 90f, 270f));
                    break;

                case CardinalDirection.Right:
                    if (doBlood)
                    {
                        Blood.SpawnDirectionalBlood(transform.position + effectsOffset, CardinalDirection.Right);
                    }
                    Pooling.Instantiate(HitPuff, transform.position, Quaternion.Euler(0f, 90f, 270f));
                    break;
                }

                //GameObject hitParticles = Instantiate(Assets.EffectAssets.UninfectedHitPrefab, transform.position + effectsOffset, Quaternion.identity);
                //GameObject hitParticles = InfectedHitPool.Instantiate(transform.position + effectsOffset, Quaternion.identity);

                /*var direction = DirectionUtilities.DegreesToDirection(hit.Direction);
                 *
                 * switch (direction)
                 * {
                 *      case CardinalDirection.Up:
                 *              SetRotation2D(hitParticles.transform, 45f);
                 *              break;
                 *      case CardinalDirection.Down:
                 *              SetRotation2D(hitParticles.transform, 225f);
                 *              break;
                 *      case CardinalDirection.Left:
                 *              SetRotation2D(hitParticles.transform, -225f);
                 *              break;
                 *      case CardinalDirection.Right:
                 *              SetRotation2D(hitParticles.transform, -45f);
                 *              break;
                 * }
                 *
                 * Flings.SpawnFlings(NormalFlings, transform.position + effectsOffset, direction);*/
            }
        }