Esempio n. 1
0
    private void FireThrusterGroup(Vector2Int orientation, float multiplier = 1)
    {
        var thrustVector = thrustVectors[orientation];

        multiplier = Mathf.Clamp01(multiplier);
        parentClass.rb2d.AddForce(RotationUtilities.RotateVector2(thrustVector.thrustVector * multiplier, parentClass.grid.rotation.eulerAngles.z));
    }
Esempio n. 2
0
        public override void spawnClone(Vector2 position, Vector2 direction)
        {
            //AnimatedSprite newSprite = new AnimatedSprite(this.sprite.name, position, new AnimationManager(this.sprite.animation.objectTexture.Copy(), this.sprite.animation.defaultDrawFrame), this.color);
            SSC_IcicleProjectile basic = new SSC_IcicleProjectile(this.owner, new AnimatedSprite("IcicleProjectile", position, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Projectiles", "Icicle"), new Animation(0, 0, 16, 16)), this.color), new Rectangle((int)this.position.X, (int)this.position.Y, this.hitBox.Width, this.hitBox.Height), position, direction, this.speed, this.maxLifeSpan, this.scale, this.damage, this.effect);

            basic.rotation = RotationUtilities.getRotationFromVector(direction);
            SeasideScramble.self.entities.projectiles.addProjectile(basic);
        }
Esempio n. 3
0
        protected RectangleF bounds()
        {
            float      ulX = Center.X - dimX / 2.0f;
            float      ulY = Center.Y - dimY / 2.0f;
            Matrix     m   = new Matrix();
            RectangleF rec = new RectangleF(ulX, ulY, dimX, dimY);

            m.RotateAt(-perspective, GameApp.RectangleFCentre(rec));
            return(RotationUtilities.TransformRectangle(rec, m));
        }
Esempio n. 4
0
        public Exit(int idxX, int idxY, KulaLevel.Orientation o)
        {
            surfacesPhysicInit(Constants.BlockWidth, 8, -RotationUtilities.getAngleFromDownOrientation(o));
            PointF newCenter = suggestedCenter(idxX, idxY, o);

            startingX       = newCenter.X;
            startingY       = newCenter.Y;
            currentX        = startingX;
            currentY        = startingY;
            isLandingNeeded = true;
        }
Esempio n. 5
0
        public Spikes(int idxX, int idxY, KulaLevel.Orientation o, Bitmap img)
        {
            surfacesPhysicInit(Constants.BlockWidth * 0.875f, 24, -RotationUtilities.getAngleFromDownOrientation(o));
            surfacesDrawInit(img, (int)(Constants.BlockWidth * 0.875f), 24);
            PointF newCenter = suggestedCenter(idxX, idxY, o);

            startingX       = newCenter.X;
            startingY       = newCenter.Y;
            currentX        = startingX;
            currentY        = startingY;
            isLandingNeeded = false;
            isEnabled       = true;
        }
Esempio n. 6
0
        public Ice(int idxX, int idxY, KulaLevel.Orientation o)
        {
            type = SurfType.Ice;
            surfacesPhysicInit(Constants.BlockWidth, 8, -RotationUtilities.getAngleFromDownOrientation(o));
            surfColor = Color.FromArgb(200, Color.Azure);
            PointF newCenter = suggestedCenter(idxX, idxY, o);

            startingX       = newCenter.X;
            startingY       = newCenter.Y;
            currentX        = startingX;
            currentY        = startingY;
            isLandingNeeded = true;
        }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        var targetPositioin = Horse.transform.position + (Vector3.up * _offsetY);

        var distanceToHorse = Vector3.Distance(transform.position, Horse.transform.position);
        var targetDistance  = 10.5f;
        var distanceOffset  = 0.2f;
        var speed           = 5f + _horseFollowPathScript.GetSpeed();
        var speedFactor     = Mathf.Abs(distanceToHorse - targetDistance);

        speed *= speedFactor;
        if (distanceToHorse > targetDistance + distanceOffset)
        {
            _controller.Move(transform.forward * speed * Time.deltaTime);
        }
        else if (distanceToHorse < targetDistance - distanceOffset)
        {
            _controller.Move((transform.forward * -1) * speed * Time.deltaTime);
        }

        var horseRotationY = RotationUtilities.ScaleRotation(Horse.transform.eulerAngles.y);
        var axelRotationY  = RotationUtilities.ScaleRotation(_directionFrame.eulerAngles.y);

        if (Mathf.Abs(horseRotationY - axelRotationY) < 40f)
        {
            var lookWagonPos = targetPositioin - transform.position;
            lookWagonPos.y = 0;
            var targetWagonRotation = Quaternion.LookRotation(lookWagonPos);
            transform.rotation = Quaternion.Slerp(transform.rotation, targetWagonRotation, 2f * Time.deltaTime);
        }

        var lookPos = targetPositioin - _directionFrame.position;

        lookPos.y = 90;
        var targetRotation = Quaternion.LookRotation(lookPos);

        _directionFrame.rotation = Quaternion.Slerp(_directionFrame.rotation, targetRotation, 5f * Time.deltaTime);

        /*float ry = _directionFrame.eulerAngles.y;
         * if (ry >= 180) ry -= 360;
         * _directionFrame.eulerAngles = new Vector3(
         *  _directionFrame.eulerAngles.x,
         *  Mathf.Clamp(ry, transform.localRotation.y - 12f, transform.localRotation.y + 12f),
         *  _directionFrame.eulerAngles.z
         * );*/

        _saddleAxel.LookAt(targetPositioin);
    }
Esempio n. 8
0
        protected PointF suggestedCenter(int idxX, int idxY, KulaLevel.Orientation o)
        {
            float  d   = Constants.BlockWidth;
            PointF off = new PointF(0, -d / 2.0f);

            Matrix m   = new Matrix();
            float  rot = -RotationUtilities.getAngleFromDownOrientation(o);

            m.Rotate(rot);
            off = m.TransformAndThenRound(off);

            float cX = d / 2.0f + d * idxX;
            float cY = d / 2.0f + d * idxY;

            off = new PointF((float)Math.Round(cX + off.X), (float)Math.Round(cY + off.Y));
            return(off);
        }
Esempio n. 9
0
    private void RotatePlayerModel(float x, float z, Vector3 move)
    {
        float modelAngle;
        float playerYRotation = _playerRef.localRotation.eulerAngles.y;

        playerYRotation = RotationUtilities.ScaleRotation(playerYRotation);
        if (move.magnitude > 0)
        {
            float modelTargetAngle = 90f - (z * 45f);
            playerYRotation          = RotationUtilities.ScaleRotation(playerYRotation);
            modelAngle               = Mathf.Lerp(playerYRotation, modelTargetAngle * x, _modelTurnInterpolation * Time.deltaTime);
            _playerRef.localRotation = Quaternion.Euler(0f, modelAngle, 0f);
        }
        else
        {
            if (_povScript.IsFirstPerson())
            {
                modelAngle = Mathf.Lerp(playerYRotation, 0, _modelTurnInterpolation * Time.deltaTime);
                _playerRef.localRotation = Quaternion.Euler(0f, modelAngle, 0f);
            }
        }
    }
Esempio n. 10
0
        public GravityChanger(int idX, int idY, float persp, Bitmap img, KulaLevel.Orientation o)
        {
            initPlaceable(idX, idY, persp, img);
            rot = RotationUtilities.getAngleFromDownOrientation(o);

            float angle = (float)Math.Round(rot - perspective) % 360;

            if (angle < 0f)
            {
                while ((angle += 360f) < 0f)
                {
                    ;
                }
            }

            if (angle % 360 == 0)
            {
                toDraw.RotateFlip(RotateFlipType.RotateNoneFlipNone);
            }
            else if (angle % 360 == 270)
            {
                toDraw.RotateFlip(RotateFlipType.Rotate90FlipNone);
            }
            else if (angle % 360 == 180)
            {
                toDraw.RotateFlip(RotateFlipType.Rotate180FlipNone);
            }
            else if (angle % 360 == 90)
            {
                toDraw.RotateFlip(RotateFlipType.Rotate270FlipNone);
            }
            else
            {
                throw new Exception("What is " + angle + "deg?");
            }
        }