Exemplo n.º 1
0
        private void StartBasicAttack()
        {
            canWalk     = false;
            weaponIsOut = true;
            hasHit      = false;
            canAttack   = false;

            weaponPosition = Vector2.Normalize(Main.mouse.RealPosition - position);

            weaponTipPosition  = weaponPosition;
            weaponTipPosition *= (EntityHeight / 2) + weaponTexture.Width;
            weaponTipPosition += position;

            weaponPosition *= EntityHeight / 2;
            weaponPosition += position;

            weaponRotation = MathAid.FindRotation(weaponPosition, Main.mouse.RealPosition);

            float rInDegrees = MathHelper.ToDegrees(weaponRotation);

            DirectTowardsRotation(rInDegrees);

            weaponTimer = new TimeSpan(0, 0, 0, 0, weaponTime);
            attackTimer = new TimeSpan(0, 0, 0, 0, attackSpeed);

            walkingAnimation[currentDirection].ChangeAnimatingState(false);
        }
Exemplo n.º 2
0
        private void Push()
        {
            if (!push)
            {
                push = true;
                pushCollision.Clear();
                pushDirection = Vector2.Normalize(Main.mouse.RealPosition - Owner.Position);
                Vector2 teleCenter = Owner.Position + pushDirection * (Owner.EntityHeight / 2);
                float   teleAngle  = MathAid.FindRotation(teleCenter, Main.mouse.RealPosition);
                pushRotation = teleAngle;
                pushStart    = Owner.Position - MathAid.AngleToVector(teleAngle + 90) * pushTexture.Height / 2;
                pushEnd      = Owner.Position - MathAid.AngleToVector(teleAngle - 90) * pushTexture.Height / 2;
                pushTime     = new TimeSpan(0, 0, 0, 0, pushMiliSeconds);
                Vector2 startToEndDirection = Vector2.Normalize(pushEnd - pushStart);

                for (int i = 0; i < pushTexture.Height; i++)
                {
                    pushCollision.Add(pushStart + startToEndDirection * i);
                }
            }
        }
Exemplo n.º 3
0
        public void DirectTowardsMouse()
        {
            float angle = MathAid.FindRotation(Position, Main.mouse.RealPosition);

            DirectTowardsRotation(MathHelper.ToDegrees(angle));
        }