Exemple #1
0
        public ICommand GetNextAction()
        {
            IActor closestThreat = null;
            var    threats       = IdentifyThreats(Host.GameInstance.Actors);

            if (threats.Count() > 0)
            {
                closestThreat = threats.OrderBy(x => x.Location.DistanceTo(Host.Location)).First();

                movementPath = pathFinder.FindPath(Host.GameInstance.Terrain, threats.ToList(), Host.Race.MovementProfile,
                                                   Host.Location.Coordinate, closestThreat.Location.Coordinate);
            }

            if ((movementPath == null) || (movementPath.Count == 0))
            {
                return(new SkipTurnCommand(Host));
            }

            if ((movementPath.Count == 1) && (closestThreat != null))
            {
                return(new AttackCommand(Host, closestThreat));
            }

            return(new MoveCommand(Host, movementPath.Dequeue().Direction, Host.GameInstance.Terrain, Host.GameInstance.Actors));
        }
        private MovementPath method_3(SimpleCellInfo class13_0)
        {
            List <MapPoint> range  = new List <MapPoint>();
            SimpleCellInfo  class2 = class13_0;

            while (class2.v_OriginPoint.CellId != this.MapPoint_FromCell.CellId)
            {
                class2 = class2.class13_0;
                range.Add(class2.v_OriginPoint);
            }
            range.Reverse();
            range.Add(class13_0.v_OriginPoint);
            if (this.v_MouvementPoints != -1)
            {
                range = range.GetRange(0, (((this.v_MouvementPoints + 1) > range.Count) ? range.Count : (this.v_MouvementPoints + 1)));
            }
            MovementPath path = new MovementPath {
                CellStart = this.MapPoint_FromCell, CellEnd = range[(range.Count - 1)]
            };
            int num = (range.Count - 2);
            int i   = 0;

            while (i <= num)
            {
                PathElement item = new PathElement {
                    Cell = range[i], Orientation = range[i].OrientationTo(range[(i + 1)])
                };
                path.Cells.Add(item);
                i += 1;
            }
            path.Compress();
            return(path);
        }
Exemple #3
0
    private IEnumerator <Transform> pointInPath; //Used to reference points returned from MyPath.GetNextPathPoint
    #endregion                                   //Private Variables

    // (Unity Named Methods)
    #region Main Methods
    public void Start()
    {
        //Make sure there is a path assigned
        if (MyPath == null)
        {
            GameObject[]   paths         = GameObject.FindGameObjectsWithTag("Path");
            MovementPath[] possiblePaths = new MovementPath[paths.Length];
            for (int i = 0; i < paths.Length; i++)
            {
                possiblePaths[i] = paths[i].GetComponent <MovementPath>();
            }
            MyPath = possiblePaths[Random.Range(0, possiblePaths.Length)];
        }

        //Sets up a reference to an instance of the coroutine GetNextPathPoint
        pointInPath = MyPath.GetNextPathPoint();
        Debug.Log(pointInPath.Current);
        //Get the next point in the path to move to (Gets the Default 1st value)
        pointInPath.MoveNext();
        Debug.Log(pointInPath.Current);

        //Make sure there is a point to move to
        if (pointInPath.Current == null)
        {
            Debug.LogError("A path must have points in it to follow", gameObject);
            return; //Exit Start() if there is no point to move to
        }

        //Set the position of this object to the position of our starting point
        transform.position = pointInPath.Current.position;
    }
        // Methods
        public static MovementPath GetClientMovement(List <uint> Keys)
        {
            var         path    = new MovementPath();
            PathElement element = null;
            var         num     = 0;
            var         num2    = 0;

            foreach (int num2_loopVariable in Keys)
            {
                num2 = num2_loopVariable;
                var point = new MapPoint(num2 & 4095);
                var item  = new PathElement {
                    Cell = point
                };
                if (num == 0)
                {
                    path.CellStart = point;
                }
                else
                {
                    element.Orientation = element.Cell.OrientationTo(item.Cell);
                }
                if (num == Keys.Count - 1)
                {
                    path.CellEnd = point;
                }
                path.Cells.Add(item);
                element = item;
                num    += 1;
            }
            return(path);
        }
