Exemple #1
0
    public static bool IsInDirection4(GenRect rect, int gx, int gy, params Direction4[] dir)
    {
        Direction8[] other = new Direction8[dir.Length];
        for (int i = 0; i < dir.Length; i++)
        {
            Direction8 target = Direction8.Bottom;
            switch (dir[i])
            {
            case Direction4.Right:
                target = Direction8.Right;
                break;

            case Direction4.Bottom:
                target = Direction8.Bottom;
                break;

            case Direction4.Left:
                target = Direction8.Left;
                break;

            case Direction4.Top:
                target = Direction8.Top;
                break;

            default:
                break;
            }
            other[i] = target;
        }
        return(IsInOctant(rect, gx, gy, other));
    }
        private void ExpandArray(Direction8 dir)
        {
            int expansion = 10;

            if (dir == Direction8.None)
            {
                return;
            }

            //expand by an arbitrary amount: 10 tiles
            Loc2D size = new Loc2D(AgeArray.GetLength(0), AgeArray.GetLength(1));

            if (Operations.GetOrientation8(dir) == Orientation8.Horiz)
            {
                size.X += expansion;
            }
            else if (Operations.GetOrientation8(dir) == Orientation8.Vert)
            {
                size.Y += expansion;
            }
            else
            {
                size.X += expansion;
                size.Y += expansion;
            }

            Loc2D diff = Operations.GetResizeOffset(AgeArray.GetLength(0), AgeArray.GetLength(1), size.X, size.Y, dir);

            Operations.ResizeArray <int>(ref AgeArray, size.X, size.Y, dir);

            TopLeft -= diff;
        }
 public SpawnCharacter(ActiveChar character, int charIndex)
 {
     this.charIndex = charIndex;
     this.charLoc = character.CharLoc;
     this.charDir = character.CharDir;
     this.form = character.CharData;
 }
Exemple #4
0
        public static bool DirBlocked(Direction8 dir, ActiveChar character, Loc2D loc, bool inAir, int distance)
        {
            if (character == FocusedCharacter && Intangible)
            {
                Operations.MoveInDirection8(ref loc, dir, 1);
                if (!Operations.IsInBound(CurrentMap.Width, CurrentMap.Height, loc.X, loc.Y))
                {
                    return(true);
                }

                return(false);
            }

            Enums.WalkMode walkMode = Enums.WalkMode.Normal;

            if (inAir)
            {
                walkMode = Enums.WalkMode.Air;
            }

            for (int i = 0; i < distance; i++)
            {
                Operations.MoveInDirection8(ref loc, dir, 1);

                if (IsBlocked(loc, walkMode))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #5
0
        public static Direction8 AddDir(Direction8 dir1, Direction8 dir2)
        {
            if ((int)dir1 <= (int)Direction8.None)
            {
                return(dir2);
            }
            if ((int)dir2 <= (int)Direction8.None)
            {
                return(dir1);
            }
            bool dir1Diag = IsDiagonal(dir1);
            bool dir2Diag = IsDiagonal(dir2);

            if (!dir1Diag && !dir2Diag)
            {
                return((Direction8)(((int)dir1 + (int)dir2) % 4));
            }
            else if (dir1Diag && dir2Diag)
            {
                return((Direction8)(((int)dir1 + (int)dir2 - 3) % 4));
            }
            else
            {
                return((Direction8)(((int)dir1 + (int)dir2) % 8 + ((int)dir1 + (int)dir2) / 8 * 4));
            }
        }
Exemple #6
0
        public static Vector2 ToVector2(this Direction8 d)
        {
            switch (d)
            {
            case Direction8.East:
                return(new Vector2(1, 0));

            case Direction8.SouthEast:
                return(new Vector2(1, 1));

            case Direction8.South:
                return(new Vector2(0, 1));

            case Direction8.SouthWest:
                return(new Vector2(-1, 1));

            case Direction8.West:
                return(new Vector2(-1, 0));

            case Direction8.NorthWest:
                return(new Vector2(-1, -1));

            case Direction8.North:
                return(new Vector2(0, -1));

            case Direction8.NorthEast:
                return(new Vector2(1, -1));

            default:
                throw new ArgumentOutOfRangeException(nameof(d));
            }
        }
Exemple #7
0
        public static void ResizeArray <T>(ref T[,] array, int width, int height, Direction8 dir, bool initialize) where T : new()
        {
            Direction4 vert  = Direction4.None;
            Direction4 horiz = Direction4.None;

            DecomposeDiagonal(dir, ref horiz, ref vert);

            Loc2D offset = new Loc2D();

            if (horiz == Direction4.None)
            {
                offset.X = (width - array.GetLength(0)) / 2;
            }
            else if (horiz == Direction4.Left)
            {
                offset.X = (width - array.GetLength(0));
            }

            if (vert == Direction4.None)
            {
                offset.Y = (height - array.GetLength(1)) / 2;
            }
            else if (vert == Direction4.Up)
            {
                offset.Y = (height - array.GetLength(1));
            }


            T[,] returnArray = new T[width, height];
            if (initialize)
            {
                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        if (x >= offset.X && x < offset.X + array.GetLength(0) &&
                            y >= offset.Y && y < offset.Y + array.GetLength(1))
                        {
                            returnArray[x, y] = array[x - offset.X, y - offset.Y];
                        }
                        else
                        {
                            returnArray[x, y] = new T();
                        }
                    }
                }
            }
            else
            {
                for (int x = Math.Max(-offset.X, 0); x < array.GetLength(0) && x + offset.X < returnArray.GetLength(0); x++)
                {
                    for (int y = Math.Max(-offset.Y, 0); y < array.GetLength(1) && y + offset.Y < returnArray.GetLength(1); y++)
                    {
                        returnArray[x + offset.X, y + offset.Y] = array[x, y];
                    }
                }
            }

            array = returnArray;
        }
