@ -0,0 +1,66 @@
|
|||||||
|
package com.example.shakecraft
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.navigation.fragment.findNavController
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.example.shakecraft.model.RecipeManager
|
||||||
|
import com.example.shakecraft.view.adapter.AdapterRecipe
|
||||||
|
|
||||||
|
|
||||||
|
class ForgeFragment : Fragment() {
|
||||||
|
private lateinit var buttonBack: TextView
|
||||||
|
private lateinit var recyclerViewObjects: RecyclerView
|
||||||
|
private lateinit var recyclerViewTools: RecyclerView
|
||||||
|
private lateinit var recyclerViewBlacksmithing: RecyclerView
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
}
|
||||||
|
private fun initializeViews(view: View) {
|
||||||
|
buttonBack = view.findViewById<TextView>(R.id.backbutton)
|
||||||
|
buttonBack.setOnClickListener{
|
||||||
|
findNavController().navigate(R.id.action_forgeFragment_to_homeFragment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
val view = inflater.inflate(R.layout.fragment_forge, container, false)
|
||||||
|
|
||||||
|
// Initialize views
|
||||||
|
initializeViews(view)
|
||||||
|
|
||||||
|
setUpRecyclerView(view)
|
||||||
|
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpRecyclerView(view: View) {
|
||||||
|
recyclerViewObjects = view.findViewById(R.id.RecyclerviewObjects)
|
||||||
|
with(recyclerViewObjects) {
|
||||||
|
layoutManager = LinearLayoutManager(view.context)
|
||||||
|
adapter = AdapterRecipe(RecipeManager.recipeListObjects)
|
||||||
|
}
|
||||||
|
recyclerViewTools = view.findViewById(R.id.RecyclerviewTools)
|
||||||
|
with(recyclerViewTools) {
|
||||||
|
layoutManager = LinearLayoutManager(view.context)
|
||||||
|
adapter = AdapterRecipe(RecipeManager.recipeListTools)
|
||||||
|
}
|
||||||
|
recyclerViewBlacksmithing = view.findViewById(R.id.RecyclerviewBlacksmithing)
|
||||||
|
with(recyclerViewBlacksmithing) {
|
||||||
|
layoutManager = LinearLayoutManager(view.context)
|
||||||
|
adapter = AdapterRecipe(RecipeManager.recipeListBlacksmithing)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.shakecraft.model
|
package com.example.shakecraft.model
|
||||||
|
|
||||||
class Recipe(val item: Item, val quantity: Int, itemsNeeded : List<Item>) {
|
class Recipe(val item: Item, val ingredients : List<Item>, val type: String) {
|
||||||
}
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package com.example.shakecraft.model
|
||||||
|
|
||||||
|
import com.example.shakecraft.R
|
||||||
|
|
||||||
|
class RecipeManager {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
var recipeListObjects : List<Recipe> = listOf(
|
||||||
|
Recipe(
|
||||||
|
Item("Wooden Stick", image = R.drawable.wooden_stick, stack = 1),listOf(
|
||||||
|
Item("Wooden Plank", image = R.drawable.wooden_plank, stack = 2)
|
||||||
|
), "Objects"),
|
||||||
|
Recipe(
|
||||||
|
Item("Wooden Plank", image = R.drawable.wooden_plank, stack = 4),listOf(
|
||||||
|
Item("Beech Log", image = R.drawable.log2, stack = 2)
|
||||||
|
), "Objects"),
|
||||||
|
Recipe(
|
||||||
|
Item("Wooden Ball", image = R.drawable.wooden_ball, stack = 1),listOf(
|
||||||
|
Item("Wooden Stick", image = R.drawable.wooden_stick, stack = 2),
|
||||||
|
Item("Wooden Plank", image = R.drawable.wooden_plank, stack = 2)
|
||||||
|
), "Objects"),
|
||||||
|
|
||||||
|
)
|
||||||
|
var recipeListTools : List<Recipe> = listOf(
|
||||||
|
|
||||||
|
Recipe(
|
||||||
|
Item("Bronze Sword", image = R.drawable.bronze_sword, stack = 1),listOf(
|
||||||
|
Item("Wooden Stick", image = R.drawable.wooden_stick, stack = 5),
|
||||||
|
Item("Bronze Ingot", image = R.drawable.bronze_ore, stack = 10)
|
||||||
|
|
||||||
|
), "Tools"),
|
||||||
|
Recipe(
|
||||||
|
Item("Wizard Staff", image = R.drawable.wizard_staff, stack = 1),listOf(
|
||||||
|
Item("Wooden Stick", image = R.drawable.wooden_stick, stack = 10),
|
||||||
|
Item("Monster Eye", image = R.drawable.monster_eyes, stack = 20),
|
||||||
|
|
||||||
|
), "Tools"),
|
||||||
|
Recipe(
|
||||||
|
Item("Diamond Axe", image = R.drawable.diamond_axe, stack = 1),listOf(
|
||||||
|
Item("Wooden Stick", image = R.drawable.wooden_stick, stack = 5),
|
||||||
|
Item("Diamond", image = R.drawable.diamond, stack = 10),
|
||||||
|
|
||||||
|
), "Tools"),
|
||||||
|
)
|
||||||
|
var recipeListBlacksmithing : List<Recipe> = listOf(
|
||||||
|
|
||||||
|
Recipe(
|
||||||
|
Item("Bronze Ingot", image = R.drawable.bronze_ingot, stack = 1),listOf(
|
||||||
|
Item("Bronze Ore", image = R.drawable.bronze_ore, stack = 5)
|
||||||
|
|
||||||
|
), "Blacksmithing"),
|
||||||
|
Recipe(
|
||||||
|
Item("Iron Ingot", image = R.drawable.iron_ingot, stack = 1),listOf(
|
||||||
|
Item("Iron Ore", image = R.drawable.iron_ore, stack = 5)
|
||||||
|
|
||||||
|
), "Blacksmithing"),
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun isCraftable(recipe: Recipe, player: Player): Boolean{
|
||||||
|
for (ingredient in recipe.ingredients) {
|
||||||
|
if (!player.hasItem(ingredient)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.example.shakecraft.view.adapter
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.example.shakecraft.R
|
||||||
|
import com.example.shakecraft.model.Recipe
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class AdapterRecipe(private val recipelist: List<Recipe>) : RecyclerView.Adapter<AdapterRecipe.ViewHolder>() {
|
||||||
|
|
||||||
|
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
|
val textView: TextView
|
||||||
|
var imageView: ImageView
|
||||||
|
|
||||||
|
|
||||||
|
init {
|
||||||
|
// Define click listener for the ViewHolder's View
|
||||||
|
|
||||||
|
textView = view.findViewById(R.id.item_name)
|
||||||
|
imageView = view.findViewById(R.id.item_image)
|
||||||
|
}
|
||||||
|
fun bind(recipe: Recipe) {
|
||||||
|
textView.text = recipe.item.name
|
||||||
|
imageView.setImageResource(recipe.item.image)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() = recipelist.size
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
val view = LayoutInflater.from(parent.context)
|
||||||
|
.inflate(R.layout.list_item, parent, false)
|
||||||
|
|
||||||
|
return ViewHolder(view)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
|
||||||
|
val recipe : Recipe = recipelist[position]
|
||||||
|
viewHolder.bind(recipe)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.8 KiB |
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@color/grey_500"/>
|
||||||
|
<corners
|
||||||
|
android:topLeftRadius="5dp"
|
||||||
|
android:topRightRadius="5dp"
|
||||||
|
android:bottomLeftRadius="5dp"
|
||||||
|
android:bottomRightRadius="5dp"/>
|
||||||
|
</shape>
|
@ -0,0 +1,4 @@
|
|||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@color/black_800"/>
|
||||||
|
<item android:drawable="@drawable/roundedreciplistcard"/>
|
||||||
|
</layer-list>
|
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@color/grey"/>
|
||||||
|
<corners
|
||||||
|
android:topLeftRadius="19dp"
|
||||||
|
android:topRightRadius="19dp"
|
||||||
|
android:bottomLeftRadius="19dp"
|
||||||
|
android:bottomRightRadius="19dp"/>
|
||||||
|
</shape>
|
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 2.3 KiB |
@ -0,0 +1,155 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/black_800"
|
||||||
|
android:scaleType="center"
|
||||||
|
tools:context=".CollectFragment">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/frameLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingTop="50dp"
|
||||||
|
android:paddingBottom="20dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
android:layout_marginBottom="20dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/backbutton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="left|center_vertical"
|
||||||
|
android:focusable="true"
|
||||||
|
android:drawableStart="@drawable/back"
|
||||||
|
android:drawableTint="@color/blue"
|
||||||
|
android:text="Home"
|
||||||
|
android:textColor="@color/blue"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:text="Ancient Forge"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/RecipeScroll"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="635dp"
|
||||||
|
android:paddingHorizontal="10dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/frameLayout">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<LinearLayout
|
||||||
|
android:background="@drawable/recipelistcard"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginVertical="10dp"
|
||||||
|
android:paddingBottom="10dp">
|
||||||
|
<TextView
|
||||||
|
android:paddingTop="20dp"
|
||||||
|
android:paddingLeft="20dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="17dp"
|
||||||
|
android:textColor="@color/grey_400"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="Objects"/>
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:overScrollMode="never"
|
||||||
|
android:id="@+id/RecyclerviewObjects"
|
||||||
|
android:layout_marginHorizontal="20dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:listitem="@layout/list_recipe"
|
||||||
|
tools:itemCount="3"/>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:background="@drawable/recipelistcard"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginVertical="10dp"
|
||||||
|
android:paddingBottom="10dp">
|
||||||
|
<TextView
|
||||||
|
android:paddingTop="20dp"
|
||||||
|
android:paddingLeft="20dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="17dp"
|
||||||
|
android:textColor="@color/grey_400"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="Tools"/>
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:overScrollMode="never"
|
||||||
|
android:id="@+id/RecyclerviewTools"
|
||||||
|
android:layout_marginHorizontal="20dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:listitem="@layout/list_recipe"
|
||||||
|
tools:itemCount="3"/>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:background="@drawable/recipelistcard"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginVertical="10dp"
|
||||||
|
android:paddingBottom="10dp">
|
||||||
|
<TextView
|
||||||
|
android:paddingTop="20dp"
|
||||||
|
android:paddingLeft="20dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="17dp"
|
||||||
|
android:textColor="@color/grey_400"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="Blacksmithing"/>
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/RecyclerviewBlacksmithing"
|
||||||
|
android:overScrollMode="never"
|
||||||
|
android:layout_marginHorizontal="20dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:listitem="@layout/list_recipe"
|
||||||
|
tools:itemCount="3"/>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:focusable="true"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginVertical="8dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:contentDescription="image of item"
|
||||||
|
android:background="@drawable/item_recipe_background"
|
||||||
|
android:id="@+id/item_image"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
app:srcCompat="@drawable/wooden_stick" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/item_name"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:text="Wooden Stick"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_above="@+id/bottomNav"
|
||||||
|
android:background="@color/grey_delimiter"></View>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|