Beispiel #1
0
    public void ChangeTile(Tile_Type _type, Player.Type _info)
    {
        Tile new_tile = null;

        switch (_type)
        {
        case Tile_Type.FLATLAND:
            new_tile = Instantiate(Resources.Load <Tile>("Prefabs/Flatland"));
            break;

        case Tile_Type.FOREST:
            new_tile = Instantiate(Resources.Load <Tile>("Prefabs/Forest"));
            break;

        case Tile_Type.MOUNTAIN:
            new_tile = Instantiate(Resources.Load <Tile>("Prefabs/Mountain"));
            break;

        default:
            break;
        }
        if (!new_tile)
        {
            return;
        }
        new_tile.name               = name;
        new_tile.transform.parent   = transform.parent;
        new_tile.transform.position = transform.position;
        new_tile.transform.SetSiblingIndex(transform.GetSiblingIndex());
        new_tile.SetOwner(_info);
        new_tile.SetPlayerHighlight();
        new_tile.GetComponent <TileEditor>().editor_owner = _info;
        new_tile.GetComponent <TileEditor>().editor_type  = _type;
    }
Beispiel #2
0
 // 타일 만들기 메뉴 함수
 void MakeMenu_Tile()
 {
     tileInfo.name = EditorGUILayout.TextField("Tile prefab name", tileInfo.name, GUILayout.Width(350.0f));
     tile_Type     = (Tile_Type)EditorGUILayout.EnumPopup("Select Tile Type", tile_Type, GUILayout.Width(350.0f));
     if (tile_Type == Tile_Type.Breakable)
     {
         tile_HitPoint = EditorGUILayout.IntField("Number of times to break", tile_HitPoint, GUILayout.Width(350.0f));
     }
     tileInfo.color = EditorGUILayout.ColorField("Tile Color", tileInfo.color, GUILayout.Width(370.0f));
     tileInfo.image = (Sprite)EditorGUILayout.ObjectField(tileInfo.image, typeof(Sprite), false, GUILayout.Width(370.0f));
     if (tileInfo.image != null)
     {
         GUILayout.Box(tileInfo.image.texture, GUILayout.Width(120.0f), GUILayout.Height(120.0f));
     }
     GUILayout.Space(3.0f);
     if (GUILayout.Button("Create Tile", GUILayout.Width(150.0f)))
     {
         if (tile_Type == Tile_Type.Background)
         {
             MakeBackGroundTile(tileInfo.image, tileInfo.color, tileInfo.name);
         }
         else if (tile_Type == Tile_Type.Breakable)
         {
             MakeBreakableTile(tileInfo.image, tileInfo.color, tileInfo.name, tile_HitPoint);
         }
         SetTiles();
     }
 }
    public void TileChange(Tile_Type type, bool setOn = false)
    {
        if (type == Tile_Type.None && setOn == false)
        {
            return;
        }

        tile_Type = type;

        Color cor = Color.white;

        switch (type)
        {
        case Tile_Type.None:
            cor = new Color(1, 1, 1, 0);
            break;

        case Tile_Type.White:
            cor = Color.white;
            break;

        case Tile_Type.Red:
            cor = Color.red;
            break;

        case Tile_Type.Blue:
            cor = Color.blue;
            break;
        }
        ColorChange(cor);
    }
Beispiel #4
0
    public bool CheckCanEnter(Vector3 destination)
    {
        Tile_Type destType = (Tile_Type)map[(int)Math.Round(destination.z, 0), (int)Math.Round(destination.x, 0)];

        if (destType == Tile_Type.Wall || destType == Tile_Type.Invalid)
        {
            return(false);
        }
        return(true);
    }
Beispiel #5
0
    public void TileChange(Tile_Type type, bool setOn = false)
    {
        if (type == Tile_Type.None && setOn == false)
        {
            return;
        }

        tile_Type = type;

        if (anim != null)
        {
            bool whiteOn = false;
            bool red     = false;
            bool blue    = false;

            switch (type)
            {
            case Tile_Type.White:
                whiteOn = true;
                red     = false;
                blue    = false;
                break;

            case Tile_Type.Red:
                whiteOn = false;
                red     = true;
                blue    = false;
                break;

            case Tile_Type.Blue:
                whiteOn = false;
                red     = false;
                blue    = true;
                break;
            }

            anim.SetBool("white", whiteOn);
            anim.SetBool("red", red);
            anim.SetBool("blue", blue);


            if (type == Tile_Type.None)
            {
                anim.gameObject.SetActive(false);
            }
        }

        if (tileChangeOn != null)
        {
            tileChangeOn();
        }
    }
