Example #1
0
        private void Update()
        {
            #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
            #endif
            if (!enable)
            {
                return;
            }

            if (game.IsEstado(GameplayEstado.JUGANDO))
            {
                for (int i = 0; i < generacion.Count; i++)
                {
                    generacion[i].Update();
                }

                if (entidadreferencia == null)
                {
                    Generar();
                }
                else
                {
                    if (Mathf.Abs(entidadreferencia.GetPosicion().z - GetPosicion().z) >= distancia)
                    {
                        Generar();
                    }
                }
            }
        }
        public void ActualizarVelocidad()
        {
            if (!IsEnable())
            {
                return;
            }


            Rigidbody r = GetEntidad().GetRigidbody();

            if (r == null)
            {
                return;
            }

            if (!gameplay.IsEstado(GameplayEstado.JUGANDO))
            {
                r.velocity = Vector3.zero;
            }
            else
            {
                Vector3 vbase = Vector3.zero;
                if (relativo && gameplay != null)
                {
                    vbase = gameplay.GetVelocidad() * Vector3.forward;
                }

                switch (tipomovimiento)
                {
                case MovimientoTipo.BASICO:
                    r.velocity = (velocidad * direccionbasica) - vbase;
                    break;

                case MovimientoTipo.SEGUIMIENTO:

                    float   distancia       = (posiciondeseada - r.position).magnitude;
                    Vector3 direccionajuste = (posiciondeseada - r.position).normalized;

                    float k = 1.0f;
                    if (distancia < distanciaactivacion)
                    {
                        k = distancia / distanciaactivacion * ajustevelocidad;
                    }

                    r.velocity = ((k * velocidad) * direccionajuste) - vbase;

                    break;
                }
            }
        }
Example #3
0
        public override void Update()
        {
            base.Update();

            if (!IsEnable())
            {
                return;
            }
            if (gameplay.IsEstado(GameplayEstado.JUGANDO))
            {
                if (horizontal.IsClickDown())
                {
                    SetPosicionX((int)posicion.x + horizontal.GetValor());
                }
                if (vertical.IsClickDown())
                {
                    SetPosicionY((int)posicion.y + vertical.GetValor());
                }
            }
        }