Beispiel #1
0
    public override Vector3 Calculate(Boid_Data x)
    {
        float dist = Vector3.Distance(x.target, x.transform.position);

        Vector3 target = path.waypoints[current];

        x.target = target;
        bool ariveFlag = false;

        if (dist < distance)
        {
            if (path.looped)
            {
                current  = (current + 1) % path.waypoints.Count;
                target   = path.waypoints[current];
                x.target = target;
            }
            else
            {
                if (current != path.waypoints.Count - 1)
                {
                    current++;
                    target   = path.waypoints[current];
                    x.target = target;
                    if (current == path.waypoints.Count)
                    {
                        Debug.Log("Trigger");
                        ariveFlag = true;
                    }
                }
            }

            // return x.GetComponent<SeekBehaviour>().Calculate(x);
        }
        int stopAt = path.waypoints.Count;

        if (!path.looped && current == path.waypoints.Count - 1)
        {
            //target = path.waypoints[path.waypoints.Count];
            // x.target = target;
            return(x.GetComponent <ArriveBehaviour>().Calculate(x));
        }
        else
        {
            return(x.GetComponent <SeekBehaviour>().Calculate(x));
        }
        //return Vector3.zero;
    }
Beispiel #2
0
    public override Vector3 Calculate(Boid_Data x)
    {
        boid = x.target;
        float dist = Vector3.Distance(x.transform.position, target);

        if (dist < 20)
        {
            target   = Random.insideUnitSphere * (radus);
            x.target = target;
        }
        return(x.GetComponent <SeekBehaviour>().Calculate(x));
    }
Beispiel #3
0
    public override Vector3 Calculate(Boid_Data x)
    {
        Vector3 disp = jitter * Random.insideUnitSphere * Time.deltaTime;

        target += disp;
        target.Normalize();
        target *= radius;

        Vector3 localTarget = (Vector3.forward * distance) + target;

        worldTarget = transform.TransformPoint(localTarget);
        Vector3 targetFound = worldTarget - transform.position;

        x.target = targetFound;
        return(x.GetComponent <SeekBehaviour>().Calculate(x));
    }
Beispiel #4
0
    public override Vector3 Calculate(Boid_Data x)
    {
        if (target != null)
        {
            float dist = Vector3.Distance(target.transform.position, x.transform.position);
            float time = dist / x.maxSpeed;

            targetPos = target.transform.position + (target.velocity * time);

            return(x.GetComponent <SeekBehaviour>().Calculate(x));
        }
        else
        {
            weight = 0;
            GetComponent <CustomWonder>().weight = 1;
            GetComponent <Boid_Data>().action    = Boid_Data.Behaviour.explore;
            return(Vector3.zero);
        }
    }
Beispiel #5
0
    void FormUp(Boid_Data x)
    {
        x.GetComponent <Drone_Data>().enabled     = false;
        x.GetComponent <CustomWonder>().weight    = 0f;
        x.GetComponent <ArriveBehaviour>().weight = 1f;
        x.GetComponent <SeekBehaviour>().weight   = 0f;
        x.GetComponent <Boid_Data>().target       = x.GetComponent <Boid_Data>().formationPosistion;
        Explore(x);
        float dist = Vector3.Distance(x.transform.position, x.target);

        if (dist < 2f)
        {
            x.action = Boid_Data.Behaviour.InFormation;
            BeginTheBattle();
        }
    }
Beispiel #6
0
    protected override void OnUpdate()
    {
        foreach (var b in GetEntities <components>())
        {
            Boid_Data x = b.boid;

            //tryed making a state machine setup but slowed down performace to 6 fps unknowen reasion
            if (x.action == Boid_Data.Behaviour.formation)
            {
                x.GetComponent <Drone_Data>().enemyTag = "";
                FormUp(x);
            }
            else if (x.action == Boid_Data.Behaviour.InFormation)
            {
                TenHuh(x);
            }
            else
            {
                Explore(x);
            }
        }
    }