Exemple #5
0
        public bool SetTripwire(VvVTrapKit deed, Point3D myLocation, Point3D wireLocation, Map map)
        {
            Links = new List <VvVTrap>();

            MovementPath path = new MovementPath(myLocation, wireLocation, map);
            int          x    = myLocation.X;
            int          y    = myLocation.Y;

            if (path.Success)
            {
                for (int i = 0; i < path.Directions.Length; ++i)
                {
                    Movement.Movement.Offset(path.Directions[i], ref x, ref y);

                    Point3D p = new Point3D(x, y, Map.GetAverageZ(x, y));

                    if (p == myLocation)
                    {
                        continue;
                    }

                    VvVTrap trap = deed.ConstructTrap(Owner);
                    Links.Add(trap);
                    trap.ParentTrap = this;

                    trap.MoveToWorld(p, map);
                }

                return(true);
            }

            return(false);
        }
Exemple #6
0
        /// <summary>
        /// Move this <see cref="Character"/> instance along the <see cref="MovementPath"/>.
        /// Movement occurs independently of fps by estimating how many pixels we should move for
        /// each time this function is called. Estimation is done by a standard formula,
        /// speed(velocity) multiplied with time passed since previous update call(delta time).
        /// </summary>
        /// <param name="elapsed">The time since previous update call.</param>
        private void MoveCharacter(TimeSpan elapsed)
        {
            if (this.MovementPath == null || this.MovementPath.Count == 0)
            {
                return;
            }

            this.pixelsToMove += Speed * elapsed.TotalSeconds;
            int pixelsToMoveFloor = (int)pixelsToMove;

            this.pixelsToMove -= pixelsToMoveFloor;

            for (int i = 0; i < pixelsToMoveFloor; i++)
            {
                Vector2 newLocation = MovementPath.Dequeue();
                this.Animation.FacingDirection = newLocation - Location;
                this.Location = (Point)newLocation;

                if (MovementPath.Count == 0)
                {
                    this.pixelsToMove = 0.0;
                    break;
                }
            }
        }
        private MovementPath method_3(SimpleCellInfo class13_0)
        {
            var range  = new List <MapPoint>();
            var class2 = class13_0;

            while (class2.v_OriginPoint.CellId != MapPoint_FromCell.CellId)
            {
                class2 = class2.class13_0;
                range.Add(class2.v_OriginPoint);
            }
            range.Reverse();
            range.Add(class13_0.v_OriginPoint);
            if (v_MouvementPoints != -1)
            {
                range = range.GetRange(0, v_MouvementPoints + 1 > range.Count ? range.Count : v_MouvementPoints + 1);
            }
            var path = new MovementPath {
                CellStart = MapPoint_FromCell, CellEnd = range[range.Count - 1]
            };
            var num = range.Count - 2;
            var i   = 0;

            while (i <= num)
            {
                var item = new PathElement {
                    Cell = range[i], Orientation = range[i].OrientationTo(range[i + 1])
                };
                path.Cells.Add(item);
                i += 1;
            }
            path.Compress();
            return(path);
        }
Exemple #8
0
        public void SelectBestPath()
        {
            Stack <Point> big_stack = new Stack <Point>();
            Stack <Point> med_stack = new Stack <Point>();
            Stack <Point> sml_stack = new Stack <Point>();

            big_stack.Push(new Point(1, 1));
            big_stack.Push(new Point(2, 2));
            big_stack.Push(new Point(4, 3));
            big_stack.Push(new Point(2, 2));
            big_stack.Push(new Point(4, 3));

            med_stack.Push(new Point(1, 1));
            med_stack.Push(new Point(2, 2));
            med_stack.Push(new Point(2, 2));

            sml_stack.Push(new Point(1, 1));
            List <MovementPath> list = new List <MovementPath>();

            list.Add(new MovementPath(new Point(10, 10), sml_stack));
            list.Add(new MovementPath(new Point(10, 10), med_stack));
            list.Add(new MovementPath(new Point(10, 10), big_stack));

            int expected = sml_stack.Count;
            int actual   = MovementPath.SelectBestPath(list).GetLength();

            Assert.IsTrue(expected == actual);
        }
