Ejemplo n.º 1
0
    public void init()
    {
        initialised = false;
        map         = FindObjectOfType <CreateMap>();


        if (x > 0 && y > 0 && x < map.sizeX - 1 && y < map.sizeY - 1)
        {
            //1e rij

            neighbors[0, 0] = map.level[x - 1, y - 1];
            neighbors[1, 0] = map.level[x - 0, y - 1];
            neighbors[2, 0] = map.level[x + 1, y - 1];

            //2e rij
            neighbors[0, 1] = map.level[x - 1, y];
            //zelf moet null zijn
            neighbors[2, 1] = map.level[x + 1, y];

            //3e rij
            neighbors[0, 2] = map.level[x - 1, y + 1];
            neighbors[1, 2] = map.level[x - 0, y + 1];
            neighbors[2, 2] = map.level[x + 1, y + 1];
        }
        initialised = true;
    }
Ejemplo n.º 2
0
            public void GenerateChunk()
            {
                int[,] temp = new int[XSize, YSize];

                for (int x = 0; x < XSize; x++)
                {
                    for (int y = 0; y < YSize; y++)
                    {
                        int num = Random.Range(0, 100);
                        if (num >= 35)
                        {
                            num = 3;
                        }
                        else if (num > 25)
                        {
                            num = 0;
                        }
                        else
                        {
                            num = 1;
                        }
                        temp[x, y] = num;
                    }
                }
                temp = CreateMap.CellularAutomata(temp, XSize, YSize, 0, 2, 1, true);

                int cnt = 0;

                foreach (Chunk chunk in Chunks)
                {
                    chunk.GenerateTile((eGeoType)temp[cnt % XSize, cnt / XSize]);
                    cnt++;
                }
            }
Ejemplo n.º 3
0
 void Start()
 {
     ownerId = 1;
     sr = GetComponent<SpriteRenderer> ();
     _createmap = GetComponentInParent<CreateMap> ();
     offsetPosition = new Vector3 (0, 0, 9f);
 }
Ejemplo n.º 4
0
    // Start is called before the first frame update
    void Start()
    {
        grassCanGo = new List <Tile>();

        createMap = GameObject.FindGameObjectWithTag("GameController").GetComponent <CreateMap>();

        spawnHumanCD = new Cooldown(timeToSpawnHuman);
        spawnHumanCD.Start();

        transformToCityCD = new Cooldown(timeToTransformToCity);
        transformToCityCD.Stop();

        spriteRender = GetComponent <SpriteRenderer>();

        transform.rotation = Quaternion.Euler(new Vector3(transform.rotation.x, transform.rotation.y + 180, transform.rotation.z));

        if (desert.Length > 0)
        {
            rnd = (int)Random.Range(0, desert.Length);
            spriteRender.material = desert[rnd];
        }
        else
        {
            spriteRender.color = Color.yellow;
        }
    }
Ejemplo n.º 5
0
 static void Main()
 {
     CreateMap.Start();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new MainFrm());
 }
Ejemplo n.º 6
0
        public AutomapperConfig()
        {
            CreateMap <Fornecedor, FornecedorViewModel> .ReverseMap();

            CreateMap <Endereco, EnderecoViewModel> .ReverseMap();

            CreateMap <Produto, ProdutoViewModel> .ReverseMap();
        }
Ejemplo n.º 7
0
        public void TestMethod3()
        {
            DijkstraSource d          = new DijkstraSource();
            CreateMap      cm         = new CreateMap();
            int            squareSize = 10;
            var            map        = cm.CreateMapTiles(squareSize);

            d.FindPathThroughMap(map);
        }
Ejemplo n.º 8
0
    public static void CreateMapWindow()
    {
        CreateMap Window = EditorWindow.GetWindow <CreateMap>("Create map information");

        if (Window != null)
        {
            Window.Show(true);
        }
    }
Ejemplo n.º 9
0
    // Start is called before the first frame update
    void Start()
    {
        canLose = new Cooldown(5f);
        canLose.Start();

        createMap = GetComponent <CreateMap>();

        pause = GetComponent <PauseController>();
        score = GetComponent <Score>();

        playerMovement = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovement>();
    }
