public GameObject MarkPath(Vector2Int pos, GameObject parent, int id)
    {
        Vector3        posAux = new Vector3(pos.x, pos.y, -2);
        GameObject     pPoint = Instantiate(DebugPathMark, posAux, Quaternion.identity, TileObj.transform);
        List <Color32> colors = new List <Color32>();

        colors.Add(new Color32(0x80, 0x00, 0x00, 0xFF));
        colors.Add(new Color32(0x9A, 0x63, 0x24, 0xFF));
        colors.Add(new Color32(0x80, 0x80, 0x00, 0xFF));
        colors.Add(new Color32(0x46, 0x99, 0x90, 0xFF));
        colors.Add(new Color32(0x00, 0x00, 0x00, 0xFF));
        colors.Add(new Color32(0xe6, 0x19, 0x4B, 0xFF));
        colors.Add(new Color32(0xf5, 0x82, 0x31, 0xFF));
        colors.Add(new Color32(0xff, 0xe1, 0x19, 0xFF));
        colors.Add(new Color32(0xbf, 0xef, 0x45, 0xFF));
        colors.Add(new Color32(0x3c, 0xb4, 0x4b, 0xFF));
        colors.Add(new Color32(0x42, 0xd4, 0xf4, 0xFF));
        colors.Add(new Color32(0x43, 0x63, 0xd8, 0xFF));
        colors.Add(new Color32(0x91, 0x1e, 0xb4, 0xFF));
        colors.Add(new Color32(0xf0, 0x32, 0xe6, 0xFF));
        colors.Add(new Color32(0xfa, 0xbe, 0xd4, 0xFF));
        colors.Add(new Color32(0xff, 0xd8, 0xb1, 0xFF));
        colors.Add(new Color32(0x00, 0x00, 0x75, 0xFF));
        colors.Add(new Color32(0xff, 0xff, 0xff, 0xFF));

        if (parent != null && id >= 0 && id < 99 && id != -1)
        {
            PathDrawer pDrawer = pPoint.GetComponent <PathDrawer>();
            pDrawer.SetParent(id, parent, colors[id]);
        }

        return(pPoint);
    }
Exemple #2
0
        protected override void Paint(Graphics graphics, float widthInInches, float heightInInches, float dpiX, float dpiY,
                                      float xMarginInInches, float yMarginInInches, int?pageNumber = null)
        {
            var pen = new Pen(options.Colour);

            IGridPixelDimensions pixelDimensions;
            IGrid grid;

            switch (options.GridType)
            {
            case GridType.Hex:
                pixelDimensions = new HexGridPixelDimensions(xMarginInInches, yMarginInInches, widthInInches,
                                                             heightInInches, options.PolygonsPerInch, dpiX, dpiY);
                grid = new HexGrid(pixelDimensions);
                break;

            case GridType.Square:
                pixelDimensions = new SquareGridPixelDimensions(xMarginInInches, yMarginInInches, widthInInches,
                                                                heightInInches, options.PolygonsPerInch, dpiX, dpiY);
                grid = new SquareGrid(pixelDimensions);
                break;

            default:
                throw new IndexOutOfRangeException();
            }

            var pathDrawer = new PathDrawer(graphics, pen);

            pathDrawer.DrawPaths(grid.GetGrid());
        }
Exemple #3
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(this);
         return;
     }
     instance = this;
 }
Exemple #4
0
 private void ReleasePathDrawerImpl(PathDrawer drawer)
 {
     if (m_poolCursor > 0)
     {
         m_poolCursor--;
         m_pool[m_poolCursor] = drawer;
     }
     drawer.gameObject.SetActive(false);
 }
