Esempio n. 1
0
 public List<Vector2> RunFinding(Cell beginCell, Cell endCell)
 {
     beCells = new PFCell[] { this[beginCell], this[endCell] };
     Run();
     return GetPath();
 }
Esempio n. 2
0
        private Cell GetCellNear(Cell cell, int dx, int dy)
        {
            GapCell gap = cell.Type == CellType.Gap ? (GapCell)cell : null;
            if (gap != null)
            {
                if (gap.Orientation.x * dx == 1) return gap.Neighbor;
                if (gap.Orientation.y * dy == 1) return gap.Neighbor;
            }

            return map[cell.Col + dx, cell.Row + dy];
        }
Esempio n. 3
0
 private PFCell this[Cell cell]
 {
     get { return grid[cell.Col, cell.Row]; }
 }
Esempio n. 4
0
        public void OnPositonChanged(Vector2 currPosition)
        {
            if (nextCell == null) return;

            if ((currPosition - nextCell.Center).magnitude <= GameConst.ACCURACY)
            {
                if (nextCell == destinationCell)
                {
                    if (state == AIState.FirstWalk) state = AIState.Hunter;
                    NextAction();
                }
                else
                {
                    pathIndex++;
                    currCell = currPath[pathIndex];
                    nextCell = currPath[pathIndex + 1];
                    avatar.T.position = currCell.Center;
                    Manipulate();
                }
            }
        }
Esempio n. 5
0
        private void SetPath(List<Vector2> receivedPath)
        {
            currPath = receivedPath.ConvertAll((p) => { return GameMap.I.GetCellByPoint(p); });

            //for (int i = 0; i < receivedPath.Count - 1; i++)
            //    Debug.DrawLine(receivedPath[i], receivedPath[i + 1], Color.red, 10);

            receivedPath.Clear();
            pathIndex = 0;
            destinationCell = currPath.Last();
            currCell = currPath[pathIndex];
            nextCell = currPath[pathIndex + 1];
            Manipulate();
        }
Esempio n. 6
0
 private void GetTacticalPath(Cell tacticalCell)
 {
     tacticalAction = true;
     if (tacticalCell != avatar.CurrentCell)
         SetPath(pathFinder.RunFinding(avatar.CurrentCell, tacticalCell));
     else
         GetRandomPath();
 }
Esempio n. 7
0
 public void OnStateChanged(StateType stateType, int someValue)
 {
     switch (stateType)
     {
         case StateType.AffectedDrug:
             state = AIState.Victime;
             break;
         case StateType.DisaffectedDrug:
             state = AIState.Hunter;
             break;
         case StateType.Died:
             state = AIState.Dead;
             break;
         case StateType.Alive:
             state = AIState.FirstWalk;
             break;
     }
     if (pathIndex + 1 < currPath.Count) destinationCell = currPath[pathIndex + 1];
 }