示例#1
0
 public Pokemon(Texture2D image, Vector2 position, Color color, Texture2D attackTexture, Texture2D deadTexture) : base(image, position, color)
 {
     rotation           = 0;
     origin             = new Vector2(image.Width, image.Height) / 2;
     ground             = (int)(position.Y + image.Height);
     thunderBolts       = new List <ThunderBolt>();
     this.attackTexture = attackTexture;
     pokemonState       = PokemonState.alive;
     this.deadTexture   = deadTexture;
     initialJump        = false;
     maxJumpTime        = TimeSpan.FromMilliseconds(10000000);
 }
示例#2
0
 /// <summary>
 /// will not notify property changes
 /// </summary>
 public void SetAll(string name, PokemonForm form, PokemonGender gender, int lv, Position position, bool substitute, int hp, PokemonState state, bool shiny)
 {
     _name        = name;
     Form         = form;
     _gender      = gender;
     Lv           = lv;
     _position.X  = position.X;
     _position.Y  = position.Y;
     IsSubstitute = substitute;
     Hp.Value     = hp;
     _state       = state;
     Shiny        = shiny;
 }
示例#3
0
 private static void DeAbnormalState(DefContext def, PokemonState state)
 {
     def.BasePower = def.Defender.State == state ? 120 : 60;
 }
示例#4
0
    private void OnReductionDone()
    {
        if (_isBeingCaptured)
        {
            _state = PokemonState.TryingToEscapeBall; // This state is useless as all the pokemon actions are dictated by the Pokéball. The only purpose of this state is to make the Pokémon wait.

            _hologram.enabled = false;
            _homeBall.EndSwallow();
            this.gameObject.SetActive(false);
        }
    }
示例#5
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.S))
        {
            CreateHologram();
        }

        if (Input.GetKeyDown(KeyCode.T))
        {
            CreateHologram();
            _state = PokemonState.TurnsIntoRedEnergy;
        }

        if (_state == PokemonState.Touched)
        {
            float decayRatio = Mathf.Clamp01(100f * Time.deltaTime);

            _anim.speed *= decayRatio;
            _nav.speed *= decayRatio;
            _nav.angularSpeed *= decayRatio;
            _nav.velocity *= decayRatio;

            //Debug.LogError("new anim speed = " + _anim.speed);
        }
        else if (_state == PokemonState.TurnsIntoRedEnergy)
        {
            _redEnergyConversionTime += Time.deltaTime;

            float percentage = _redEnergyConversionTime / _redEnergyConversionTotalTime;

            if (percentage < 1f)
            {
                foreach (Material mat in _hologram.materials)
                {
                    float inversedPercentage = 1f - percentage;
                    mat.color = new Color(1f, inversedPercentage, inversedPercentage, 0.5f + 0.5f * inversedPercentage);
                    if (mat.HasProperty("_EmissionColor"))
                    {
                        mat.SetColor("_EmissionColor", new Color(percentage, 0f, 0f));
                    }

                    if (mat.HasProperty("_Glossiness"))
                    {
                        mat.SetFloat("_Glossiness", 0f);
                    }
                }
            }
            else
            {
                if (_isBeingCaptured)
                {
                    Swallow(_homeBall);
                }
                else
                {
                    _state = PokemonState.LaserSwallowed;
                    _homeBall.Recall();
                    //_hologram.gameObject.BroadcastMessage("StartShrinking", _tr);
                    _meshReductor.StartShrinking(_homeBall.transform);
                }
            }
        }
        /*else if (_state == PokemonState.Swallowed)
        {
            float timeLeft = 1f - Mathf.Clamp01(Time.time - _captureTime); // Goes from 1 to 0.

            if (timeLeft <= 0f)
            {
                _state = PokemonState.TryingToEscapeBall; // This should actually start when the pokeball hits the ground.

                _homeBall.EndSwallow();
                this.gameObject.SetActive(false);
            }
            else
            {
                float scaleRatio = Mathf.Pow(timeLeft * (1 - _shrinkingRatio), 2f) + _shrinkingRatio;
                _tr.localScale = _baseLocalScale * scaleRatio;

                float threshold = 0.9f;
                if (timeLeft < threshold)
                {
                    _tr.position = _homeBall.transform.position + _pathToBall * timeLeft * (1f / threshold);
                }
            }

            return;
        }*/
        else if (_state == PokemonState.BeingReleased)
        {
            if (_tr.localScale != _baseLocalScale)
            {
                _tr.localScale += _baseLocalScale * 6f * Time.deltaTime;

                if (_tr.localScale.magnitude > _baseLocalScale.magnitude)
                {
                    _tr.localScale = _baseLocalScale;
                }
            }

            if (_deformation.DeformationHasEnded() && !_spawningParticle.isPlaying)
            {
                _emissionOriginalColor = Color.white;
                _emissionTargetColor = Color.black;

                if (_isCaptured)
                {
                    _state = PokemonState.Idle;
                    _anim.SetTrigger("TauntTrigger");
                }
                else
                {
                    _state = PokemonState.Roaming;
                }
            }
        }
        else if (_state == PokemonState.Roaming)
        {
            _anim.SetFloat("MoveSpeed", _nav.velocity.magnitude);
            _waitTime -= Time.deltaTime;

            if (_nav.remainingDistance < 0.1f && _waitTime <= 0f)
            {
                if (Random.value < 0.4f)
                {
                    _waitTime = Random.Range(1f, 3f);
                }
                else
                {
                    _nav.SetDestination(new Vector3(Random.Range(-_range, _range), 0f, Random.Range(-_range, _range)));
                }
            }
        }

        Color _currentEmissionColor = _rend.material.GetColor("_EmissionColor");
        if (_emissionTargetColor != _currentEmissionColor) // We assume all the materials are at the same emission level and none of the materials use this property.
        {
            foreach (Material mat in _rend.materials)
            {
                Color newEmission = _currentEmissionColor + (_emissionTargetColor - _emissionOriginalColor) * 1.5f * Time.deltaTime;

                // If we went passed the target emission, we set it right.
                if (Mathf.Clamp01(newEmission.r) != newEmission.r)
                {
                    newEmission = _emissionTargetColor;
                }

                mat.SetColor("_EmissionColor", newEmission); // 0.5 second transition.
            }
        }
    }