Ejemplo n.º 10
0
    void OnEnable()
    {
        Camera.main.GetComponent <CameraFollow>().SetTarget(this.transform);


        _mapReference = GameObject.Find("MAP").GetComponent <CreateMap>();
        _mapMatrixVec = _mapReference.MapMatrixVec;

        _newMapReference = GameObject.Find("MAP");

        _playerTarget = transform.position;
    }
Ejemplo n.º 11
0
        public void Create_Map()
        {
            StringBuilder sb         = new StringBuilder();
            int           squareSize = 20;

            CreateMap cm  = new CreateMap();
            var       map = cm.CreateMapTiles(squareSize);

            for (int i = 0; i < squareSize; i++)
            {
                for (int j = 0; j < squareSize; j++)
                {
                    if (map.GetLocationType(j, i) == RTSGameMap.RTSGameMapOccupied.True)
                    {
                        sb.Append("#");
                    }
                    else
                    {
                        sb.Append(".");
                    }
                }
                Debug.WriteLine(sb.ToString());
                sb.Clear();
            }

            FindPath       fp         = new FindPath();
            List <History> mapHistory = fp.FindPathThroughMap(map);

            for (int i = 0; i < squareSize; i++)
            {
                for (int j = 0; j < squareSize; j++)
                {
                    if (map.GetLocationType(j, i) == RTSGameMap.RTSGameMapOccupied.True)
                    {
                        sb.Append("#");
                    }
                    else
                    {
                        if (mapHistory.Where(x => x.Location.x == j && x.Location.y == i).Any())
                        {
                            sb.Append("X");
                        }
                        else
                        {
                            sb.Append(".");
                        }
                    }
                }
                Debug.WriteLine(sb.ToString());
                sb.Clear();
            }
        }
Ejemplo n.º 12
0
        private void mapsConstructorToolStripMenuItem_Click(object sender, EventArgs e) //включение режима конструктора
        {
            //заполнение панели спрайтов
            Graphics gr = CreateMap.CreateGraphics();

            gr.DrawImage(Maps.MakeSpritePanel(), 0, 0);

            //вывод пустой карты
            Maps.EmptyMap(mapArr); //загрузить в массив пустую карту
            Graphics gr2 = Battleground.CreateGraphics();

            gr2.DrawImage(Maps.MakeMap(mapArr), 0, 0); //рисуем пустую карту
        }
Ejemplo n.º 13
0
    public override void OnInspectorGUI()
    {
        base.DrawDefaultInspector();

        CreateMap CM = target as CreateMap;

        if (GUILayout.Button("CreateMap"))
        {
            CM.GenerateMap();
        }
        if (GUILayout.Button("DestroyMap"))
        {
            CM.DestroyMap();
        }
    }
Ejemplo n.º 14
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        CreateMap createMap = (CreateMap)target;

        if (GUILayout.Button("Restart"))
        {
            createMap.RecreateMap();
        }
        if (GUILayout.Button("Save"))
        {
            createMap.SaveMap();
        }
    }
Ejemplo n.º 15
0
            public void Smoothing()
            {
                int[,] nGeo = new int[nXSize * 8, nYSize * 8];
                foreach (TileData tile in TileList)
                {
                    nGeo[tile.X, tile.Y] = tile.Height;
                }

                nGeo = CreateMap.CellularAutomata(nGeo, nXSize * 8, nYSize * 8, 2, 2, 4, true);

                foreach (TileData tile in TileList)
                {
                    tile.Height = nGeo[tile.X, tile.Y];
                    tile.CoverDirt();
                }
            }
Ejemplo n.º 16
0
    public void GenerateSeed()
    {
        if (useStringSeed)
        {
            seed = stringSeed.GetHashCode();
        }

        if (randomizeSeed)
        {
            seed = Random.Range(0, 99999);
        }

        Random.InitState(seed);

        mapCreator = GetComponent <CreateMap>();
    }
Ejemplo n.º 17
0
    private void Awake()
    {
        if (SharedInstance != null && SharedInstance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            SharedInstance = this;
        }

        GenerateSeed();

        mapCreator = GetComponent <CreateMap>();
    }
