示例#1
0
文件: Map.cs 项目: uvbs/bot-2016
        /// <summary>
        /// Levelspies one floor up or down.
        /// </summary>
        /// <returns></returns>
        public bool LevelSpy(Enums.Direction direction)
        {
            if (!this.LevelSpyStatus)
            {
                return(false);
            }
            if (direction != Enums.Direction.Up && direction != Enums.Direction.Down)
            {
                return(false);
            }

            int  address = this.GetLevelSpyAddress();
            byte playerZ = this.Client.Player.Z;
            int  floor   = this.Client.Memory.ReadInt32(address);
            int  z       = floor + (direction == Enums.Direction.Down ? 1 : -1);

            if (playerZ <= 7 && z > 0 && z <= 7) // check if player is above ground
            {
                this.Client.Memory.WriteInt32(address, z);
                return(true);
            }
            else if (playerZ > 7 && z > 0 && z <= 4) // check if player is underground
            {
                this.Client.Memory.WriteInt32(address, z);
                return(true);
            }
            return(false);
        }
        public BasicItemInformation()
        {
            this.name                    = "";
            this.description             = "";
            this.categoryName            = "";
            this.categoryColor           = new Color(0, 0, 0);
            this.price                   = 0;
            this.staminaRestoredOnEating = -300;
            this.healthRestoredOnEating  = -300;
            this.canBeSetIndoors         = false;
            this.canBeSetOutdoors        = false;

            this.animationManager = new AnimationManager();
            this.drawPosition     = Vector2.Zero;
            this.DrawColor        = Color.White;
            this.inventory        = new InventoryManager();
            this.lightManager     = new LightManager();

            this.facingDirection = Enums.Direction.Down;
            this.id                    = "";
            this.shakeTimer            = 0;
            this.alwaysDrawAbovePlayer = false;
            this.colorManager          = new ColorManager(Enums.DyeBlendMode.Blend, 0.5f);

            this.ignoreBoundingBox         = false;
            this.boundingBoxTileDimensions = new Vector2(1, 1);
        }
示例#3
0
    private void changeDirection()
    {
        switch (direction)
        {
        case Enums.Direction.North:
            transform.LookAt(new Vector3(transform.position.x, transform.position.y, transform.position.z - 1), Vector3.up);
            lastDirection = Enums.Direction.South;
            break;

        case Enums.Direction.East:
            transform.LookAt(new Vector3(transform.position.x - 1, transform.position.y, transform.position.z), Vector3.up);
            lastDirection = Enums.Direction.West;
            break;

        case Enums.Direction.South:
            transform.LookAt(new Vector3(transform.position.x, transform.position.y, transform.position.z + 1), Vector3.up);
            lastDirection = Enums.Direction.North;
            break;

        case Enums.Direction.West:
            transform.LookAt(new Vector3(transform.position.x + 1, transform.position.y, transform.position.z), Vector3.up);
            lastDirection = Enums.Direction.East;
            break;
        }
    }
    } // end FindAvailableCells()


    public static Quaternion FindDirection(Enums.Direction direction)
    {
        Quaternion quatDir;

        switch (direction)
        {
        case Enums.Direction.Up:
            quatDir = Quaternion.Euler(0, 0, 0);
            break;

        case Enums.Direction.Down:
            quatDir = Quaternion.Euler(0, 0, 180);
            break;

        case Enums.Direction.Left:
            quatDir = Quaternion.Euler(0, 0, 90);
            break;

        case Enums.Direction.Right:
            quatDir = Quaternion.Euler(0, 0, 270);
            break;

        default:
            quatDir = Quaternion.Euler(0, 0, 90);
            break;
        }
        return(quatDir);
    }  // end FindDirection
示例#5
0
        public bool IsDirectionClearAtDistance(BackingBox B, Enums.Direction Direction, float Distance, bool ShouldTranslate = false)
        {
            Box adjustedBox;

            if (ShouldTranslate)
            {
                adjustedBox = B.B;
                adjustedBox.GetTranslation(GraphicsHelper.GetVector3FromDirection(Direction) * Distance);
            }
            else
            {
                adjustedBox = B.B.GetDirectionalExpansion(Direction, Distance, -2, -4);
            }
            foreach (BackingBox b in boxes)
            {
                if (b == B || b.InteractionType != BackingBox.IType.Static)
                {
                    continue;
                }
                if (b.B.DoesIntersect(adjustedBox))
                {
                    return(false);
                }
            }
            return(true);
        }
示例#6
0
    private void MoveTiles(Enums.Direction direction)
    {
        MovementSetup();
        bool gridChanged = grid.MoveTilesInGrid(direction);

        PostMovement(gridChanged);
    }