Exemple #8
0
    /// <summary>
    /// Converts the direction into a Vector2 instance
    /// </summary>
    /// <param name="dir8"></param>
    /// <returns></returns>
    public static Vector2 ToVector2(this Direction8 dir8)
    {
        switch (dir8)
        {
        case Direction8.Up:
            return(Vector2.up);

        case Direction8.UpRight:
            return(new Vector2(1, 1).normalized);

        case Direction8.Right:
            return(Vector2.right);

        case Direction8.DownRight:
            return(new Vector2(1, -1).normalized);

        case Direction8.Down:
            return(Vector2.down);

        case Direction8.DownLeft:
            return(new Vector2(-1, -1).normalized);

        case Direction8.Left:
            return(Vector2.left);

        case Direction8.UpLeft:
            return(new Vector2(-1, 1).normalized);

        default:
            throw new ArgumentOutOfRangeException("Not a valid direction");
        }
    }
 public SpawnCharacter(ActiveChar character, int charIndex)
 {
     this.charIndex = charIndex;
     charLoc        = character.CharLoc;
     charDir        = character.CharDir;
     form           = character.CharData;
 }
Exemple #10
0
 protected virtual void SetDirection(Vector2 dir)
 {
     if (body.velocity.sqrMagnitude > directionalDeadZone)
     {
         Direction8 dir8 = Direction.ToDirection8(dir);
         direction.SetDirection(dir8);
     }
 }
Exemple #11
0
    void SetDirection(Vector2 dir)
    {
        Direction8 dir8 = Direction.ToDirection8(dir);

        direction.SetDirection(dir8);
        animator.SetFloat("hdirection", rotateDir.x);
        animator.SetFloat("vdirection", rotateDir.y);
    }
Exemple #12
0
 public Player(Loc2D newLoc, Direction8 charDir)
 {
     CharLoc = newLoc;
     CharDir = charDir;
     dead    = false;
     Name    = "Hero";
     Initialize();
 }