Ejemplo n.º 18
0
    // Use this for initialization
    void Start()
    {
        instance    = this;
        scalefactor = 1;

        for (int i = 0; i <= size.x; i++)
        {
            for (int j = 0; j <= size.y; j++)
            {
                for (int k = 0; k <= size.z; k++)
                {
                    //Debug.Log(k.ToString() + i.ToString() + j.ToString());
                    Instantiate(sphere, startSphere.transform.position + new Vector3(i * scalefactor, j * scalefactor, k * scalefactor), startSphere.rotation);
                }
            }
        }
    }
    public override void OnInspectorGUI()
    {
        CreateMap voronoiDiagram = (CreateMap)target;

        if (DrawDefaultInspector())
        {
            if (voronoiDiagram.autoUpdate) //if the auto button is activated
            {
                voronoiDiagram.Create();   //then Create
            }
        }

        if (GUILayout.Button("Create"))   //if Create button in the edditor is pressed
        {
            voronoiDiagram.Create();      //then Create
        }
    }
Ejemplo n.º 20
0
 //, AddElemento ae)
 public MakeMap(FileHandler fh, List<Elemento> herr, CreateMap cm)
 {
     InitializeComponent();
     //
     Matriz = new List<Elemento>();
     temMap = new Map("", 0, 0, (int)width.Value, (int)height.Value, trackBar1.Maximum);
     S_M = new SceneManager();
     R_M = new RenderManager();
     R_M.AddHandlers(new SceneHandler(S_M.PlayScene), fh);
     F_H = fh;
     temMap.SetFileManager(fh);
     CrearMatriz((int)height.Value,(int)width.Value,trackBar1.Value,1);
     temMap.Draw(new RenderHandler(R_M.AddData));
     R_M.Fondo = Color.White;
     temp = new List<Elemento>();
     Herramienta = herr;
     pm = new PhisicManager();
     C_M = cm;
 }
Ejemplo n.º 21
0
    private void Awake()
    {
        m_FoundPath = new List <Vector2Int>();
        List <MapKeyData> data = new List <MapKeyData>();

        foreach (MapKeyDataMono readerMono in m_MapReaderMono)
        {
            MapKeyData d = new MapKeyData(readerMono.TileType, readerMono.Prefab);
            data.Add(d);
        }

        m_MapReader = new MapReader();
        m_CreateMap = new CreateMap(data, m_TxtFile);
        m_CreateMap.MapCreator();

        foreach (var item in m_CreateMap.WalkablePath)
        {
            m_FoundPath.Add(new Vector2Int(item.x / 2, item.y / 2));
        }

        m_StartPos = new Vector2Int(m_CreateMap.StartTilePos.x / 2, m_CreateMap.StartTilePos.y / 2);
        m_EndPos   = new Vector2Int(m_CreateMap.EndTilePos.x / 2, m_CreateMap.EndTilePos.y / 2);
    }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            StringBuilder sb         = new StringBuilder();
            int           squareSize = 64;
            CreateMap     cm         = new CreateMap();
            var           map        = cm.CreateMapTiles(squareSize);

            for (int i = 0; i < squareSize; i++)
            {
                for (int j = 0; j < squareSize; j++)
                {
                    if (map.GetLocationType(j, i) == RTSGameMap.RTSGameMapOccupied.True)
                    {
                        sb.Append("#");
                    }
                    else
                    {
                        sb.Append(".");
                    }
                }
                Console.WriteLine(sb.ToString());
                sb.Clear();
            }

            DijkstraSource fp         = new DijkstraSource();
            Stack <Coords> mapHistory = fp.FindPathThroughMap(map);

            while (mapHistory.Count != 0)
            {
                var t = mapHistory.Pop();
                Console.SetCursorPosition(t.x, t.y);
                Thread.Sleep(50);
                Console.Write("X");
            }

            var ff = Console.ReadLine();
        }
Ejemplo n.º 23
0
    private void PlacePlayerOnMapAndGetInfo()
    {
        if (!flag_got_map_info)
        {
            planeInfo = FindObjectOfType<Playground>().gameObject;
            myMapInfo = planeInfo.GetComponent<CreateMap>();
            m_enemy_i = myMapInfo.getEnemies();
            myGridSize = myMapInfo.getGridSize();
            myLocationOfFirstCube = myMapInfo.getFirstLocationOfCube();
            myMap = myMapInfo.GetMyMap();

            //Reduce player size if player size is bigger than grid size
            Vector3 player_size = this.transform.localScale;
            if (player_size[0] > myGridSize[0])
                player_size[0] = myGridSize[0] - myGridSize[0] / 10;
            if (player_size[2] > myGridSize[2])
                player_size[2] = myGridSize[2] - myGridSize[2] / 10;
            this.transform.localScale = player_size;

            this.transform.position = LocateFirstAvailableSpace(myMap, myLocationOfFirstCube, myGridSize) + new Vector3(0f, transform.position[1], 0f);
            //+new Vector3(this.transform.localScale[0] / 2, 0f, this.transform.localScale[2] / 2);

            flag_got_map_info = true;
        }
    }
