예제 #1
0
        public static bool Execute(UnitOrder order)
        {
            //Debug.Log("Executing to pos - " + order.GetTo().Index);
            var index       = ChunkUtil.GetUpper(order.GetTo().Index);
            var chunkNumber = order.GetUnit().ChunkNumber;
            var chunk       = ChunkManager.GetChunkByNum(chunkNumber);

            if (order.GetUnit().CurrentPos != index &&
                ChunkUtil.IsAnyEntity(chunkNumber, index))
            {
                var obj = chunk.GetGameObjectByIndex(index);
                if (obj == null)
                {
                    return(GameMoveManager.CancelPathVVay(order.GetUnit())); //return false;
                }
                var underEnt = obj.GetComponent <GameEntity>();
                if (underEnt.Owner != order.GetUnit().Owner)
                {
                    return(AttackTo(order));
                }
                //Debug.Log("Cancel attacking");
                return(GameMoveManager.CancelPathVVay(order.GetUnit())); //return false;
            }
            //Debug.Log("Moving to: " + order.GetTo().Index);
            return(MoveExecutor.Execute(order));
        }
예제 #2
0
        public static bool MoveTo(GameUnit unit, Vector3Int vecTo)
        {
            var indexPos = ChunkUtil.GetDovvner(vecTo);
            var pos3D    = Util.Get3DPosByIndex(vecTo);

            return(MoveExecutor.Execute(new UnitOrder
                                        (
                                            unit,
                                            new TilePosition(pos3D, indexPos),
                                            OrderTypes.MoveOrder
                                        )));
        }