Пример #1
0
 public MoveModel newMove(MoveStats stats, bool right)
 {
     //foreach (MoveModel moveModel in moves) if (moveModel.Stats.Equals(stats)) return null;
     MoveModel move = new MoveModel(stats, right, playerIndex);
     moves.Add(move);
     return move;
 }
Пример #2
0
        private void SuperKeyDown(float directionX, float directionY, float downTimer, int playerIndex)
        {
            if (model.resetTimeLeft <= 0)
            {
                if (!model.attackMode)
                {
                    MoveStats moveStats;
                    if (navigation.X == 0 && navigation.Y == 0)
                    {
                        moveStats = stats.x;
                    }
                    else if (Math.Abs(navigation.X) > Math.Abs(navigation.Y))
                    {
                        moveStats = stats.xLR;
                        model.faceRight = navigation.X > 0;
                    }
                    else if (navigation.Y > 0) moveStats = stats.xDown;
                    else if (model.jumpsLeft > 0)
                    {
                        moveStats = stats.xUp;
                        model.jumpsLeft = 0;
                    }
                    else return;

                    if (moveStats != null)
                    {
                        currentMove = moves.newMove(moveStats, model.faceRight);
                        if (currentMove == null) return;
                        if (currentMove.Stats.Type == MoveType.Charge)
                        {
                            model.setState(CharacterState.charging);
                        }
                        else
                        {
                            model.setState(CharacterState.attacking, currentMove.Stats);
                            if (currentMove.Stats.Start == 0) moves.StartMove(view.Position, view.Velocity, currentMove);
                            if (currentMove.Stats.Adjustable) adjustAngle = model.faceRight ? currentMove.Stats.StartAngle : Math.PI - currentMove.Stats.StartAngle;
                        }
                    }
                }
                else if (currentMove.Stats.Adjustable && currentMove.attackTimeLeft <= 0)
                {
                    model.attackMode = false;
                    NaturalState();
                }
            }
        }
Пример #3
0
        private void HitKeyDown(float directionX, float directionY, float downTimer, int playerIndex)
        {
            if (model.resetTimeLeft <= 0)
            {
                if (!model.attackMode)
                {
                    MoveStats moveStats;
                    if ((newXdir || newYdir) && (Math.Abs(navigation.X) > 0.9 || newYdir && Math.Abs(navigation.Y) > 0.9))
                    {
                        if (Math.Abs(navigation.X) >= Math.Abs(navigation.Y) || (!model.inAir && navigation.Y > 0) || (view.VelocityY < -stats.jumpStartVelocity + 2 && navigation.Y < 0)) moveStats = newXdir? stats.aLR : stats.a;
                        else moveStats = model.inAir && navigation.Y > 0 ? stats.aDown : stats.aUp;
                    }
                    else moveStats = stats.a;

                    if (moveStats != null)
                    {
                        currentMove = moves.newMove(moveStats, model.faceRight);
                        if (currentMove == null) return;
                        if (currentMove.Stats.Type == MoveType.Charge)
                        {
                            model.setState(CharacterState.charging, currentMove.Stats);
                        }
                        else
                        {
                            model.setState(CharacterState.attacking, currentMove.Stats);
                            if (currentMove.Stats.Start == 0) moves.StartMove(view.Position, view.Velocity, currentMove);
                            if (currentMove.Stats.Adjustable) adjustAngle = model.faceRight ? currentMove.Stats.StartAngle : Math.PI - currentMove.Stats.StartAngle;
                        }

                    }
                }
                else if (currentMove.Stats.Adjustable)
                {
                    model.attackMode = false;
                    NaturalState();
                }
            }
        }
Пример #4
0
        public void StartMove(Vector2 characterPosition, Vector2 characterVelocity, MoveModel move)
        {
            if (!move.Started)
            {
                move.Img = Img.AddPosition(characterPosition + move.Stats.SqFrom * move.Xdirection);
                move.Img.SetBoundBox(World, (int)move.Stats.SqSize.X, (int)move.Stats.SqSize.Y, Vector2.Zero, Category.Cat20, Category.Cat11);

                move.Img.BoundBox.IgnoreGravity = true;
                move.Img.BoundBox.IsStatic = false;
                move.Img.BoundBox.UserData = move;
                move.Started = true;

                if (move.Stats.Type == MoveType.Range)
                {
                    move.Img.BoundBox.LinearVelocity = move.Stats.BulletVelocity * move.Xdirection;
                    Img.AnimateFrame(move.Img, move.Stats.AniBulletFrom, move.Stats.AniBulletTo, 14);
                    //if (move.Xdirection == new Vector2(-1, 1)) move.Img.
                    if (move.Stats.Gravity) move.Img.BoundBox.IgnoreGravity = false;
                    move.Img.BoundBox.CollidesWith = Category.Cat11 | Category.Cat10 | Category.Cat9 | Category.Cat8 | Category.Cat7;
                    if (move.Stats.Explotion != null)
                        move.Img.BoundBox.CollisionCategories = Category.Cat31;
                    move.Img.BoundBox.OnCollision += Collision;
                }
                else
                {
                    Vector2 velocity = ConvertUnits.ToSimUnits((move.Stats.SqTo - move.Stats.SqFrom) / (move.Stats.End - move.Stats.Start) * 1000) * move.Xdirection;
                    velocity = move.Stats.SqFrom == move.Stats.SqTo ? characterVelocity : velocity + characterVelocity;
                    move.Img.BoundBox.LinearVelocity = velocity;
                    move.Img.CurrentFrame = -1;
                }
            }
        }
Пример #5
0
 public void RemoveMove(MoveModel move)
 {
     moves.Remove(move);
 }
Пример #6
0
 public void EndMove(MoveModel move)
 {
     Img.RemovePosition(move.Img);
 }