Exemple #5
0
    void SpawnPathDrawer()
    {
        var lr_holder = Instantiate(prefab_lr_holder) as GameObject;

        lr_holder.transform.parent = transform;
        pd = lr_holder.GetComponent <PathDrawer>();

        dp.AddPD(pd);
        //NetworkServer.Spawn(lr_holder, gameObject);
    }
 public void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
 void Start()
 {
     if (startCursorPrefab != null)
     {
         startCursorInstance = Instantiate <Transform>(startCursorPrefab, GridManager.GetCellPos(startCell), Quaternion.identity);
     }
     if (endCursorPrefab != null)
     {
         endCursorInstance = Instantiate <Transform>(endCursorPrefab, GridManager.GetCellPos(targetCell), Quaternion.identity);
     }
     previewPathDrawer = PathManager.CreatePathDrawer();
 }
        private void DrawSimulation()
        {
            PathDrawer drawer = new PathDrawer(this.picSimulation.Width, this.picSimulation.Height)
            {
                PathFinder      = this.pathFinder,
                SpeedPoints     = this.actionSpace.Data,
                SpeedValues     = this.actionSpace.Speeds,
                ShowSpeedPoints = true
            };

            this.picSimulation.Image = drawer.Image;
        }
        private void RefreshPathAfterRun(object sender, EventArgs e)
        {
            PathDrawer drawer = new PathDrawer(this.picTrack.Width, this.picTrack.Height)
            {
                PathFinder      = this.pathFinder,
                BackgroundColor = Color.White,
                ShowOptimalPath = true,
                ShowWayPoints   = true
            };

            this.picTrack.Image = drawer.Image;
        }
        public Image GetImage(int width, int height)
        {
            PathDrawer drawer = new PathDrawer(width, height)
            {
                PathFinder      = PathFinder,
                SpeedPoints     = Points.ToArray(),
                SpeedValues     = Speeds.ToArray(),
                ShowSpeedPoints = true
            };

            return(drawer.Image);
        }
Exemple #11
0
 public MoveState(
     Interactor interactor,
     BoardNavigator boardNavigator,
     CursorManager cursorManager,
     IPathfinder pathfinder,
     PathDrawer pathDrawer)
 {
     this.interactor     = interactor;
     this.pathfinder     = pathfinder;
     this.boardNavigator = boardNavigator;
     this.cursorManager  = cursorManager;
     this.pathDrawer     = pathDrawer;
 }
Exemple #12
0
 private PathDrawer CreatePathDrawerImpl()
 {
     if (m_poolCursor < m_pool.Length)
     {
         PathDrawer result = m_pool[m_poolCursor];
         m_poolCursor++;
         result.gameObject.SetActive(true);
         return(result);
     }
     else
     {
         return(null);
     }
 }
Exemple #13
0
 public Interactor(
     BoardNavigator boardNavigator,
     CursorManager cursorManager,
     SelectionManager selectionManager,
     CharacterManager characterManager,
     IPathfinder pathfinder,
     PathDrawer pathDrawer)
 {
     this.characterManager = characterManager;
     this.selectionState   = new SelectionState(this, boardNavigator, selectionManager, cursorManager);
     this.moveState        = new MoveState(this, boardNavigator, cursorManager, pathfinder, pathDrawer);
     this.castState        = new CastState(this, boardNavigator, cursorManager);
     this.waitState        = new WaitState(this);
 }
        protected override void Paint(Graphics graphics, float widthInInches, float heightInInches, float dpiX,
                                      float dpiY, float xMarginInInches, float yMarginInInches, int?pageNumber = null)
        {
            using (var image = GetType().Assembly.GetManifestResourceStream("HexDrawer.Images.GreenGoblin.png"))
            {
                var pixelDimensions = new TuckBoxPixelDimensions(options.HeightInInches, options.WidthInInches,
                                                                 options.DepthInInches, xMarginInInches, yMarginInInches, TabAsFractionOfDepth, CornerAsFractionOfTab,
                                                                 100, 100);

                var tuckBox    = new TuckBox(pixelDimensions, image);
                var pen        = Pens.Black;
                var pathDrawer = new PathDrawer(graphics, pen);
                var paths      = new List <Path>();

                switch (pageNumber)
                {
                case null:
                    paths.AddRange(tuckBox.GetFrontAndSides());
                    paths.AddRange(tuckBox.GetAttachedBack());
                    break;

                case 1:
                    paths.AddRange(tuckBox.GetFrontAndSides());
                    break;

                case 2:
                    paths.AddRange(tuckBox.GetSeparateBack());
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(pageNumber));
                }

                foreach (var path in paths)
                {
                    pathDrawer.DrawPaths(path);
                }
            }
        }
Exemple #15
0
    void OnSceneGUI()
    {
        PathDrawer pathDrawer = (PathDrawer)target;

        Texture2D texture = new Texture2D(1, 1);

        texture.SetPixel(0, 0, Color.white);

        for (int i = 0; i < (pathDrawer.nodes.Length - 1); i++)
        {
            GameObject startNode = pathDrawer.nodes[i];
            GameObject endNode   = pathDrawer.nodes[i + 1];

            Vector3 startPos     = startNode.transform.position;
            Vector3 endPos       = endNode.transform.position;
            Vector3 startTangent = startPos + startNode.transform.forward;
            Vector3 endTangent   = endPos - endNode.transform.forward;

            Handles.DrawBezier(startPos, endPos
                               , startTangent, endTangent
                               , Color.green, texture, 3f);
        }
    }