Beispiel #6
0
        public void set_tile_type_str(string sType, List <KeyValuePair <Tile_Type, Texture2D> > textures)
        {
            Tile_Type next_tilTyp = Tile_Type.Void;

            switch (sType)
            {
            case "DWr":
                next_tilTyp = Tile_Type.Deep_Water;
                break;

            case "DF":
                next_tilTyp = Tile_Type.DirtFloor;
                break;

            case "DW":
                next_tilTyp = Tile_Type.DirtWall;
                break;

            case "GV":
                next_tilTyp = Tile_Type.Gravel;
                break;

            case "SWr":
                next_tilTyp = Tile_Type.Shallow_Water;
                break;

            case "SF":
                next_tilTyp = Tile_Type.StoneFloor;
                break;

            case "SW":
                next_tilTyp = Tile_Type.StoneWall;
                break;

            case "SB":
                next_tilTyp = Tile_Type.Shallow_Blood;
                break;

            case "DB":
                next_tilTyp = Tile_Type.Deep_Blood;
                break;
            }

            set_tile_type(next_tilTyp, textures);
        }
Beispiel #7
0
        private Vector2 corner_4; //Lower right

        public Tile(Tile_Type sType, int sVari, ContentManager sCont, Texture2D bText, Vector2 sPos, gridCoordinate sgCoord,
                    Texture2D[] textures)
        {
            cont             = sCont;
            my_Position      = sPos;
            grid_coord       = sgCoord;
            tile_typ         = sType;
            random_variation = sVari;
            set_tile_type(sType, textures);
            smells           = new List <Scent>();
            my_Aura          = Aura.None;
            my_blank_texture = bText;

            corner_1 = new Vector2(sPos.X + 16, sPos.Y + 13);
            corner_2 = new Vector2(sPos.X + 16, sPos.Y + 19);
            corner_3 = new Vector2(sPos.X + 13, sPos.Y + 16);
            corner_4 = new Vector2(sPos.X + 19, sPos.Y + 16);
        }
Beispiel #8
0
 public void SetNodeType(Tile_Type type)
 {
     Type = NodeType.Tile_Offset + (int)type;
 }
Beispiel #9
0
 public Node(float x, float y, Tile_Type type)
 {
     X    = (int)x;
     Y    = (int)y;
     Type = NodeType.Tile_Offset + (int)type;
 }
Beispiel #10
0
        public void set_tile_type(Tile_Type sType, Texture2D[] textures)
        {
            tile_typ = sType;
            switch (sType)
            {
            case Tile_Type.StoneFloor:
                opaque                 = false;
                deflect_sound          = false;
                passable               = true;
                sound_absorbtion_value = 1;
                if (random_variation < 5)
                {
                    my_Texture = textures[2];
                }
                else if (random_variation >= 5 && random_variation <= 10)
                {
                    my_Texture = textures[1];
                }
                else
                {
                    my_Texture = textures[0];
                }
                break;

            case Tile_Type.StoneWall:
                opaque                 = true;
                deflect_sound          = true;
                passable               = false;
                sound_absorbtion_value = 1;
                if (random_variation < 15)
                {
                    my_Texture = textures[2];
                }
                else if (random_variation >= 15 && random_variation <= 57)
                {
                    my_Texture = textures[1];
                }
                else
                {
                    my_Texture = textures[0];
                }
                break;

            case Tile_Type.Exit:
                opaque                 = false;
                deflect_sound          = false;
                passable               = true;
                sound_absorbtion_value = 1;
                my_Texture             = textures[0];
                break;

            case Tile_Type.Entrance:
                opaque                 = false;
                deflect_sound          = false;
                passable               = true;
                sound_absorbtion_value = 1;
                my_Texture             = textures[0];
                break;

            case Tile_Type.DirtFloor:
                opaque                 = false;
                deflect_sound          = false;
                passable               = true;
                sound_absorbtion_value = 2;
                if (random_variation <= 50)
                {
                    my_Texture = textures[0];
                }
                else
                {
                    my_Texture = textures[1];
                }
                break;

            case Tile_Type.DirtWall:
                opaque                 = true;
                deflect_sound          = true;
                passable               = false;
                sound_absorbtion_value = 3;
                if (random_variation < 15)
                {
                    my_Texture = textures[2];
                }
                else if (random_variation >= 15 && random_variation <= 57)
                {
                    my_Texture = textures[1];
                }
                else
                {
                    my_Texture = textures[0];
                }
                break;

            case Tile_Type.Rubble_Floor:
                opaque                 = false;
                deflect_sound          = false;
                passable               = true;
                sound_absorbtion_value = 1;
                my_Texture             = textures[0];
                break;

            case Tile_Type.Rubble_Wall:
                opaque                 = true;
                deflect_sound          = true;
                passable               = false;
                sound_absorbtion_value = 2;
                my_Texture             = textures[0];
                break;

            case Tile_Type.Dungeon_Exit:
                opaque                 = false;
                deflect_sound          = false;
                passable               = true;
                sound_absorbtion_value = 1;
                my_Texture             = textures[0];
                break;

            case Tile_Type.Locked_Dungeon_Exit:
                opaque                 = false;
                deflect_sound          = false;
                passable               = false;
                sound_absorbtion_value = 2;
                my_Texture             = textures[1];
                break;

            case Tile_Type.Void:
            default:
                opaque                 = true;
                deflect_sound          = false;
                passable               = false;
                sound_absorbtion_value = 1000;
                my_Texture             = textures[0];
                break;
            }
        }
