Exemplo n.º 1
0
    void MakeMap(IMapData mapData)
    {
        GameObject[] objs = GameObject.FindGameObjectsWithTag("Floor");
        foreach (GameObject obj in objs)
            GameObject.DestroyImmediate (obj);

        foreach (Vector3 pos in mapData.CubePos) {
            GameObject cube = GameObject.CreatePrimitive (PrimitiveType.Cube);
            cube.tag = "Floor";
            cube.name = "C"+pos.x+pos.y+pos.z;	// 'C'ube
            cube.transform.position = pos;
        }
        for (int i = 0; i < mapData.SlopePos.Length; i++) {
            GameObject slope = makeSlope ();
            Vector3 pos = mapData.SlopePos[i];
            slope.tag = "Floor";
            slope.name = "S"+pos.x+pos.y+pos.z;	// 'S'lope
            slope.transform.position = pos;
            slope.transform.rotation = mapData.SlopeRot[i];
        }
        foreach (RotatingObject data in mapData.RotObj) {
            GameObject obj = GameObject.Find(data.name);
            if (obj == null) continue;
            Rotating script = obj.AddComponent("Rotating") as Rotating;
            script.point = data.point;
            script.axis = data.axis;
            script.PlayerRot = data.playerRot;
        }
        {
            GameObject player = GameObject.Find ("Player");
            player.transform.position = new Vector3(mapData.PlayerStart.x, mapData.PlayerStart.y + 1, mapData.PlayerStart.z);
            player.GetComponent<MoveCharacter>().Init();
        }
    }
Exemplo n.º 2
0
 public BombermanWalkState(IMapData mapData, TilePosition targetPosition, NewAI aiBehavior, GameObject target)
     : base(mapData, targetPosition, aiBehavior)
 {
     this.m_Target     = target;
     this.m_HPBehavior = this.m_AIBehavior.gameObject.GetComponent <KodoHPBehavior>();
     this.m_StateName  = "BombermanWalk";
 }