Exemple #9
0
 private bool MoveToCell(int cellId)
 {
     if (cellId != Fighter.CellId)
     {
         if (!(IsCellWalkable(cellId)))
         {
             int      num       = -1;
             int      num2      = 5000;
             MapPoint point     = new MapPoint(Fighter.CellId);
             MapPoint point2    = new MapPoint(cellId);
             int      direction = 1;
             while (true)
             {
                 MapPoint nearestCellInDirection = point2.GetNearestCellInDirection(direction, 1);
                 if (IsCellWalkable(nearestCellInDirection.CellId))
                 {
                     int num4 = point.DistanceToCell(nearestCellInDirection);
                     if (num4 < num2)
                     {
                         num2 = num4;
                         num  = nearestCellInDirection.CellId;
                     }
                 }
                 direction = (direction + 2);
                 if (direction > 7)
                 {
                     if (num == -1)
                     {
                         return(false);
                     }
                     cellId = num;
                     break;
                 }
             }
         }
         SimplePathfinder pathfinder = new SimplePathfinder((BlueSheep.Data.D2p.Map)m_Account.Map.Data);
         pathfinder.SetFight(Fighters, Fighter.MovementPoints);
         MovementPath path = pathfinder.FindPath(Fighter.CellId, cellId);
         if (path != null)
         {
             List <UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);
             //Account.Network.SendToServer(new GameMapMovementRequestMessage(serverMovement.ToList().Select<uint, short>(ui => (short)ui).ToArray(), Account.Game.Map.Id));
             using (BigEndianWriter writer = new BigEndianWriter())
             {
                 GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.ToList().Select <uint, short>(ui => (short)ui).ToArray(), m_Account.Map.Id);
                 msg.Serialize(writer);
                 writer.Content = m_Account.HumanCheck.hash_function(writer.Content);
                 MessagePackaging pack = new MessagePackaging(writer);
                 pack.Pack((int)msg.ProtocolID);
                 m_Account.SocketManager.Send(pack.Writer.Content);
                 if (m_Account.DebugMode.Checked)
                 {
                     m_Account.Log(new BotTextInformation("[SND] 950 (GameMapMovementRequestMessage)"), 0);
                 }
             }
             return(true);
         }
     }
     return(false);
 }
Exemple #10
0
        public static void GameMapMovementMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            GameMapMovementMessage msg = (GameMapMovementMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            List <uint> keys = new List <uint>();

            foreach (short s in msg.keyMovements)
            {
                keys.Add((uint)s);
            }
            MovementPath clientMovement = MapMovementAdapter.GetClientMovement(keys);

            BlueSheep.Core.Fight.Entity entity = null;
            foreach (BlueSheep.Core.Fight.Entity en in account.Map.Entities)
            {
                if (en.Id == msg.actorId)
                {
                    entity = en;
                }
            }
            if (entity != null)
            {
                (account.Map.Entities[account.Map.Entities.IndexOf(entity)]).CellId = clientMovement.CellEnd.CellId;
            }

            //GameRolePlayGroupMonsterInformations e = null;
            foreach (MonsterGroup en in account.Map.List)
            {
                if (en.m_contextualId == msg.actorId)
                {
                    en.m_cellId = clientMovement.CellEnd.CellId;
                }
            }
            //if (e != null)
            //{
            //    account.Map.List.RemoveAt(i);
            //    account.Map.List.Add(new GameRolePlayGroupMonsterInformations(msg.actorId, e.look, new EntityDispositionInformations((short)clientMovement.CellEnd.CellId, e.disposition.direction), e.keyRingBonus, e.hasHardcoreDrop, e.hasAVARewardToken, e.staticInfos, e.ageBonus, e.lootShare, e.alignmentSide));
            //}
            //if (msg.actorId == account.Map.Character.Id)
            //{
            //    account.Wait(100, 200);
            //    using (BigEndianWriter writer = new BigEndianWriter())
            //    {
            //        GameMapMovementConfirmMessage newmsg = new GameMapMovementConfirmMessage();
            //        newmsg.Serialize(writer);
            //        MessagePackaging pack = new MessagePackaging(writer);
            //        pack.Pack((int)newmsg.ProtocolID);
            //        account.SocketManager.Send(pack.Writer.Content);
            //    }
            //}
            //    if (account.Fight.flag != 0)
            //    {
            //        account.Fight.LaunchFight(account.Fight.flag);
            //    }
            //}
        }