示例#7
0
        public static bool MoveNpcInDirection(Enums.Direction direction, IMap map, Client target, PacketHitList packetList, int mapNpcSlot)
        {
            switch (direction)
            {
            case Enums.Direction.Up:
            {
                return(MoveNpcUp(map, target, packetList, mapNpcSlot));
            }

            case Enums.Direction.Down:
            {
                return(MoveNpcDown(map, target, packetList, mapNpcSlot));
            }

            case Enums.Direction.Left:
            {
                return(MoveNpcLeft(map, target, packetList, mapNpcSlot));
            }

            case Enums.Direction.Right:
            {
                return(MoveNpcRight(map, target, packetList, mapNpcSlot));
            }
            }
            return(false);
        }
示例#8
0
        public Enums.Direction? GetLeftStickTapDirection()
        {
            Vector2 leftStickVector = GetLeftStickVector();

            if (leftStickVector != Vector2.Zero)
            {
                return(null);
            }
            Enums.Direction?maybeTappedDirection = null;
            for (int i = 1; i < REVOLVING_BUFFER_SIZE; i++)
            {
                Vector2 rolledbackLeftStickVector = GetLeftStickVector(i);
                if (maybeTappedDirection != null)
                {
                    if (rolledbackLeftStickVector == Vector2.Zero)
                    {
                        return(maybeTappedDirection);
                    }
                    Enums.Direction currentTappedDirection = GraphicsHelper.GetDirectionFromVector(rolledbackLeftStickVector);
                    if (currentTappedDirection != maybeTappedDirection)
                    {
                        return(null);
                    }
                }
                else
                {
                    if (rolledbackLeftStickVector != Vector2.Zero)
                    {
                        maybeTappedDirection = GraphicsHelper.GetDirectionFromVector(rolledbackLeftStickVector);
                    }
                }
            }
            return(null);
        }
示例#9
0
    private void MutateAtom(Vector3 p)
    {
        if (Random.value < PointMutationRate)
        {
            details[(int)p.x, (int)p.y, (int)p.z].Mutate();
        }

        if (Random.value < ExpansionRate)
        {
            Enums.Direction direction = (Enums.Direction)Random.Range(0, 6) + 1;  //add one to skip direction.none

            Vector3 childLoc = Enums.InDirection(p, direction);
            if (details[(int)childLoc.x, (int)childLoc.y, (int)childLoc.z] == null) //only create the child if there's space
            {
                details[(int)childLoc.x, (int)childLoc.y, (int)childLoc.z]           = AtomDetails.CreateRandom();
                details[(int)p.x, (int)p.y, (int)p.z].children[((int)direction - 1)] = true;
            }
        }

        //Mutate by traversing over children depth first.
        for (int i = 0; i < details[(int)p.x, (int)p.y, (int)p.z].children.Length; i++)
        {
            Enums.Direction childDir = (Enums.Direction)(i + 1);
            if (details[(int)p.x, (int)p.y, (int)p.z].children[i])
            {
                MutateAtom(Enums.InDirection(p, childDir));
            }
        }
    }
示例#10
0
        /// <summary>
        /// Checks if two <see cref="Enums.Direction"/> are close.
        /// </summary>
        /// <param name="dir1"><see cref="Enums.Direction"/></param>
        /// <param name="dir2"><see cref="Enums.Direction"/></param>
        /// <returns><c>True</c> if specified directions are close; <c>False</c> otherwise.</returns>
        internal static bool AreCloseDirections(Enums.Direction dir1, Enums.Direction dir2)
        {
            if (dir1 == dir2)
            {
                return(true);
            }

            switch (dir1)
            {
            case Enums.Direction.Bottom:
                return(dir2 == Enums.Direction.BottomLeft || dir2 == Enums.Direction.BottomRight);

            case Enums.Direction.BottomLeft:
                return(dir2 == Enums.Direction.Bottom || dir2 == Enums.Direction.Left);

            case Enums.Direction.BottomRight:
                return(dir2 == Enums.Direction.Bottom || dir2 == Enums.Direction.Right);

            case Enums.Direction.Left:
                return(dir2 == Enums.Direction.TopLeft || dir2 == Enums.Direction.BottomLeft);

            case Enums.Direction.Right:
                return(dir2 == Enums.Direction.TopRight || dir2 == Enums.Direction.BottomRight);

            case Enums.Direction.Top:
                return(dir2 == Enums.Direction.TopLeft || dir2 == Enums.Direction.TopRight);

            case Enums.Direction.TopLeft:
                return(dir2 == Enums.Direction.Top || dir2 == Enums.Direction.Left);

            case Enums.Direction.TopRight:
                return(dir2 == Enums.Direction.Top || dir2 == Enums.Direction.Right);
            }
            return(false);
        }
