Пример #1
0
    private void FixedUpdate()
    {
        if ((Vector2)transform.position == (Vector2)TravelPoints[loc].position)
        {
            if (movingForward && loc < TravelPoints.Count - 1)
            {
                loc++;
            }
            else if (movingForward && loc == TravelPoints.Count - 1)
            {
                movingForward = false;
            }
            if (!movingForward && loc != 0)
            {
                loc--;
            }
            else if (!movingForward && loc == 0)
            {
                movingForward = true;
            }
        }

        Vector2 dir = Vector2.zero;

        if (transform.position.y < TravelPoints[loc].position.y)
        {
            dir.y = 1;
        }
        else if (transform.position.y > TravelPoints[loc].position.y)
        {
            dir.y = -1f;
        }
        if (transform.position.x < TravelPoints[loc].position.x)
        {
            dir.x = 1;
        }
        else if (transform.position.x > TravelPoints[loc].position.x)
        {
            dir.x = -1;
        }

        float   dist;
        Vector2 vel = new Vector2(speedInPix, speedInPix);

        dist = Vector2.Distance(transform.position, TravelPoints[loc].position);

        if (dist < speedInPix)
        {
            vel.x = dist;
        }
        if (dist < speedInPix)
        {
            vel.y = dist;
        }

        vel *= 50f;
        vel *= dir;
        actor.SetVelocity(vel);
    }
Пример #2
0
    private void FixedUpdate()
    {
        if (timePassed > lifetime)
        {
            //bullet has not collided with anything in its lifetime(10 seconds)
            _actor.Remove();
        }

        if (beenShot)
        {
            //Moves bullet
            _actor.SetVelocity(vel);

            if (_actor._ControllerState.HasCollisions && !collided)
            {
                //we hit something.
                _actor.Active = false;
                collided      = true;
                timePassed    = 0;
            }
        }
    }
Пример #3
0
    private void FixedUpdate()
    {
        if (collided)
        {
            particleEffect.transform.SetParent(null, true);
            Object.Destroy(particleEffect, 5f);
            _actor.Remove();
        }
        else if (beenShot)
        {
            //Moves bullet
            _actor.SetVelocity(vel);
            platform.SetVelocity(vel);

            if (_actor._ControllerState.HasCollisions && !collided)
            {
                //we hit something.
                if (timePassed > .07f)
                {
                    smoke.transform.parent = null;
                    smoke.GetComponent <ParticleSystem>().Stop();
                    GameObject.Destroy(smoke, 5f);
                    _actor.Active   = false;
                    platform.Active = false;
                    collided        = true;
                    particleEffect.GetComponent <ParticleSystem>().Play();
                    ActorManager.instance.PlaySound("BombExplosionFinal", 1);
                    foreach (var item in _actor._ControllerState.hasCollisionsWith)
                    {
                        if (item.GetComponent <SuperPlayer>())
                        {
                            item.GetComponent <SuperPlayer>().Die();
                        }
                    }
                    platform.Remove();
                }
            }
        }
    }