Пример #1
0
        public void Update(GameTime gameTime)
        {
            this.Rect = rect;
            if (!IsKilled)
            {
                rigidbody.LinearVelocity = new Vector2(walkSpeed, rigidbody.LinearVelocity.Y);

                RaySide();
                RayUp();

                if (dirChange)
                {
                    walkSpeed *= -1f;
                    dirChange  = false;

                    if (faceDir == FaceDir.left)
                    {
                        faceDir = FaceDir.right;
                    }
                    else if (faceDir == FaceDir.right)
                    {
                        faceDir = FaceDir.left;
                    }
                }
                Frames();
            }
            else
            {
                rect = new Rectangle(64, 896, 32, 32);
            }
        }
Пример #2
0
        public void Update(GameTime gameTime)
        {
            if (!IsKilled)
            {
                rigidbody.LinearVelocity = new Vector2(walkSpeed, rigidbody.LinearVelocity.Y);

                RaySide();
                RayUp();

                if (dirChange)
                {
                    walkSpeed *= -1f;
                    dirChange  = false;

                    if (faceDir == FaceDir.left)
                    {
                        faceDir = FaceDir.right;
                    }
                    else if (faceDir == FaceDir.right)
                    {
                        faceDir = FaceDir.left;
                    }
                }
            }
        }
Пример #3
0
        internal static FaceDir RotateBy(this FaceDir faceDir, Rotation r)
        {
            var f  = faceDir.Forward();
            var x1 = (int)f.x;
            var z1 = (int)f.z;

            var(x2, z2) = TopoArrayUtils.SquareRotateVector(x1, z1, r);
            if (x1 == x2 && z1 == z2)
            {
                return(faceDir);
            }
            if (x2 == 1)
            {
                return(FaceDir.Right);
            }
            if (x2 == -1)
            {
                return(FaceDir.Left);
            }
            if (z2 == 1)
            {
                return(FaceDir.Forward);
            }
            if (z2 == -1)
            {
                return(FaceDir.Back);
            }
            throw new System.Exception();
        }
Пример #4
0
        /// <summary>
        /// 3          3
        ///   1     1
        /// 4    *     4
        ///   2     2
        /// 5          5
        /// </summary>
        Vector3 FindEmptyPos(Vector3 pos, EmbattleType type, uint index, ref FaceDir dir)
        {
            var newPos       = new Vector3(pos.x, pos.y, 0);
            var embattleData = configMgr.GetEmbattlePosData(type);

            if (!embattleData.ContainsKey(index))
            {
                return(Vector3.zero);
            }
            var offsetPos = embattleData[index];

            if (type == EmbattleType.BothSides)
            {
                var viewPortMargin = LogicConst.Viewport_Margin;
                var v = offsetPos.x > 0 ? 1 : -1;
                newPos.x += v * viewPortMargin + offsetPos.x;
                dir       = offsetPos.x > 0 ? FaceDir.Left : FaceDir.Right;
            }
            else
            {
                newPos.x += offsetPos.x;
                if (type == EmbattleType.Center)
                {
                    dir = FaceDir.Right;
                }
                else
                {
                    dir = type == EmbattleType.Left ? FaceDir.Right : FaceDir.Left;
                }
            }
            newPos.y += offsetPos.y;
            newPos.z += offsetPos.z;
            return(newPos);
        }
Пример #5
0
 public void SetFaceDir(FaceDir faceDir)
 {
     if (ani != null)
     {
         ani.SetInteger("FaceDir", (int)faceDir);
     }
 }
Пример #6
0
 public void SetFace(FaceDir nextFace)
 {
     if (m_faceDir != nextFace)
     {
         m_faceDir = nextFace;
         m_spriteRenderer.flipX = m_faceDir == FaceDir.LEFT ? false : true;
     }
 }
Пример #7
0
        /// <summary>
        /// 设置朝向
        /// </summary>
        /// <param name="dir"></param>
        public void SetFaceDir(FaceDir dir)
        {
            var trans = gameObject.GetChild <Transform>("roleObject");
            var scale = trans.localScale;
            var x     = dir == FaceDir.Left ? Math.Abs(scale.x): Math.Abs(scale.x) * -1;

            trans.localScale = new Vector3(x, scale.y, scale.z);
        }