示例#11
0
 //Runs the Move method with the given direction over and over until Move returns false
 public void MoveRepeatedly(Enums.Direction direction)
 {
     while (Move(direction))
     {
         // No need to put anything in here.
     }
 }
示例#12
0
    private bool DisplaceTile(Tile tile, Enums.Direction direction)
    {
        Vector2Int currentSquare   = tile.Coordinate;
        Vector2Int directionVector = directionVectors[direction];
        Vector2Int nextSquare      = tile.Coordinate + directionVector;

        while (CoordinateBelongsToGrid(nextSquare))
        {
            if (TileExistsInSquare(nextSquare))
            {
                Tile tileInNextSquare = tiles[nextSquare];

                if (TilesCanMerge(tile, tileInNextSquare))
                {
                    return(MergeTiles(tileInNextSquare, tile));
                }
                else
                {
                    break; // Equivalent of facing a wall
                }
            }

            nextSquare += directionVector;
        }

        nextSquare -= directionVector;
        return(MoveTile(tile, nextSquare));
    }
示例#13
0
        public string GetDirectionString(Enums.Direction direction)
        {
            switch (direction)
            {
            case Enums.Direction.Down:
                return("Down");

            case Enums.Direction.DownLeft:
                return("DownLeft");

            case Enums.Direction.DownRight:
                return("DownRight");

            case Enums.Direction.Left:
                return("Left");

            case Enums.Direction.Right:
                return("Right");

            case Enums.Direction.Up:
                return("Up");

            case Enums.Direction.UpLeft:
                return("UpLeft");

            case Enums.Direction.UpRight:
                return("UpRight");

            default:
                return(null);
            }
        }
示例#14
0
文件: Location.cs 项目: uvbs/bot-2016
        /// <summary>
        /// Checks whether this location is inside a pre-defined area.
        /// </summary>
        /// <param name="areaEffect">The area effect used.</param>
        /// <param name="location">The center of the area.</param>
        /// <param name="direction">The direction of the area effect used.</param>
        /// <returns></returns>
        public bool IsInAreaEffect(Objects.AreaEffect areaEffect, Objects.Location location,
                                   Enums.Direction direction)
        {
            ushort y = 0;

            Objects.Location currentLoc = this.Clone();
            byte             dir        = areaEffect.Type == AreaEffect.EffectType.Spell ? (byte)direction : (byte)1;

            foreach (byte[] row in areaEffect.GetArea())
            {
                int center = row.Length / 2;
                for (int i = 0; i < row.Length; i++)
                {
                    if (row[i] != dir)
                    {
                        continue;
                    }
                    if (location.Offset(i - center, y, 0) == currentLoc)
                    {
                        return(true);
                    }
                }
                y++;
            }
            return(false);
        }
示例#15
0
    //Used to set two rooms as neighbours
    void setNeighbour(int i, RoomComponent neighbour, Enums.Direction direction)
    {
        switch (direction)
        {
        case Enums.Direction.NORTH:
            rooms[i].topNeighbour     = neighbour;
            neighbour.bottomNeighbour = rooms[i];
            break;

        case Enums.Direction.EAST:
            rooms[i].rightNeighbour  = neighbour;
            neighbour.leftNeihghbour = rooms[i];
            break;

        case Enums.Direction.SOUTH:
            rooms[i].bottomNeighbour = neighbour;
            neighbour.topNeighbour   = rooms[i];
            break;

        case Enums.Direction.WEST:
            rooms[i].leftNeihghbour  = neighbour;
            neighbour.rightNeighbour = rooms[i];
            break;
        }
    }
示例#16
0
 /// <summary>
 /// Déplace un objet en avant ou arrière plan.
 /// </summary>
 /// <param name="direction">Avant ou arrière plan</param>
 /// <param name="max">Au premier ou au dernier plan</param>
 public void MoveObjectInPlan(Enums.Direction direction, bool max)
 {
     RunServiceTask(delegate
     {
         _Business.MoveObjectInPlan(direction, max);
     }, Errors.ERROR_STAGE_STR_LOAD, direction.ToString(), max.ToString());
 }
示例#17
0
    //Main method to build rooms
    //Gets called by the DungeonMaster
    public void buildRoom(RoomComponent roomData, Enums.Direction direction, List <GameObject> activeMonsters)
    {
        //Clear all tilemaps before drawing
        clearRoom();
        currentRoom = roomData;
        drawFloor();
        drawWalls();

        createDoorData(roomData.getDirections().Count);

        insertMissingDoors();

        buildDoors();

        if (!builtRooms.Contains(currentRoom.getRoomNumber()))
        {
            builtRooms.Add(currentRoom.getRoomNumber());
        }

        if (currentRoom.getKey())
        {
            currentRoom.getKey().SetActive(true);
        }

        spawnMonster(activeMonsters);

        minimap.drawRoom(currentRoom, direction);
    }
