示例#1
0
    void Update()
    {
        float height = transform.position.z;

        //si alcanzamos un punto debemos cambiar de target al otro punto
        float distance = (currentTarget - kineticsAgent.transform.position).magnitude;

        if (distance <= 1f) //intercambiamos targets
        {
            Vector3 swap = currentTarget;
            currentTarget = otherTarget;
            otherTarget   = swap;
        }

        //ajustamos el tamanno del pokemon de acuerdo a la altura
        //float targetSize = Math.Abs(height)*(0.4f);
        float targetSize = (float)Math.Log(Math.Abs(height));

        if (targetSize < minSize)
        {
            targetSize = minSize;
        }

        float caught = 1f;

        if (transform.localScale.x == 0)//si ya lo atraparon no queremos seguir cambiando su size
        {
            caught = 0f;
        }
        transform.localScale = new Vector3(targetSize * caught, targetSize * caught, 1f * caught);

        //hacemos seek al punto actuall
        steeringAgent.UpdateSteering(seek.getSteering2(currentTarget, 1));
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        Vector3 screenPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        screenPoint.z = 0f;
        kineticsEnemy.transform.position = screenPoint;
        steeringAgent.UpdateSteering(priority.getSteering());
    }
示例#3
0
    void Update()
    {
        //un pokemon es atrapado cuando su tamanno se vuelve 0
        float caught = pokemons[currentPokemon].transform.localScale.x;

        //SI EL POKEMON QUE SEGUIAMOS FUE ATRAPADO
        if (caught == 0f)
        {
            currentPokemon++;//pasamos al siguiente
            //si ya no hay pokemones
            if (currentPokemon == amountPokemon)
            {
                //dejamos de movernos
                kineticsAgent.velocity = Vector3.zero;
                steeringAgent.linear   = Vector3.zero;
                //apagamos este componente
                enabled = false;
                return;
            }
            UpdatePath();//actualizamos al nuevo camino a seguir
        }


        currentPosition = kineticsAgent.transform.position;//posicion actual del trainer


        //OJO: ese 5f se consiguio tanteando
        //SI ESTAMOS MUY CERCA DEL TRIANGULO QUE SEGUIMOS
        if (Vector3.Distance(currentPosition, currentPath[indexPath]) < 5f)
        {
            indexPath++;                            //nos movemos al siguiente triangulo
            int n = currentPath.Length;
            if (indexPath >= n)                     //si nos pasamos del largo del path
            {
                indexPath = n - 1;                  //nos quedamos en el ultimo
            }
            currentTarget = currentPath[indexPath]; //siguiente triangulo a seguir
        }

        //SI ALCANZAMOS DONDE ESTABA EL POKEMON
        if (Vector3.Distance(currentPosition, pokemonPosition) < 3f)
        {
            //si el pokemon se movio hay que actualizar el camino
            if (pokemonPosition != pokemons[currentPokemon].transform.position)
            {
                UpdatePath();
            }
            else  //si no estamos dentro del triangulo del pokemon asi que lo seguimos
            {
                currentTarget = pokemonPosition;
            }
        }

        //Perseguimos al pokemon
        // con seek
        steeringAgent.UpdateSteering(seek.getSteering2(currentTarget, seek_or_flee));
    }
示例#4
0
    void Update()
    {
        //si alcanzamos un punto debemos cambiar de target al otro punto
        float distance = (currentTarget - kineticsAgent.transform.position).magnitude;

        if (distance <= 1f) //intercambiamos targets
        {
            Vector3 swap = currentTarget;
            currentTarget = otherTarget;
            otherTarget   = swap;
        }


        //hacemos seek al punto actuall
        steeringAgent.UpdateSteering(seek.getSteering2(currentTarget, 1));
    }
示例#5
0
    void Update()
    {
        //si el pokemon actual fue atrapado
        if (pokemons[currentPokemon].transform.localScale.x == 0f)
        {
            currentPokemon++;                                //pasamos al siguiente
            currentPokemon = currentPokemon % amountPokemon; //si nos pasamos del largo del arreglo volvemos al primero
            //actualizamos el target
            pursue.pTarget = pokemonKins[currentPokemon];
        }



        //Perseguimos al enemigo
        // con seek aceleracion
        steeringAgent.UpdateSteering(pursue.getSteering(seek_or_flee));
    }
