Ejemplo n.º 1
0
        private void CalculateCurrentTarget()
        {
            int count = path.Count;

            if (count > 0)
            {
                target         = MapIns.CellToWorld(path[count - 1]);
                Rotator.Target = target;
            }
        }
Ejemplo n.º 2
0
        public List <float> GetTimes()
        {
            float             distance     = 0.0f;
            List <Vector3Int> currentPath  = GetMovePath();
            List <float>      separateTime = new List <float>();

            Vector3 currentPosition = transform.position;

            for (int i = currentPath.Count; i > 0; i--)
            {
                Vector3 nextPosition = MapIns.CellToWorld(currentPath[i - 1]);
                distance = Vector3.Distance(currentPosition, nextPosition);
                separateTime.Add(distance / maxSpeed); // time
                currentPosition = nextPosition;
            }
            return(separateTime);
        }
Ejemplo n.º 3
0
        private void InitalizeMove(bool foundPath)
        {
            if (Remote.FixedMove.IsMoving)
            {
                Remote.FixedMove.Stop();
            }

            InitForMove(foundPath);

            pathRenderer.LineRendererGenPath(
                foundPath: foundPath,
                worldPath: MapIns.CellToWorld(path),
                t: GetPerHasGone(), // (count - (maxMoveStep - CurrentMoveStep)) * 1.0f / count
                position: transform.position,
                target: MapIns.CellToWorld(EndPosition)
                );
        }
Ejemplo n.º 4
0
        private bool FindPath(Vector3Int start, Vector3Int end)
        {
            StartPosition = start;
            EndPosition   = end;
            if (curMoveStep >= maxMoveStep || (path != null && path.Count == 0))
            {
                curMoveStep = 0;
            }

            bool foundPath = false;

            foundPath = AStar.FindPath(StartPosition.ZToZero(), EndPosition.ZToZero());
            path      = AStar.Path;

            pathRenderer.LineRendererGenPath(
                foundPath: foundPath,
                worldPath: MapIns.CellToWorld(path),
                t: GetPerHasGone(), // (count - (maxMoveStep - CurrentMoveStep)) * 1.0f / count
                position: transform.position,
                target: MapIns.CellToWorld(EndPosition)
                );
            return(foundPath);
        }
Ejemplo n.º 5
0
 public void SetPosition()
 {
     Cursor.updateCursor(MapIns.CellToWorld(Position));
 }
Ejemplo n.º 6
0
 private void UpdateCursor(Vector3Int position)
 {
     Cursor.PositionCursor.SetPosTxt(position.x.ToString(), position.y.ToString());
     Cursor.updateCursor(MapIns.CellToWorld(position));
 }
Ejemplo n.º 7
0
    private IEnumerator StartCreateRssWaiting()
    {
        AJPHelper.Operation oper = RSSPositionTable.Operation;
        while (!oper.IsDone)
        {
            yield return(null);
        }

        //if (!treeInited)
        //{
        //    int rssCount = RSSPositionTable.Count;
        //    for (int iter = 0; iter < rssCount; iter++)
        //    {
        //        rssPositionTree.Insert
        //            (RSSPositionTable.ReadOnlyRows[iter].Position.Parse3Int().ToClientPosition());
        //    }
        //    treeInited = true;
        //}

        if (!treeInited)
        {
            rssPositionTree.AsyncCreateTree(GetRssPositionEnumerable());
            while (!rssPositionTree.IsAsyncCreateComplete)
            {
                yield return(null);
            }
            treeInited = true;
            Debugger.Log("quad tree inited");
        }

        isCreateComplete = false;
        int count = WaitForCreate.Count;

        //int i = count - 1;

        while (WaitForCreate.Count > 0 && !isCreateComplete)
        {
            Vector3Int      pos     = WaitForCreate[WaitForCreate.Count - 1].ToSerPosition();
            RSS_PositionRow rssData = RSSPositionTable.GetRssAt(pos);
            if (rssData != null &&
                !Resources.ContainsKey(rssData.ID))
            {
                /// Using pool object for natural resource
                NaturalResource rs = RssPooling.GetItem();
                rs.gameObject.name = "Resource" + rssData.RssType.ToString() + rssData.ID;

                Vector3 worldPos = MapIns.CellToWorld(rssData.Position.Parse3Int().ToClientPosition());
                rs.SetResourceData(rssData, Flag.Owner, worldPos);
                Resources[rssData.ID] = rs;
                rs.gameObject.SetActive(true);

                //Debugger.Log("Created " + rssData.ID);
            }

            WaitForCreate.RemoveAt(WaitForCreate.Count - 1);
            //i--;
            yield return(null);
        }
        isCreateComplete = true;
        yield break;
    }