示例#18
0
    //Checks if room has neighbour in direction
    public bool hasNeighbour(int direction)
    {
        Enums.Direction dir    = (Enums.Direction)direction;
        bool            result = true;

        if (dir == Enums.Direction.NORTH)
        {
            if (topNeighbour == null)
            {
                result = false;
            }
        }
        else if (dir == Enums.Direction.EAST)
        {
            if (rightNeighbour == null)
            {
                result = false;
            }
        }
        else if (dir == Enums.Direction.SOUTH)
        {
            if (bottomNeighbour == null)
            {
                result = false;
            }
        }
        else if (dir == Enums.Direction.WEST)
        {
            if (leftNeihghbour == null)
            {
                result = false;
            }
        }
        return(result);
    }
示例#19
0
 public static string BuildName(string Prefix, Enums.Direction Direction)
 {
     cachedAnimationNames.TryGetValue((Prefix, Direction), out var result);
     if (result == null)
     {
         result = Prefix + "_" + Direction.ToString();
         cachedAnimationNames[(Prefix, Direction)] = result;
示例#20
0
        static bool ObjectsCollide(List <GameObject> objects, Enums.Direction direction, GameObject ob)
        {
            if (direction == Enums.Direction.Down)
            {
                if (objects.FirstOrDefault(x => x.yCoord == (ob.yCoord - 1) && x.xCoord == ob.xCoord) != null)
                {
                    return(true);
                }
            }
            if (direction == Enums.Direction.Up)
            {
                if (objects.FirstOrDefault(x => x.yCoord == (ob.yCoord + 1) && x.xCoord == ob.xCoord) != null)
                {
                    return(true);
                }
            }
            if (direction == Enums.Direction.Left)

            {
                if (objects.FirstOrDefault(x => x.xCoord == (ob.xCoord - 1) && x.yCoord == ob.yCoord) != null)
                {
                    return(true);
                }
            }
            if (direction == Enums.Direction.Right)
            {
                if (objects.FirstOrDefault(x => x.xCoord == (ob.xCoord + 1) && x.yCoord == ob.yCoord) != null)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#21
0
            /// <summary>
            /// Attempts to turn to a given direction.
            /// </summary>
            /// <param name="direction"></param>
            public void Turn(Enums.Direction direction)
            {
                switch (direction)
                {
                case Enums.Direction.Down:
                    this.FunctionTurnSouth.Call(0x50F);
                    break;

                case Enums.Direction.Left:
                    this.FunctionTurnWest.Call(0x50D);
                    break;

                case Enums.Direction.Right:
                    this.FunctionTurnEast.Call(0x50E);
                    break;

                case Enums.Direction.Up:
                    this.FunctionTurnNorth.Call(0x50C);
                    break;

                default:
                    return;
                }
                if (this.Turned != null)
                {
                    this.Turned(direction);
                }
            }
示例#22
0
        public static int GetAnimDirInt(Enums.Direction dir)
        {
            switch (dir)
            {
            case Enums.Direction.Down:
                return(0);

            case Enums.Direction.Left:
                return(1);

            case Enums.Direction.Up:
                return(2);

            case Enums.Direction.Right:
                return(3);

            case Enums.Direction.DownLeft:
                return(4);

            case Enums.Direction.UpLeft:
                return(5);

            case Enums.Direction.UpRight:
                return(6);

            case Enums.Direction.DownRight:
                return(7);

            default:
                return(0);
            }
        }
示例#23
0
        private Tile GetAroundTile(Enums.Direction direction, Tile tile)
        {
            var p = new Point(tile.XIndex, tile.YIndex);

            switch (direction)
            {
            case Enums.Direction.UP:
                p = new Point(tile.XIndex, tile.YIndex - 1);
                break;

            case Enums.Direction.DOWN:
                p = new Point(tile.XIndex, tile.YIndex + 1);
                break;

            case Enums.Direction.LEFT:
                p = new Point(tile.XIndex - 1, tile.YIndex);
                break;

            case Enums.Direction.RIGHT:
                p = new Point(tile.XIndex + 1, tile.YIndex);
                break;
            }
            var t = _tiles.FirstOrDefault(x => x.XIndex == p.X && x.YIndex == p.Y);

            return(t);
        }
示例#24
0
 public BeamMoveAnimation(int X1, int Y1, Enums.Direction dir, int distance)
 {
     StartX    = X1;
     StartY    = Y1;
     Direction = dir;
     Distance  = distance;
 }
示例#25
0
        private void MoveToDirection(Tile tile, Enums.Direction direction)
        {
            var units = 10;

            for (int i = 0; i < tile.Len / units; i++)
            {
                var p = new Point();
                if (direction == Enums.Direction.UP)
                {
                    p = new Point(tile.Location.X, tile.Location.Y - units);
                }
                if (direction == Enums.Direction.DOWN)
                {
                    p = new Point(tile.Location.X, tile.Location.Y + units);
                }
                if (direction == Enums.Direction.LEFT)
                {
                    p = new Point(tile.Location.X - units, tile.Location.Y);
                }
                if (direction == Enums.Direction.RIGHT)
                {
                    p = new Point(tile.Location.X + units, tile.Location.Y);
                }

                tile.Location = p;
                Thread.Sleep(1);
            }
        }
示例#26
0
    public void faceCharacter(Transform currentNode, Enums.Direction direction)
    {
        Vector3 dir = currentNode.position;

        switch (direction)
        {
        case Enums.Direction.UP:
            dir += new Vector3(5, 0, 0);
            break;

        case Enums.Direction.DOWN:
            dir += new Vector3(-5, 0, 0);
            break;

        case Enums.Direction.LEFT:
            dir += new Vector3(0, 0, 5);
            break;

        case Enums.Direction.RIGHT:
            dir += new Vector3(0, 0, -5);
            break;

        default:
            throw new System.Exception("This should never happen!");
        }
        Vector3 rotation = new Vector3(dir.x - currentNode.position.x, 0, dir.z - currentNode.position.z);

        characterTransform.rotation = Quaternion.LookRotation(rotation);
    }
示例#27
0
        public BasicItemInformation(string name, string description, string categoryName, Color categoryColor, int edibility, int fragility, bool isLamp, int price, Vector2 TileLocation, bool canBeSetOutdoors, bool canBeSetIndoors, string id, string data, Texture2D texture, Color color, int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights) : base(id, data, texture, color, tileIndex, bigCraftable, type, craftingData)
        {
            this.name          = name;
            this.description   = description;
            this.categoryName  = categoryName;
            this.categoryColor = categoryColor;
            this.price         = price;
            this.TileLocation  = TileLocation;
            this.edibility     = edibility;

            this.canBeSetOutdoors = canBeSetOutdoors;
            this.canBeSetIndoors  = canBeSetIndoors;
            this.fragility        = fragility;
            this.isLamp           = isLamp;

            this.animationManager = animationManager;
            if (this.animationManager.IsNull)
            {
                this.animationManager = new AnimationManager(new Graphics.Texture2DExtended(), new Animation(new Rectangle(0, 0, 16, 16)), false);
                this.animationManager.getExtendedTexture().texture = this.texture;
            }
            else
            {
                this.texture = this.animationManager.getTexture();
            }

            this.drawPosition      = Vector2.Zero;
            this.drawColor         = drawColor;
            this.ignoreBoundingBox = ignoreBoundingBox;
            this.recreateDataString();
            this.inventory       = Inventory ?? new InventoryManager();
            this.lightManager    = Lights ?? new LightManager();
            this.facingDirection = Enums.Direction.Down;
        }
示例#28
0
 public Surface GetSheet(FrameType type, Enums.Direction dir)
 {
     if (FrameTypeHelper.IsFrameTypeDirectionless(type))
     {
         dir = Enums.Direction.Down;
     }
     return(animations[type][dir]);
 }
示例#29
0
 public TileMoveAnimation(int targetX, int targetY, Enums.MoveRange rangeType, Enums.Direction dir, int range)
 {
     StartX    = targetX;
     StartY    = targetY;
     RangeType = rangeType;
     Direction = dir;
     Range     = range;
 }
 public ArrowMoveAnimation(int X1, int Y1, Enums.Direction dir, int distance)
 {
     StartX        = X1;
     StartY        = Y1;
     Direction     = dir;
     Distance      = distance;
     TotalMoveTime = Globals.Tick;
 }
示例#31
0
文件: Entity.cs 项目: echen67/Nullptr
 /// <summary> Initializes an entity to a starting transform. </summary>
 /// <param name="loc"> The transform to initialize to. </param>
 /// <param name="manager"> Reference to this entites manager for callbacks on death. </param>
 /// <param name="type"> The type of this entity in the manager. </param>
 /// <param name="instance"> The specific instance of this entity in the manager. </param>
 /// <param name="direction"> The direction this entity is facing at init. </param>
 internal void Init(Transform loc, EntityManager manager, int type, int instance, Enums.Direction direction)
 {
     transform.position = loc.position;
     transform.localRotation = loc.rotation;
     this.manager = manager;
     this.type = type;
     this.instance = instance;
     this.direction = direction;
     InitData();
 }
示例#32
0
        public Actor(Sprite sprite, Vector2 position, Level currentLevel, int health_max)
            : base(sprite, position, currentLevel)
        {
            this.currentLevel = currentLevel;

            this.Health_max = health_max;
            this.Health_current = health_max;

            this.FacingDirection = Enums.Direction.Left;

            drawColor = Color.White;
        }
示例#33
0
 public CarCommand(char command)
 {
     var dir = (Enums.Direction)command;
     switch (dir) {
         case Enums.Direction.forward:
         case Enums.Direction.back:
         case Enums.Direction.left:
         case Enums.Direction.right:
             _direction = dir;
             break;
         default:
             throw new IsNotEnumException("CarCommand: " + "\"" + command + "\"" + " is not a valid Car command.");
     }
 }
示例#34
0
 /// <summary> Initializes an entity to a starting transform. </summary>
 /// <param name="loc"> The transform to initialize to. </param>
 /// <param name="manager"> Reference to this entites manager for callbacks on death. </param>
 /// <param name="type"> The type of this entity in the manager. </param>
 /// <param name="instance"> The specific instance of this entity in the manager. </param>
 /// <param name="direction"> The direction this entity is facing at init. </param>
 internal void Init(Transform loc, EntityManager manager, int type, int instance, Enums.Direction direction, bool isCutScene)
 {
     transform.position = loc.position;
     transform.rotation = loc.rotation;
     if (isCutScene)
         transform.localScale = loc.localScale;
     this.manager = manager;
     this.type = type;
     this.instance = instance;
     this.direction = direction;
     this.isCutScene = isCutScene;
     paused = false;
     InitData();
 }
示例#35
0
 /// <summary> Initializes an entity to a starting transform. </summary>
 /// <param name="loc"> The transform to initialize to. </param>
 /// <param name="manager"> Reference to this entites manager for callbacks on death. </param>
 /// <param name="type"> The type of this entity in the manager. </param>
 /// <param name="instance"> The specific instance of this entity in the manager. </param>
 /// <param name="direction"> The direction this entity is facing at init. </param>
 internal void Init(Transform loc, EntityManager manager, int type, int instance, Enums.Direction direction, bool isCutScene)
 {
     transform.position = loc.position;
     transform.localRotation = loc.rotation;
     if (isCutScene)
     {
         transform.localScale = loc.localScale;
         gameObject.layer = LayerMask.NameToLayer("CutScene");
     }
     this.manager = manager;
     this.type = type;
     this.instance = instance;
     this.direction = direction;
     this.isCutScene = isCutScene;
     InitData();
 }
示例#36
0
 public override void Update()
 {
     if (Managers.GameManager.State == Enums.GameStates.Battle)
     {
         if (moveCompleted)
         {
             switch (direction)
             {
                 case Enums.Direction.Left:
                     if (upOrDown == Enums.Direction.Down && !currentNode.panelExists(Enums.Direction.Down))
                         upOrDown = Enums.Direction.Up;
                     else if (upOrDown == Enums.Direction.Up && !currentNode.panelExists(Enums.Direction.Up))
                         upOrDown = Enums.Direction.Down;
                     if (currentNode.panelExists(Enums.Direction.Left) && currentNode.Left.panelExists(Enums.Direction.Down) && upOrDown == Enums.Direction.Down)
                         target = currentNode.Left.Down;
                     else if (currentNode.panelExists(Enums.Direction.Left) && currentNode.Left.panelExists(Enums.Direction.Up) && upOrDown == Enums.Direction.Up)
                         target = currentNode.Left.Up;
                     else
                     {
                         dead = true;
                     }
                     moveCompleted = false;
                     break;
                 case Enums.Direction.Right:
                     if (upOrDown == Enums.Direction.Down && !currentNode.panelExists(Enums.Direction.Down))
                         upOrDown = Enums.Direction.Up;
                     else if (upOrDown == Enums.Direction.Up && !currentNode.panelExists(Enums.Direction.Up))
                         upOrDown = Enums.Direction.Down;
                     if (currentNode.panelExists(Enums.Direction.Right) && currentNode.Right.panelExists(Enums.Direction.Down) && upOrDown == Enums.Direction.Down)
                         target = currentNode.Right.Down;
                     else if (currentNode.panelExists(Enums.Direction.Right) && currentNode.Right.panelExists(Enums.Direction.Up) && upOrDown == Enums.Direction.Up)
                         target = currentNode.Right.Up;
                     else
                     {
                         dead = true;
                     }
                     moveCompleted = false;
                     break;
             }
         }
         if (dead)
         {
             Destroy(this.gameObject);
         }
         Move();
     }
 }
示例#37
0
        void Update()
        {
            if (Managers.GameManager.State == Enums.GameStates.Battle)
            {
                if (CustomInput.BoolFreshPress(CustomInput.UserInput.Up))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Up, Type))
                    {
                        direction = Enums.Direction.Up;
                        nextNode = currentNode.Up;
                    }
                }
                else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Down))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Down, Type))
                    {
                        direction = Enums.Direction.Down;
                        nextNode = currentNode.Down;
                    }
                }
                else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Left))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Left, Type))
                    {
                        direction = Enums.Direction.Left;
                        nextNode = currentNode.Left;
                    }
                }
                else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Right))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Right, Type))
                    {
                        direction = Enums.Direction.Right;
                        nextNode = currentNode.Right;
                    }
                }
                else
                    direction = Enums.Direction.None;
                //get next state
                currState = machine.update(hit, animDone, direction, hand.GetCurrentType(), hand.Empty());

                //state clean up
                if (prevState != currState)
                {
                    doOnce = false;
                    animDone = false;
                    hit = false;
                    anim.SetInteger("state", (int)currState);
                }
                if (invunTimer > 0)
                {
                    if (renderTimer > renderTime)
                    {
                        render = !render;
                        renderTimer = 0;
                        //GetComponent<Renderer>().enabled = render;
                    }
                    hit = false;
                    renderTimer += Time.deltaTime;
                    invunTimer -= Time.deltaTime;
                }
                else
                {
                    //GetComponent<Renderer>().enabled = true;
                    invun = false;
                }

                //run state
                doState[(int)currState]();

                if (move)
                {
                    move = false;
                    currentNode.clearOccupied();
                    currentNode = nextNode;
                    currentNode.Owner = (this);
                    transform.position = currentNode.transform.position;
                }

                if (useCard)
                {
                    if (!hand.Empty())
                    {
                        useCard = false;
                        hand.UseCurrent(this);
                        CardUIEvent();
                    }
                }

                if (basicAttack)
                {
                    basicAttack = false;
                    Weapons.Projectiles.Bullet b = Instantiate(bullet).GetComponent<Weapons.Projectiles.Bullet>();
                    b.transform.position = barrel.position;
                    b.Direction = Direction;
                }

                if (damage > 0 && takeDamage)
                {
                    takeDamage = false;
                    TakeDamage(damage);
                    damage = 0;
                }
                prevState = currState;
            }
        }