Пример #8
0
        private void OnNpcFaceDir(long npcid, FaceDir dir)
        {
            var npcView = npcMgr.GetNpc(npcid) as RoleView;

            if (npcView != null)
            {
                npcView.SetFaceDir(dir);
            }
        }
Пример #9
0
 public void setToFaceX()
 {
     if (faceDir == FaceDir.X)
     {
         GeneralSettings.rightLaser.reverseFacingDir();
         return;
     }
     faceDir = FaceDir.X;
     GeneralSettings.rightLaser.setFacingX();
 }
Пример #10
0
        public void SetFaceDir()
        {
            // exit early if there is no movement
            if (move.x == 0 && move.y == 0)
            {
                return;
            }

            // exit early if we are moving in the same direction that we were last frame
            if (lastMove.x == move.x && lastMove.y == move.y)
            {
                return;
            }

            // get direction to face
            if (move.x == -1 && move.y == 0)
            {
                faceDir = FaceDir.left;
            }
            else if (move.x == 1 && move.y == 0)
            {
                faceDir = FaceDir.right;
            }
            else if (move.x == 0 && move.y == 1)
            {
                faceDir = FaceDir.up;
            }
            else if (move.x == 0 && move.y == -1)
            {
                faceDir = FaceDir.down;
            }
            else if (move.x == -1 && move.y == -1)
            {
                faceDir = FaceDir.leftDown;
            }
            else if (move.x == -1 && move.y == 1)
            {
                faceDir = FaceDir.leftUp;
            }
            else if (move.x == 1 && move.y == 1)
            {
                faceDir = FaceDir.rightUp;
            }
            else if (move.x == 1 && move.y == -1)
            {
                faceDir = FaceDir.rightDown;
            }

            // turn the character (this must only happen once. otherwise character will freeze if this loops)
            TurnCharacter();
        }
Пример #11
0
    protected void UpdateFacing()
    {
        Transform walkingSprite = transform.Find("BaseCharacter/Walking/WalkingSprite");

        if (walkingSprite == null)
        {
            return;
        }

        Vector3 normDir = Direction;

        normDir.Normalize();

        FaceDir tempDir = FaceDir.LEFT;

        //Figure out which way we're facing
        if (normDir.x < 0.0f)
        {
            tempDir = FaceDir.RIGHT;
        }


        //Flip here
        if (currentDir != tempDir)
        {
            if (tempDir == FaceDir.LEFT)
            {
                //LEFT
                walkingSprite.localEulerAngles = new Vector3(0, 0, 0);
                // Update z offset of all children to be in front of animation
                foreach (Transform child in walkingSprite.transform)
                {
                    child.localPosition = new Vector3(child.localPosition.x, child.localPosition.y, Mathf.Abs(child.localPosition.z));
                }
            }
            else
            {
                //RIGHT
                walkingSprite.localEulerAngles = new Vector3(0, 180, 0);
                // Update z offset of all children to be in front of animation
                foreach (Transform child in walkingSprite.transform)
                {
                    child.localPosition = new Vector3(child.localPosition.x, child.localPosition.y, -Mathf.Abs(child.localPosition.z));
                }
            }

            currentDir = tempDir;
        }
    }
Пример #12
0
        /// <returns>Returns (0, 1, 0) vector for most faces, and returns (0, 0, 1) for the top/bottom faces.</returns>
        public static Vector3Int Up(this FaceDir faceDir)
        {
            switch (faceDir)
            {
            case FaceDir.Left:
            case FaceDir.Right:
            case FaceDir.Forward:
            case FaceDir.Back:
                return(Vector3Int.up);

            case FaceDir.Up:
            case FaceDir.Down:
                return(new Vector3Int(0, 0, 1));
            }
            throw new Exception();
        }