Exemple #13
0
 public Player(Loc2D newLoc, Direction8 charDir)
 {
     CharLoc = newLoc;
     CharDir = charDir;
     dead = false;
     Name = "Hero";
     Initialize();
 }
Exemple #14
0
 public RingBuilder StartTo(Direction8 direction)
 {
     multishape = new List <IPaintable>();
     lastField  = new RoadField(startPosition, direction, color);
     startField = lastField;
     multishape.Add(startField);
     return(this);
 }
Exemple #15
0
 public static Direction8 Rotate(this Direction8 dir, int octaClockwise)
 {
     while (octaClockwise < 0)
     {
         octaClockwise += 8;
     }
     return((Direction8)(((int)dir + octaClockwise) % 8));
 }
Exemple #16
0
 public static Direction8 ReverseDir(Direction8 dir)
 {
     if ((int)dir <= (int)Direction8.None)
     {
         return(dir);
     }
     return((Direction8)(((int)dir + 2) % 4 + (int)dir / 4 * 4));
 }
Exemple #17
0
 //draw offset, height offset, and frame are determined on runtime based on
 //-CurrentAction
 //-ActionTime
 //-CharDir
 public CharSprite(Loc2D charLoc, Direction8 charDir)
 {
     CharLoc    = charLoc;
     CharDir    = charDir;
     ActionDone = true;
     //everything else at default values
     //CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender is 0 for now
     CharData = new Gameplay.FormData();
 }
Exemple #18
0
 public Character(Loc2D newLoc, Direction8 charDir)
 {
     //clean variables
     BaseMoves = new Move[Processor.MAX_MOVE_SLOTS];
     for (int i = 0; i < Processor.MAX_MOVE_SLOTS; i++)
     {
         BaseMoves[i] = new Move();
     }
 }
Exemple #19
0
 public Character(Loc2D newLoc, Direction8 charDir)
 {
     //clean variables
     BaseMoves = new Move[Processor.MAX_MOVE_SLOTS];
     for (int i = 0; i < Processor.MAX_MOVE_SLOTS; i++)
     {
         BaseMoves[i] = new Move();
     }
 }
Exemple #20
0
 //draw offset, height offset, and frame are determined on runtime based on
 //-CurrentAction
 //-ActionTime
 //-CharDir
 public CharSprite(Loc2D charLoc, Direction8 charDir)
 {
     this.charLoc = charLoc;
     this.CharDir = charDir;
     this.ActionDone = true;
     //everything else at default values
     //CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender is 0 for now
     CharData = new Gameplay.FormData();
 }
Exemple #21
0
 public static List <BorderCondition> GetBorderConditions(Direction8 direction)
 {
     if (cachedConditions.ContainsKey(direction))
     {
         return(cachedConditions[direction]);
     }
     cachedConditions [direction] = CreateBorderConditions(direction);
     return(cachedConditions [direction]);
 }
Exemple #22
0
    /// <summary>
    /// Rotates the direction a set amount of times
    /// </summary>
    /// <param name="dir8"></param>
    public static Direction8 Rotate(this Direction8 dir8, int times)
    {
        if (times >= 0)
        {
            return((Direction8)(((int)dir8 + times) % 8));
        }

        throw new ArgumentException("Argument must be greater than or equal to zero");
    }
Exemple #23
0
        public static int Difference(this Direction8 d, Direction8 o)
        {
            var num = Utility.Mod(o - d, 8);

            if (num > 4)
            {
                num -= 8;
            }
            return(num);
        }
Exemple #24
0
    /// <summary>
    /// Converts this Direction8 into a Direction4
    /// </summary>
    /// <param name="dir8"></param>
    /// <returns></returns>
    public static Direction4 ToDirection4(this Direction8 dir8)
    {
        //Argument is not is a compound direction.
        if ((int)dir8 % 2 == 1)
        {
            throw new ArgumentException("Cannot convert direction " + dir8 + " to cardinal");
        }

        return((Direction4)dir8);
    }
