示例#1
0
        virtual public bool Live(Launcher launcher, Vector position) //returns whether or not the bullet is still alive, check collision
        {
            if (rangeCounter >= data.range)
            {
                return(false);
            }

            rangeCounter += direction.Length;

            double t = map.Clash(body, direction);

            if (t < 1 - Constants.Epsilon)
            {
                if (!data.boing)
                {
                    return(false);
                }

                if (map.Clash(body, direction.Just(0)) < 1 - Constants.Epsilon)
                {
                    direction.x = -direction.x;
                }
                if (map.Clash(body, direction.Just(1)) < 1 - Constants.Epsilon)
                {
                    direction.y = -direction.y;
                }

                body.angle = direction.Angle;
            }

            body.position += direction;

            return(true);
        }
示例#2
0
        public LinkedList <Vector> Navigate(int maxAmount)
        {
            for (int i = 0; i < maxAmount && queue.Count > 0; ++i)
            {
                Vector next = queue.Dequeue();

                if (values[next].Item1 != null && (values[next].Item1 - target).Length < (best - target).Length)
                {
                    best = next;
                }

                if (values[next].Item1 != null)
                {
                    Vector position = map.ToBlockPosition(values[next].Item1);

                    if ((position - targetPosition).Length <= (maximumDistance + minimumDistance) / 2 &&
                        (position - targetPosition).Length >= minimumDistance &&
                        map.Clash(new Rect(position, new Vector(10, 10)), targetPosition - position) > 1 - Constants.Epsilon)
                    {
                        return(GetList(next));
                    }
                }

                foreach (Vector direction in directions)
                {
                    if (!map[next + direction].Solid && !map[next + direction.Just(0)].Solid && !map[next + direction.Just(1)].Solid &&
                        !values.ContainsKey(next + direction))
                    {
                        Enqueue(next + direction, next);
                    }
                }
            }

            return(GetList(best));
        }
示例#3
0
        public IBullet GetBullet(Vector position, Vector direction, Universe.Map map)
        {
            double t = map.Clash(new Rect(position, new Vector(1, size.y), null, direction.Angle), direction * size.x);

            Rect body = new Rect(position + direction * size.x * t / 2, new Vector(size.x * t, size.y), texture, direction.Angle);

            return(new LongBullet(body, direction, this));
        }
示例#4
0
        public Tuple <Vector, double, bool> Interact(Thing obj)
        {
            if (target == null || (obj.position - body.position).Length < (target - body.position).Length)
            {
                if (map.Clash(body, obj.position - body.position) > 1 - Constants.Epsilon)
                {
                    target = obj.position;
                }
            }

            return(null);
        }
示例#5
0
        protected void Move(Universe.Map map, Vector movement)
        {
            for (int i = 0; i < Constants.Dimentions; ++i)
            {
                double t = map.Clash(body, movement.Just(i));

                if (t > Constants.Epsilon)
                {
                    body.position += movement.Just(i) * t;
                }
                else
                {
                    knockBack[i] = -knockBack[i];
                }
            }
        }
示例#6
0
        /* returns whether or not the entity is still alive or not */
        public virtual bool Live(Universe.Map map)
        {
            if (agentActions['Q'] == State.FirstTimeDown)
            {
                bag.Swap();
            }

            Vector currentKB = knockBack / 20;

            double t = body.angle;

            body.angle = agentActions.lookDirection.Angle;

            if (map.Clash(body, new Vector()) < Constants.Epsilon)
            {
                body.angle = t;                                                 //we can't change the angle due to the collision
            }
            Vector movement = agentActions.MovementDirection * 2.5 + currentKB; //add speed

            Move(map, movement);

            knockBack -= currentKB;

            if (agentActions[Mouse.Left] != State.Up)
            {
                bag.Primary.Shoot(body.position, Vector.FromAngle(body.angle), map);
            }

            bag.Live(map, body.position);

            agentActions.Live();

            if (hp <= 0)
            {
                return(false);
            }

            return(true);
        }