Пример #13
0
        /// <summary>
        /// Given a FaceDetails on given face of the cube,
        /// rotates the cube, and returns the new face and correctly oriented FaceDetails
        /// </summary>
        internal static (FaceDir, FaceDetails) ApplyRotator(FaceDir faceDir, FaceDetails faceDetails, MatrixInt3x3 rotator)
        {
            var rotatedFaceDirForward = rotator.Multiply(faceDir.Forward());
            var rotatedFaceDirUp      = rotator.Multiply(faceDir.Up());
            var rotatedFaceDirRight   = rotator.Multiply(Vector3.Cross(faceDir.Forward(), faceDir.Up()));
            var rotatedFaceDir        = FromNormal(rotatedFaceDirForward);
            var trueUp      = rotatedFaceDir.Up();
            var trueForward = rotatedFaceDirForward; // =  rotatedFaceDir.Forward();
            var trueRight   = Vector3.Cross(trueForward, trueUp);
            // Find the rotation that will map rotatedFaceDirUp to trueUp
            // and rotatedFaceDirRight to trueRight
            var      dot   = Vector3.Dot(rotatedFaceDirUp, trueUp);
            var      cross = Vector3.Dot(rotatedFaceDirUp, trueRight);
            Rotation faceRot;

            if (dot == 1)
            {
                faceRot = new Rotation();
            }
            else if (dot == -1)
            {
                faceRot = new Rotation(180);
            }
            else if (cross == 1)
            {
                faceRot = new Rotation(270);
            }
            else if (cross == -1)
            {
                faceRot = new Rotation(90);
            }
            else
            {
                throw new Exception();
            }
            if (Vector3.Dot(Vector3.Cross(rotatedFaceDirForward, rotatedFaceDirUp), rotatedFaceDirRight) < 0)
            {
                faceRot = new Rotation(360 - faceRot.RotateCw, true);
            }


            var rotatedFaceDetails = faceDetails.RotateBy(faceRot);

            return(rotatedFaceDir, rotatedFaceDetails);
        }
Пример #14
0
        public void TurnCharacterP(float direction)
        {
            if (direction < 0)
            {
                faceDir = FaceDir.left;
            }
            else if (direction > 0)
            {
                faceDir = FaceDir.right;
            }

            bool flipSprite = (spriteRenderer.flipX ? (direction > 0) : (direction < 0));

            if (flipSprite)
            {
                spriteRenderer.flipX = !spriteRenderer.flipX;
            }
        }
Пример #15
0
        /// <summary>
        /// Convert from Tessera enum to DeBroglie enum.
        /// </summary>
        internal static Direction ToDirection(this FaceDir faceDir)
        {
            switch (faceDir)
            {
            case FaceDir.Left: return(Direction.XMinus);

            case FaceDir.Right: return(Direction.XPlus);

            case FaceDir.Up: return(Direction.YPlus);

            case FaceDir.Down: return(Direction.YMinus);

            case FaceDir.Forward: return(Direction.ZPlus);

            case FaceDir.Back: return(Direction.ZMinus);
            }
            throw new Exception();
        }
Пример #16
0
        /// <returns>Returns the face dir with the opposite normal vector.</returns>
        public static FaceDir Inverted(this FaceDir faceDir)
        {
            switch (faceDir)
            {
            case FaceDir.Left: return(FaceDir.Right);

            case FaceDir.Right: return(FaceDir.Left);

            case FaceDir.Up: return(FaceDir.Down);

            case FaceDir.Down: return(FaceDir.Up);

            case FaceDir.Forward: return(FaceDir.Back);

            case FaceDir.Back: return(FaceDir.Forward);
            }
            throw new Exception();
        }
Пример #17
0
    Vector3 GetMoveDir(FaceDir direction)
    {
        switch (direction)
        {
        case FaceDir.UP:
            return(new Vector3(0.0f, 0.0f, 1.0f));

        case FaceDir.LEFT:
            return(new Vector3(-1.0f, 0.0f, 0.0f));

        case FaceDir.RIGHT:
            return(new Vector3(1.0f, 0.0f, 0.0f));

        case FaceDir.DOWN:
            return(new Vector3(0.0f, 0.0f, -1.0f));
        }
        return(new Vector3(0.0f, 0.0f, 0.0f));
    }