Exemple #11
0
    public void OnNextClick( )
    {
        int _currentStageIndex = (int)m_creatingStage;

        creators[_currentStageIndex].SetActive(false);
        if (_currentStageIndex == creators.Length - 1)
        {
            // now we has came the last stage of creating
            // the player name should not be null
            if (!PlayerData.GetInstance().GetPlayerName().Equals(""))
            {
                // The player has completed the class creating, and should be leaded to the game
                PlayerData.GetInstance().SaveAll();
                //move the camera
                MovementPath mmPath = Camera.main.GetComponent <MovementPath>();
                mmPath.enabled = true;
                mmPath.OnReach = JumpToGame;
                previousStageButton.gameObject.SetActive(false);
                nextStageButton.gameObject.SetActive(false);
            }
            return;
        }
        else
        {
            m_creatingStage = (CreatingStage)(++_currentStageIndex);
            creators[_currentStageIndex].SetActive(true);
            m_initFuncs[_currentStageIndex]();
        }
    }
        public static void GeneratePathGraphic(Grid overlayGrid, MovementPath movementPath)
        {
//            Tile[] arrowTile = Resources.LoadAll<Tile>("TileMaps/ArrowTiles/");

            var tileMap = SetupTileMapObject(overlayGrid, "Arrow Overlay", 4);

            var      renderer           = tileMap.GetComponent <TilemapRenderer>();
            Material tileRenderMaterial = (Material)Resources.Load("Materials/TileRenderMaterial", typeof(Material));

            renderer.material = tileRenderMaterial;

            tileMap.ClearAllTiles();


            var pathEnumerator = movementPath.getPositionsInPath();

            pathEnumerator.MoveNext();
            var previousCell = pathEnumerator.Current;

            while (pathEnumerator.MoveNext())
            {
                Debug.Log(pathEnumerator.Current);
                var currentCell = pathEnumerator.Current;
                var diff        = currentCell.ToVec2() - previousCell.ToVec2();
                Debug.Log(diff);
                var arrowIndex = arrowMap[diff] * 4;
                //var arrowTileSelected = arrowTile[arrowIndex];
                var arrowTileSelected = GetTileImage(arrowIndex);
                tileMap.SetTile(new Vector3Int(previousCell.x, previousCell.y, 0), arrowTileSelected);
                previousCell = currentCell;
            }

            tileMap.RefreshAllTiles();
        }
    private IEnumerator <Transform> pointInPath; //Used to reference points returned from MyPath.GetNextPathPoint
    #endregion                                   //Private Variables

    // (Unity Named Methods)
    #region Main Methods
    public void Start()
    {
        //Make sure there is a path assigned
        if (MyPath == null)
        {
            pathObject = GameObject.FindGameObjectWithTag("MyPath");
            MyPath     = pathObject.GetComponent <MovementPath>();
            //Debug.LogError("Movement Path cannot be null, I must have a path to follow.", gameObject);
            //return;
        }

        //Sets up a reference to an instance of the coroutine GetNextPathPoint
        pointInPath = MyPath.GetNextPathPoint();
        Debug.Log(pointInPath.Current);
        //Get the next point in the path to move to (Gets the Default 1st value)
        pointInPath.MoveNext();
        Debug.Log(pointInPath.Current);

        //Make sure there is a point to move to
        if (pointInPath.Current == null)
        {
            Debug.LogError("A path must have points in it to follow", gameObject);
            return; //Exit Start() if there is no point to move to
        }

        //Set the position of this object to the position of our starting point
        transform.position = pointInPath.Current.position;
    }
    /// <summary>
    /// This function first checks if a Foot instance is at the end of a group that continues into another group
    /// If so it resets the path variables to the ones of the continueing group
    /// </summary>
    private void RespawnFoot()
    {
        // If previous to last node was a sensor, respawn this foot in the connecting group
        if (PreviousSensorType == SensorType.FirstSensorNode || PreviousSensorType == SensorType.SecondSensorNode)
        {
            Transform currentNode = Path.PathSequence[CurrentNodeId];

            if (currentNode.parent.parent.name == "path0")
            {
                // Group 0 path 0
                if (PathName.Equals("0"))
                {
                    // Group 1 path 1
                    Path = TrafficSpawnManager.FootRespawnPaths[1].GetComponent <MovementPath>();
                }
                // Group 1 path 0
                else if (PathName.Equals("1"))
                {
                    // Group 0 path 1
                    Path = TrafficSpawnManager.FootRespawnPaths[0].GetComponent <MovementPath>();
                }
                // Group 3 path 0
                else if (PathName.Equals("3"))
                {
                    // Group 4 path 0
                    Path = TrafficSpawnManager.FootRespawnPaths[3].GetComponent <MovementPath>();
                }
                // Group 4 path 0
                else if (PathName.Equals("4"))
                {
                    // Group 5 path 1
                    Path = TrafficSpawnManager.FootRespawnPaths[5].GetComponent <MovementPath>();
                }
                // Group 5 path 0
                else if (PathName.Equals("5"))
                {
                    // Group 4 path 1
                    Path = TrafficSpawnManager.FootRespawnPaths[4].GetComponent <MovementPath>();
                }
            }
            else
            {
                // Group 4 path 1
                if (PathName.Equals("4"))
                {
                    // Group 3 path 1
                    Path = TrafficSpawnManager.FootRespawnPaths[2].GetComponent <MovementPath>();
                }
            }
            transform.position = Path.PathSequence[0].position;
            PathName           = Path.PathSequence[0].parent.parent.parent.name;
            CurrentNodeId      = 0;
            LightName          = GetCurrentTrafficlight();
        }
        else
        {
            Destroy(gameObject);
        }
    }