示例#6
0
    public void TurnIntoRedEnergy(bool status_)
    {
        _redEnergyConversionTime = 0f;

        if (status_ == true)
        {
            _state = PokemonState.TurnsIntoRedEnergy;

            _anim.speed = 0f;
            CreateHologram(); // Also enables the MeshRenderer that is _hologram.

            if (_skinnedMesh != null)
            {
                _skinnedMesh.enabled = false;
            }

            //_recallingParticle.Play();
        }
        else
        {
            _state = PokemonState.Idle;

            _anim.speed = 1f;
            if (_hologram != null)
            {
                _hologram.enabled = false;
            }

            if (_skinnedMesh != null)
            {
                _skinnedMesh.enabled = true;
            }

            //_recallingParticle.Stop();
        }
    }
示例#7
0
    public Vector3 Touched(Pokeball ball)
    {
        // Returns the position the Pokeball should bounce back at.

        /// The next steps are the following:
        /// - the Pokémon brakes until it's frozen (can be frozen mid-air).
        /// - meanwhile, the Pokéball bounces back and turns to face the Pokémon.
        /// - once the pokeball is in position, the pokeball opens and the pokemon turns into red energy.
        /// - I'd like to keep the white flash light at the moment.
        /// - the pokeball closes once all the energy is inside.
        /// - then we proceed normally with the fall followed shaking.
        /// - note: I'll need to manage the breakout of the pokeball once I'll be able to pick some more from my back.

        Debug.Log("Touched method called.");

        if (_homeBall != null)
        {
            // You can't capture someone else's Pokémon!
            return Vector3.zero;
        }

        _state = PokemonState.Touched;
        _homeBall = ball;
        _isBeingCaptured = true;

        //_emissionOriginalColor = _rend.material.GetColor("_EmissionColor");
        //_emissionTargetColor = Color.white;

        // Calculating the bounce destination. A ajuster.
        Vector3 destination = ball.transform.position - _tr.position;
        destination.y = 0;
        //destination.Normalize();

        Bounds bounds = _rend.bounds;
        destination.y = ball.transform.position.y + Mathf.Max(0.6f, bounds.extents.y); // Rajouter une telle hauteur va faire traverser les Pokémons volants au dessus du joueur à la Pokéball.

        return destination;
    }
示例#8
0
    public void Swallow(Pokeball ball)
    {
        _state = PokemonState.Swallowed;

        _hologram.GetComponent<MeshReductor>().StartShrinking(_homeBall.transform);

        _captureTime = Time.time;
        _anim.speed = 0f; // Freezes the Pokemon.
        _nav.enabled = false;

        // Calculating the shrinking ratio for the Pokémon to fit within the Pokéball.
        Bounds bounds = _rend.bounds;
        float diagonal = bounds.size.magnitude; // La magnitude de la taille de la bounding box représente la diagonale de cette boite et est un bon indicateur du volume du personne.
        _shrinkingRatio = Mathf.Sqrt(0.018252f) / diagonal; // Attention aux divisions par 0 ! Racine de 0.018252 est la diagonale de la bounding box de la pokeball.

        _pathToBall = _tr.position - ball.transform.position;
    }
示例#9
0
 public void StoreInPokeball()
 {
     _state = PokemonState.StoredInPokeball;
     _recallingParticle.Stop();
 }
示例#10
0
    public void ReleaseFromPokeball()
    {
        _state = PokemonState.BeingReleased;

        _tr.localScale = Vector3.one / 100000f;
        _anim.speed = 1f;
        _nav.enabled = true;
        _nav.speed = _defaultAgentSpeed;
        _nav.angularSpeed = _defaultAgentAngularSpeed;

        _skinnedMesh.enabled = true;
        _rend.material.SetColor("_EmissionColor", Color.white);
        _emissionOriginalColor = Color.white;
        _emissionTargetColor = Color.white;

        if (_deformation != null)
        {
            if (_deformation._animator == null)
            {
                _deformation._animator = _anim;
            }

            _deformation.LaunchDeformation();
        }

        if (_spawningParticle != null)
        {
            if (!_spawningParticle.isStopped)
            {
                _spawningParticle.Stop();
            }

            //_spawningParticle.Play();
        }

        if (!_isCaptured)
        {
            _homeBall = null;
        }
    }