Exemple #25
0
        private static void ProcessDir(Direction8 dir, ActiveChar character, ref bool moveMade)
        {
            if (character.Status == Enums.StatusAilment.Freeze)
            {
                return;
            }

            character.CharDir = dir;
            Display.Screen.AddResult(new Results.Dir(CharIndex(character), character.CharDir));
        }
        /// <summary>
        ///  Vector2からDirectionへ
        /// </summary>
        public Direction(Vector2Int v, bool yUp = true)
        {
            // y座標のプラス方向を下にしたい場合
            if (yUp == false)
            {
                v.y *= -1;
            }

            v.x = Mathf.Min(v.x, 1);
            v.x = Mathf.Max(v.x, -1);
            v.y = Mathf.Min(v.y, 1);
            v.y = Mathf.Max(v.y, -1);

            int mag = (int)v.sqrMagnitude;

            switch (mag)
            {
            case 2:
            {
                if (v.y < 0)
                {
                    this.value = (v.x < 0) ? Direction8.LeftDown : Direction8.RightDown;
                    return;
                }
                else
                {
                    this.value = (v.x < 0) ? Direction8.LeftUp : Direction8.RightUp;
                    return;
                }
            }

            case 1:
            {
                if (0 < v.y)
                {
                    this.value = Direction8.Up; return;
                }
                if (v.y < 0)
                {
                    this.value = Direction8.Down; return;
                }
                if (v.x < 0)
                {
                    this.value = Direction8.Left; return;
                }
                if (0 < v.x)
                {
                    this.value = Direction8.Right; return;
                }
                break;
            }
            }

            this.value = Direction8.Neutral;
        }
Exemple #27
0
        public void SetDirection(Direction8 direction)
        {
            this.direction = direction;
            double theta;

            switch (direction)
            {
            case Direction8.East:
                theta = 0;
                break;

            case Direction8.South:
                theta = -Math.PI / 2;
                break;

            case Direction8.West:
                theta = Math.PI;
                break;

            case Direction8.North:
                theta = Math.PI / 2;
                break;

            default:
                theta = 0;
                break;
            }
            double d8 = Module / 8;
            double x0 = -Module / 2;
            double y0 = -Module / 4;
            double x1 = x0 * Math.Cos(theta) + y0 * Math.Sin(theta);
            double y1 = y0 * Math.Cos(theta) - x0 * Math.Sin(theta);

            chassis.X = x1;
            chassis.Y = y1;

            x0    = d8 - Module / 2;
            y0    = d8 - Module / 4;
            x1    = x0 * Math.Cos(theta) + y0 * Math.Sin(theta);
            y1    = y0 * Math.Cos(theta) - x0 * Math.Sin(theta);
            cab.X = x1;
            cab.Y = y1;

            x0 = 7 * d8 - Module / 2;
            y0 = d8 - Module / 4;
            x1 = x0 * Math.Cos(theta) + y0 * Math.Sin(theta);
            y1 = y0 * Math.Cos(theta) - x0 * Math.Sin(theta);
            lightL.SetPosition(x1 + position.X, y1 + position.Y);

            x0 = 7 * d8 - Module / 2;
            y0 = 3 * d8 - Module / 4;
            x1 = x0 * Math.Cos(theta) + y0 * Math.Sin(theta);
            y1 = y0 * Math.Cos(theta) - x0 * Math.Sin(theta);
            lightR.SetPosition(x1 + position.X, y1 + position.Y);
        }