Exemple #16
0
 // Use this for initialization
 void Start()
 {
     if ((moveType == MovementType.Pursue || moveType == MovementType.Evade) && target == null)
     {
         moveType = MovementType.Wander;
     }
     if (target != null)
     {
         AIMovement script = target.GetComponent <AIMovement>();
         if (script != null)
         {
             _targetArriveRadius = script.arriveRadius;
         }
     }
     if ((moveType == MovementType.PathFollowing || moveType == MovementType.ConeCheck || moveType == MovementType.CollisionPredict) && pathObject != null)
     {
         PathDrawer pathScript = pathObject.GetComponent <PathDrawer>();
         _path = new Transform[pathScript.nodes.Length];
         for (int i = 0; i < pathScript.nodes.Length; i++)
         {
             _path[i] = pathScript.nodes[i];
         }
     }
 }
    void Update()
    {
        Ray        ray = currentCamera.ScreenPointToRay(Input.mousePosition);
        RaycastHit rayHit;

        if (Physics.Raycast(ray, out rayHit))
        {
            if (rayHit.collider.tag == "Ground")
            {
                isHitGround = true;
                Vector2Int point        = new Vector2Int((int)rayHit.point.x, (int)rayHit.point.z);
                Actor      currentActor = BattleManager.GetInstance().GetCurrentActor(currentBattleId);
                if (currentActor == null)
                {
                    return;
                }
                if (point != lastPos)
                {
                    lastPos = point;
                    PathDrawer.GetInstance().HidePath();
                    ActionInfo actionInfo = currentActor.GetActionInfo(point);
                    if (actionInfo != null && actionInfo.ActionList.Count > 0 && actionInfo.ActionList[0].Type == ActionType.Walk)
                    {
                        Vector2Int[] pathVec = Converter.ConvertPath(((MovingAction)actionInfo.ActionList[0]).Path);
                        PathDrawer.GetInstance().ShowPath(pathVec);
                    }
                }
                if (Input.GetMouseButtonDown(0))
                {
                    ActionInfo actionInfo = currentActor.GetActionInfo(point);
                    currentActor.Perform(actionInfo, delegate(bool result) {
                        isHitGround = false;
                        lastPos     = Vector2Int.zero;
                        if (currentActor.Stat.MovePoints.Value <= 0)
                        {
                            BattleManager.GetInstance().GetBattle(currentBattleId).NextTurn();
                        }
                        GridManager.GetInstance().ShowBattleGrid(currentBattleId);
                    });
                }
            }
            else if (rayHit.collider.tag == "Actor")
            {
                if (Input.GetMouseButtonDown(0))
                {
                    Actor currentActor  = BattleManager.GetInstance().GetCurrentActor(currentBattleId);
                    Actor selectedActor = rayHit.collider.GetComponentInParent <Actor>();
                    if (selectedActor != null && currentActor != null)
                    {
                        ActionInfo actionInfo = currentActor.GetActionInfo(selectedActor);
                        if (actionInfo != null)
                        {
                            currentActor.Perform(actionInfo, delegate(bool result) {
                                if (currentActor.Stat.MovePoints.Value <= 0)
                                {
                                    BattleManager.GetInstance().GetBattle(currentBattleId).NextTurn();
                                }
                                GridManager.GetInstance().ShowBattleGrid(currentBattleId);
                            });
                        }
                    }
                }
            }
            else
            {
                if (isHitGround)
                {
                    isHitGround = false;
                    lastPos     = Vector2Int.zero;
                    PathDrawer.GetInstance().HidePath();
                }
            }
        }
    }
Exemple #18
0
 void Awake()
 {
     main = this;
     grid = (GameObject.Find("HexGrid").GetComponent <HexGrid>());
     line = this.gameObject.GetComponent <LineRenderer>();
 }
Exemple #19
0
 public static void ReleasePathDrawer(PathDrawer drawer)
 {
     instance.ReleasePathDrawerImpl(drawer);
 }
Exemple #20
0
 private void Awake()
 {
     instance = this;
 }
 void Start()
 {
     _pathDrawer = FindObjectOfType <PathDrawer>();
 }
Exemple #22
0
 public void AppointPath()
 {
     mazeElementsPathFindParametersRestarter.RestartMazeElementsParameters();
     pathFromStartToEnd = FindPath();
     PathDrawer.DrawPathFromStartToEnd(pathFindAlgoBoundary.FindDestinationPlaceForPathFinding());
 }
Exemple #23
0
 void Awake()
 {
     instance = this;
 }
Exemple #24
0
 // Start is called before the first frame update
 void Start()
 {
     pathDrawer = GetComponent <PathDrawer>();
 }