Пример #18
0
        public void AnimateCharacterRPG(bool thisIsTurn = false)
        {
            // exit early if character is jumping
            if (isJumping)
            {
                return;
            }

            // is the character moving? if no, turn on last movement animation and exit early
            bool moving = !(move.x == 0 && move.y == 0);

            if (!moving)
            {
                if (lastAnimationName != "")
                {
                    animator.SetBool(lastAnimationName, false);
                }
                return;
            }

            // get animation direction
            SetAnimDir(thisIsTurn);

            // turn off last movement
            if (lastAnimationName != animationName && lastAnimationName != "")
            {
                animator.SetBool(lastAnimationName, false);
            }

            // turn on movement if it is a new movement
            bool result = animator.GetBool(animationName);

            if (result == false)
            {
                animator.SetBool(animationName, true);
            }

            lastFaceDir       = faceDir;
            lastAnimationName = animationName;
        }
Пример #19
0
        internal void Initialize(Vector2 currPos)
        {
            battlePos = currPos;
            embattles.Clear();
            var types = new EmbattleType[]
            {
                EmbattleType.Left,
                EmbattleType.Right,
                EmbattleType.Center,
                EmbattleType.BothSides
            };
            var NumPos = 5;

            foreach (EmbattleType emType in types)
            {
                for (uint i = 1; i <= NumPos; i++)
                {
                    if (emType == EmbattleType.BothSides && i >= NumPos)
                    {
                        continue;
                    }
                    List <EmbattlePos> items = null;
                    embattles.TryGetValue(emType, out items);
                    if (items == null)
                    {
                        items = new List <EmbattlePos>();
                        embattles.Add(emType, items);
                    }
                    FaceDir dir    = FaceDir.Left;
                    var     newPos = FindEmptyPos(currPos, emType, i, ref dir);

                    var item = new EmbattlePos();
                    item.id      = i;
                    item.pos     = newPos;
                    item.isUsing = false;
                    item.faceDir = dir;
                    items.Add(item);
                }
            }
        }
Пример #20
0
        public Enemy(Vector2 p)
        {
            this.tile     = texture = Game1.content.Load <Texture2D>("Sprites/kenney_32x32");
            this.Position = p;

            sn_kill_enemy = Game1.content.Load <SoundEffect>("Sounds/Randomize3");

            killed  = false;
            bite    = false;
            faceDir = FaceDir.right;

            //Set rigidbody behaivior here
            // rigidbody = BodyFactory.CreateRectangle(Game1.world, ConvertUnits.ToSimUnits(rect.Width), ConvertUnits.ToSimUnits(rect.Height), 1.0f, ConvertUnits.ToSimUnits(this.Position));
            rigidbody                     = BodyFactory.CreateCircle(Game1.world, ConvertUnits.ToSimUnits(rect.Width / 2), 1.0f, ConvertUnits.ToSimUnits(this.Position));
            rigidbody.BodyType            = BodyType.Dynamic;
            rigidbody.FixedRotation       = true;
            rigidbody.Restitution         = 0f;            // No bounciness
            rigidbody.Friction            = 0f;
            rigidbody.CollisionCategories = Category.Cat3; // cat3 is coins

            rigidbody.OnCollision += Rigidbody_OnCollision;
        }
Пример #21
0
        public Enemy(Vector2 p)
        {
            this.tile = texture = Game1.content.Load<Texture2D>("Sprites/kenney_32x32");
            this.Position = p;

            sn_kill_enemy = Game1.content.Load<SoundEffect>("Sounds/Randomize3");

            killed = false;
            bite = false;
            faceDir = FaceDir.right;

            //Set rigidbody behaivior here
            // rigidbody = BodyFactory.CreateRectangle(Game1.world, ConvertUnits.ToSimUnits(rect.Width), ConvertUnits.ToSimUnits(rect.Height), 1.0f, ConvertUnits.ToSimUnits(this.Position));
            rigidbody = BodyFactory.CreateCircle(Game1.world, ConvertUnits.ToSimUnits(rect.Width/2), 1.0f, ConvertUnits.ToSimUnits(this.Position));
            rigidbody.BodyType = BodyType.Dynamic;
            rigidbody.FixedRotation = true;
            rigidbody.Restitution = 0f; // No bounciness
            rigidbody.Friction = 0f;
            rigidbody.CollisionCategories = Category.Cat3; // cat3 is coins

            rigidbody.OnCollision += Rigidbody_OnCollision;
        }
