Beispiel #1
0
    public void changeActive(Vector3 initPos)
    {
        switch (state)
        {
        case bulletState.ACTIVE:
            gameObject.transform.position = initPos;
            state = bulletState.INACTIVE;
            break;

        case bulletState.INACTIVE:
            soundManager.soundsSingleton.playSoundEffect(Random.Range(4, 7));

            state = bulletState.ACTIVE;

            gameObject.transform.position = initPos;

            dirPos = alpaca.transform.position;

            dirPos = new Vector3(transform.position.x - dirPos.x, transform.position.y - dirPos.y, 0);

            dirPos = Vector3.Normalize(dirPos);

            transform.LookAt(transform.position + dirPos);

            break;
        }
    }
Beispiel #2
0
    public void changeActive(Vector3 targets)
    {
        switch (state)
        {
        case bulletState.ACTIVE:
            gameObject.SetActive(false);
            state = bulletState.INACTIVE;
            break;

        case bulletState.INACTIVE:
            gameObject.SetActive(true);
            state = bulletState.ACTIVE;

            target = targets;

            distToTarget     = Vector3.Distance(transform.position, target);
            distToTargetHalf = distToTarget / 2;

            dirPos = target;

            point = dirPos;

            transform.LookAt(dirPos);

            dirPos = new Vector3(dirPos.x - transform.position.x, 0, dirPos.z - transform.position.z);

            dirPos = Vector3.Normalize(dirPos);

            break;
        }
    }
Beispiel #3
0
    void Update()
    {
        if (status == bulletState.waiting)
        {
            return;
        }



        //if beam, have the turret control it
        //    if (beam)
        //       transform.parent = shooter.transform;

        //force



        //travel distance
        travelled += velocity * Time.deltaTime;

        if (travelled > range)
        {
            status = bulletState.miss;
        }

        //remove if ended last frame
        if (status == bulletState.hit || status == bulletState.miss)
        {
            Destroy(gameObject);
        }


        transform.SetParent(cleanup.getCleaner());
    }
Beispiel #4
0
    public void changeActive(Vector3 position)
    {
        switch (state)
        {
        case bulletState.ACTIVE:
            gameObject.SetActive(false);
            state = bulletState.INACTIVE;
            break;

        case bulletState.INACTIVE:
            gameObject.SetActive(true);
            state = bulletState.ACTIVE;

            dirPos = position;

            point = dirPos;

            transform.LookAt(dirPos);

            dirPos = new Vector3(dirPos.x - transform.position.x, 0, dirPos.z - transform.position.z);

            dirPos = Vector3.Normalize(dirPos);

            break;
        }
    }
Beispiel #5
0
    void Hit(Collider other)
    {
        other.SendMessageUpwards("BulletHit", this, SendMessageOptions.DontRequireReceiver);

        if (AmmoManager.checkAlias(hitEffectAlias))
        {
            Instantiate(AmmoManager.getHit(hitEffectAlias).gameObject, transform.position, transform.rotation);
        }

        status = bulletState.hit;


        //alt kinetic force
        if (impactForce > 0)
        {
            if (other.GetComponentInParent <Rigidbody>())
            {
                other.GetComponentInParent <Rigidbody>().AddForceAtPosition(impactForce * GetComponentInParent <Rigidbody>().velocity, transform.position);
            }
        }
    }