Ejemplo n.º 24
0
 // Use this for initialization
 void Start()
 {
     _grid = GetComponent<CreateMap> ();
     _drawPath = GetComponent<DrawPath> ();
 }
Ejemplo n.º 25
0
 // Use this for initialization
 void Start()
 {
     m_aCreateMap = GetComponent <CreateMap>();
 }
Ejemplo n.º 26
0
    IEnumerator setUpMap()
    {
        if (DataSaver.instance.mapExists(mapName) && !makeNewMap)
        {
            CreateMap create = new CreateMap(false, length, xSize, zSize, mapName);
            while (create.totalNodes == 0)
            {
                yield return(null);
            }
            //Debug.Log("Total nodes: " + create.totalNodes);
            //Debug.Log("Created nodes: " + create.createdNodes);
            while (!create.mapIsReady)
            {
                CameraUI.instance.progressText.text = create.createdNodes + "/" + create.totalNodes;
                CameraUI.instance.progressBar.value = create.createdNodes / create.totalNodes;
                yield return(null);
            }
            CameraUI.instance.progressText.text = create.createdNodes + "/" + create.totalNodes;
            CameraUI.instance.progressBar.value = create.createdNodes / create.totalNodes;

            nodes = create.nodes;
            xSize = create.xSize;
            zSize = create.zSize;
            //print("Node count: " + nodes.Length);

            GameObject g = Instantiate((GameObject)Resources.Load(mapName));
            g.transform.position = new Vector3(xSize / 2, 0, zSize / 2);

            g = Instantiate(nodeMarker);
            g.transform.position   = nodes[0, 0].position;
            g.transform.localScale = vLength;

            g = Instantiate(nodeMarker2);
            g.transform.position   = nodes[0, nodes.GetLength(0) - 1].position;
            g.transform.localScale = vLength;

            g = Instantiate(nodeMarker3);
            g.transform.position   = nodes[nodes.GetLength(0) - 1, 0].position;
            g.transform.localScale = vLength;

            g = Instantiate(nodeMarker2);
            g.transform.position   = nodes[nodes.GetLength(0) - 1, nodes.GetLength(nodes.Rank - 1) - 1].position;
            g.transform.localScale = vLength;

            print("Finished loading map");
            mapIsReady = true;
        }
        else
        {
            print("Making new map");
            //print("Length: " + length + ", x size: " + xSize + ", Z size: " + zSize);
            if (xSize == 0 || zSize == 0)
            {
                xSize = 2000;
                zSize = 2000;
            }
            CreateMap m = new CreateMap(makeNewMap, length, xSize, zSize, mapName);
            while (m.totalNodes == 0)
            {
                yield return(null);
            }
            while (!m.mapIsReady)
            {
                CameraUI.instance.progressText.text = m.touchedNodes + "/" + m.totalNodes;
                CameraUI.instance.progressBar.value = m.touchedNodes / m.totalNodes;
                yield return(null);
            }
            CameraUI.instance.progressText.text = m.touchedNodes + "/" + m.totalNodes;
            CameraUI.instance.progressBar.value = m.touchedNodes / m.totalNodes;
            nodes = m.nodes;
            //print("Node count: " + nodes.Length);

            GameObject g = Instantiate(nodeMarker);
            g.transform.position   = nodes[0, 0].position;
            g.transform.localScale = vLength;

            g = Instantiate(nodeMarker2);
            g.transform.position   = nodes[0, nodes.GetLength(0) - 1].position;
            g.transform.localScale = vLength;

            g = Instantiate(nodeMarker3);
            g.transform.position   = nodes[nodes.GetLength(0) - 1, 0].position;
            g.transform.localScale = vLength;

            g = Instantiate(nodeMarker2);
            g.transform.position   = nodes[nodes.GetLength(0) - 1, nodes.GetLength(nodes.Rank - 1) - 1].position;
            g.transform.localScale = vLength;


            //Save map
            mapData mData = new mapData();
            nodeData[,] data = new nodeData[(int)(xSize * (1 / length)), (int)(zSize * (1 / length))];
            for (int i = 0; i < (xSize * (1 / length)); i++)
            {
                for (int j = 0; j < (zSize * (1 / length)); j++)
                {
                    nodeData n = new nodeData();
                    n.populate(nodes[i, j]);
                    data[i, j] = n;
                }
                yield return(null);
            }
            mData.mName      = mapName;
            mData.mapNodes   = data;
            mData.xSize      = xSize;
            mData.zSize      = zSize;
            mData.nodeLength = length;

            //DataSaver.instance.saveMap(mData);

            mapIsReady = true;
            print("Finished making and saving map");
        }
    }
