Пример #1
0
 public override void Process(GameObject entity, Projectile projectile, Destroyable destroyable)
 {
     if (destroyable.Destroyed)
     {
         RobotArmsUtils.RunAtEndOfFrame(() => GameObject.Destroy(entity));
     }
 }
Пример #2
0
    public override void Process(GameObject entity, Asteroid asteroid, VectoredMovement vectoredMovement, Destroyable destroyable)
    {
        var asteroidRoot = GetBlackboard <Blackboard>().AsteroidRoot;

        if (destroyable.Destroyed)
        {
            destroyable.Destroyed = false;
            switch (asteroid.Size)
            {
            case AsteroidSize.Large:
                asteroid.Size = AsteroidSize.Medium;
                BreakAsteroid(asteroid, vectoredMovement, asteroidRoot);
                break;

            case AsteroidSize.Medium:
                asteroid.Size = AsteroidSize.Small;
                BreakAsteroid(asteroid, vectoredMovement, asteroidRoot);
                break;

            case AsteroidSize.Small:
                RobotArmsUtils.RunAtEndOfFrame(() => {
                    GameObject.Destroy(asteroid.gameObject);
                });
                break;
            }

            GameObject.Instantiate(destroyable.DestroyedEffect, entity.transform.position, entity.transform.rotation);
        }
    }
Пример #3
0
    static void BreakAsteroid(Asteroid asteroid, VectoredMovement vectoredMovement, Transform asteroidRoot)
    {
        // New asteroid will be initialized in the above Initialize method as it is a new GameObject with new components.
        RobotArmsUtils.RunAtEndOfFrame(() => {
            var newAsteroid = GameObject.Instantiate(asteroid.gameObject) as GameObject;
            newAsteroid.transform.parent = asteroidRoot;

            RandomizeAsteroidMovement(vectoredMovement);
            SetSpriteAndBoundsForCurrentSize(asteroid);
        });
    }
Пример #4
0
    public override void Process(GameObject entity, Ship ship, PlayerInput input, VectoredMovement movement, Trigger2D trigger, Destroyable destroyable)
    {
        if (ship.Fuel > 0)
        {
            if (input.Thrust)
            {
                movement.Velocity += entity.transform.up * ship.ThrustForce * Time.deltaTime;
                if (movement.Velocity.magnitude > ship.MaxSpeed)
                {
                    movement.Velocity = movement.Velocity.normalized * ship.MaxSpeed;
                }

                ship.Fuel -= ship.FuelConsumptionPerSecond * Time.deltaTime;
            }

            entity.transform.Rotate(0, 0, -input.Rotation * ship.RotationSpeed * Time.deltaTime);
        }

        if (input.Fire)
        {
            RobotArmsUtils.RunAtEndOfFrame(() => {
                var projectile              = GameObject.Instantiate(ship.Projectile, ship.transform.position, ship.transform.rotation) as GameObject;
                var projectileMovement      = projectile.GetComponent <VectoredMovement>();
                projectileMovement.Velocity = projectile.transform.up * projectile.GetComponent <Projectile>().Speed;
            });
        }

        if (trigger.Colliders.Any(c => destroyable.DestroyWhenTouchingTag.Contains(c.tag)))
        {
            RobotArmsUtils.RunAtEndOfFrame(() => {
                GameObject.Instantiate(destroyable.DestroyedEffect, entity.transform.position, entity.transform.rotation);
                GameObject.Destroy(entity);
                GetBlackboard <Blackboard>().GameOverScreen.SetActive(true);
            });
        }
    }