示例#38
0
 public CarCommand(Enums.Direction direction)
 {
     _direction = direction;
 }
示例#39
0
 public MovementBehavior(IMoveable moveable)
 {
     horizontalState = Direction.none;
     verticalState = Direction.none;
     m_moveable = moveable;
 }
示例#40
0
 public Bullet(Sprite sprite, Vector2 position, Level currentLevel, Enums.Direction facingDirection)
     : base(sprite, position, currentLevel)
 {
     this.FacingDirection = facingDirection;
 }
 public void Load(Enums.Direction direction)
 {
     this.direction = direction;
 }
示例#42
0
        void Update()
        {
            if (Managers.GameManager.State == Enums.GameStates.Battle && !stun)
            {
                if (paused)
                {
                    paused = false;
                    anim.speed = animSpeed;
                }
                if (CustomInput.BoolFreshPress(CustomInput.UserInput.Up, playerNumber))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Up, Type))
                    {
                        directionToMove = Enums.Direction.Up;
                        nextNode = currentNode.Up;
                    }
                }
                else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Down, playerNumber))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Down, Type))
                    {
                        directionToMove = Enums.Direction.Down;
                        nextNode = currentNode.Down;
                    }
                }
                else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Left, playerNumber))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Left, Type))
                    {
                        directionToMove = Enums.Direction.Left;
                        nextNode = currentNode.Left;
                    }
                }
                else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Right, playerNumber))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Right, Type))
                    {
                        directionToMove = Enums.Direction.Right;
                        nextNode = currentNode.Right;
                    }
                }
                else
                    directionToMove = Enums.Direction.None;
                //get next state
                currState = machine.update(hit, animDone, directionToMove, hand.GetCurrentType(), hand.Empty(), playerNumber);

                //state clean up
                if (prevState != currState)
                {
                    doOnce = false;
                    animDone = false;
                    attack = false;
                    basicAttack = false;
                    move = false;
                    hit = false;
                    if (weapon != null)
                        Destroy(weapon);
                    anim.SetInteger("state", (int)currState);
                }
                if (invunTimer > 0)
                {
                    if (renderTimer > renderTime)
                    {
                        render = !render;
                        renderTimer = 0;
                        //GetComponent<Renderer>().enabled = render;
                    }
                    hit = false;
                    renderTimer += Time.deltaTime;
                    invunTimer -= Time.deltaTime;
                }
                else
                {
                    //GetComponent<Renderer>().enabled = true;
                    invun = false;
                }

                //run state
                switch (currState)
                {
                    case Enums.PlayerState.Idle:Idle(); break;
                    case Enums.PlayerState.MoveBegining: MoveBegining(); break;
                    case Enums.PlayerState.MoveEnding: MoveEnding(); break;
                    case Enums.PlayerState.Hit: Hit(); break;
                    case Enums.PlayerState.Dead: Dead(); break;
                    case Enums.PlayerState.BasicAttack: BasicAttack(); break;
                    case Enums.PlayerState.HoriSwingMid: CardAnim(); break;
                    case Enums.PlayerState.VertiSwingHeavy: CardAnim(); break;
                    case Enums.PlayerState.ThrowLight: CardAnim(); break;
                    case Enums.PlayerState.ThrowMid: CardAnim(); break;
                    case Enums.PlayerState.Shoot: CardAnim(); break;
                    case Enums.PlayerState.ChiAttack: CardAnim(); break;
                    case Enums.PlayerState.ChiStationary: CardAnim(); break;
                    case Enums.PlayerState.TauntGokuStretch: Taunt(); break;
                    case Enums.PlayerState.TauntPointPoint: Taunt(); break;
                    case Enums.PlayerState.TauntThumbsDown: Taunt(); break;
                    case Enums.PlayerState.TauntWrasslemania: Taunt(); break;
                    case Enums.PlayerState.TauntYaMoves: Taunt(); break;
                }

                if (move)
                {
                    move = false;
                    currentNode.clearOccupied();
                    currentNode = nextNode;
                    currentNode.Owner = (this);
                    transform.position = currentNode.transform.position;
                }

                if (useCard)
                {
                    if (!hand.Empty())
                    {
                        Enums.CardTypes type = hand.GetCurrentType();
                        if (type == Enums.CardTypes.SwordHori || type == Enums.CardTypes.SwordVert)
                        {
                            weapon = Instantiate(Katana);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0,0,0);

                        }
                        else if (type == Enums.CardTypes.NaginataHori || type == Enums.CardTypes.NaginataVert)
                        {
                            weapon = Instantiate(Naginata);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        else if (type == Enums.CardTypes.HammerHori || type == Enums.CardTypes.HammerVert)
                        {
                            weapon = Instantiate(Hammer);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0,0,0);
                        }
                        else if (type == Enums.CardTypes.Fan)
                        {
                            weapon = Instantiate(Fan);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        else if (type == Enums.CardTypes.Kanobo)
                        {
                            weapon = Instantiate(Kanobo);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        else if (type == Enums.CardTypes.Tanto)
                        {
                            weapon = Instantiate(Tanto);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        else if (type == Enums.CardTypes.Wakizashi)
                        {
                            weapon = Instantiate(Wakizashi);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        else if (type == Enums.CardTypes.Tonfa)
                        {
                            weapon = Instantiate(Tonfa);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        else if (type == Enums.CardTypes.BoStaff)
                        {
                            weapon = Instantiate(BoStaff);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        useCard = false;
                        hand.UseCurrent(this);
                        CardUIEvent();
                    }
                }

                if (basicAttack)
                {
                    basicAttack = false;
                    Weapons.Hitbox b = Instantiate(bullet);
                    AddElement.AddElementByEnum(b.gameObject,(Enums.Element)Random.Range(0,5),true);
                    b.Owner = this.gameObject;
                    b.transform.position = Direction == Enums.Direction.Left ? currentNode.Left.transform.position : currentNode.Right.transform.position;
                    b.CurrentNode = Direction == Enums.Direction.Left ? currentNode.Left : currentNode.Right;
                    b.Direction = Direction;
                }

                if (damage > 0 && takeDamage)
                {
                    takeDamage = false;
                    TakeDamage(damage, damageElement);
                    damage = 0;
                    damageElement = Enums.Element.None;
                }
                prevState = currState;
            }
            else
            {
                if (!paused)
                {
                    animSpeed = anim.speed;
                    anim.speed = 0;
                    paused = true;
                }
                if (stun)
                {
                    if ((stunTimer += Time.deltaTime) > stunTime)
                    {
                        stunTimer = 0f;
                        stun = false;
                    }
                }
            }
        }
 public void Load(string id, Enums.Direction direction)
 {
     this.id = id;
     this.direction = direction;
 }
示例#44
0
 public Coin(Sprite sprite, Vector2 position, Level currentLevel, Enums.Direction facingDirection)
     : base(sprite, position, currentLevel)
 {
     this.FacingDirection = Enums.Direction.Left;
 }