Ejemplo n.º 27
0
    // Update is called once per frame
    void Update()
    {
        //        m_Agent.destination = TragetPos;
        if (!updated_env)
        {
            myMapInfo = FindObjectOfType<CreateMap>();
            mPlayerInfo = FindObjectOfType<PlayerController>();
            myGridSize = myMapInfo.getGridSize();
            myLocationOfFirstCube = myMapInfo.getFirstLocationOfCube();
            myMap = myMakeCopyOf(myMapInfo.GetMyMap());
            int rand_col = UnityEngine.Random.Range((int)0, (int)2);
            transform.position = myFindFirstRandomPlace(myMap, myLocationOfFirstCube, myGridSize, mPlayerInfo.transform.position, rand_col) + new Vector3(0f, transform.position[1], 0f);
            setTargetPos(transform.position - new Vector3(0f, this.transform.position[1], 0f), false);
            updated_env = true;

        }
        flag_hit_player = false;
        if (EnemyType == myEnemyType.NotFollowingPlayer)
        {
            float threshold = Mathf.Abs(EnemySpeed);
            bool flag_find_new_target = false;
            if ((this.transform.position - new Vector3(0.0f, transform.position[1], 0.0f) - TragetPos).magnitude < threshold)
            {
                flag_find_new_target = true;
            }
            else if (myUpdatedPath != null)
            {
                if (myUpdatedPath.Count == 0)
                {
                    flag_find_new_target = true;
                }
            }
            if (flag_find_new_target)
            {
                int rand_pos = UnityEngine.Random.Range((int)0, (int)2);
                if (rand_pos == 0)
                    TragetPos = myFindRandomPlace(myMap, myLocationOfFirstCube, myGridSize, true) + new Vector3(0f, transform.position[1], 0f);
                else
                    TragetPos = myFindRandomPlace(myMap, myLocationOfFirstCube, myGridSize, false) + new Vector3(0f, transform.position[1], 0f);
                flag_update_path = true;
            }
        }

        if (flag_update_path)
        {
            if (EnemyType == myEnemyType.FollowingPlayer)
            {
                setTargetPos(FindObjectOfType<PlayerController>().transform.position, true);//get position of the agent
            }
            else
            {
                setTargetPos(TragetPos, false);
            }
            Vector3 pos1 = mPosToMapIndex(transform.position, myLocationOfFirstCube, myGridSize);
            pos1[0] = Mathf.Round(pos1[0]);
            pos1[2] = Mathf.Round(pos1[2]);
            Vector3 pos2 = TragetPos;
            myUpdatedPath = mFindPath(pos1, pos2, myUpdatedPath);
            flag_update_path = false;
        }

        if (EscapeTileBombPos[1] >= 0)
        {
            Vector3 dis_player_bomb = transform.position - EscapeTileBombPos;
            if (!(Mathf.Abs(dis_player_bomb[0]) < myGridSize[0] && Mathf.Abs(dis_player_bomb[2]) < myGridSize[2]))
            {
                EscapeTileBombPos[1] = -1;
            }
        }

        mMoveOnThePath(myUpdatedPath, myLocationOfFirstCube, myGridSize);
        checkBombHitEnemy();
    }
