예제 #1
0
        private void Update()
        {
            temporizador.Update();

            for (int i = 0; i < entidades.Count; i++)
            {
                if (entidades[i] == null)
                {
                    entidades.RemoveAt(i--);
                }
            }

            if (game.IsEstado(GameplayEstado.JUGANDO))
            {
                for (int i = 0; i < generacion.Length; i++)
                {
                    generacion[i].Update();
                }
                if (temporizador.IsActivo() && automatico)
                {
                    if (Generar())
                    {
                        temporizador.Start();
                    }
                }
            }
        }
예제 #2
0
        public void  ActualizarVelocidad()
        {
            if (!IsEnable())
            {
                return;
            }
            if (gameplay == null)
            {
                gameplay = ManagerGameplay.GetInstancia();
            }

            Rigidbody r = GetEntidad().GetRigidbody();

            if (r == null)
            {
                return;
            }

            if (!gameplay.IsEstado(GameplayEstado.JUGANDO))
            {
                Detener();
            }
            else
            {
                direccion = direccion.normalized;
                AjustarVelocidad(r.velocity + (velocidad * direccion));

                /*
                 * Vector3 target = posiciondeseada;
                 * target.y = 0;
                 * Vector3 origen = r.position;
                 * origen.y = 0;
                 *
                 * float distancia = (target - origen).magnitude;
                 * direccion = (target - origen).normalized;
                 *
                 * float k = 1.0f;
                 * if (distancia < distanciaactivacion)
                 *  k = distancia / distanciaactivacion * velocidadajuste;
                 *
                 * AjustarVelocidad(r,r.velocity + ((k * velocidad) * direccion));
                 */
            }
        }