Пример #22
0
    void TurnAntiClockwise()
    {
        if (!CanRotate(-1.0f))
        {
            return;
        }

        switch (FacingDir)
        {
        case FaceDir.UP:
            FacingDir = FaceDir.LEFT;
            break;

        case FaceDir.LEFT:
            FacingDir = FaceDir.DOWN;
            break;

        case FaceDir.RIGHT:
            FacingDir = FaceDir.UP;
            break;

        case FaceDir.DOWN:
            FacingDir = FaceDir.RIGHT;
            break;

        default:
        {
            // Do nothing
        }
        break;
        }

        transform.Rotate(new Vector3(0.0f, -90.0f, 0.0f));
        EndRot = transform.rotation;
        transform.Rotate(new Vector3(0.0f, 90.0f, 0.0f));
        RotateDir      = -1.0f;
        TurnInProgress = true;
    }
Пример #23
0
        internal void Draw(Face face, FaceDir dir, Color colorApply, bool transparent)
        {
            System.Drawing.Graphics g = Graphics;

            // test if face can actuallt be seen
            if ((Vector3D.DotProduct(face.Normal, CameraPosition - Target) > 0.0 && dir == FaceDir.BACK) ||
                (Vector3D.DotProduct(face.Normal, CameraPosition - Target) < 0.0 && dir == FaceDir.FRONT))
            {
                return;
            }

            // compute face color
            double cosA  = Math.Abs(Vector3D.DotProduct(face.Normal, VLight));
            Color  color = Color.FromArgb(
                transparent ? 64 : 255
                , (int)(colorApply.R * cosA)
                , (int)(colorApply.G * cosA)
                , (int)(colorApply.B * cosA));

            Point[] pt = TransformPoint(GetCurrentTransformation(), face.Points);

            Brush brush = new SolidBrush(color);

            g.FillPolygon(brush, pt);
            // draw path
            float fThickness = transparent ? 2.0f : 1.0f;
            Brush brush0     = new SolidBrush(face.ColorPath);
            int   ptCount    = pt.Length;

            for (int i = 1; i < ptCount; ++i)
            {
                // there is a bug here!
                // -> a polygon that result from first split will lose all edges
                // when split a second time
                g.DrawLine(new Pen(brush0, fThickness), pt[i - 1], pt[i]);
            }
            g.DrawLine(new Pen(brush0, fThickness), pt[ptCount - 1], pt[0]);
        }
Пример #24
0
        internal void Draw(Triangle tr, FaceDir dir)
        {
            System.Drawing.Graphics g = Graphics;

            // test if triangle can actually be seen
            if ((Vector3D.DotProduct(tr.Normal, CameraPosition - Target) > 0.0 && dir == FaceDir.BACK) ||
                (Vector3D.DotProduct(tr.Normal, CameraPosition - Target) < 0.0 && dir == FaceDir.FRONT))
            {
                return;
            }
            // compute triangle color
            double cosA  = Math.Abs(Vector3D.DotProduct(tr.Normal, VLight));
            Color  color = Color.FromArgb(
                tr.IsSolid ? 255 : (dir == FaceDir.FRONT ? 64 : 255)
                , (int)(tr.ColorFill.R * cosA)
                , (int)(tr.ColorFill.G * cosA)
                , (int)(tr.ColorFill.B * cosA));
            Brush brush = new SolidBrush(color);

            // draw filled triangle
            Point[] pt = TransformPoint(GetCurrentTransformation(), tr.Points);
            g.FillPolygon(brush, pt);
            // draw path
            Brush brush0 = new SolidBrush(tr.ColorPath);
            Pen   pen0   = new Pen(brush0, 0);

            for (int i = 1; i < pt.Length; ++i)
            {
                if (tr.DrawPath[i - 1])
                {
                    g.DrawLine(pen0, pt[i - 1], pt[i]);
                }
            }
            if (tr.DrawPath[2])
            {
                g.DrawLine(pen0, pt[pt.Length - 1], pt[0]);
            }
        }