Ejemplo n.º 28
0
    void OnEnable()
    {
        MapProperty = (CreateMap)target;

        mGrid = serializedObject.FindProperty("Grid");
        mRow = serializedObject.FindProperty("i_Row");
        mColumn = serializedObject.FindProperty("i_Column");
        mRect = serializedObject.FindProperty("Rect");

        MapProperty.gameObject.tag = "EditorTool";
    }
Ejemplo n.º 29
0
    // Update is called once per frame
    void Update()
    {
        if (!updated_env)
        {
            myMapInfo = FindObjectOfType<CreateMap>();
            myGridSize = myMapInfo.getGridSize();
            myLocationOfFirstCube = myMapInfo.getFirstLocationOfCube();
            myMap = myMakeCopyOf(myMapInfo.GetMyMap());
            int rand_col = UnityEngine.Random.Range((int)0, (int)2);
            this.transform.localScale = new Vector3(myGridSize[0]/2, this.transform.localScale[1], myGridSize[2]/2);
            transform.position = myFindFirstRandomPlace(myMap, myLocationOfFirstCube, myGridSize, rand_col) + new Vector3(0f, transform.position[1], 0f);
            setTargetPos(transform.position - new Vector3(0f, this.transform.position[1], 0f), false);
            updated_env = true;

        }

        if (EnemyType == myEnemyType.NotFollowingPlayer)
        {
            float threshold = Mathf.Abs(EnemySpeed);
            bool flag_find_new_target = false;
            if ((this.transform.position - new Vector3(0.0f, transform.position[1], 0.0f) - TragetPos).magnitude < threshold)
            {
                flag_find_new_target = true;
            }
            else if (myUpdatedPath != null)
            {
                if (myUpdatedPath.Count == 0)
                {
                    flag_find_new_target = true;
                }
            }
            if (flag_find_new_target)
            {
                int rand_pos = UnityEngine.Random.Range((int)0, (int)2);
                if (rand_pos == 0)
                    TragetPos = myFindRandomPlace(myMap, myLocationOfFirstCube, myGridSize, true) + new Vector3(0f, transform.position[1], 0f);
                else
                    TragetPos = myFindRandomPlace(myMap, myLocationOfFirstCube, myGridSize, false) + new Vector3(0f, transform.position[1], 0f);
                flag_update_path = true;
            }
        }

        if (flag_update_path)
        {
            if (EnemyType == myEnemyType.FollowingPlayer)
            {
            }
            else
            {
                setTargetPos(TragetPos, false);
            }
            Vector3 pos1 = mPosToMapIndex(transform.position, myLocationOfFirstCube, myGridSize);
            pos1[0] = Mathf.Round(pos1[0]);
            pos1[2] = Mathf.Round(pos1[2]);
            Vector3 pos2 = TragetPos;
            myUpdatedPath = mFindPath(pos1, pos2, myUpdatedPath);
            flag_update_path = false;
        }

        mMoveOnThePath(myUpdatedPath, myLocationOfFirstCube, myGridSize);
    }
Ejemplo n.º 30
0
    protected override void LoadContent()
    {
        font = Content.Load<SpriteFont>("Content/MS20");
        sprite = new SpriteBatch(GraphicsDevice);
        cpu = new CPU(Gm.GraphicsDevice, sprite, mapa, eneLv);
        blast = new Unit(Gm.GraphicsDevice, sprite, unimap );
        cmap = new CreateMap(Gm.GraphicsDevice, sprite);
        Tgazo = Content.Load<Texture2D>("Content/sampgame");
        gazo2 = Content.Load<Texture2D>("Content/sampgame2");
         for (int i = 0; i < 10; i++)
        {

                using (Stream stream = File.OpenRead("img/no" + i + ".png"))
                {
                    noimg[i] = Texture2D.FromStream(GraphicsDevice , stream);
                }

         }
         Stream s1= File.OpenRead("img/luM.png");
         uni1 = Texture2D.FromStream(GraphicsDevice, s1);
         Stream s11 = File.OpenRead("img/luM.png");
         uni3 = Texture2D.FromStream(GraphicsDevice, s11);
         Stream s12 = File.OpenRead("img/luM.png");
         uni4 = Texture2D.FromStream(GraphicsDevice, s12);
         Stream s13 = File.OpenRead("img/luM.png");
         uni5 = Texture2D.FromStream(GraphicsDevice, s13);
         Stream s14 = File.OpenRead("img/luM.png");
         uni6 = Texture2D.FromStream(GraphicsDevice, s14);
         Stream s15 = File.OpenRead("img/luM.png");
         uni7 = Texture2D.FromStream(GraphicsDevice, s15);

         Stream s2 = File.OpenRead("img/boM.png");
         uni2 = Texture2D.FromStream(GraphicsDevice, s2);
         Stream s4 = File.OpenRead("img/lvup.png");
         me3 = Texture2D.FromStream(GraphicsDevice, s4);
         Stream s42 = File.OpenRead("img/sale.png");
         me32 = Texture2D.FromStream(GraphicsDevice, s42);
         Stream s5 = File.OpenRead("img/lvup2.png");
         me4 = Texture2D.FromStream(GraphicsDevice, s5);
         Stream s6 = File.OpenRead("img/unitmen.png");
         me5 = Texture2D.FromStream(GraphicsDevice, s6);
        base.LoadContent();
    }