Exemple #28
0
        public Input(KeyboardDevice keyboard, MouseDevice mouse)
        {
            Loc2D dirLoc = new Loc2D();


            if (keyboard[Key.Down])
            {
                Operations.MoveInDirection8(ref dirLoc, Direction8.Down, 1);
            }
            if (keyboard[Key.Left])
            {
                Operations.MoveInDirection8(ref dirLoc, Direction8.Left, 1);
            }
            if (keyboard[Key.Up])
            {
                Operations.MoveInDirection8(ref dirLoc, Direction8.Up, 1);
            }
            if (keyboard[Key.Right])
            {
                Operations.MoveInDirection8(ref dirLoc, Direction8.Right, 1);
            }

            dir = Operations.GetDirection8(new Loc2D(), dirLoc);

            inputStates[(int)InputType.X] = keyboard[Key.X];
            inputStates[(int)InputType.Z] = keyboard[Key.Z];
            inputStates[(int)InputType.C] = keyboard[Key.C];
            inputStates[(int)InputType.A] = keyboard[Key.A];
            inputStates[(int)InputType.S] = keyboard[Key.S];
            inputStates[(int)InputType.D] = keyboard[Key.D];

            inputStates[(int)InputType.Q] = keyboard[Key.Q];
            inputStates[(int)InputType.W] = keyboard[Key.W];

            inputStates[(int)InputType.Enter] = (keyboard[Key.Enter]);

            LeftMouse  = mouse[MouseButton.Left];
            RightMouse = mouse[MouseButton.Right];

            MouseWheel = mouse.Wheel;

            MouseLoc = new Loc2D(mouse.X, mouse.Y);

            Shift = keyboard[Key.ShiftLeft] || keyboard[Key.ShiftRight];

            ShowDebug = keyboard[Key.F1];
            SpeedDown = keyboard[Key.F2];
            SpeedUp   = keyboard[Key.F3];
#if GAME_MODE
            Intangible = keyboard[Key.F4];
            Print      = keyboard[Key.F5];
            Restart    = keyboard[Key.F12];
#endif
        }
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        Direction8 heroDir  = hero.direction.dir8;
        Vector2    forceDir = Direction.ToVector(heroDir).normalized;

        frame++;

        float easingMultiplier = AttackMoveEasing(frame / 30);

        hero.ForceMove(forceDir * easingMultiplier * 2f);
    }
Exemple #30
0
        // Unused but might come in handy later
        private RectangleF GetIntersectionArea(Direction8 dir)
        {
            if (!dir.IsHorizontal() && !dir.IsVertical())
            {
                return(new RectangleF());
            }

            var pos  = Position + dir.ToNormalizedVector2(48);
            var size = dir.IsVertical() ? new Vector2(64, 160) : new Vector2(160, 64);

            return(new RectangleF(pos, size));
        }
Exemple #31
0
 private bool HasFullGuard(AntHill hill, out Direction8 emptySpot)
 {
     foreach (Direction8 direction in Enum.GetValues(typeof(Direction8)))
     {
         if (gameState.GetIsUnoccupied(gameState.GetDestination(hill, direction)))
         {
             emptySpot = direction;
             return(false);
         }
     }
     emptySpot = Direction8.North;
     return(true);
 }
		public BulletSplitter(GameScreen scrn, Bullet b, Direction8 d) : base(scrn)
		{
			scale = b.Scale;
			ShapePosition = b.BulletPosition;
			ShapeAlpha = 1f;
			Fraction = b.Fraction;
			velocity = VELOCITIES[(int)d] * FloatMath.GetRangedRandom(0.5f, 2f) + ConvertUnits.ToDisplayUnits(b.PhysicsBody.LinearVelocity)/10f;
			maxLifetime = FloatMath.GetRangedRandom(SPLITTER_LIFETIME_MIN, SPLITTER_LIFETIME_MAX);
			ShapeRotation = FloatMath.ToRadians((int) d * 45f);
			rotationSpeed = FloatMath.GetRangedRandom(-FloatMath.TAU, FloatMath.TAU);

			DrawingBoundingBox = new FSize(Bullet.BULLET_DIAMETER, Bullet.BULLET_DIAMETER) * scale;
		}
Exemple #33
0
 protected override void SetDirection(Vector2 dir)
 {
     if (dir.sqrMagnitude > directionalDeadZone)
     {
         Direction8 newDir8 = Direction.ToDirection8(dir);
         if (newDir8 != direction.dir8)
         {
             CmdSetDirection(newDir8);
         }
         direction.SetDirection(newDir8);
         animator.SetFloat("direction", direction.ToAnimDirection());
     }
 }