示例#6
0
    //en este caso la accion es actualizar la acelaracion del usuario
    public override void DoAction()
    {
        Vector3 agent  = agentKin.transform.position;
        Vector3 target = currentTargetPoint;

        if (underground)
        {
            target.z = agent.z;//esta linea hace que sigamos los puntos a la misma altura
        }

        float modifier = 1f;//este numero sera util para que el seek no se pase mucho de los puntos
        int   n        = path.Length;

        //ACTUALIZAR PUNTO
        if (Vector3.Distance(target, agent) < 4f)
        {
            currentIndexPoint++;
            oldTargetPoint = target;
            if (currentIndexPoint == n)                   //si nos pasamos del largo del path
            {
                currentIndexPoint = n - 1;                //nos quedamos en el ultimo
            }
            currentTargetPoint = path[currentIndexPoint]; //siguiente triangulo a seguir
        }

        //ACELERAR MUCHO SI ESTAMOS CAMBIANDO DE PUNTO
        if (Vector3.Distance(oldTargetPoint, agent) < 5f) //si estamos muy cerca del punto anterior
        {
            modifier = 5f;                                //aceleraremos mas para cambiar de direccion al siguiente punto bien
        }

        //SI ESTAMOS EN EL ULTIMO PUNTO NO MODIFICAR ACELERACION
        if (currentIndexPoint == n)
        {
            modifier = 1f;
        }



        //seguimos el punto actual
        steeringAgent.UpdateSteering(seek.getSteering2(target, 1));
        steeringAgent.linear *= modifier;//ajustamos la aceleracion
    }
    //en este caso la accion es actualizar la acelaracion del usuario
    public override void DoAction()
    {
        //HUIMOS DEL TARGET QUE ESTE MAS CERCA
        float    min           = float.PositiveInfinity;
        Vector3  agentPosition = kineticsAgent.transform.position;
        Kinetics currentKin;
        float    currentDistance;

        for (int i = 0; i < kineticsTargets.Length; i++)
        {
            currentKin      = kineticsTargets[i];
            currentDistance = Vector3.Distance(agentPosition, currentKin.transform.position);
            if (currentDistance < min)
            {
                min         = currentDistance;
                seek.target = currentKin;
            }
        }

        //actualizamos aceleracion
        steeringAgent.UpdateSteering(seek.getSteering(0));
    }
 // Update is called once per frame
 void Update()
 {
     steeringAgent.UpdateSteering(priority.getSteering());
 }
示例#9
0
 //en este caso la accion es actualizar la acelaracion del usuario
 public override void DoAction()
 {
     steeringAgent.UpdateSteering(seek.getSteering(1));
 }
示例#10
0
 // Update is called once per frame
 void Update()
 {
     //miramos hacia donde vayamos
     steeringAgent.UpdateSteering(look.getSteering());
 }
示例#11
0
 //en este caso la accion es actualizar la acelaracion del usuario
 public override void DoAction()
 {
     steeringAgent.UpdateSteering(arrive.getSteering());
 }
示例#12
0
 public override void DoAction()
 {
     steering.UpdateSteering(face.getSteeringF2(sensor.detectedSignal.transform.position));
 }
示例#13
0
 void Update()
 {
     //Perseguimos al enemigo
     // con seek aceleracion
     steeringAgent.UpdateSteering(pursue.getSteering(seek_or_flee));
 }
示例#14
0
 // Update is called once per frame
 void Update()
 {
     steeringAgent.UpdateSteering(face.getSteering());
 }
示例#15
0
 void Update()
 {
     //Perseguimos al enemigo
     // con seek aceleracion
     steeringAgent.UpdateSteering(separation.getSteering());
 }
示例#16
0
 void Update()
 {
     //Perseguimos al enemigo
     // con arrive accels
     steeringAgent.UpdateSteering(velMatch.getSteering());
 }
 void Update()
 {
     //Perseguimos al enemigo
     // con seek aceleracion
     steeringAgent.UpdateSteering(obstacleAvoidance.getSteering());
 }
示例#18
0
 // Update is called once per frame
 void Update()
 {
     // igualamos orietacion
     steeringAgent.UpdateSteering(align.getSteering());
 }
示例#19
0
 // Update is called once per frame
 void Update()
 {
     //seguimos el camino
     steeringAgent.UpdateSteering(follow.getSteering());
 }
示例#20
0
 // Update is called once per frame
 void Update()
 {
     steeringAgent.UpdateSteering(blendFlock.getSteering());
     kineticsAgent.GetNewOrietation(kineticsAgent.velocity);
 }
 void Update()
 {
     //Perseguimos al enemigo
     // con seek aceleracion
     steeringAgent.UpdateSteering(collision.getSteering(steeringAgent));
 }
示例#22
0
 // Update is called once per frame
 void Update()
 {
     steeringAgent.UpdateSteering(wander.getSteering());
 }