Ejemplo n.º 31
0
    // Update is called once per frame
    void Update()
    {
        if (!updated_env)
        {
            myMapInfo             = FindObjectOfType <CreateMap>();
            myGridSize            = myMapInfo.getGridSize();
            myLocationOfFirstCube = myMapInfo.getFirstLocationOfCube();
            myMap = myMakeCopyOf(myMapInfo.GetMyMap());
            int rand_col = UnityEngine.Random.Range((int)0, (int)2);
            this.transform.localScale = new Vector3(myGridSize[0] / 2, this.transform.localScale[1], myGridSize[2] / 2);
            transform.position        = myFindFirstRandomPlace(myMap, myLocationOfFirstCube, myGridSize, rand_col) + new Vector3(0f, transform.position[1], 0f);
            setTargetPos(transform.position - new Vector3(0f, this.transform.position[1], 0f), false);
            updated_env = true;
        }

        if (EnemyType == myEnemyType.NotFollowingPlayer)
        {
            float threshold            = Mathf.Abs(EnemySpeed);
            bool  flag_find_new_target = false;
            if ((this.transform.position - new Vector3(0.0f, transform.position[1], 0.0f) - TragetPos).magnitude < threshold)
            {
                flag_find_new_target = true;
            }
            else if (myUpdatedPath != null)
            {
                if (myUpdatedPath.Count == 0)
                {
                    flag_find_new_target = true;
                }
            }
            if (flag_find_new_target)
            {
                int rand_pos = UnityEngine.Random.Range((int)0, (int)2);
                if (rand_pos == 0)
                {
                    TragetPos = myFindRandomPlace(myMap, myLocationOfFirstCube, myGridSize, true) + new Vector3(0f, transform.position[1], 0f);
                }
                else
                {
                    TragetPos = myFindRandomPlace(myMap, myLocationOfFirstCube, myGridSize, false) + new Vector3(0f, transform.position[1], 0f);
                }
                flag_update_path = true;
            }
        }

        if (flag_update_path)
        {
            if (EnemyType == myEnemyType.FollowingPlayer)
            {
            }
            else
            {
                setTargetPos(TragetPos, false);
            }
            Vector3 pos1 = mPosToMapIndex(transform.position, myLocationOfFirstCube, myGridSize);
            pos1[0] = Mathf.Round(pos1[0]);
            pos1[2] = Mathf.Round(pos1[2]);
            Vector3 pos2 = TragetPos;
            myUpdatedPath    = mFindPath(pos1, pos2, myUpdatedPath);
            flag_update_path = false;
        }

        mMoveOnThePath(myUpdatedPath, myLocationOfFirstCube, myGridSize);
    }
Ejemplo n.º 32
0
 private void Awake()
 {
     Instance = this;
 }
Ejemplo n.º 33
0
 void Awake()
 {
     G_State = GameObject.Find("Game_Manager").GetComponent <Game_State>();
     Map     = GameObject.Find("MapCreator").GetComponent <CreateMap>();
 }
Ejemplo n.º 34
0
 //    public InputField indexText; //used for test
 void Start()
 {
     m = new Material (shader);
     g = new GameObject("g");
     lineNow = 0;
     isNewLine = true;
     GameObject go = GameObject.Find("MapController");
     _createMap = go.GetComponent<CreateMap> ();
     Debug.Log ("未考虑怪物不能走斜线的问题");
 }