Example #1
0
    public void GenerateVisuals()
    {
        GameObject container = transform.Find("Visuals").gameObject;

        for (int i = 0; i < container.transform.childCount; i++)
        {
            Destroy(container.transform.GetChild(i).gameObject);
        }
        SpriteMetarial newVisual = Instantiate(m_Prefab, transform.position, m_Prefab.transform.rotation, container.transform);

        newVisual.SetSprite(m_SpriteIndex);
        m_Visual = newVisual.GetComponent <Renderer>();
    }
Example #2
0
    public void SetType2D(TileType2D t, int index)
    {
        m_TileType2D  = t;
        m_SpriteIndex = index;
        m_Impassible  = false;
        switch (t)
        {
        case TileType2D.Impassible:
            m_MovementCost = 9999;
            m_Impassible   = true;
            m_Prefab       = TilePrefabHolder.m_Instance.m_TileImpassiblePrefab;
            break;

        case TileType2D.Road:
            m_MovementCost = 1;
            m_DefenseRate  = 0;
            m_Prefab       = TilePrefabHolder.m_Instance.m_TileRoadPrefab;
            break;

        case TileType2D.Plain:
            m_MovementCost = 1.5f;
            m_DefenseRate  = 10;
            m_Prefab       = TilePrefabHolder.m_Instance.m_TilePlainPrefab;
            break;

        case TileType2D.Wasteland:
            m_MovementCost = 3;
            m_DefenseRate  = 30;
            m_Prefab       = TilePrefabHolder.m_Instance.m_TileWastelandPrefab;
            break;

        case TileType2D.Villa:
            m_MovementCost = 1;
            m_DefenseRate  = 50;
            m_Prefab       = TilePrefabHolder.m_Instance.m_TileVillaPrefab;
            break;

        case TileType2D.Forest:
            m_MovementCost = 2;
            m_DefenseRate  = 40;
            m_Prefab       = TilePrefabHolder.m_Instance.m_TileTreePrefab;
            break;
        }
        GenerateVisuals();
    }