예제 #1
0
        public void SetPath(Vector3[] paths, bool isRay = false)
        {
            List <Vector3> points = new List <Vector3>();

            for (int i = 0; i < paths.Length; i++)
            {
                points.Add(paths[i].Clone());
            }


            PathGroup group = new PathGroup();

            group.gap                       = gap;
            group.pathNum                   = 8;
            group.lengthRadius              = lengthRadius;
            group.hitRadiusMultiply         = hitRadiusMultiply;
            group.hitRadiusMultiplyVertical = hitRadiusMultiplyVertical;
            group.buildLayer                = layerMask_Build;

            group.points = points;
            group.GenerationSubPaths();
            group.CheckBuild();

            for (int i = 0; i < group.paths.Count; i++)
            {
                group.paths[i].s0 = group.paths[0].s;
            }


            War.scene.AddPathCache(onceCount, from, to, group);

            SetPathGroup(group);
        }
예제 #2
0
        public void SetContents(List <IContent> contentsBefore, List <IContent> contentsAfter)
        {
            TrimPathContent trimPathContentBefore = null;

            for (var i = contentsBefore.Count - 1; i >= 0; i--)
            {
                var content = contentsBefore[i];
                if (content is TrimPathContent trimPathContent && trimPathContent.Type == ShapeTrimPath.Type.Individually)
                {
                    trimPathContentBefore = trimPathContent;
                }
            }
            if (trimPathContentBefore != null)
            {
                trimPathContentBefore.ValueChanged += OnValueChanged;
            }

            PathGroup currentPathGroup = null;

            for (var i = contentsAfter.Count - 1; i >= 0; i--)
            {
                var content = contentsAfter[i];
                if (content is TrimPathContent trimPathContent && trimPathContent.Type == ShapeTrimPath.Type.Individually)
                {
                    if (currentPathGroup != null)
                    {
                        _pathGroups.Add(currentPathGroup);
                    }
                    currentPathGroup              = new PathGroup(trimPathContent);
                    trimPathContent.ValueChanged += OnValueChanged;
                }
예제 #3
0
        public void AddPathCache(int onceCount, Transform from, Transform to, PathGroup pathGroup)
        {
            Dictionary <Transform, Dictionary <Transform, PathGroup> > onceCountDict = null;

            if (!pathCache.TryGetValue(onceCount, out onceCountDict))
            {
                onceCountDict = new Dictionary <Transform, Dictionary <Transform, PathGroup> >();
                pathCache.Add(onceCount, onceCountDict);
            }

            Dictionary <Transform, PathGroup> fromDict = null;

            if (!onceCountDict.TryGetValue(from, out fromDict))
            {
                fromDict = new Dictionary <Transform, PathGroup>();
                onceCountDict.Add(from, fromDict);
            }



            if (fromDict.ContainsKey(to))
            {
                fromDict[to] = pathGroup;
            }
            else
            {
                fromDict.Add(to, pathGroup);
            }
        }
예제 #4
0
 public WaypointEventArgs(ReasonType t, PathGroup g, RobotPath s, WayPoint pt)
 {
     Reason = t;
     Group  = g;
     Path   = s;
     Point  = pt;
 }
예제 #5
0
        public void MoveTo(Transform from, Transform to)
        {
            this.from = from;
            this.to   = to;


            PathGroup pathGroup = War.scene.GetPathCache(onceCount, from, to);

            if (pathGroup != null)
            {
                SetPathGroup(pathGroup);
            }
            else
            {
                Vector3[] paths = War.sceneData.pathData.GetPath(fromUnitCtl.unitData.uid, toUnitCtl.unitData.uid);

                SetPath(paths);

//				RaycastHit hitInfo;
//				if (Physics.Linecast(from.position, to.position, out hitInfo, layerMask_Obstacle.value))
//				{
//					StartCoroutine(DelayMoveTo());
//				}
//				else
//				{
//					Vector3[] paths = new Vector3[]{from.position, to.position};
//					SetPath(paths);
//				}
            }
        }
예제 #6
0
 public WaypointEventArgs(ReasonType t)
 {
     Reason = t;
     Group  = null;
     Path   = null;
     Point  = null;
 }
        public void Serialize(IByteBuffer byteBuffer, GetTrieNodesMessage message)
        {
            (int contentLength, int allPathsLength, int[] pathsLengths) = CalculateLengths(message);

            byteBuffer.EnsureWritable(Rlp.LengthOfSequence(contentLength), true);
            NettyRlpStream stream = new (byteBuffer);

            stream.StartSequence(contentLength);

            stream.Encode(message.RequestId);
            stream.Encode(message.RootHash);

            if (message.Paths == null || message.Paths.Length == 0)
            {
                stream.EncodeNullObject();
            }
            else
            {
                stream.StartSequence(allPathsLength);

                for (int i = 0; i < message.Paths.Length; i++)
                {
                    PathGroup group = message.Paths[i];

                    stream.StartSequence(pathsLengths[i]);

                    for (int j = 0; j < group.Group.Length; j++)
                    {
                        stream.Encode(group.Group[j]);
                    }
                }
            }

            stream.Encode(message.Bytes);
        }
        private PathGroup DecodeGroup(RlpStream stream)
        {
            PathGroup group = new PathGroup();

            group.Group = stream.DecodeArray(s => stream.DecodeByteArray());

            return(group);
        }
예제 #9
0
    PathNode buildPathNode(PathGroup group, int index)
    {
        Goal goal = group.getGoal(index);

        PathNode node = new PathNode();

        node.init(goal);
        return(node);
    }
예제 #10
0
 private void initPathGroup()
 {
     if (transform.position.x > 0)
     {
         pathGroup = PathManager.right;
     }
     else
     {
         pathGroup = PathManager.left;
     }
 }
예제 #11
0
 protected void Start()
 {
     _mapPlatform           = MapPlatformGameObject.GetComponent <MapPlatform>();
     _pathGroupTeam1        = PathGroupTeam1.GetComponent <PathGroup>();
     _pathGroupTeam2        = PathGroupTeam2.GetComponent <PathGroup>();
     _currentShadowTiles2X2 = new List <GameObject>();
     if (Debugger)
     {
         _myDebugger = Debugger.GetComponent <MyDebugger>();
     }
     Instance = this;
 }
        private PathGroup[] GetPathGroups(AccountsToRefreshRequest request)
        {
            PathGroup[] groups = new PathGroup[request.Paths.Length];

            for (int i = 0; i < request.Paths.Length; i++)
            {
                AccountWithStorageStartingHash path = request.Paths[i];
                groups[i] = new PathGroup()
                {
                    Group = new[] { path.PathAndAccount.Path.Bytes, _emptyBytes }
                };
            }

            return(groups);
        }
예제 #13
0
 public void create(int[] pointsIndex, PathGroup group)
 {
     //groupName = group.name;
     nodes = new PathNode[pointsIndex.Length];
     for (int i = 0; i < pointsIndex.Length; i++)
     {
         int index = pointsIndex[i];
         nodes[i] = buildPathNode(group, index);
     }
     //connectNodes
     for (int i = 0; i < nodes.Length; i++)
     {
         int j = i + 1;
         if (j < nodes.Length)
         {
             nodes[i].next = nodes[j];
         }
     }
 }
        public void Roundtrip_OneAccountPath()
        {
            GetTrieNodesMessage msg = new()
            {
                RequestId = MessageConstants.Random.NextLong(),
                RootHash  = TestItem.KeccakA,
                Paths     = new PathGroup[]
                {
                    new PathGroup()
                    {
                        Group = new [] { TestItem.RandomDataA }
                    }
                },
                Bytes = 10
            };
            GetTrieNodesMessageSerializer serializer = new();

            SerializerTester.TestZero(serializer, msg);
        }
예제 #15
0
    public static void init()
    {
        pathDefine = new int[][] {
            new int[] { 1, 2, 9, 10 },

            new int[] { 12, 10, 9, 4, 11 },
            new int[] { 1, 2, 9, 4, 11 },

            new int[] { 12, 10, 9 },
            new int[] { 1, 2, 9 },

            new int[] { 12, 10, 9, 2, 3, 4, 5, 6, 7, 8 },
            new int[] { 1, 2, 3, 4, 5, 6, 7, 8 },
        };

        left = new PathGroup();
        left.constructPath(GameObject.Find("leftPath").transform, pathDefine);
        right = new PathGroup();
        right.constructPath(GameObject.Find("rightPath").transform, pathDefine);
    }
예제 #16
0
        public void SetPathGroup(PathGroup pathGroup)
        {
            if (isInitCache)
            {
                Destroy(gameObject);
                return;
            }

            int count = list.Count;

            group = pathGroup.Clone(count);

            for (int i = 0; i < count; i++)
            {
                list[i].SetPath(group.paths[i]);
            }

            group.Synchronous(0.5f, War.scene);

            Destroy(gameObject);
        }
        private (int contentLength, int allPathsLength, int[] pathsLengths) CalculateLengths(GetTrieNodesMessage message)
        {
            int contentLength = Rlp.LengthOf(message.RequestId);

            contentLength += Rlp.LengthOf(message.RootHash);

            int allPathsLength = 0;

            int[] pathsLengths = new int[message.Paths.Length];

            if (message.Paths == null || message.Paths.Length == 0)
            {
                allPathsLength = 1;
            }
            else
            {
                for (var i = 0; i < message.Paths.Length; i++)
                {
                    PathGroup pathGroup   = message.Paths[i];
                    int       groupLength = 0;

                    foreach (byte[] path in pathGroup.Group)
                    {
                        groupLength += Rlp.LengthOf(path);
                    }

                    pathsLengths[i] = groupLength;
                    allPathsLength += Rlp.LengthOfSequence(groupLength);
                }
            }

            contentLength += Rlp.LengthOfSequence(allPathsLength);

            contentLength += Rlp.LengthOf(message.Bytes);

            return(contentLength, allPathsLength, pathsLengths);
        }
 // Use this for initialization
 void Start()
 {
     _group = GetComponent<PathGroup> ();
 }
 void ResetPathGroup(PathGroup pathGroup)
 {
     if (path)
     {
         pathContainer = path.GetComponent<PathContainer> ();
     }
     if (pathContainer && pathGroup == pathContainer.pathGroup) {
         //Debug.Log ("ResetPathGroup: "+pathHead);
         transform.position = pathHead.transform.position;
     }
 }
예제 #20
0
 // Use this for initialization
 void Start()
 {
     _pathGroup = pathGroupObj.GetComponent<PathGroup> ();
 }
예제 #21
0
 void ResetPathGroup(PathGroup pathGroup)
 {
 }
예제 #22
0
        protected override void OnUpdate()
        {
            base.OnUpdate();

            if (!sendArmData.sending)
            {
                return;
            }
            if (!War.isGameing)
            {
                return;
            }
            if (_forced == false && unitData.freezedSendArm)
            {
                return;
            }
            if (unitData.unitNum <= 0 || unitData.death)
            {
                Stop();
                return;
            }


            armOnceWidth = legionData.soliderData.armOnceWidth;
            radius       = legionData.soliderData.radius;
            gapV         = legionData.soliderData.gapV;
            gapH         = radius * 2;
            if (gapV < 0)
            {
                gapV = gapH;
            }
            if (armOnceWidth < 0)
            {
                armOnceWidth = 8;
            }
            onceCount = Mathf.FloorToInt(armOnceWidth / gapH);


            targetCount = sendArmData.targets.Count;
            for (int j = 0; j < targetCount; j++)
            {
                SendArmDataTarget targetData = sendArmData.targets[j];

                int count = Mathf.Min(targetData.num, onceCount);
                count = Mathf.Min(count, unitData.unitNum);
                //Debug.Log ("j=" + j + " count=" + count + "  targetData.num=" + targetData.num);
                if (count <= 0)
                {
                    sendArmData.WillRemoveTarget(targetData);
                    continue;
                }

                if (count > 8)
                {
                    count = 8;
                }

                if (Time.time > targetData.nextTime)
                {
                    PathGroup pathGroup = War.scene.GetPathCache(onceCount, transform, targetData.target.transform);
                    isInitPathCache = pathGroup != null;
                    List <UnitPath> unitPathList  = new List <UnitPath>();
                    UnitPathGroup   unitPathGroup = null;
                    if (!isInitPathCache)
                    {
                        GameObject groupGO = War.factory.CreatePathGroup();
                        groupGO.transform.position = transform.position;
                        unitPathGroup = groupGO.GetComponent <UnitPathGroup>();
                    }

                    float moveSpeed = 1f;
                    for (int i = 0; i < count; i++)
                    {
                        int pathIndex = (int)((i + 1) / 2) * (i % 2 == 0 ? 1 : -1);

                        targetData.num      += -1;
                        sendArmData.sendNum += -1;
                        unitData.AddUnitNum(-1);

//											GameObject soliderGO = War.factory.CreateSolider(unitData.legionId);
                        GameObject soliderGO       = War.soliderPool.Get();
                        UnitData   soliderUnitData = legionData.soliderData.Clone();
                        soliderUnitData.id   = targetData.idBegin++;
                        soliderUnitData.from = unitData;
                        soliderUnitData.to   = targetData.target.unitData;
                        unitData.soliderPropContainer.UnitApp(soliderUnitData);
                        legionData.soliderPropContainer.UnitApp(soliderUnitData);
                        legionData.soliderInitPropContainer.UnitApp(soliderUnitData, true);

                        soliderGO.AddEComponent(soliderUnitData);
                        soliderUnitData.Init();
                        if (targetData.forced)
                        {
                            soliderUnitData.moveSpeed = targetData.speed;
                        }
                        UnitAgent unitAgent = soliderGO.GetComponent <UnitAgent>();
                        unitAgent.Walk();
                        unitAgent.angel = HMath.angle(transform.position.z, transform.position.x, targetData.target.transform.position.z, targetData.target.transform.position.x);


                        soliderGO.name = "War_Solider-" + soliderUnitData.id;


                        UnitPath unitPath = soliderGO.GetComponent <UnitPath>();
                        unitPath.index               = pathIndex;
                        unitPath.maxSpeed            = targetData.forced ? targetData.speed : soliderUnitData.moveSpeed;
                        soliderGO.transform.position = transform.position;

                        if (isInitPathCache)
                        {
                            unitPathList.Add(unitPath);
                        }
                        else
                        {
                            unitPathGroup.list.Add(unitPath);
                        }



                        moveSpeed = unitPath.maxSpeed;
                        if (targetData.forced)
                        {
                            soliderUnitData.moveSpeed = moveSpeed;
                            soliderUnitData.Props[PropId.InitMoveSpeed] = moveSpeed;
                        }

                        soliderUnitData.to.AddFromLegionUnit(soliderUnitData.legionId, 1);

                        SoliderPoolItem soliderPoolItem = soliderGO.GetComponent <SoliderPoolItem>();
                        if (soliderPoolItem != null)
                        {
                            soliderPoolItem.Rest();
                        }
                    }

                    //				Debug.Log(string.Format("<color=green>isInitPathCache={0}</color>", isInitPathCache));
                    if (isInitPathCache)
                    {
                        pathGroup = War.scene.GetPathCache(onceCount, transform, targetData.target.transform);
                        int unitPathListCount = unitPathList.Count;
                        pathGroup = pathGroup.Clone(unitPathListCount);

                        for (int i = 0; i < unitPathListCount; i++)
                        {
                            unitPathList[i].SetPath(pathGroup.paths[i]);
                        }
                    }
                    else
                    {
                        unitPathGroup.gap       = gapH;
                        unitPathGroup.pathNum   = count;
                        unitPathGroup.onceCount = onceCount;
                        unitPathGroup.MoveTo(unitCtl, targetData.target);
                    }

                    if (float.IsNaN(moveSpeed) || moveSpeed <= 0)
                    {
                        moveSpeed = 1f;
                    }
                    targetData.nextTime = Time.time + (gapV + sendArmData.sendUnitSpeed) / moveSpeed;
                }
            }

            sendArmData.ExeRemoveTargets();
        }