/// <summary>
 /// Called when the movement loses control. Override to do any reset type actions.
 /// </summary>
 override public void LosingControl()
 {
     pullDirection  = 0;
     pullable       = null;
     latched        = false;
     pullDelayTimer = 0;
 }
예제 #2
0
        public GunController(AbilityConfiguration abilityItemConfig)
        {
            _returnObjectToPull = new GenericSubscriptionAction <GunAbilityView>();
            _returnObjectToPull.SubscribeOnChange(OnReturnObjectToPull);

            _abilityItemConfig = abilityItemConfig;
            _gunPull           = new ProjectilePull(abilityItemConfig, _returnObjectToPull);
        }
예제 #3
0
    private void Start()
    {
        pullable = objectToPull.GetComponent <IPullable>();

        MeshRenderer renderer = GetComponent <MeshRenderer>();

        pullSourceBounds = renderer.bounds;
    }
예제 #4
0
 public CruiserBulletManager(IEnemy enemy, Transform bullet, IShip ship, float bulletSpeed)
 {
     _bulletSpeed   = bulletSpeed;
     _enemy         = enemy;
     _upTimer       = new UpTimer(0.0f, 0.5f);
     _returnChecker = new TransformCollisionAndReturnChecker(ship);
     _bulletPull    = new BulletPull(bullet);
     _bullets       = new List <Transform>();
 }
 /// <summary>
 /// Restrict the number of rows returned by executing a pull query over a STREAM or a TABLE. ksqldb 0.24.0
 /// </summary>
 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
 /// <param name="source">The sequence to take elements from.</param>
 /// <param name="count">The number of elements to return.</param>
 /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
 public static IPullable <TSource> Take <TSource>(this IPullable <TSource> source, int count)
 {
     return(source.Provider.CreateQuery <TSource>(
                Expression.Call(
                    null,
                    TakeTSource(typeof(TSource)),
                    source.Expression, Expression.Constant(count)
                    )));
 }
예제 #6
0
 public BulletManager(Transform bullet, Transform barrel, float bulletSpeed, ShipWeaponLocker weaponLocker)
 {
     _barrel        = barrel;
     _bulletSpeed   = bulletSpeed;
     _fire          = new PCUserInputFire();
     _bulletPull    = new BulletPull(bullet);
     _returnChecker = new TransformReturnChecker();
     _bullets       = new List <Transform>();
     _weaponLocker  = weaponLocker;
 }
        public SourceMetric(string parentName, string key, string name, IPullable <float> source, string unit, TimeDomain domain)
        {
            this.ParentName = parentName;
            this.Key        = key;
            this.Name       = name;
            this.Unit       = unit;
            this.Domain     = domain;

            this.source = source;
        }
    private static async Task GetAsync(IPullable <IoTSensorStats> pullQuery)
    {
        var result = await pullQuery
                     .FirstOrDefaultAsync();

        Console.WriteLine(
            $"Pull query GetAsync result => Id: {result?.SensorId} - Avg Value: {result?.AvgValue} - Window Start {result?.WindowStart}");

        Console.WriteLine();
    }
예제 #9
0
 public SetSourceMetric(string parentName, string key, string name, IPullable <float> source, string unit, TimeDomain domain, IAggregator <float> aggregator = null) : base(parentName, key, name, source, unit, domain)
 {
     if (aggregator == null)
     {
         this.aggregator = new AverageAggregator();
     }
     else
     {
         this.aggregator = aggregator;
     }
 }
예제 #10
0
        public EnemyManager(IShip ship, params EnemyData[] enemies)
        {
            _ship      = ship;
            _enemyPool = new EnemyPool(ship, enemies);
            _enemies   = new List <IEnemy>();
            _transformReturnChecker = new TransformReturnChecker();
            _shipCollisionChecker   = new ShipCollisionChecker(ship);
            _positionSetter         = new PositionSetter(ship);
            _messageBroker          = new MessageBroker();

            AddEnemies(enemies.Length);
        }
예제 #11
0
        public static string ToQueryString <TSource>(this IPullable <TSource> source)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            var pullSet = source as KPullSet <TSource>;

            var dependencies = pullSet?.GetDependencies();

            return(dependencies?.QueryStreamParameters.Sql);
        }