Пример #25
0
        public Enemy(Vector2 p)
        {
            Load("Sprites/actor");
            position = p;
            rect     = new Rectangle(224, 128, 32, 32);

            // sn_kill_enemy = Setup.ContentDevice.Load<SoundEffect>("Sounds/Randomize3");

            killed  = false;
            bite    = false;
            faceDir = FaceDir.right;

            //Set rigidbody behaivior here
            // rigidbody = BodyFactory.CreateRectangle(Game1.world, ConvertUnits.ToSimUnits(rect.Width), ConvertUnits.ToSimUnits(rect.Height), 1.0f, ConvertUnits.ToSimUnits(this.Position));
            rigidbody                     = BodyFactory.CreateCircle(Game1.world, ConvertUnits.ToSimUnits(rect.Width / 2), 1.0f, ConvertUnits.ToSimUnits(position));
            rigidbody.BodyType            = BodyType.Dynamic;
            rigidbody.FixedRotation       = true;
            rigidbody.Restitution         = 0f;            // No bounciness
            rigidbody.Friction            = 0f;
            rigidbody.CollisionCategories = Category.Cat3; // cat3 is coins

            rigidbody.OnCollision += Rigidbody_OnCollision;
        }
Пример #26
0
        /// <summary>
        /// Draw a face
        /// </summary>
        /// <param name="face">Face object to be drawn</param>
        internal void Draw(Face face, FaceDir dir)
        {
            System.Drawing.Graphics g = Graphics;

            // test if face can actually be seen
            if ((Vector3D.DotProduct(face.Normal, ViewDirection) < 0.0 && dir == FaceDir.BACK) ||
                (Vector3D.DotProduct(face.Normal, ViewDirection) > 0.0 && dir == FaceDir.FRONT))
            {
                return;
            }

            // compute face color
            double cosA  = Math.Abs(Vector3D.DotProduct(face.Normal, VLight));
            Color  color = Color.FromArgb(
                face.IsSolid ? 255 : (dir == FaceDir.FRONT ? 64 : 255)
                , (int)(face.ColorFill.R * cosA)
                , (int)(face.ColorFill.G * cosA)
                , (int)(face.ColorFill.B * cosA));

            Point[] pt = TransformPoint(face.Points);

            Brush brush = new SolidBrush(color);

            g.FillPolygon(brush, pt);
            // draw path
            Brush brush0  = new SolidBrush(face.ColorPath);
            int   ptCount = pt.Length;

            for (int i = 1; i < ptCount; ++i)
            {
                // there is a bug here!
                // -> a polygon that result from first split will lose all edges
                // when split a second time
                g.DrawLine(new Pen(brush0, 1.5f), pt[i - 1], pt[i]);
            }
            g.DrawLine(new Pen(brush0, 1.5f), pt[ptCount - 1], pt[0]);
        }
Пример #27
0
    public void Move(Vector2 movement, bool isOnPlatform = false)
    {
        m_collisionInfo.Reset();

        HorizontalCollisions(ref movement);
        VerticalCollisions(ref movement);

        transform.Translate(movement);

        if (movement.x > 0)
        {
            m_faceDir = FaceDir.Right;
        }
        else if (movement.x < 0)
        {
            m_faceDir = FaceDir.Left;
        }

        if (isOnPlatform)
        {
            m_collisionInfo.m_below = true;
            m_belowCollisionCB?.Invoke();
        }
    }