Exemple #34
0
        public static bool MoveBlocked(Loc2D loc, Direction8 dir)
        {
            Enums.WalkMode walkMode = Enums.WalkMode.Air;

            Operations.MoveInDirection8(ref loc, dir, 1);

            if (TileBlocked(loc, walkMode))
            {
                return(true);
            }

            return(false);
        }
Exemple #35
0
 public static Direction8 Clockwise45(this Direction8 self)
 {
     return(self switch
     {
         Direction8.East => Direction8.SouthEast,
         Direction8.SouthEast => Direction8.South,
         Direction8.South => Direction8.SouthWest,
         Direction8.SouthWest => Direction8.West,
         Direction8.West => Direction8.NorthWest,
         Direction8.NorthWest => Direction8.North,
         Direction8.North => Direction8.NorthEast,
         Direction8.NorthEast => Direction8.East,
         _ => throw new ArgumentException("Unknown direction", "self"),
     });
Exemple #36
0
        public Input(KeyboardDevice keyboard, MouseDevice mouse)
        {
            Loc2D dirLoc = new Loc2D();

            if (keyboard[Key.Down]) {
                Operations.MoveInDirection8(ref dirLoc, Direction8.Down, 1);
            }
            if (keyboard[Key.Left]) {
                Operations.MoveInDirection8(ref dirLoc, Direction8.Left, 1);
            }
            if (keyboard[Key.Up]) {
                Operations.MoveInDirection8(ref dirLoc, Direction8.Up, 1);
            }
            if (keyboard[Key.Right]) {
                Operations.MoveInDirection8(ref dirLoc, Direction8.Right, 1);
            }

            dir = Operations.GetDirection8(new Loc2D(), dirLoc);

            inputStates[(int)InputType.X] = keyboard[Key.X];
            inputStates[(int)InputType.Z] = keyboard[Key.Z];
            inputStates[(int)InputType.C] = keyboard[Key.C];
            inputStates[(int)InputType.A] = keyboard[Key.A];
            inputStates[(int)InputType.S] = keyboard[Key.S];
            inputStates[(int)InputType.D] = keyboard[Key.D];

            inputStates[(int)InputType.Q] = keyboard[Key.Q];
            inputStates[(int)InputType.W] = keyboard[Key.W];

            inputStates[(int)InputType.Enter] = (keyboard[Key.Enter]);

            LeftMouse = mouse[MouseButton.Left];
            RightMouse = mouse[MouseButton.Right];

            MouseWheel = mouse.Wheel;

            MouseLoc = new Loc2D(mouse.X, mouse.Y);

            Shift = keyboard[Key.ShiftLeft] || keyboard[Key.ShiftRight];

            ShowDebug = keyboard[Key.F1];
            SpeedDown = keyboard[Key.F2];
            SpeedUp = keyboard[Key.F3];
            #if GAME_MODE
            Intangible = keyboard[Key.F4];
            Print = keyboard[Key.F5];
            Restart = keyboard[Key.F12];
            #endif
        }
Exemple #37
0
        public ActiveChar(Loc2D newLoc, Direction8 charDir)
        {
            //clean variables
            CharLoc = newLoc;
            CharDir = charDir;
            HP = MaxHP;
            Status = Enums.StatusAilment.OK;
            StatusCounter = 0;
            Moves = new MoveState[Processor.MAX_MOVE_SLOTS];
            for (int i = 0; i < Processor.MAX_MOVE_SLOTS; i++)
            {
                Moves[i] = new MoveState();
            }

            VolatileStatus = new Dictionary<string, ExtraStatus>();
        }
Exemple #38
0
 public Npc(Loc2D newLoc, Direction8 charDir, int npcIndex)
 {
     CharLoc = newLoc;
     CharDir = charDir;
     CharData.Species = npcIndex;
     if (npcIndex == 1) {
         Name = "Bandaid Mouse";
         Atk = 0;
         MaxHP = 8;
     } else if (npcIndex == 2) {
         Name = "Slime";
         Ability1 = "Slow Body";
         Atk = -2;
         MaxHP = 4;
     }
     Tactic = new AI(this);
     Initialize();
 }
Exemple #39
0
 public static bool DirBlocked(Direction8 dir, ActiveChar character, bool inAir, int distance)
 {
     return DirBlocked(dir, character, character.CharLoc, inAir, distance);
 }
Exemple #40
0
        private void ExpandArray(Direction8 dir)
        {
            int expansion = 10;

            if (dir == Direction8.None)
                return;

            //expand by an arbitrary amount: 10 tiles
            Loc2D size = new Loc2D(AgeArray.GetLength(0), AgeArray.GetLength(1));

            if (Operations.GetOrientation8(dir) == Orientation8.Horiz)
                size.X += expansion;
            else if (Operations.GetOrientation8(dir) == Orientation8.Vert)
                size.Y += expansion;
            else
            {
                size.X += expansion;
                size.Y += expansion;
            }

            Loc2D diff = Operations.GetResizeOffset(AgeArray.GetLength(0), AgeArray.GetLength(1), size.X, size.Y, dir);
            Operations.ResizeArray<int>(ref AgeArray, size.X, size.Y, dir);

            TopLeft -= diff;
        }
Exemple #41
0
        bool IsBlocked(int x, int y, Direction8 dir)
        {
            Operations.MoveInDirection8(ref x, ref y, dir, 1);

            if (x < 0 || x > Width - 1 || y < 0 || y > Height - 1)
                return true;

            if (AgeArray[x, y] != -1)
                return true;

            return false;
        }
Exemple #42
0
        bool IsBlocked(int x, int y, Direction8 dir)
        {
            Operations.MoveInDirection8(ref x, ref y, dir, 1);

            if (x < 0 || x > Width - 1 || y < 0 || y > Height - 1) {
                return true;
            }

            if (GridArray[x, y] == GridType.Blocked) {
                return true;
            }

            return false;
        }
Exemple #43
0
 public Input()
 {
     dir = Direction8.None;
 }
Exemple #44
0
 public Dir(int charIndex, Direction8 newDir)
 {
     this.charIndex = charIndex;
     this.newDir = newDir;
 }
Exemple #45
0
 public static bool DirBlocked(Direction8 dir, ActiveChar character, bool inAir)
 {
     return DirBlocked(dir, character, inAir, 1);
 }
Exemple #46
0
 public static RenderTime GetPassTime(Gameplay.FormData charData, Direction8 dir, ActionType actionType)
 {
     switch (actionType)
     {
         case ActionType.None:
             return RenderTime.FromMillisecs(1000);
         case ActionType.Idle:
             return RenderTime.FromMillisecs(0);
         case ActionType.Walk:
             return RenderTime.FromMillisecs(200);
         case ActionType.Attack:
         case ActionType.AltAttack:
             return RenderTime.FromMillisecs(200);
         case ActionType.SpAttack:
         case ActionType.SpAttackShoot:
             return RenderTime.FromMillisecs(200);
         case ActionType.SpAttackCharge:
             return RenderTime.FromMillisecs(280);
         case ActionType.Sleeping:
         case ActionType.Hurt:
         case ActionType.Defeated:
         case ActionType.Throw:
         case ActionType.Item:
         case ActionType.Jump:
         case ActionType.JumpHit:
         case ActionType.Deflect:
         case ActionType.Knockback:
             return GetActionTime(charData, dir, actionType);
         default:
             return RenderTime.Zero;
     }
 }
Exemple #47
0
 public NpcSprite(Loc2D charLoc, Direction8 charDir, Gameplay.FormData data)
     : base(charLoc, charDir)
 {
     CharData = data;
 }
Exemple #48
0
        private static void ProcessDir(Direction8 dir, ActiveChar character, ref bool moveMade)
        {
            if (character.Status == Enums.StatusAilment.Freeze) {
                return;
            }

            character.CharDir = dir;
            Display.Screen.AddResult(new Results.Dir(CharIndex(character), character.CharDir));
        }
Exemple #49
0
        public static bool MoveBlocked(Loc2D loc, Direction8 dir)
        {
            Enums.WalkMode walkMode = Enums.WalkMode.Air;

            Operations.MoveInDirection8(ref loc, dir, 1);

            if (TileBlocked(loc, walkMode))
                return true;

            return false;
        }
Exemple #50
0
        public static bool DirBlocked(Direction8 dir, ActiveChar character, Loc2D loc, bool inAir, int distance)
        {
            if (character == FocusedCharacter && Intangible)
            {
                Operations.MoveInDirection8(ref loc, dir, 1);
                if (!Operations.IsInBound(CurrentMap.Width, CurrentMap.Height, loc.X, loc.Y))
                    return true;

                return false;
            }

            Enums.WalkMode walkMode = Enums.WalkMode.Normal;

            if (inAir)
                walkMode = Enums.WalkMode.Air;

            for (int i = 0; i < distance; i++) {

                Operations.MoveInDirection8(ref loc, dir, 1);

                if (IsBlocked(loc, walkMode))
                    return true;
            }

            return false;
        }
Exemple #51
0
        public static RenderTime GetActionTime(Gameplay.FormData charData, Direction8 dir, ActionType actionType)
        {
            switch (actionType)
            {
                case ActionType.None:
                    return RenderTime.FromMillisecs(1000);
                case ActionType.Idle:
                    {
                        int frames = TextureManager.GetSpriteSheet(charData.Species, charData.Form, charData.Shiny, charData.Gender).FrameData.GetFrameCount(FrameType.Idle, dir);

                        return IDLE_FRAME_LENGTH * frames;
                    }
                case ActionType.Walk:
                    {
                        RenderTime passTime = GetPassTime(charData, dir, actionType);
                        int frames = TextureManager.GetSpriteSheet(charData.Species, charData.Form, charData.Shiny, charData.Gender).FrameData.GetFrameCount(FrameType.Walk, dir);

                        if (frames == 0)
                            return GetPassTime(charData, dir, actionType);

                        int totalFrames = frames;
                        while (WALK_FRAME_LENGTH * frames < passTime)
                        {
                            totalFrames += frames;
                        }
                        return WALK_FRAME_LENGTH * totalFrames;
                    }
                case ActionType.Attack:
                case ActionType.AttackArm:
                case ActionType.AltAttack:
                    return RenderTime.FromMillisecs(400);
                case ActionType.SpAttack:
                case ActionType.SpAttackShoot:
                    return RenderTime.FromMillisecs(480);
                case ActionType.SpAttackCharge:
                    return RenderTime.FromMillisecs(320);
                case ActionType.Sleeping:
                    return RenderTime.FromMillisecs(1000);
                case ActionType.Hurt:
                    return RenderTime.FromMillisecs(360);
                case ActionType.Defeated:
                    return RenderTime.FromMillisecs(720);
                case ActionType.Throw:
                    return RenderTime.FromMillisecs(200);
                case ActionType.Item:
                    return RenderTime.FromMillisecs(200);
                case ActionType.Jump:
                    return RenderTime.FromMillisecs(300);
                case ActionType.JumpHit:
                    return RenderTime.FromMillisecs(600);
                case ActionType.Deflect:
                    return RenderTime.FromMillisecs(600);
                case ActionType.Knockback:
                    return RenderTime.FromMillisecs(80);
                default:
                    return RenderTime.Zero;
            }
        }
Exemple #52
0
 public static bool DirBlocked(Direction8 dir, ActiveChar character)
 {
     return DirBlocked(dir, character, false);
 }