예제 #12
0
    void BreakHooked()
    {
        //this method will stop a pullableobject from being hooked toward the player
        IPullable pullableObject = null;

        if (hookedObject != null)
        {
            pullableObject = hookedObject.GetComponent <IPullable>();
        }
        if (pullableObject != null)
        {
            pullableObject.CancelPull();
        }
    }
        public WindowSourceMetric(string parentName, string key, string name, IPullable <float> source, string unit, TimeDomain domain, IAggregator <float> aggregator = null, int?windowSize = null) : base(parentName, key, name, source, unit, domain, aggregator)
        {
            if (windowSize.HasValue)
            {
                if (windowSize.Value <= 0)
                {
                    throw new Exception("WindowStatMetric windowSize must be greater than 0");
                }

                this.windowSize = windowSize.Value;
            }
            else
            {
                this.windowSize = this.Domain.ResInTicks;
            }
        }
    /// <summary>
    /// Projects a single pull query response into a new form.
    /// </summary>
    /// <typeparam name="TSource">The type of the elements of source.</typeparam>
    /// <typeparam name="TResult">The type of the value returned by selector.</typeparam>
    /// <param name="source">The sequence to take elements from.</param>
    /// <param name="selector">A transform function to apply to the single response.</param>
    /// <returns></returns>
    public static IPullable <TResult> Select <TSource, TResult>(this IPullable <TSource> source, Expression <Func <TSource, TResult> > selector)
    {
        if (source == null)
        {
            throw new ArgumentNullException(nameof(source));
        }

        if (selector == null)
        {
            throw new ArgumentNullException(nameof(selector));
        }

        return(source.Provider.CreateQuery <TResult>(
                   Expression.Call(
                       null,
                       SelectTSourceTResult(typeof(TSource), typeof(TResult)),
                       source.Expression, Expression.Quote(selector)
                       )));
    }
예제 #15
0
        public static IPullable <TSource> Where <TSource>(this IPullable <TSource> source, Expression <Func <TSource, bool> > predicate)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (predicate == null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }

            return(source.Provider.CreateQuery <TSource>(
                       Expression.Call(
                           null,
                           WhereTSource(typeof(TSource)),
                           source.Expression, Expression.Quote(predicate)
                           )));
        }
 public DigestSourceMetric(string parentName, string key, string name, IPullable <float> source, string unit, TimeDomain domain, IAggregator <float> aggregator = null) : base(parentName, key, name, source, unit, domain, aggregator)
 {
 }
예제 #17
0
 public PollSourceMetric(string parentName, string key, string name, IPullable <float> source, string unit, TimeDomain domain) : base(parentName, key, name, source, unit, domain)
 {
 }