Пример #28
0
 void Update()
 {
     direction = this.GetComponent <MoveEnnemi>().direction;
     if (direction.y == 1)
     {
         regard = FaceDir.F_haut;
     }
     else if (direction.y == -1)
     {
         regard = FaceDir.F_bas;
     }
     else if (direction.x == 1)
     {
         regard = FaceDir.F_droite;
     }
     else if (direction.x == -1)
     {
         regard = FaceDir.F_gauche;
     }
     if (regard == FaceDir.F_bas)
     {
         spriteRenderer.sprite = bas;
     }
     else if (regard == FaceDir.F_droite)
     {
         spriteRenderer.sprite = droite;
     }
     else if (regard == FaceDir.F_gauche)
     {
         spriteRenderer.sprite = gauche;
     }
     else if (regard == FaceDir.F_haut)
     {
         spriteRenderer.sprite = haut;
     }
 }
Пример #29
0
 public void imp_setFacingX()
 {
     faceDir = FaceDir.X;
 }
Пример #30
0
        internal void Draw(Face face, FaceDir dir, Color colorApply, bool transparent)
        {
            System.Drawing.Graphics g = Graphics;

            // test if face can actuallt be seen
            if ((Vector3D.DotProduct(face.Normal, _vCameraPos - _vTarget) > 0.0 && dir == FaceDir.BACK)
                || (Vector3D.DotProduct(face.Normal, _vCameraPos - _vTarget) < 0.0 && dir == FaceDir.FRONT))
                return;

            // compute face color
            double cosA = System.Math.Abs(Vector3D.DotProduct(face.Normal, VLight));
            Color color = Color.FromArgb(
                transparent ? 64 : 255
                , (int)(colorApply.R * cosA)
                , (int)(colorApply.G * cosA)
                , (int)(colorApply.B * cosA));
            Point[] pt = TransformPoint(GetCurrentTransformation(), face.Points);

            Brush brush = new SolidBrush(color);
            g.FillPolygon(brush, pt);
            // draw path
            float fThickness = transparent ? 2.0f : 1.0f;
            Brush brush0 = new SolidBrush(face.ColorPath);
            int ptCount = pt.Length;
            for (int i = 1; i < ptCount; ++i)
            {
                // there is a bug here!
                // -> a polygon that result from first split will lose all edges
                // when split a second time
                g.DrawLine(new Pen(brush0, fThickness), pt[i - 1], pt[i]);
            }
            g.DrawLine(new Pen(brush0, fThickness), pt[ptCount - 1], pt[0]);
        }
Пример #31
0
        void MoveToward(Vector3 direction)
        {
            if (!playerAttack.isAfterAttack)
            {
                if (direction.x == 0 && direction.y == 1)
                {
                    faceDir = FaceDir.Up;
                    this.gameObject.GetComponent<Animator>().CrossFade("Run_Back_A", 0f);
                }
                else if (direction.x == -1 && direction.y == 0)
                {
                    faceDir = FaceDir.Left;
                    this.gameObject.GetComponent<Animator>().CrossFade("Run_Left_A", 0f);
                }
                else if (direction.x == 1 && direction.y == 0)
                {
                    faceDir = FaceDir.Right;
                    this.gameObject.GetComponent<Animator>().CrossFade("Run_Right_A", 0f);
                }
                else if (direction.x == 0 && direction.y == -1)
                {
                    faceDir = FaceDir.Down;
                    this.gameObject.GetComponent<Animator>().CrossFade("Run_Front_A", 0f);
                }

                transform.position += direction * Time.deltaTime * speed;
            }
        }
Пример #32
0
        public void Update(GameTime gameTime)
        {
            this.Rect = rect;
            if (!IsKilled)
            {
                rigidbody.LinearVelocity = new Vector2(walkSpeed, rigidbody.LinearVelocity.Y);

                RaySide();
                RayUp();

                if (dirChange)
                {
                    walkSpeed *= -1f;
                    dirChange = false;

                    if (faceDir == FaceDir.left)
                    {
                        faceDir = FaceDir.right;
                    }
                    else if (faceDir == FaceDir.right)
                    {
                        faceDir = FaceDir.left;
                    }

                }
                Frames();
            }
            else
            {
                rect = new Rectangle(64, 896, 32, 32);
            }
        }
Пример #33
0
 public void imp_setFacingZ()
 {
     faceDir = FaceDir.Z;
 }
Пример #34
0
 public void imp_setFacingY()
 {
     faceDir = FaceDir.Y;
 }