Exemplo n.º 3
0
        public static bool GetIsAreaFree(this IMapData data, Vector2 position, Vector2 size)
        {
            var intSize = new Vector2Int(Mathf.CeilToInt(size.x), Mathf.CeilToInt(size.y));
            var intPos  = new Vector2Int(Mathf.FloorToInt(position.x), Mathf.FloorToInt(position.y));

            var toCompare = data.GetHeightAt(intPos.x, intPos.y);

            for (int x = 0; x <= intSize.x; x++)
            {
                for (int y = 0; y <= intSize.y; y++)
                {
                    var localPos = intPos + new Vector2Int(x, y);
                    if (localPos.x < 0 || localPos.x >= data.Width || localPos.y < 0 || localPos.y >= data.Length)
                    {
                        return(false);
                    }

                    if (Math.Abs(toCompare - data.GetHeightAt(localPos.x, localPos.y)) > 0.001)
                    {
                        return(false);
                    }

                    if (data.GetMapObjectAt(localPos.x, localPos.y) != MapObject.None && x != intSize.x && y != intSize.y)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 4
0
 public CharacterGCalculator(IMapData mapData, int destinationRow, int destinationColumn)
 {
     this.m_DestinationRow               = destinationRow;
     this.m_DestinationColumn            = destinationColumn;
     this.m_MapData                      = mapData;
     this.m_PreviousTargetLightPositions = new List <int>();
 }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        IMapData mp7 = new Map07();

        currentMap = mp7;
        MakeMap(mp7);
    }
Exemplo n.º 6
0
        private void CodeView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            IMapData data = e.OldValue as IMapData;

            if (data != null)
            {
                data.PropertyChanged -= Data_PropertyChanged;
            }
            data = e.NewValue as IMapData;
            if (data != null && data.Items != null)
            {
                data.PropertyChanged += Data_PropertyChanged;
                colorizer.Data        = data;
                code.Text             = data.Text;
                code.ScrollToHome();
                var main = DataContext as MainVM;
                if (main.SelectedValue != null)
                {
                    Goto(data.Items.FirstOrDefault(it => it is IMapValueItem && (it as IMapValueItem).Value == main.SelectedValue.Value));
                }
            }
            else
            {
                colorizer.Data = null;
                code.Text      = string.Empty;
            }
        }
Exemplo n.º 7
0
 public VillagerWalkState(IMapData mapData, TilePosition targetPosition, NewAI aiBehavior, IBuildingInfo targetInfo) :
     base(mapData, targetPosition, aiBehavior, targetInfo)
 {
     this.m_ActorConfig = ActorPrefabConfig.Instance.GetComponent <ActorConfig>();
     this.WalkVelocity  = this.m_ActorConfig.VillagerMoveVelocity;
     this.m_Offset      = targetPosition - targetInfo.ActorPosition;
 }
Exemplo n.º 8
0
 public LoadButton(int x, int y)
     : base(x, y)
 {
     _settings = DependencyInjection.Resolve<IReadOnlySettings>();
     _mapData = DependencyInjection.Resolve<IMapData>();
     _ledgesLoader = DependencyInjection.Resolve<ILedgesLoader>();
 }
Exemplo n.º 9
0
            private static void IdentifySuccessors(IMapData Map, NavigationNode Node, INode Goal, NavigationNodeStack OpenedNodes, NavigationNodeStack ClosedNodes)
            {
                INode[] neighbors = GetNeighbors(Map, Node);

                for (int i = 0; i < neighbors.Length; ++i)
                {
                    INode neighborNode = neighbors[i];

                    INode jumpNode = Jump(Map, neighborNode, Node.Node, Goal, OpenedNodes);

                    if (jumpNode == null || IsNavigationNodeInList(jumpNode, ClosedNodes))
                    {
                        continue;
                    }

                    NavigationNode jumpNavNode = GetNavigationNode(jumpNode, OpenedNodes);

                    bool alreadyIsInOpenNodes = (jumpNavNode != null);

                    if (jumpNavNode == null)
                    {
                        jumpNavNode = GetOrAddNavigationNode(jumpNode, OpenedNodes);
                    }

                    Number heuristic     = NavigationNode.CalculateHeuristicCost(Node.Node, jumpNode);
                    Number nextExactCost = Node.ExactCost + heuristic;

                    if (!alreadyIsInOpenNodes || nextExactCost < jumpNavNode.ExactCost)
                    {
                        jumpNavNode.SetExactCost(nextExactCost);
                        jumpNavNode.SetHeuristicCost(jumpNavNode.HeuristicCost != 0 ? jumpNavNode.HeuristicCost : NavigationNode.CalculateHeuristicCost(jumpNode, Goal));
                        jumpNavNode.SetParent(Node);
                    }
                }
            }
Exemplo n.º 10
0
 public InvaderWalkState(IMapData mapData, TilePosition targetPosition, NewAI aiBehavior, GameObject target)
     : base(mapData, targetPosition, aiBehavior)
 {
     this.m_Target    = target;
     this.m_StateName = "InvaderWalk";
     this.m_Values    = new string[2];
 }
Exemplo n.º 11
0
        /// <summary>
        /// Для добавления объекта разметки к записям соответствующим значениям разметки объекта
        /// </summary>
        static void AddRecordInfo <T>(IEnumerable <IMapRecordFull> lst, IMapData data, Func <string, IMapRecordFull> Getter) where T : IMapBaseItem
        {
            var items = data.Items.OfType <T>().ToArray();

#if MAPPED_DATA_OPTIMIZE
            var store = new List <IComparable>()
            {
                Capacity = items.Length
            };
#endif
            //SortedSet лчень быстро выкинет дубли и вернет чистенький сортированы энум
            foreach (var item in new SortedSet <T>(items, MapBaseItemComparer <T> .Comparer))
            {
                var rec = Getter(item.Value);
                (rec as IMapRecordFull).Data.Add(data);
                if (rec is IMapValueRecord mvr)
                {
                    mvr.WasLinked = true;
                }
#if MAPPED_DATA_OPTIMIZE
                store.Add(rec);
#endif
            }

#if MAPPED_DATA_OPTIMIZE
            foreach (var item in items.OfType <IMapOptimizableValueItem>())
            {
                item.SwapValueToMapRecord((IMapRecord)store[store.BinarySearch(item.Value)]);
            }
#endif
        }
Exemplo n.º 12
0
        public static INode[] GetOptimizedNodes(IMapData Map, INode[] Nodes)
        {
            List <INode> positionList = new List <INode>();

            INode start       = Nodes[0];
            INode lastChecked = start;

            positionList.Add(start);

            for (int i = 1; i < Nodes.Length; ++i)
            {
                INode curr = Nodes[i];

                bool intersects = CheckIntersection(Map, start, curr);

                if (intersects)
                {
                    positionList.Add(lastChecked);

                    start = curr;
                }

                lastChecked = curr;
            }

            positionList.Add(lastChecked);

            return(positionList.ToArray());
        }
Exemplo n.º 13
0
 /// <summary>
 /// Для удаления объекта разметки из записей ссылающихся на него
 /// </summary>
 static void RemoveRecordInfo <T>(IEnumerable <IMapRecordFull> lst, IMapData data, Func <string, IMapRecordFull> Getter) where T : IMapBaseItem
 {
     foreach (var item in new SortedSet <T>(data.Items.OfType <T>().ToArray(), MapBaseItemComparer <T> .Comparer))
     {
         Getter(item.Value).Data.Remove(data);
     }
 }
Exemplo n.º 14
0
    public BuilderBuildHoverState(IObstacleInfo targetInfo, IMapData mapData, TilePosition targetPosition, NewAI aiBehavior)
        : base(mapData, targetPosition, aiBehavior, targetInfo)
    {
        ActorConfig config = ActorPrefabConfig.Instance.GetComponent <ActorConfig>();

        this.WalkVelocity = config.BuilderMoveVelocity;
    }
Exemplo n.º 15
0
 public BuilderBuildState(NewAI aiBehavior, IObstacleInfo targetInfo, IMapData mapData, TilePosition buildPosition) : base(aiBehavior)
 {
     this.m_TargetInfo     = targetInfo;
     this.m_TargetPosition = this.m_TargetInfo.BuildingPosition;
     this.m_BuildPosition  = buildPosition;
     this.m_MapData        = mapData;
 }
Exemplo n.º 16
0
 public DeleteLayerController(IMapData mapData,
                              IStatusTable statusTable,
                              IMapLayerUpdateTopicClient topicClient)
 {
     _mapData     = mapData;
     _statusTable = statusTable;
     _topicClient = topicClient;
 }
 public void Construct(IMapData mapData,
                       IMutableMapSectionData mutableMapSectionData,
                       ILogger logger)
 {
     _mapData        = mapData;
     _mapSectionData = mutableMapSectionData;
     _logger         = logger;
 }
Exemplo n.º 18
0
 public LayerCacheRefreshService(IMapData mapData,
                                 IMapLayerUpdateSubscriptionClient subscriptionClient,
                                 ILogger <LayerCacheRefreshService> logger)
 {
     _mapData            = mapData;
     _subscriptionClient = subscriptionClient;
     _logger             = logger;
 }
Exemplo n.º 19
0
        private void RootOnMapLoaded(IMapData obj)
        {
            var x = (obj.Width - 1) / 2f;
            var z = (obj.Length - 1) / 2f;

            MinimapCamera.transform.localPosition = new Vector3(x, 50, z);
            MinimapCamera.orthographicSize        = Mathf.Max(x, z);
        }
Exemplo n.º 20
0
 public Task SetLookAt(Vector2 position, IMapData mapData)
 {
     return(SyncContext.Execute(() =>
     {
         mLookTarget = GameUtils.GetPosition(position, mapData);
         transform.rotation = Quaternion.LookRotation(mLookTarget.Value - transform.localPosition);
     }));
 }
Exemplo n.º 21
0
        public MaterialData(IMapData diffuse, IMapData normal, IMapData specular, Material mat)
        {
            diffuseMap = diffuse;
            normalMap = normal;
            specularMap = specular;

            material = mat;
        }
Exemplo n.º 22
0
 /// <summary>
 /// Удаляет размеченные данные из словарей
 /// </summary>
 /// <param name="data">Размеченные данные</param>
 static void RemoveMapInfo(IMapData data)
 {
     if (data.IsMapped)
     {
         RemoveRecordInfo <IMapValueItem>(_ValuesDictionary.OfType <IMapRecordFull>(), data, GetValueRecord);
         RemoveRecordInfo <IMapMethodItem>(_MethodsDictionary.OfType <IMapRecordFull>(), data, GetMethodRecord);
     }
 }
Exemplo n.º 23
0
        public AnimatedMaterialData(IMapData diffuse, IMapData normal, IMapData specular, IMapData emissive, Material mat)
        {
            diffuseMap = diffuse;
            normalMap = normal;
            specularMap = specular;
            emissiveMap = emissive;

            material = mat;
        }
Exemplo n.º 24
0
//        private static DocumentClient _client;

        /// <summary>
        ///     Create a new GdalConversionService instance.
        /// </summary>
        /// <param name="logger">system logger</param>
        /// <param name="options">global options for the Map Server</param>
        /// <param name="mapdata">Map data layers</param>
        public GdalConversionService(ILogger <GdalConversionService> logger, Options options, IMapData mapdata)
        {
            _logger  = logger;
            _mapdata = mapdata;
            _options = options;
//            var EndpointUrl = "https://localhost:8081";
//            var AuthorisationKey = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==";
//            _client = new DocumentClient(new Uri(EndpointUrl), AuthorisationKey);
        }
Exemplo n.º 25
0
	//private BuildingBasePropertyBehavior m_TargetProperty;
	
	public KodoWalkState(IMapData mapData, TilePosition targetPosition, NewAI aiBehavior, GameObject target) 
		: base(mapData, targetPosition, aiBehavior)
	{
		this.m_Target = target;
		this.WalkVelocity = this.CharacterAI.PropertyBehavior.MoveVelocity;
		this.m_HPBehavior = this.m_AIBehavior.gameObject.GetComponent<KodoHPBehavior>();
		//this.m_TargetProperty = this.m_Target.GetComponent<BuildingBasePropertyBehavior>();
		this.m_StateName = "KodoWalk";
	}
Exemplo n.º 26
0
 /// <summary>
 /// Обновляет данные разметки
 /// </summary>
 /// <param name="data">Разметкп</param>
 /// <param name="ifChanged">Только если файл изменен</param>
 public static void UpdateData(IMapData data, bool ifChanged)
 {
     if (data != null && (!ifChanged || data.IsChanged) && _Data.Contains(data))
     {
         RemoveMapInfo(data);
         data.Remap(ifChanged);
         AddMapInfo(data);
     }
 }
Exemplo n.º 27
0
Arquivo: Map.cs Projeto: gormel/rts
        public Map(int width, int length)
        {
            var data = new float[width, length];

            for (int i = 0; i < 20; i++)
            {
                var x     = Random.Range(0, width);
                var y     = Random.Range(0, length);
                var sizeX = Random.Range(5, 10) / 2;
                var sizeY = Random.Range(5, 10) / 2;

                for (int x1 = x - sizeX; x1 <= x + sizeX; x1++)
                {
                    for (int y1 = y - sizeY; y1 <= y + sizeY; y1++)
                    {
                        if (x1 < 0 || y1 < 0 || x1 >= width || y1 >= width)
                        {
                            continue;
                        }

                        var h = 1f;
                        if ((x1 == x - sizeX || x1 == x + sizeX) &&
                            (y1 == y - sizeY || y1 == y + sizeY))
                        {
                            h = 0.5f;
                        }

                        data[x1, y1] = h;
                    }
                }
            }

            var objs = new MapObject[width, length];

            for (int i = 0; i < 10; i++)
            {
                var x = Random.Range(0, width);
                var y = Random.Range(0, length);
                GenerateForest(x, y, objs, 0);
            }

            for (int i = 0; i < 20; i++)
            {
                var x = Random.Range(0, width - 1);
                var y = Random.Range(0, length - 1);
                if (objs[x, y] != MapObject.None)
                {
                    i--;
                    continue;
                }

                objs[x, y] = MapObject.Crystal;
            }

            Data = new MapData(width, length, data, objs);
        }
Exemplo n.º 28
0
        public TextureGenerator(IMapData mapData)
        {
            this.mapData = mapData;

            sizeX = mapData.Tiles.GetLength(0);
            sizeY = mapData.Tiles.GetLength(1);

            tileSizeX = (int)mapData.TileSize.x;
            tileSizeY = (int)mapData.TileSize.y;
        }
Exemplo n.º 29
0
 public GetLayerController(IMapData mapData,
                           IResourceLinksGenerator resourceLinksGenerator,
                           ITileStorage tileStorage,
                           IStyleStorage styleStorage)
 {
     _mapData = mapData;
     _resourceLinksGenerator = resourceLinksGenerator;
     _tileStorage            = tileStorage;
     _styleStorage           = styleStorage;
 }
Exemplo n.º 30
0
 public LayerStyleService(IMapData mapData,
                          ILogger <LayerStyleService> logger,
                          IStyleStorage styleStorage,
                          IWorkspaceStyleCache styleCache)
 {
     _styleStorage = styleStorage;
     _styleCache   = styleCache;
     _mapData      = mapData;
     _logger       = logger;
 }
Exemplo n.º 31
0
        public void Construct(IInputLock inputLock, IMapData mapData, IReplayPlaybackManager playbackManager,
                              ICommandHistorySaver commandHistorySaver)
        {
            _inputLock           = inputLock;
            _mapData             = mapData;
            _playbackManager     = playbackManager;
            _commandHistorySaver = commandHistorySaver;

            Preconditions.CheckNotNull(_animator, _scrubSlider, _cancelReplayButton);
        }
Exemplo n.º 32
0
            public static NavigationResult GetPath(IMapData Map, INode StartNode, INode GoalNode)
            {
                Vector3[] path = CalculatePath(Map, StartNode, GoalNode);

                if (path == null)
                {
                    return(null);
                }

                return(new NavigationResult(path, NavigationResult.Types.Complete));
            }
Exemplo n.º 33
0
    private void MakeMap(IMapData mapData)
    {
        GameObject[] floor = GameObject.FindGameObjectsWithTag("Floor");
        foreach (GameObject obj in floor)
        {
            GameObject.Destroy(obj);
        }
        GameObject[] end = GameObject.FindGameObjectsWithTag("Endpoint");
        foreach (GameObject obj in end)
        {
            GameObject.Destroy(obj);
        }


        foreach (Vector3 pos in mapData.CubePos)
        {
            GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            cube.tag  = "Floor";
            cube.name = "C" + pos.x + pos.y + pos.z;    // 'C'ube
            cube.transform.position = pos;
        }
        for (int i = 0; i < mapData.SlopePos.Length; i++)
        {
            GameObject slope = makeSlope();
            Vector3    pos   = mapData.SlopePos[i];
            slope.tag  = "Floor";
            slope.name = "S" + pos.x + pos.y + pos.z;   // 'S'lope
            slope.transform.position = pos;
            slope.transform.rotation = mapData.SlopeRot[i];
        }
        foreach (RotatingObject data in mapData.RotObj)
        {
            GameObject obj = GameObject.Find(data.name);
            if (obj == null)
            {
                continue;
            }
            Rotating script = obj.AddComponent <Rotating>() as Rotating;
            script.point     = data.point;
            script.axis      = data.axis;
            script.PlayerRot = data.playerRot;
        }
        {
            GameObject player = GameObject.Find("Player");
            player.transform.position = new Vector3(mapData.PlayerStart.x, mapData.PlayerStart.y + 1, mapData.PlayerStart.z); //
            player.GetComponent <MoveCharacter>().Init();
        }
        //关卡终点
        {
            GameObject endpoint = (GameObject)Resources.Load("Prefabs/endpoint");
            endpoint.transform.position = mapData.GameEnd;
            Object.Instantiate(endpoint);
        }
    }
Exemplo n.º 34
0
        public void Construct(IMapSectionContext mapSectionContext, IMapData mapData, IInputLock inputLock,
                              LoadMapCommandData loadMapCommandData, ICommandQueue commandQueue)
        {
            _nextSectionButton.onClick.AddListener(HandleNextSectionButtonCLicked);
            _previousSectionButton.onClick.AddListener(HandlePreviousSectionButtonCLicked);

            _mapSectionContext  = mapSectionContext;
            _loadMapCommandData = loadMapCommandData;
            _mapData            = mapData;
            _inputLock          = inputLock;
            _commandQueue       = commandQueue;
        }
Exemplo n.º 35
0
	public static bool IsBuildingHover(this IObstacleInfo buildingInfo, IMapData mapData)
	{
		if(Application.loadedLevelName != ClientStringConstants.BUILDING_SCENE_LEVEL_NAME)
		{
			return false;
		}
		else
		{
			TilePosition buildingPosition = buildingInfo.GetBuildingFirstBuildingPosition();
			return mapData.GetBuildingObjectFromBuildingObstacleMap(buildingPosition.Row, buildingPosition.Column) == null;
		}
	}
Exemplo n.º 36
0
 public LedgesLoader()
 {
     _mapData = DependencyInjection.Resolve<IMapData>();
 }