예제 #18
0
    public IEnumerator TossChain()
    {
        //place two raycasts for more accuracy
        Collider2D ourHit = null; // Physics2D.Raycast(transform.position, transform.right, 1.0f, whatIsHookable);

        Debug.DrawRay(transform.position, transform.right * 30, Color.blue);

        transform.position = player.transform.position;
        throwing           = true;
        bool hooked = false;

        ourRigidbody.bodyType = RigidbodyType2D.Dynamic;

        Vector2 origin             = player.transform.position;
        Vector2 mousePos           = Input.mousePosition;
        Vector2 mousePositionWorld = Camera.main.ScreenToWorldPoint(new Vector2(mousePos.x, mousePos.y));
        Vector2 trans = mousePositionWorld - origin;

        trans.Normalize();


        while (Mathf.Abs((Vector2.Distance(origin, transform.position))) <= chainMaxLength)
        {
            ourHit = Physics2D.OverlapCircle(transform.position, 1.0f, whatIsHookable);
            // //Debug.Log("we hit " + ourHit.gameObject.name + " and is it " + pReference.locationHandler.currentSwitch.name + " ");
            // ourHit = Physics2D.Raycast(transform.position, transform.right, 1.0f, whatIsHookable);
            if (ourHit && ourHit.gameObject != hookedObject)
            {
                if (pReference.locationHandler.onPlanet && ourHit.gameObject == pReference.locationHandler.currentPlanet || ourHit.gameObject == pReference.locationHandler.currentSwitch)
                {
                    hooked = false;
                }

                else
                {
                    hooked = true;
                }
            }

            if (hooked)
            {
                break;
            }
            ourRigidbody.velocity = trans * throwSpeed;
            var dir   = (Vector3)mousePositionWorld - transform.position;
            var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
            transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);


            yield return(null);
        }
        throwing = false;
        ZeroOutVelocity();

        if (hooked && ourHit.gameObject != hookedObject && ourHit.gameObject != pReference.locationHandler.currentSwitch)
        {
            ObjectHooked(ourHit.gameObject);
            IPullable pullableObject = ourHit.GetComponent <IPullable>();
            if (pullableObject != null)
            {
                Debug.Log("Pullable object does not equal null");

                pullableObject.BeginPull(player.transform);
            }
            else
            {
                Debug.Log("We're moving toward hookshot");
                // //Debug.Log("Terrain hook " + ourHit.gameObject.name);
                MoveToHookShot(transform.position, ourHit.gameObject);
                DetermineHookedObject(ourHit.gameObject);
            }
            //
        }
        else
        {
            StartCoroutine(ReturnChain());
        }
    }
        /// <summary>
        /// Gets a value indicating whether this movement wants to control the movement on the ground.
        /// This movement wants control if the side colliders are pulling a box.
        /// </summary>
        /// <value><c>true</c> if this instance wants control; otherwise, <c>false</c>.</value>
        override public bool WantsGroundControl()
        {
            if (!enabled)
            {
                return(false);
            }
            if (character.DefaultGroundMovement == this)
            {
                Debug.LogError("The Pull movement can't be the default ground movement. Disabling movement.");
                enabled = false;
            }

            // Early out, only pull if grounded.
            if (!character.Grounded)
            {
                LosingControl();
                return(false);
            }

            // Early out, if last frame we were pulling one way, we want to lose control for at least one frame before pulling another way
            if (!latched && pullDirection == -character.Input.HorizontalAxisDigital)
            {
                LosingControl();
                return(false);
            }

            // Early out, if we were pulling, and our velocity is non zero and we are still holding down pull keep going
            if (pullable != null && !latched && pullDirection == character.Input.HorizontalAxisDigital && character.Velocity.x != 0)
            {
                return(true);
            }

            // If we are latched check if we are still latched
            if (latched && pullable != null)
            {
                if (character.Input.HorizontalAxisDigital == -pullDirection || character.Input.HorizontalAxisDigital == 0)
                {
                    if (latchTimer <= 0)
                    {
                        LosingControl();
                    }
                    return(false);
                }
                // Start pulling
                if (character.Input.HorizontalAxisDigital == pullDirection)
                {
                    latched        = false;
                    pullDelayTimer = PullDelayTime;
                    return(true);
                }
            }

            // Try to find a pullable
            int         hitCount            = 0;
            IPullable   matchingPullable    = null;
            float       pullableDistance    = 1;
            float       nonPullableDistance = 1;
            RaycastType typeToCheck         = (character.Input.HorizontalAxisDigital == 1 ? RaycastType.SIDE_RIGHT : RaycastType.SIDE_LEFT);

            initialPullOffset = 0;
            for (int i = 0; i < character.Colliders.Length; i++)
            {
                if (character.Colliders[i].RaycastType == typeToCheck)
                {
                    RaycastHit2D hit = character.GetClosestCollision(i);
                    if (hit.collider != null)
                    {
                        IPullable currentPullable = (IPullable)hit.collider.GetComponent(typeof(IPullable));
                        // Pulling  something that isn't pushable TODO add distance checks.
                        if (currentPullable == null)
                        {
                            if (hit.fraction < nonPullableDistance)
                            {
                                nonPullableDistance = hit.fraction;
                            }
                        }
                        else
                        {
                            if (currentPullable != matchingPullable)
                            {
                                // Found a closer pushable (or if matching pushable is null we just found a pushable)
                                if (hit.fraction < pullableDistance)
                                {
                                    pullableDistance  = hit.fraction;
                                    matchingPullable  = currentPullable;
                                    initialPullOffset = (hit.fraction * (character.Colliders[i].Length + character.Colliders[i].LookAhead)) - character.Colliders[i].Length - character.Colliders[i].LookAhead;
                                    hitCount          = 1;
                                }
                            }
                            else
                            {
                                hitCount++;
                            }
                        }
                    }
                }
            }

            if (matchingPullable != null && pullableDistance < nonPullableDistance && initialPullOffset < 0)
            {
                pullable           = matchingPullable;
                initialPullOffset *= -character.Input.HorizontalAxisDigital;
                pullDirection      = -character.Input.HorizontalAxisDigital;
                latched            = true;
                latchTimer         = LatchTime;
            }
            return(false);
        }