Exemple #15
0
 void TestMovement()
 {
     BaseUnit spaceMarine = new BaseUnit();
     //spaceMarine.setMovementType(MovementType.NORMAL);
     MovementPath movementPath = new MovementPath();
     //TODO: mock movementPath
     MovementEngine.getInstance().move(spaceMarine, movementPath);
 }
Exemple #16
0
        public void TestNextDirectStepAsInShortestPathTest()
        {
            MovementPath path     = new MovementPath(new Point(1, 1), new Point(8, 2));
            Point        p        = path.GetNextDirectStep();
            Point        expected = new Point(2, 1);

            Assert.IsTrue(expected.X == p.X);
            Assert.IsTrue(expected.Y == p.Y);
        }
Exemple #17
0
        public void TestNextDirectStepDiagonal()
        {
            MovementPath path     = new MovementPath(new Point(1, 1), new Point(2, 5));
            Point        p        = path.GetNextDirectStep();
            Point        expected = new Point(1, 2);

            Assert.IsTrue(expected.X == p.X);
            Assert.IsTrue(expected.Y == p.Y);
        }
Exemple #18
0
        public void DistanceBetweenPoints7()
        {
            MovementPath path     = new MovementPath(new Point(1, 1), new Point(8, 2));
            double       expected = 6.08276;
            double       actual   = path.DistanceToEnd(new Point(2, 1));
            double       delta    = .0001;

            Assert.IsTrue(Math.Abs(expected - actual) < delta);
        }
Exemple #19
0
        public void DistanceBetweenPoints4()
        {
            MovementPath path     = new MovementPath(new Point(1, 1), new Point(4, 4));
            double       expected = 4.24264;
            double       actual   = path.DistanceToEnd(new Point(1, 1));
            double       delta    = .0001;

            Assert.IsTrue(Math.Abs(expected - actual) < delta);
        }
Exemple #20
0
        public void DistanceBetweenPoints1()
        {
            MovementPath path     = new MovementPath(new Point(0, 0), new Point(0, 5));
            double       expected = 5;
            double       actual   = path.DistanceToEnd(new Point(0, 0));
            double       delta    = .0001;

            Assert.IsTrue(Math.Abs(expected - actual) < delta);
        }