Beispiel #11
0
 public void SetSelectTileType(Tile_Type tile_Type)
 {
     this.select_Tile_Type = tile_Type;
 }
Beispiel #12
0
        public void set_tile_type(Tile_Type sType, List <KeyValuePair <Tile_Type, Texture2D> > textures)
        {
            tile_typ = sType;

            List <Texture2D> relevant_textures = new List <Texture2D>();

            for (int i = 0; i < textures.Count; i++)
            {
                if (tile_typ == textures[i].Key)
                {
                    relevant_textures.Add(textures[i].Value);
                }
            }

            switch (sType)
            {
            case Tile_Type.StoneFloor:
                opaque                 = false;
                deflect_sound          = false;
                passable               = true;
                sound_absorbtion_value = 1;
                if (random_variation < 5)
                {
                    my_Texture = relevant_textures[2];
                }
                else if (random_variation >= 5 && random_variation <= 10)
                {
                    my_Texture = relevant_textures[1];
                }
                else
                {
                    my_Texture = relevant_textures[0];
                }
                break;

            case Tile_Type.StoneWall:
                opaque                 = true;
                deflect_sound          = true;
                passable               = false;
                sound_absorbtion_value = 1;
                if (random_variation < 15)
                {
                    my_Texture = relevant_textures[2];
                }
                else if (random_variation >= 15 && random_variation <= 57)
                {
                    my_Texture = relevant_textures[1];
                }
                else
                {
                    my_Texture = relevant_textures[0];
                }
                break;

            case Tile_Type.Exit:
                opaque                 = false;
                deflect_sound          = false;
                passable               = true;
                sound_absorbtion_value = 1;
                my_Texture             = relevant_textures[0];
                break;

            case Tile_Type.Entrance:
                opaque                 = false;
                deflect_sound          = false;
                passable               = true;
                sound_absorbtion_value = 1;
                my_Texture             = relevant_textures[0];
                break;

            case Tile_Type.DirtFloor:
                opaque                 = false;
                deflect_sound          = false;
                passable               = true;
                sound_absorbtion_value = 2;
                if (random_variation <= 50)
                {
                    my_Texture = relevant_textures[0];
                }
                else
                {
                    my_Texture = relevant_textures[1];
                }
                break;

            case Tile_Type.DirtWall:
                opaque                 = true;
                deflect_sound          = true;
                passable               = false;
                sound_absorbtion_value = 3;
                if (random_variation < 15)
                {
                    my_Texture = relevant_textures[2];
                }
                else if (random_variation >= 15 && random_variation <= 57)
                {
                    my_Texture = relevant_textures[1];
                }
                else
                {
                    my_Texture = relevant_textures[0];
                }
                break;

            case Tile_Type.Rubble_Floor:
                opaque                 = false;
                deflect_sound          = false;
                passable               = true;
                sound_absorbtion_value = 1;
                my_Texture             = relevant_textures[0];
                break;

            case Tile_Type.Rubble_Wall:
                opaque                 = true;
                deflect_sound          = true;
                passable               = false;
                sound_absorbtion_value = 2;
                my_Texture             = relevant_textures[0];
                break;

            case Tile_Type.Dungeon_Exit:
                opaque                 = false;
                deflect_sound          = false;
                passable               = true;
                sound_absorbtion_value = 1;
                my_Texture             = relevant_textures[0];
                break;

            case Tile_Type.Locked_Dungeon_Exit:
                opaque                 = false;
                deflect_sound          = false;
                passable               = false;
                sound_absorbtion_value = 2;
                my_Texture             = relevant_textures[1];
                break;

            case Tile_Type.Gravel:
                opaque                 = false;
                deflect_sound          = false;
                passable               = true;
                sound_absorbtion_value = 2;
                my_Texture             = relevant_textures[0];
                break;

            case Tile_Type.Shallow_Blood:
            case Tile_Type.Shallow_Water:
                opaque                 = false;
                deflect_sound          = false;
                passable               = true;
                sound_absorbtion_value = 1;
                my_Texture             = relevant_textures[0];
                break;

            case Tile_Type.Deep_Water:
                opaque                 = false;
                deflect_sound          = false;
                passable               = false;
                sound_absorbtion_value = 1;
                my_Texture             = relevant_textures[0];
                break;

            case Tile_Type.Void:
            default:
                opaque                 = true;
                deflect_sound          = false;
                passable               = false;
                sound_absorbtion_value = 1000;
                my_Texture             = relevant_textures[0];
                break;
            }
        }
Beispiel #13
0
 /// <summary>
 /// Set the tile at position [x, y] to type
 /// </summary>
 /// <param name="x">position in x</param>
 /// <param name="y">position in y</param>
 /// <param name="type">tile type</param>
 public void set(int x, int y, Tile_Type type)
 {
     map[x, y] = type;
 }