Exemple #21
0
 public CellMovement(IAccount account, MovementPath mp)
 {
     _account               = account;
     StartCell              = mp.CellStart.CellId;
     EndCell                = mp.CellEnd.CellId;
     _path                  = mp;
     _timeoutTimer          = new Timer(20000);
     _timeoutTimer.Elapsed += _timeoutTimer_Elapsed;
 }
Exemple #22
0
        public MovementPath Move(IPacket packet)
        {
            var movementPath = new MovementPath();

            movementPath.Decode(packet);
            Position   = new Point(movementPath.X, movementPath.Y);
            MoveAction = movementPath.MoveActionLast;
            Foothold   = movementPath.FHLast;
            return(movementPath);
        }
Exemple #23
0
        public void TestNextDirectStepDiagonalTie()
        {
            MovementPath path      = new MovementPath(new Point(1, 1), new Point(3, 3));
            Point        p         = path.GetNextDirectStep();
            Point        expected1 = new Point(1, 2);
            Point        expected2 = new Point(2, 1);

            Assert.IsTrue(expected1.X == p.X || expected2.X == p.X);
            Assert.IsTrue(expected1.Y == p.Y || expected2.Y == p.Y);
        }
Exemple #24
0
        public void PathReachesEndFalse()
        {
            Stack <Point> stack = new Stack <Point>();

            stack.Push(new Point(2, 1));
            stack.Push(new Point(3, 1));
            stack.Push(new Point(4, 1));
            Point        end  = new Point(5, 5);
            MovementPath path = new MovementPath(end, stack);

            Assert.IsFalse(path.IsComplete());
        }
Exemple #25
0
        public void StartPath(int id, bool backwards)
        {
            MovementPath path = this.LevelManager.Groups[id].Path;

            path.Backwards    = backwards;
            path.NeedsTrigger = false;
            if (path.SaveTrigger && this.LevelManager.IsPathRecorded(id) || !path.SaveTrigger)
            {
                return;
            }
            this.LevelManager.RecordMoveToEnd(id);
        }
Exemple #26
0
    private void SpawnRandomTrain()
    {
        var train = Instantiate(TrainPrefab);

        int r = rnd.Next(TrainPaths.Count);

        GameObject   path         = TrainPaths[r];
        MovementPath movementPath = path.GetComponent <MovementPath>();

        train.GetComponent <Movement>().Path = movementPath;
        train.transform.position             = movementPath.PathSequence[0].position;
    }
Exemple #27
0
        //INSTANT C# NOTE: Overloaded method(s) are created above to convert the following method having optional parameters:
        //ORIGINAL LINE: Public Function FindPath(ByVal FromCell As Integer, ByVal ToCell As Integer, Optional ByVal ate As Boolean = true, Optional ByVal adc As Boolean = true) As MovementPath
        public MovementPath FindPath(int FromCell, int ToCell, bool ate, bool adc)
        {
            MovPath            = new MovementPath();
            MovPath.CellStart  = new MapPoint(FromCell);
            MovPath.CellEnd    = new MapPoint(ToCell);
            AllowDiag          = adc;
            AllowDiagCornering = adc;
            AllowTroughEntity  = ate;

            StartPathfinding(new MapPoint(FromCell), new MapPoint(ToCell));
            ProcessPathfinding();
            return(MovPath);
        }
        public static List <uint> GetServerMovement(MovementPath Path)
        {
            var list        = new List <uint>();
            var orientation = 0;

            foreach (var element in Path.Cells)
            {
                orientation = element.Orientation;
                list.Add(Convert.ToUInt32(((orientation & 7) << 12) | (element.Cell.CellId & 4095)));
            }
            list.Add(Convert.ToUInt32(((orientation & 7) << 12) | (Path.CellEnd.CellId & 4095)));
            return(list);
        }
Exemple #29
0
        public ICellMovement MoveToCellWithDistance(int cellId, int maxDistance, bool bool1)
        {
            MovementPath path           = null;
            var          savDistance    = -1;
            var          characterPoint = new MapPoint(_account.Character.CellId);
            var          targetPoint    = new MapPoint(cellId);

            foreach (var point in GetListPointAtGoodDistance(characterPoint, targetPoint, maxDistance))
            {
                Pathfinder pathFinding = null;
                if (targetPoint.DistanceToCell(point) > maxDistance ||
                    targetPoint.X != point.X && targetPoint.Y != point.Y)
                {
                    continue;
                }
                var distance = characterPoint.DistanceTo(point);
                if (savDistance != -1 && distance >= savDistance)
                {
                    continue;
                }
                if (bool1)
                {
                    if (Data.IsWalkable(point.CellId))
                    {
                        goto Label_00A8;
                    }
                    continue;
                }
                if (!NothingOnCell(point.CellId))
                {
                    continue;
                }
Label_00A8:
                pathFinding = new Pathfinder(_account.Character.Map);
                var path2 = pathFinding.FindPath(_account.Character.CellId, point.CellId);
                if (path2 == null)
                {
                    continue;
                }
                path        = path2;
                savDistance = distance;
            }
            if (path == null)
            {
                return(null);
            }
            var move = new CellMovement(_account, path);

            return(move);
        }
Exemple #30
0
    private void SpawnRandomCycle()
    {
        var bike = Instantiate(BikePrefab);

        int r = rnd.Next(BikePaths.Count);

        GameObject   path         = BikePaths[r];
        MovementPath movementPath = path.GetComponent <MovementPath>();
        var          bikeMovement = bike.GetComponent <Movement>();

        bikeMovement.Path       = movementPath;
        bike.transform.position = movementPath.PathSequence[0].position;
        bikeMovement.Speed      = GetRandomSpeed(bikeMovement.MinCycleSpeed, bikeMovement.MaxCycleSpeed);
    }
Exemple #31
0
    private void SpawnRandomFoot()
    {
        var foot = Instantiate(FootPrefab);

        int r = rnd.Next(FootSpawnPaths.Count);

        GameObject   path         = FootSpawnPaths[r];
        MovementPath movementPath = path.GetComponent <MovementPath>();
        var          footMovement = foot.GetComponent <Movement>();

        footMovement.Path       = movementPath;
        foot.transform.position = movementPath.PathSequence[0].position;
        footMovement.Speed      = GetRandomSpeed(footMovement.MinFootSpeed, footMovement.MaxFootSpeed);
    }
Exemple #32
0
 public void move(BaseUnit unit, MovementPath movementPath)
 {
     //Move unit
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="path"></param>
 public virtual void Move(MovementPath path)
 {
     CurrentAction = new GameMapMovementAction(this, path);
     StartAction(GameActionTypeEnum.MAP_MOVEMENT);
 }
Exemple #34
0
                private bool CanPath()
                {
                    IPoint3D p = this.m_Tamer as IPoint3D;

                    if (p == null)
                        return false;

                    if (this.m_Creature.InRange(new Point3D(p), 1))
                        return true;

                    MovementPath path = new MovementPath(this.m_Creature, new Point3D(p));
                    return path.Success;
                }
Exemple #35
0
		//use path check vs simple move fail to prevent needless teleports that burn up mana
		public virtual void OnFailedMove()
		{
			// Adam: add the check to DisallowAllMoves - we should not teleport!
			if (m_Mobile.Combatant != null && !m_Mobile.DisallowAllMoves)
			{
				Mobile c = m_Mobile.Combatant;
				MovementPath path = new MovementPath(m_Mobile, new Point3D(c.Location));
				if (!path.Success && (SmartAI ? Utility.Random(4) == 0 : ScaleByMagery(TeleportChance) > Utility.RandomDouble()))
				{
					if (m_Mobile.Target != null)
						m_Mobile.Target.Cancel(m_Mobile, TargetCancelType.Canceled);

					new TeleportSpell(m_Mobile, null).Cast();

					m_Mobile.DebugSay("I am stuck, I'm going to try teleporting away");
				}
			}

			else if (m_Mobile.Combatant == null && !m_Mobile.DisallowAllMoves && (SmartAI ? Utility.Random(4) == 0 : ScaleByMagery(TeleportChance) > Utility.RandomDouble()))
			{
				if (m_Mobile.Target != null)
					m_Mobile.Target.Cancel(m_Mobile, TargetCancelType.Canceled);

				new TeleportSpell(m_Mobile, null).Cast();

				m_Mobile.DebugSay("I am stuck, I'm going to try teleporting away");
			}

			else if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
			{
				if (m_Mobile.Debug)
					m_Mobile.DebugSay("My move is blocked, so I am going to attack {0}", m_Mobile.FocusMob.Name);

				m_Mobile.Combatant = m_Mobile.FocusMob;
				Action = ActionType.Combat;
			}
			else
			{
				m_Mobile.DebugSay("I am stuck");
			}
		}
        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="movementPath"></param>
        /// <param name="cellId"></param>
        public void MovementFinish(AbstractEntity entity, MovementPath movementPath, int cellId)
        {
            var fighter = (AbstractFighter)entity;

            fighter.UsedMP += movementPath.MovementLength;

            Dispatch(WorldMessage.GAME_ACTION(GameActionTypeEnum.FIGHT_PM_LOST, fighter.Id, fighter.Id + ",-" + movementPath.MovementLength));

            fighter.Orientation = movementPath.GetDirection(movementPath.LastStep);
            fighter.SetCell(GetCell(cellId));
        }
				private bool CanPath()
				{
					IPoint3D p = m_Tamer;

					if (p == null)
					{
						return false;
					}

					if (m_Creature.InRange(new Point3D(p), 1))
					{
						return true;
					}

					var path = new MovementPath(m_Creature, new Point3D(p));

					return path.Success;
				}
 /// <summary>
 /// 
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="path"></param>
 public GameFightMovementAction(AbstractFighter entity, MovementPath path)
     : base(GameActionTypeEnum.MAP_MOVEMENT, entity, entity.Type == EntityTypeEnum.TYPE_CHARACTER ? 5000 : (long)path.MovementTime)
 {
     Path = path;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="path"></param>
 public GameMapMovementAction(AbstractEntity entity, MovementPath path)
     : base(GameActionTypeEnum.MAP_MOVEMENT, entity, (long)path.MovementTime)
 {
     Path = path;
     SkillId = -1;
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        public new void Move(MovementPath path)
        {
            CurrentAction = new GameFightMovementAction(this, path);

            StartAction(GameActionTypeEnum.MAP_MOVEMENT);
        }
Exemple #41
0
 public AnimationPath()
 {
     movementPath = new MovementPath();
     rotationPath = new RotationPath();
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="path"></param>
        /// <param name="cellId"></param>
        public void MovementFinish(AbstractEntity entity, MovementPath path, int cellId)
        {
            if (entity.Type == EntityTypeEnum.TYPE_CHARACTER)
            {
                var character = (CharacterEntity)entity;
                if (character.CanGameAction(GameActionTypeEnum.FIGHT))
                {
                    foreach (var monsterGroup in m_entityById.Values.OfType<MonsterGroupEntity>())
                    {
                        if (CanBeAggro(character, cellId, monsterGroup))
                        {
                            entity.CellId = cellId;
                            if (monsterGroup.AlignmentId == -1)
                            {
                                if (FightManager.StartMonsterFight(character, monsterGroup))
                                    return;
                            }
                            else
                            {
                                if (FightManager.StartAggression(monsterGroup, character))
                                    return;
                            }
                        }         
                    }
                }
            }

            if (entity.CellId == cellId)
                return;

            entity.Orientation = path.GetDirection(path.LastStep);

            if (entity.Type == EntityTypeEnum.TYPE_CHARACTER)
            {
                var character = (CharacterEntity)entity;
                var cell = GetCell(cellId);
                if (cell != null)
                {
                    if (cell.Trigger != null)
                    {
                        if(!cell.SatisfyConditions(character))
                        {
                            entity.Dispatch(WorldMessage.IM_ERROR_MESSAGE(InformationEnum.ERROR_CONDITIONS_UNSATISFIED));
                            return;
                        }

                        entity.CellId = cellId;
                        cell.ApplyActions(character);
                        return;
                    }                    
                }     
            }

            entity.CellId = cellId;
        }