Compare commits

..

No commits in common. 'master' and 'change_to_navgraph' have entirely different histories.

@ -1,24 +0,0 @@
kind: pipeline
type: docker
name: ShakeAndCraft
trigger:
event:
- push
steps:
- name: code-analysis
image: openjdk:8-jdk
environment:
SONAR_TOKEN:
from_secret: SONAR_TOKEN
settings:
sources: ./src/
commands:
- export SONAR_SCANNER_VERSION=4.7.0.2747
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
- export SONAR_SCANNER_OPTS="-server"
- sonar-scanner -D sonar.projectKey=ShakeAndCraft -D sonar.sources=. -D sonar.host.url=https://codefirst.iut.uca.fr/sonar

@ -7,4 +7,11 @@
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="VisualizationToolProject">
<option name="state">
<ProjectState>
<option name="scale" value="0.2" />
</ProjectState>
</option>
</component>
</project>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

@ -1,23 +1,14 @@
<p align="center">
<img src="https://codefirst.iut.uca.fr/git/lucas.delanier/ShakeAndCraft/raw/branch/master/Documentations/banner.png" />
<img src="https://codefirst.iut.uca.fr/git/lucas.delanier/ShakeAndCraft/raw/branch/master/Documentations/banner-shakeandcraft.png" />
</p>
![Kotlin](https://img.shields.io/badge/Kotlin-7F52FF.svg?style=for-the-badge&logo=Kotlin&logoColor=white)
![Android Studio](https://img.shields.io/badge/Android%20Studio-3DDC84.svg?style=for-the-badge&logo=Android-Studio&logoColor=white)
![Android](https://img.shields.io/badge/Android-3DDC84.svg?style=for-the-badge&logo=Android&logoColor=white)</br>
![Android](https://img.shields.io/badge/Android-3DDC84.svg?style=for-the-badge&logo=Android&logoColor=white)
[![Maintainability Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=sqale_rating&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
[![Security Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=security_rating&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
[![Reliability Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=reliability_rating&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
[![Vulnerabilities](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=vulnerabilities&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
[![Code Smells](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=code_smells&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
[![Bugs](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=bugs&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
[![Technical Debt](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=sqale_index&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
[![Duplicated Lines (%)](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=duplicated_lines_density&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
**ShakeAndCraft** est un jeu mobile de type RPG dans lequel vous etes invités a secouer votre téléphone pour récuperer des ressources ainsi que combattre des boss surpuissants. Vous y découvrirais également un systeme de craft et d'évenement relié a la météo en temps réel.
## :floppy_disk: FEATURES
@ -34,42 +25,23 @@ La page "Dungeon" est une page de jeu dans laquelle le joueur doit secouer son t
![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
## :bar_chart: distribution of work
- ✅ Fragment Home : Lucas Delanier <img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Fragment Craft : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Fragment Forge : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Fragment Boss : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Fragment Collect : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Gestion de la rotation de l'écran Home fragment : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Gestion du capteur Accélérometre : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ RecyclerView, Adapter, viewholder : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ ViewModel : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ LiveData : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Model, Player, Item, Tool, Boss, ItemManager, Generator : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Requete API, retrofit : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- 👷 Persistence profonde : Lucas Delanier, Theo Renaud<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"><img src ="https://codefirst.iut.uca.fr/git/avatars/af9299d66a9a0bf7be17f8dc156f67b9?size=870" height="20px"></br>
## :dizzy: Getting Started
Une fois le dépot cloné, vous pouvez lancer le code sur votre téléphone Android grace a l'outil Android studio ou grace a un émulateur android.
## :gift: OverView
<p align="center">
<img src="https://codefirst.iut.uca.fr/git/lucas.delanier/ShakeAndCraft/raw/branch/master/Documentations/overview-shakeandcraft.png" />
</p>
## :wrench: SUPPORT
En cas de problème lors de l'utilisation de l'application, vous pouvez nous contacer aux adresses suivantes :
Lucas Delanier : **lucas.delanier@etu.uca.fr** </br>
Théo Renaud : **Theo.RENAUD@etu.uca.fr**
![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
## ✨ Contributors
@ -77,9 +49,6 @@ Théo Renaud : **Theo.RENAUD@etu.uca.fr**
<a href = "https://codefirst.iut.uca.fr/git/lucas.delanier">
<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="50px">
</a>
<a href = "https://codefirst.iut.uca.fr/git/theo.renaud">
<img src ="https://codefirst.iut.uca.fr/git/avatars/af9299d66a9a0bf7be17f8dc156f67b9?size=870" height="50px">
</a>

@ -1,186 +0,0 @@
package com.example.shakecraft
import android.content.Context
import android.content.pm.ActivityInfo
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import android.os.Bundle
import android.os.Vibrator
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.Animation
import android.view.animation.ScaleAnimation
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.TextView
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.shakecraft.model.Boss
import com.example.shakecraft.model.Generator
import com.example.shakecraft.model.Item
import com.example.shakecraft.model.Player
import com.example.shakecraft.view.adapter.AdapterBossLoot
import com.example.shakecraft.viewmodel.MainViewModel
import kotlin.math.pow
import kotlin.math.sqrt
class BossFragment() : Fragment() {
private lateinit var sensorManager: SensorManager
private lateinit var accelerometer: Sensor
private lateinit var accelerometerEventListener: SensorEventListener
private lateinit var progressBar: ProgressBar
private lateinit var image: ImageView
private lateinit var buttonCollect: TextView
private lateinit var recyclerView: RecyclerView
val viewModel : MainViewModel by activityViewModels<MainViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_boss, container, false)
// Initialize views
initializeViews(view)
// Set up boss
if(!viewModel.isBossInitialized)
viewModel.currentBoss = Generator.generateBoss()
setUpBoss(viewModel.currentBoss)
// Set up RecyclerView for boss loot
setUpRecyclerView(view)
// Set up accelerometer listener
viewModel.currentPlayer.value?.let { setUpAccelerometerListener(view, it) }
// Set up activity orientation
setUpActivityOrientation()
// Return fragment view
return view
}
private fun initializeViews(view: View) {
progressBar = view.findViewById(R.id.progressBar)
image = view.findViewById(R.id.imageBoss)
buttonCollect = view.findViewById<TextView>(R.id.backbutton)
buttonCollect.setOnClickListener{
findNavController().navigate(R.id.action_bossFragment_to_homeFragment)
}
}
private fun setUpBoss(boss: Boss) {
progressBar.max = boss.maxlife
progressBar.progress = boss.life.toInt()
image.setImageResource(boss.image)
// Create scale animation for boss image
val scaleAnimation = ScaleAnimation(
1.2f, // from 1.2 to 1.0
1.0f,
1.2f,
1.0f,
Animation.RELATIVE_TO_SELF,
0.5f,
Animation.RELATIVE_TO_SELF,
0.5f
)
scaleAnimation.duration = 1000 // lasts 1 second
scaleAnimation.repeatCount = Animation.INFINITE // repeat indefinitely
scaleAnimation.repeatMode = Animation.REVERSE // reverse animation direction
image.startAnimation(scaleAnimation)
}
private fun setUpRecyclerView(view: View) {
recyclerView = view.findViewById(R.id.recyclerviewBossLoot)
with(recyclerView) {
layoutManager = LinearLayoutManager(view.context)
adapter = AdapterBossLoot(viewModel.currentBoss.possibleLoot)
}
}
private fun setUpActivityOrientation(){
val activity = requireActivity()
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
private fun displayToast(view: View, item: Item){
val toastView = view.findViewById<View>(R.id.toast)
val lootImage = toastView.findViewById<ImageView>(R.id.imageViewLoot)
val lootName = toastView.findViewById<TextView>(R.id.nameLoot)
val xpReward = toastView.findViewById<TextView>(R.id.xpRewarded)
toastView.visibility = View.VISIBLE
lootImage.setImageResource(item.type.image)
lootName.text = item.type.name
xpReward.text = viewModel.currentBoss.xpReward.toString()
toastView.postDelayed({
toastView.visibility = View.GONE
}, 3000)
}
private fun setUpAccelerometerListener(view: View, currentPlayer: Player) {
sensorManager = requireActivity().getSystemService(Context.SENSOR_SERVICE) as SensorManager
accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
accelerometerEventListener = object : SensorEventListener {
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
// Do nothing
}
override fun onSensorChanged(event: SensorEvent?) {
val acceleration = sqrt(event!!.values[0].pow(2) + event.values[1].pow(2) + event.values[2].pow(2))
if (viewModel.currentBoss.life <= 0) {
//Vibration to signal the death of the boss
val vibrator = context?.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
vibrator.vibrate(100)
// Generate a loot item and XP reward
val item = Generator.generateLootBoss(viewModel.currentBoss.possibleLoot)
currentPlayer.addItem(item)
currentPlayer.gainXp(viewModel.currentBoss.xpReward)
// Show loot toast view for 3 seconds
displayToast(view,item)
// Spawn new boss and reset progress bar
viewModel.currentBoss = Generator.generateBoss()
setUpBoss(viewModel.currentBoss)
//Update displayed information
setUpRecyclerView(view)
} else {
if(acceleration > 20){
viewModel.currentBoss.takeDamage(((acceleration / 80)+ currentPlayer.attack()/100).toDouble())
}
else{
viewModel.currentBoss.takeDamage(currentPlayer.attack().toDouble()/100)
}
progressBar.progress = viewModel.currentBoss.life.toInt()
}
}
}
// Register accelerometer sensor earphone with manager
sensorManager.registerListener(
accelerometerEventListener,
accelerometer,
SensorManager.SENSOR_DELAY_GAME
)
}
override fun onDestroy() {
super.onDestroy()
// Unregister the accelerometer sensor listener when the fragment is destroyed
sensorManager.unregisterListener(accelerometerEventListener)
val activity = requireActivity()
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
}
}

@ -1,102 +0,0 @@
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.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Observer
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.shakecraft.model.Player
import com.example.shakecraft.model.Recipe
import com.example.shakecraft.model.RecipeManager
import com.example.shakecraft.view.adapter.AdapterMaterials
import com.example.shakecraft.viewmodel.MainViewModel
class CraftFragment : Fragment() {
private lateinit var buttonBack: TextView
private lateinit var recyclerViewMaterials: RecyclerView
private lateinit var recipe: Recipe
private lateinit var image: ImageView
private lateinit var name: TextView
private lateinit var buttonForge: Button
private lateinit var buttonForgeMax: Button
private lateinit var numberCraftable: TextView
private lateinit var craftValue : TextView
private val viewModel : MainViewModel by activityViewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_craft, container, false)
recipe = arguments?.getParcelable("recipe")!!
viewModel.currentPlayer.observe(this.viewLifecycleOwner, Observer {player ->
initializeViews(view, player)
setUpRecyclerView(view, player)
})
return view
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
private fun setUpRecyclerView(view: View, currentPlayer: Player) {
recyclerViewMaterials = view.findViewById(R.id.RecyclerviewMaterials)
with(recyclerViewMaterials) {
layoutManager = LinearLayoutManager(view.context)
adapter = AdapterMaterials(recipe.ingredients, currentPlayer)
}
}
private fun initializeViews(view: View, currentPlayer: Player) {
buttonBack = view.findViewById(R.id.backbutton)
buttonForge = view.findViewById(R.id.buttonForge)
buttonForgeMax = view.findViewById(R.id.buttonForgeMax)
numberCraftable = view.findViewById(R.id.craftableNumber)
craftValue = view.findViewById(R.id.craftValue)
buttonBack.setOnClickListener{
findNavController().navigate(R.id.action_craftFragment_to_forgeFragment)
}
image = view.findViewById(R.id.item_image)
name = view.findViewById(R.id.item_name)
image.setImageResource(recipe.item.type.image)
name.text = recipe.item.type.name
buttonForge.isEnabled = RecipeManager.isCraftable(recipe,currentPlayer)
buttonForgeMax.isEnabled = RecipeManager.isCraftable(recipe,currentPlayer)
numberCraftable.text = RecipeManager.HowManyCraftable(recipe,currentPlayer).toString()
craftValue.text = recipe.item.stack.toString()
buttonForge.setOnClickListener{
viewModel.craft(recipe)
}
buttonForgeMax.setOnClickListener{
viewModel.craft(recipe, RecipeManager.HowManyCraftable(recipe, currentPlayer))
}
}
}

@ -1,84 +0,0 @@
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.core.os.bundleOf
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.shakecraft.model.Recipe
import com.example.shakecraft.model.RecipeManager
import com.example.shakecraft.view.adapter.AdapterRecipe
class ForgeFragment : Fragment(), AdapterRecipe.OnItemClickListener {
private lateinit var buttonBack: TextView
private lateinit var recyclerViewObjects: RecyclerView
private lateinit var recyclerViewTools: RecyclerView
private lateinit var recyclerViewBlacksmithing: RecyclerView
private lateinit var recipe: Recipe
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onItemClick(position: Int, type: String) {
recipe = when(type){
"Objects" -> RecipeManager.recipeListObjects[position]
"Tools" -> RecipeManager.recipeListTools[position]
"Blacksmithing" -> RecipeManager.recipeListBlacksmithing[position]
else -> {RecipeManager.recipeListObjects[position]}
}
val bundle = bundleOf("recipe" to recipe)
findNavController().navigate(R.id.action_forgeFragment_to_craftFragment, bundle)
}
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, this)
return view
}
private fun setUpRecyclerView(view: View, listener: AdapterRecipe.OnItemClickListener) {
recyclerViewObjects = view.findViewById(R.id.RecyclerviewObjects)
with(recyclerViewObjects) {
layoutManager = LinearLayoutManager(view.context)
adapter = AdapterRecipe(RecipeManager.recipeListObjects, listener)
}
recyclerViewTools = view.findViewById(R.id.RecyclerviewTools)
with(recyclerViewTools) {
layoutManager = LinearLayoutManager(view.context)
adapter = AdapterRecipe(RecipeManager.recipeListTools, listener)
}
recyclerViewBlacksmithing = view.findViewById(R.id.RecyclerviewBlacksmithing)
with(recyclerViewBlacksmithing) {
layoutManager = LinearLayoutManager(view.context)
adapter = AdapterRecipe(RecipeManager.recipeListBlacksmithing, listener)
}
}
}

@ -1,124 +0,0 @@
package com.example.shakecraft
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Observer
import androidx.navigation.NavOptions
import androidx.navigation.fragment.findNavController
import com.example.shakecraft.model.Player
import com.example.shakecraft.viewmodel.MainViewModel
class HomeFragment : Fragment() {
private lateinit var pseudoEditText : EditText
private lateinit var progressbar : ProgressBar
private lateinit var level : TextView
private lateinit var rank : TextView
private lateinit var maxXp : TextView
private lateinit var xp : TextView
private lateinit var buttonCollect : ConstraintLayout
private lateinit var buttonBoss : ConstraintLayout
private lateinit var buttonForge : ConstraintLayout
private lateinit var playermage : ImageView
private lateinit var equipeditem: ImageView
private lateinit var eventFishing: ImageView
val viewModel : MainViewModel by activityViewModels<MainViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val isRaining = (activity as MainActivity).isRaining
val view = inflater.inflate(R.layout.fragment_home,container,false)
// Initialize views
viewModel.currentPlayer.observe(viewLifecycleOwner, Observer {
initializeViews(view, it, isRaining)
})
return view
}
/*fun loadWeatherDate(){
CoroutineScope(Dispatchers.IO).launch {
val
}
}*/
private fun initializeViews(view: View, currentPlayer : Player, isRaining : Boolean) {
progressbar = view.findViewById(R.id.levelProgressBar)
level = view.findViewById(R.id.levelTextView)
rank = view.findViewById(R.id.rankTextView)
maxXp = view.findViewById(R.id.maxXpTextView)
xp = view.findViewById(R.id.xpTextView)
playermage = view.findViewById(R.id.playerImage)
buttonCollect = view.findViewById(R.id.buttonCollect)
equipeditem = view.findViewById(R.id.equipedItemAttack)
eventFishing = view.findViewById(R.id.buttonFishing)
buttonCollect.setOnClickListener{
findNavController().navigate(R.id.action_homeFragment_to_collectFragment, null, NavOptions.Builder().setPopUpTo(R.id.homeFragment, false).build())
}
buttonBoss = view.findViewById(R.id.buttonBoss)
buttonBoss.setOnClickListener{
findNavController().navigate(R.id.action_homeFragment_to_bossFragment, null, NavOptions.Builder().setPopUpTo(R.id.homeFragment, false).build())
}
buttonForge = view.findViewById(R.id.buttonForge)
buttonForge.setOnClickListener{
findNavController().navigate(R.id.action_homeFragment_to_forgeFragment, null, NavOptions.Builder().setPopUpTo(R.id.homeFragment, false).build())
}
level.text = currentPlayer.level.toString()
rank.text = currentPlayer.rank
xp.text = currentPlayer.xp.toString()
maxXp.text = (currentPlayer.level*100).toString()
progressbar.progress = currentPlayer.xp
progressbar.max = currentPlayer.level*100
playermage.setImageResource(currentPlayer.image)
if(currentPlayer.equipedItem?.type?.image != null) {
equipeditem.setImageResource(currentPlayer.equipedItem!!.type.image)
}
if(isRaining){
eventFishing.visibility = View.VISIBLE
}
pseudoEditText = view.findViewById(R.id.pseudoEditText)
pseudoEditText.setText(currentPlayer.pseudo)
pseudoEditText.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
/*
do nothing
*/
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
/*
do nothing
*/
}
override fun afterTextChanged(s: Editable?) {
currentPlayer.pseudo = s.toString()
}
})
}
}

@ -1,62 +0,0 @@
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.Toast
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.shakecraft.model.Tool
import com.example.shakecraft.view.adapter.AdapterInventory
import com.example.shakecraft.viewmodel.MainViewModel
class InventoryFragment() : Fragment( ), AdapterInventory.OnItemLongClickListener {
private lateinit var recyclerView: RecyclerView
val viewModel : MainViewModel by activityViewModels<MainViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onItemLongClick(position: Int) {
if (viewModel.currentPlayer.value!!.items[position] is Tool) {
val text = if (viewModel.equipeItem(viewModel.currentPlayer.value!!.items[position]) ) " was well equipped" else " has been well unequipped"
Toast.makeText(
context,
viewModel.currentPlayer.value!!.items[position].type.name + text,
Toast.LENGTH_SHORT
).show()
setUpRecyclerView(view?.parent as ViewGroup, this)
}
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_inventory, container, false)
// Initialize views
setUpRecyclerView(view, this)
return view
}
private fun setUpRecyclerView(view: View,listener: AdapterInventory.OnItemLongClickListener ) {
recyclerView = view.findViewById(R.id.recyclerviewInventory)
with(recyclerView) {
layoutManager = LinearLayoutManager(view.context)
adapter = viewModel.currentPlayer.value?.let {
AdapterInventory(viewModel.currentPlayer.value!!.items, listener ,
it
)
}
}
}
}

@ -1,100 +0,0 @@
package com.example.shakecraft
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import androidx.activity.viewModels
import androidx.annotation.RequiresApi
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import androidx.navigation.findNavController
import androidx.navigation.ui.NavigationUI
import androidx.navigation.ui.setupWithNavController
import com.example.shakecraft.services.OpenWeatherMapService
import com.example.shakecraft.viewmodel.MainViewModel
import com.google.android.material.bottomnavigation.BottomNavigationView
import kotlinx.coroutines.*
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
class MainActivity: AppCompatActivity() {
var isRaining = false
private val model: MainViewModel by viewModels()
@RequiresApi(Build.VERSION_CODES.R)
private fun hideSystemUI() {
WindowCompat.setDecorFitsSystemWindows(window, false)
WindowInsetsControllerCompat(window,
window.decorView.findViewById(android.R.id.content)).let { controller ->
controller.hide(WindowInsetsCompat.Type.systemBars())
controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
}
private lateinit var bottomNav : BottomNavigationView
@RequiresApi(Build.VERSION_CODES.R)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
hideSystemUI()
setContentView(R.layout.activity_main)
val apiKey = "85a2724ad38b3994c2b7ebe1d239bbff"
val cityName = "Clermont-Ferrand"
val retrofit = Retrofit.Builder()
.baseUrl("https://api.openweathermap.org/data/2.5/")
.addConverterFactory(GsonConverterFactory.create())
.build()
val openWeatherMapService = retrofit.create(OpenWeatherMapService::class.java)
CoroutineScope(Dispatchers.IO).launch {
val weatherResponse = openWeatherMapService.getCurrentWeather(cityName, apiKey)
isRaining =
weatherResponse.weather.any { it.main.contains("rain", ignoreCase = true) }
println(isRaining)
}
bottomNav = findViewById(R.id.bottomNavigationView)
val navController = findNavController(R.id.fragment)
navController.popBackStack(R.id.fragment, false)
bottomNav.setupWithNavController(navController)
bottomNav.setOnItemReselectedListener { item ->
// Pop everything up to the reselected item
val reselectedDestinationId = item.itemId
navController.popBackStack(reselectedDestinationId, inclusive = false)
}
bottomNav.setOnItemSelectedListener { item ->
NavigationUI.onNavDestinationSelected(item, navController)
true
}
}
override fun onResume() {
super.onResume()
// Masquer la barre de navigation et la barre d'état
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
}
}

@ -1,45 +0,0 @@
package com.example.shakecraft
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
class PlusFragment : Fragment() {
private lateinit var buttonWiki : LinearLayout
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
val view = inflater.inflate(R.layout.fragment_plus, container, false)
// Initialize views
setUpRecyclerView(view)
return view
}
private fun setUpRecyclerView(view: View,) {
buttonWiki = view.findViewById(R.id.wikiButton)
buttonWiki.setOnClickListener{
val url = "https://codefirst.iut.uca.fr/git/lucas.delanier/ShakeAndCraft"
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(url)
intent.setPackage("com.android.chrome")
startActivity(intent)
}
}
}

@ -1,20 +0,0 @@
package com.example.shakecraft.data
import com.example.shakecraft.model.*
class Stub {
fun load() : Player{
val currentPlayer = Player("Winker",0)
currentPlayer.addItem(Item(type = ITEMS.BEECH_LOG.itemtype, stack = 30))
currentPlayer.addItem(Item(type = ITEMS.BRONZE_INGOT.itemtype, stack = 30))
currentPlayer.addItem(Tool(type = ITEMS.DIAMOND_AXE.itemtype, stack = 1, damage = 8))
return currentPlayer
}
}

@ -1,19 +0,0 @@
package com.example.shakecraft.data
data class WeatherResponse(
val weather: List<Weather>,
val info: Info
)
data class Weather(
val id: Int,
val main: String,
val description: String,
val icon: String
)
data class Info(
val temp: Double,
val feelsLike: Double,
val humidity: Int
)

@ -1,15 +0,0 @@
package com.example.shakecraft.data.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.example.shakecraft.model.Item
@Dao
interface ItemDao {
@Query("SELECT * FROM item")
suspend fun getAllItems(): List<Item>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertItem(item: Item)
}

@ -1,16 +0,0 @@
package com.example.shakecraft.data.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.example.shakecraft.model.Player
@Dao
interface PlayerDao {
@Query("SELECT * FROM player")
suspend fun getAllPlayers(): List<Player>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertPlayer(player: Player)
}

@ -1,16 +0,0 @@
package com.example.shakecraft.model
class Boss (
var name: String,
var life: Double,
var maxlife: Int,
var image: Int,
var xpReward: Int,
val possibleLoot: List<Pair<Item, Double>>,
){
fun takeDamage(strength: Double) {
this.life -= strength
}
}

@ -1,46 +0,0 @@
package com.example.shakecraft.model
import android.os.Parcel
import android.os.Parcelable
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "items")
open class Item(
val type: ItemType,
var stack: Int = 1,
) : Parcelable {
@PrimaryKey(autoGenerate = true) val id: String = type.name
override fun describeContents(): Int {
return 0
}
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeString(type.name)
parcel.writeInt(type.rarity)
parcel.writeInt(type.image)
parcel.writeInt(type.xpReward)
parcel.writeInt(stack)
}
companion object CREATOR : Parcelable.Creator<Item> {
override fun createFromParcel(parcel: Parcel): Item {
return Item(
ItemType(parcel.readString()!!,parcel.readInt(),
parcel.readInt(),
parcel.readInt(),),
parcel.readInt()
)
}
override fun newArray(size: Int): Array<Item?> {
return arrayOfNulls(size)
}
}
}

@ -1,31 +0,0 @@
package com.example.shakecraft.model
import com.example.shakecraft.R
enum class ITEMS(val itemtype: ItemType){
// Craftable items and resources
BEECH_LOG(ItemType(name = "Beech Log", image = R.drawable.log2, rarity = 1, xpReward = 10)),
WOODEN_STICK(ItemType(name = "Wooden Stick", image = R.drawable.wooden_stick, rarity = 1, xpReward = 0)),
WOODEN_PLANK(ItemType(name = "Wooden Plank", image = R.drawable.wooden_plank, rarity = 1, xpReward = 0)),
WOODEN_BALL(ItemType(name = "Wooden Ball", image = R.drawable.wooden_ball, rarity = 1, xpReward = 0)),
WIZARD_STAFF(ItemType(name = "Wizard Staff", image = R.drawable.wizard_staff, rarity = 3, xpReward = 0)),
DIAMOND(ItemType(name = "Diamond", image = R.drawable.diamond, rarity = 3, xpReward = 30)),
DIAMOND_AXE(ItemType(name = "Diamond Axe", image = R.drawable.diamond_axe, rarity = 3, xpReward = 0)),
BRONZE_ORE(ItemType(name = "Bronze Ore", image = R.drawable.bronze_ore, rarity = 2, xpReward = 20)),
BRONZE_INGOT(ItemType(name = "Bronze Ingot", image = R.drawable.bronze_ingot, rarity = 1, xpReward = 0)),
BRONZE_SWORD(ItemType(name = "Bronze Sword", image = R.drawable.bronze_sword, rarity = 2, xpReward = 0)),
IRON_ORE(ItemType(name = "Iron Ore", image = R.drawable.iron_ore, rarity = 2, xpReward = 25)),
IRON_INGOT(ItemType(name = "Iron Ingot", image = R.drawable.iron_ingot, rarity = 1, xpReward = 0)),
// Lootable items
MONSTER_BONES(ItemType(name = "Monster Bones", image = R.drawable.monster_bones, rarity = 1, xpReward = 10)),
MONSTER_EYE(ItemType(name = "Monster Eye", image = R.drawable.monster_eyes, rarity = 2, xpReward = 20)),
TREASURE_KEY(ItemType(name = "Treasure Key", image = R.drawable.treasure_key, rarity = 2, xpReward = 20)),
}

@ -1,6 +0,0 @@
package com.example.shakecraft.model
class ItemType (val name : String,val image : Int,val rarity : Int, val xpReward : Int){
}

@ -1,102 +0,0 @@
package com.example.shakecraft.model
import com.example.shakecraft.R
class Player(var pseudo: String, var xp: Int = 0) {
var level: Int = 1
private set
val image: Int = R.drawable.player_image
var items: MutableList<Item> = mutableListOf()
private set
var rank: String = "Beginner"
private set
var equipedItem : Tool? = null
private set
fun changeRank(){
this.rank = when(level){
in 1..2 -> "Beginner"
in 3..5 -> "Intermediate"
in 6..8 -> "Proficient"
in 9..11 -> "Expert"
in 12..14 -> "Master"
in 15..17 -> "Professional"
in 18..19 -> "Champion"
in 20..22 -> "Legend"
in 23..25 -> "Invincible"
else -> {"Divine"}
}
}
fun addItem(item: Item) {
val findItem = items.find { it.type.name == item.type.name }
if(findItem!= null){
findItem.stack += item.stack
}
else{
if(item is Tool){
items.add(Tool(type = item.type, stack = item.stack, 4))
}
else{
items.add(Item(type = item.type, stack = item.stack))
}
}
}
fun gainXp(xp: Int) {
this.xp += xp
if (this.xp >= this.level *100){
this.level +=1
this.xp = 0
changeRank()
}
}
fun attack() : Int{
if(equipedItem == null)
return 0
return equipedItem!!.damage
}
fun hasItem(item: Item) : Boolean{
for (playeritem in items){
if(playeritem.type.name == item.type.name && playeritem.stack >= item.stack){
return true
}
}
return false
}
fun craft(recipe: Recipe, count: Int = 1) : Boolean{
println("test")
for (i in 1..count) {
for (ingredient in recipe.ingredients) {
val searchedItem = items.find { it.type == ingredient.type }
if (searchedItem != null) {
searchedItem.stack -= ingredient.stack
if (searchedItem.stack == 0) {
items.remove(searchedItem)
}
}
}
println("item:" + recipe.item.stack)
addItem(recipe.item)
}
return true
}
fun equipeItem(item : Item) : Boolean{
if(equipedItem == item) {
println("ca jarte")
equipedItem = null
return false
}
equipedItem = item as Tool
return true
}
}

@ -1,29 +0,0 @@
package com.example.shakecraft.model
import android.os.Parcel
import android.os.Parcelable
class Recipe(val item: Item, val ingredients : List<Item>, val type: String) : Parcelable {
override fun describeContents(): Int {
return 0
}
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeParcelable(item, flags)
parcel.writeTypedList(ingredients)
parcel.writeString(type)
}
companion object CREATOR : Parcelable.Creator<Recipe> {
override fun createFromParcel(parcel: Parcel): Recipe {
return Recipe(
parcel.readParcelable(Item::class.java.classLoader)!!,
parcel.createTypedArrayList(Item.CREATOR)!!,
parcel.readString()!!
)
}
override fun newArray(size: Int): Array<Recipe?> {
return arrayOfNulls(size)
}
}
}

@ -1,91 +0,0 @@
package com.example.shakecraft.model
class RecipeManager {
companion object {
val recipeListObjects : List<Recipe> = listOf(
Recipe(
Item(type = ITEMS.WOODEN_STICK.itemtype, stack = 1),listOf(
Item(type = ITEMS.WOODEN_PLANK.itemtype, stack = 2)
), "Objects"),
Recipe(
Item(type = ITEMS.WOODEN_PLANK.itemtype, stack = 3),listOf(
Item(type = ITEMS.BEECH_LOG.itemtype, stack = 1)
), "Objects"),
Recipe(
Item(type = ITEMS.WOODEN_BALL.itemtype, stack = 1),listOf(
Item(type = ITEMS.WOODEN_STICK.itemtype, stack = 2),
Item(type = ITEMS.WOODEN_PLANK.itemtype, stack = 2)
), "Objects"),
)
val recipeListTools : List<Recipe> = listOf(
Recipe(
Tool(type = ITEMS.BRONZE_SWORD.itemtype, stack = 1, damage = 4),listOf(
Item(type = ITEMS.WOODEN_STICK.itemtype, stack = 5),
Item(type = ITEMS.BRONZE_INGOT.itemtype, stack = 10)
), "Tools"),
Recipe(
Tool(type = ITEMS.WIZARD_STAFF.itemtype, stack = 1, damage = 6),listOf(
Item(type = ITEMS.WOODEN_STICK.itemtype, stack = 10),
Item(type = ITEMS.MONSTER_EYE.itemtype, stack = 20),
), "Tools"),
Recipe(
Tool(type = ITEMS.DIAMOND_AXE.itemtype, stack = 1, damage = 8),listOf(
Item(type = ITEMS.WOODEN_STICK.itemtype, stack = 5),
Item(type = ITEMS.DIAMOND.itemtype, stack = 10),
), "Tools"),
)
val recipeListBlacksmithing : List<Recipe> = listOf(
Recipe(
Item(type = ITEMS.BRONZE_INGOT.itemtype, stack = 1),listOf(
Item(type = ITEMS.BRONZE_ORE.itemtype, stack = 5)
), "Blacksmithing"),
Recipe(
Item(type = ITEMS.IRON_INGOT.itemtype, stack = 1),listOf(
Item(type = ITEMS.IRON_ORE.itemtype, stack = 5)
), "Blacksmithing"),
)
fun isCraftable(recipe: Recipe, player: Player): Boolean{
for (ingredient in recipe.ingredients) {
if (!player.hasItem(ingredient)) {
return false
}
}
return true
}
fun HowManyCraftable(recipe: Recipe, player: Player): Int{
val divisedList = mutableListOf<Int>()
return if (!isCraftable(recipe,player)) 0
else{
for(element in recipe.ingredients){
val itemSearch = player.items.find { it.type.name == element.type.name }
if(itemSearch!= null)
divisedList.add(itemSearch.stack / element.stack)
}
divisedList.min()
}
}
}
}

@ -1,4 +0,0 @@
package com.example.shakecraft.model
class Tool(type : ItemType, stack: Int,val damage : Int) : Item(type, stack) {
}

@ -1,12 +0,0 @@
package com.example.shakecraft.services
import com.example.shakecraft.data.WeatherResponse
import retrofit2.http.GET
import retrofit2.http.Query
interface OpenWeatherMapService {
@GET("weather")
suspend fun getCurrentWeather(
@Query("q") cityName: String,
@Query("appid") apiKey: String
): WeatherResponse
}

@ -1,80 +0,0 @@
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.Item
import com.example.shakecraft.model.Player
import com.example.shakecraft.model.Tool
class AdapterInventory(
private val inventory: List<Item>,
private val listener: OnItemLongClickListener,
private val currentPlayer : Player
) :
RecyclerView.Adapter<AdapterInventory.ViewHolder>() {
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view), View.OnLongClickListener {
val textView: TextView
val textViewNumber: TextView
var imageView: ImageView
var armorIndicator : ImageView
init {
// Define click listener for the ViewHolder's View
itemView.setOnLongClickListener(this)
textView = view.findViewById(R.id.item_name)
textViewNumber = view.findViewById(R.id.item_stock)
imageView = view.findViewById(R.id.item_image)
armorIndicator = view.findViewById(R.id.armor_indicator)
}
override fun onLongClick(v: View?): Boolean {
val position = adapterPosition
if(position != RecyclerView.NO_POSITION) {
listener.onItemLongClick(position)
}
return true
}
fun bind(item: Item) {
textView.text = item.type.name
textViewNumber.text = item.stack.toString()
imageView.setImageResource(item.type.image)
if (item is Tool) {
println("tool")
armorIndicator.visibility = View.VISIBLE
if(currentPlayer.equipedItem == item) armorIndicator.setImageResource(R.drawable.armor_equiped_icon) else armorIndicator.setImageResource(R.drawable.armor_icon)
}
}
}
interface OnItemLongClickListener{
fun onItemLongClick(position: Int)
}
override fun getItemCount() = inventory.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 item : Item = inventory[position]
viewHolder.bind(item)
}
}

@ -1,65 +0,0 @@
package com.example.shakecraft.view.adapter
import android.graphics.Color
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.Item
import com.example.shakecraft.model.Player
class AdapterMaterials(private val materials: List<Item>, val currentplayer: Player) : RecyclerView.Adapter<AdapterMaterials.ViewHolder>() {
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val textView: TextView
val textViewNumberNeeded: TextView
val textViewNumberPlayer: TextView
var imageView: ImageView
init {
// Define click listener for the ViewHolder's View
textView = view.findViewById(R.id.item_name)
textViewNumberPlayer = view.findViewById(R.id.numberCurrentPlayer)
textViewNumberNeeded = view.findViewById(R.id.numberNeeded)
imageView = view.findViewById(R.id.item_image)
}
fun bind(item: Item, currentplayer: Player) {
textView.text = item.type.name
val itemSearch = currentplayer.items.find { it.type.name == item.type.name }
textViewNumberNeeded.text = item.stack.toString()
textViewNumberPlayer.text = itemSearch?.stack?.toString() ?: "0"
imageView.setImageResource(item.type.image)
if (itemSearch != null) {
if(item.stack > itemSearch.stack) textViewNumberPlayer.setTextColor(Color.RED) else textViewNumberPlayer.setTextColor(Color.WHITE)
}
else textViewNumberPlayer.setTextColor(Color.RED)
}
}
override fun getItemCount() = materials.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.list_craft, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
val item : Item = materials[position]
viewHolder.bind(item, currentplayer)
}
}

@ -1,66 +0,0 @@
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>,
private val listener: OnItemClickListener
) :
RecyclerView.Adapter<AdapterRecipe.ViewHolder>() {
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view), View.OnClickListener {
val textView: TextView
var imageView: ImageView
init {
// Define click listener for the ViewHolder's View
itemView.setOnClickListener(this)
textView = view.findViewById(R.id.item_name)
imageView = view.findViewById(R.id.item_image)
}
override fun onClick(v: View?) {
val position = adapterPosition
val type = recipelist.first().type
if(position != RecyclerView.NO_POSITION) {
listener.onItemClick(position, type)
}
}
fun bind(recipe: Recipe) {
textView.text = recipe.item.type.name
imageView.setImageResource(recipe.item.type.image)
}
}
interface OnItemClickListener{
fun onItemClick(position: Int, type: String)
}
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)
}
}

@ -1,39 +0,0 @@
package com.example.shakecraft.viewmodel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.example.shakecraft.data.Stub
import com.example.shakecraft.model.Boss
import com.example.shakecraft.model.Item
import com.example.shakecraft.model.Recipe
class MainViewModel : ViewModel() {
var currentPlayer = MutableLiveData(Stub().load())
lateinit var currentBoss : Boss
val isBossInitialized get() = this::currentBoss.isInitialized
fun craft(recipe : Recipe, count : Int = 1){
currentPlayer.value?.craft(recipe, count)
this.currentPlayer.value = currentPlayer.value
}
fun addItem(item: Item) {
currentPlayer.value?.addItem(item)
this.currentPlayer.value = currentPlayer.value
}
fun gainXp(xpReward: Int) {
currentPlayer.value?.gainXp(xpReward)
this.currentPlayer.value = currentPlayer.value
}
fun equipeItem(item: Item): Boolean {
currentPlayer.value?.equipeItem(item)
this.currentPlayer.value = currentPlayer.value
return true
}
}

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--When the button is not enabled-->
<item android:state_enabled="false" android:color="@color/grey" />
<!--When button is enabled-->
<item android:state_enabled="true" android:color="@color/blue" />
<!--Default Text Color-->
<item android:color="#db402c" />
</selector>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 929 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/black_800"/>
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"/>
<stroke android:width="1dp"
android:color="@color/grey_100" />
</shape>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/grey_100" />
</shape>
</item>
<item android:top="1dp" android:bottom="1dp" >
<shape android:shape="rectangle">
<solid android:color="@color/black_800" />
</shape>
</item>
</layer-list>

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/blue" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
</shape>
</item>
</selector>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

@ -1,9 +0,0 @@
<?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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

@ -1,4 +0,0 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/black_800"/>
<item android:drawable="@drawable/roundedreciplistcard"/>
</layer-list>

@ -1,9 +0,0 @@
<?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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

@ -1,450 +0,0 @@
<?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"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingBottom="10dp"
android:text="@string/home_title"
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" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:background="@drawable/rounded_border_button"
android:paddingLeft="15dp"
android:paddingRight="15dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2">
<LinearLayout
android:id="@+id/profil_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="10dp">
<ImageView
android:id="@+id/imageView2"
android:layout_width="60dp"
android:layout_height="95dp"
android:layout_gravity="bottom"
android:contentDescription="@string/landscape"
android:src="@drawable/background" />
<ImageView
android:id="@+id/playerImage"
android:layout_width="50dp"
android:layout_height="80dp"
android:layout_gravity="bottom"
android:contentDescription="Landscape" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="5dp"
android:orientation="vertical">
<EditText
android:id="@+id/pseudoEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pseudo"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lvl."
android:textColor="@color/grey_300" />
<TextView
android:id="@+id/levelTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:textColor="@color/grey_300" />
<ProgressBar
android:id="@+id/levelProgressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="5dp"
android:layout_marginHorizontal="10dp"
android:layout_weight="1"
android:max="100"
android:progress="20"
android:progressDrawable="@drawable/custom_level_progressbar" />
<TextView
android:id="@+id/xpTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="349"
android:textColor="@color/white" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:textColor="@color/white" />
<TextView
android:id="@+id/maxXpTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10dp"
android:text="Rank"
android:textColor="@color/grey_300" />
<TextView
android:id="@+id/rankTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Beginner"
android:textColor="@color/white"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingBottom="15dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/profil_container"
tools:layout_editor_absoluteX="15dp">
<ImageView
android:id="@+id/equipedItemAttack"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="bottom"
android:layout_marginRight="10dp"
android:background="@drawable/background_equiped_item"
android:contentDescription="Landscape"
android:tooltipText="Equiped Weapon" />
<ImageView
android:id="@+id/equipedItemFishing"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="bottom"
android:layout_marginRight="10dp"
android:background="@drawable/background_equiped_item"
android:contentDescription="Landscape"
android:tooltipText="Equiped Fishing Rod" />
<ImageView
android:id="@+id/equipedItemCollect"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="bottom"
android:layout_marginRight="10dp"
android:background="@drawable/background_equiped_item"
android:contentDescription="Landscape"
android:tooltipText="Equiped Tool" />
<ImageView
android:id="@+id/equipedItemArmor"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="bottom"
android:layout_marginRight="10dp"
android:background="@drawable/background_equiped_item"
android:contentDescription="Landscape"
android:tooltipText="Equiped Armor" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<ScrollView
android:id="@+id/scroll_activties"
android:layout_width="220dp"
android:layout_height="200dp"
android:layout_marginStart="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/constraintLayout"
app:layout_constraintTop_toBottomOf="@+id/textView2">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/buttonForge"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="10dp"
android:background="@drawable/rounded_border_button"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/constraintLayout">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView2"
android:layout_width="40dp"
android:layout_height="50dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:src="@drawable/ic_anvil" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ancient Forge"
android:textColor="@color/white"
android:textStyle="bold" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Craft ever more powerful tools."
android:textColor="@color/grey_300"
android:textSize="11sp" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/buttonCollect"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="10dp"
android:background="@drawable/rounded_border_button"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buttonForge">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView2"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:src="@drawable/ic_tree" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pleasant Forest"
android:textColor="@color/white"
android:textStyle="bold" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Collect ressources to became powerfull."
android:textColor="@color/grey_300"
android:textSize="11sp" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/buttonBoss"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="10dp"
android:background="@drawable/rounded_border_button"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buttonCollect">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView2"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:src="@drawable/ic_key" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dungeon"
android:textColor="@color/white"
android:textStyle="bold" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Defeat boss to gain Mystic rewards."
android:textColor="@color/grey_300"
android:textSize="11sp" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<LinearLayout
android:id="@+id/event_container"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="20dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/scroll_activties"
app:layout_constraintTop_toBottomOf="@+id/textView2">
<ImageView
android:id="@+id/event_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:clickable="true"
android:maxWidth="200dip"
android:scaleType="centerCrop"
android:src="@drawable/event_message"
android:visibility="visible">
</ImageView>
<ImageView
android:id="@+id/buttonFishing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:clickable="true"
android:visibility="gone"
android:maxWidth="200dip"
android:scaleType="centerCrop"
android:src="@drawable/fishing_event">
</ImageView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,165 +0,0 @@
<?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="@drawable/backgroundboss"
android:scaleType="center"
tools:context=".BossFragment">
<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">
<TextView
android:id="@+id/backbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
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="Dungeon"
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>
<ImageView
android:id="@+id/imageView"
android:layout_width="200dp"
android:layout_height="130dp"
android:src="@drawable/image_boss"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/frameLayout" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="8dp"
android:layout_marginHorizontal="50dp"
android:max="300"
android:progress="300"
android:progressDrawable="@drawable/custom_boss_progressbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
<ImageView
android:layout_marginTop="20dp"
android:id="@+id/imageBoss"
android:layout_width="150dp"
android:layout_height="150dp"
app:layout_constraintBottom_toTopOf="@+id/recyclerviewBossLoot"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/progressBar"
tools:src="@drawable/skeleton"></ImageView>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerviewBossLoot"
android:overScrollMode="never"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginHorizontal="40dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageBoss"
tools:listitem="@layout/list_item" />
<androidx.constraintlayout.widget.ConstraintLayout
android:visibility="invisible"
tools:visibility="visible"
android:id="@+id/toast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="20dp"
android:paddingVertical="2dp"
android:layout_marginBottom="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:background="@drawable/toast_notification">
<ImageView
android:id="@+id/imageViewLoot"
android:layout_margin="5dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/item_background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageViewLoot"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/nameLoot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="15sp"
android:textColor="@color/white"></TextView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/xpRewarded"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="10"
android:textColor="@color/grey_300"
android:textSize="10sp"></TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="xp"
android:textColor="@color/grey_300"
android:textSize="10sp"></TextView>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,209 +0,0 @@
<?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="start|center_vertical"
android:focusable="true"
android:text="@string/ancient_forge"
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"
app:drawableStartCompat="@drawable/back"
app:drawableTint="@color/blue" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/recipe"
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>
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/recipelistcard"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/frameLayout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:gravity="start"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/item_image"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/item_recipe_background"
android:contentDescription="@string/image_of_item"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/wooden_stick" />
<TextView
android:id="@+id/craftValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:text="1"
android:paddingRight="2dp"
android:textColor="@color/white" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:textColor="@color/white"
android:textStyle="bold"
tools:text="Wooden Stick" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@drawable/recipelistcard"
android:orientation="vertical"
android:paddingBottom="15dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:paddingTop="20dp"
android:text="Materials"
android:textColor="@color/grey_400"
android:textSize="17dp"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/RecyclerviewMaterials"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:overScrollMode="never"
tools:itemCount="3"
tools:listitem="@layout/list_craft" />
</LinearLayout>
<Button
android:id="@+id/buttonForgeMax"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginBottom="5dp"
android:backgroundTint="@color/button_background_color"
android:text="FORGE MAX"
android:textColor="@color/white"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/buttonForge"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.473"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/buttonForge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginBottom="10dp"
android:backgroundTint="@color/button_background_color"
android:text="Forge"
android:textColor="@color/white"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:gravity="center"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="@+id/buttonForgeMax"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:background="@drawable/craftable_background"
android:paddingVertical="5dp">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Craftable "
android:textColor="@color/grey_400"/>
<TextView
android:id="@+id/craftableNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="804"
android:textColor="@color/white"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,166 +0,0 @@
<?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="30dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/RecipeScroll">
<TextView
android:id="@+id/backbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:focusable="true"
app:drawableStartCompat="@drawable/back"
app: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>
<androidx.core.widget.NestedScrollView
android:id="@+id/RecipeScroll"
android:layout_width="match_parent"
android:layout_height="4294967294dp"
android:paddingHorizontal="10dp"
app:layout_constraintTop_toBottomOf="@id/frameLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="10dp"
android:background="@drawable/recipelistcard"
android:orientation="vertical"
android:paddingBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:paddingTop="20dp"
android:text="Objects"
android:textColor="@color/grey_400"
android:textSize="17sp"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/RecyclerviewObjects"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:overScrollMode="never"
tools:itemCount="3"
tools:listitem="@layout/list_recipe" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="10dp"
android:background="@drawable/recipelistcard"
android:orientation="vertical"
android:paddingBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="20dp"
android:paddingTop="20dp"
android:text="Tools"
android:textColor="@color/grey_400"
android:textSize="17sp"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/RecyclerviewTools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:overScrollMode="never"
tools:itemCount="3"
tools:listitem="@layout/list_recipe" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="10dp"
android:background="@drawable/recipelistcard"
android:orientation="vertical"
android:paddingBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="20dp"
android:paddingTop="20dp"
android:text="Blacksmithing"
android:textColor="@color/grey_400"
android:textSize="17sp"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/RecyclerviewBlacksmithing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:overScrollMode="never"
tools:itemCount="3"
tools:listitem="@layout/list_recipe"/>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,86 +0,0 @@
<?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"
tools:context=".PlusFragment">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:paddingBottom="20dp"
android:text="@string/plus_title"
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" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/buttonForge"
android:layout_width="match_parent"
android:layout_marginHorizontal="15dp"
android:layout_height="60dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:layout_marginVertical="10dp"
android:background="@drawable/rounded_border_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2">
<LinearLayout
android:id="@+id/wikiButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:contentDescription="@string/wikiImage"
android:id="@+id/imageView2"
android:layout_width="60dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_height="60dp"
android:src="@drawable/wiki_image" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Shake&amp;Craft Wiki"
android:textColor="@color/white"
android:textStyle="bold" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Development info, gameplay &amp; more"
android:textColor="@color/grey_300"
android:textSize="11sp" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,79 +0,0 @@
<?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:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<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_background"
android:id="@+id/item_image"
android:layout_width="40dp"
android:layout_height="40dp"
app:srcCompat="@drawable/log2" />
<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="Beech Log"/>
<View
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" />
<TextView
android:id="@+id/numberCurrentPlayer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textStyle="bold"
tools:text="804"/>
<TextView
android:id="@+id/item_stock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/grey_300"
android:text="/"/>
<TextView
android:id="@+id/numberNeeded"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/grey_300"
tools:text="1"/>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

@ -1,70 +0,0 @@
<?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"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<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_background"
android:id="@+id/item_image"
android:layout_width="50dp"
android:layout_height="50dp"
app:srcCompat="@drawable/ic_key" />
<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" />
<View
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" />
<TextView
android:id="@+id/item_stock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/grey_300"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/grey_300"
android:text="%"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

@ -1,65 +0,0 @@
<?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>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
<cloud-backup>
</cloud-backup>
</data-extraction-rules>

Before

Width:  |  Height:  |  Size: 254 B

After

Width:  |  Height:  |  Size: 254 B

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Before

Width:  |  Height:  |  Size: 593 KiB

After

Width:  |  Height:  |  Size: 593 KiB

@ -17,7 +17,6 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
@ -33,37 +32,19 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
packagingOptions {
exclude 'META-INF/atomicfu.kotlin_module'
}
}
apply plugin: 'kotlin-kapt'
dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.google.ar.sceneform:filament-android:1.17.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
implementation 'androidx.fragment:fragment-ktx:1.5.6'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation "androidx.room:room-runtime:2.5.1"
kapt "androidx.room:room-compiler:2.5.1"
implementation "androidx.room:room-ktx:2.5.1"
//Retrofit
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
//Coroutine
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
}

@ -2,7 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-feature android:name="android.hardware.sensor.accelerometer" />
<application
android:allowBackup="true"
@ -13,6 +12,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.ShakeCraft"
tools:targetApi="31">
<activity
android:name=".CollectActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">

Before

Width:  |  Height:  |  Size: 172 KiB

After

Width:  |  Height:  |  Size: 172 KiB

@ -0,0 +1,126 @@
package com.example.shakecraft
import android.annotation.SuppressLint
import android.content.Context
import android.content.pm.ActivityInfo
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import android.os.Bundle
import android.os.Vibrator
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.TextView
import androidx.navigation.fragment.findNavController
import com.example.shakecraft.data.Stub
import com.example.shakecraft.model.Boss
import com.example.shakecraft.model.Generator
import com.example.shakecraft.model.Player
import kotlin.math.pow
import kotlin.math.sqrt
class BossFragment() : Fragment() {
private lateinit var sensorManager: SensorManager
private lateinit var accelerometer: Sensor
private lateinit var accelerometerEventListener: SensorEventListener
private lateinit var progressBar: ProgressBar
private lateinit var image: ImageView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
var player = (activity as MainActivity).currentPlayer
// Récupérez une référence à la ProgressBar dans la vue
val view = inflater.inflate(R.layout.fragment_boss, container, false)
val buttonCollect = view.findViewById<TextView>(R.id.backbutton)
buttonCollect.setOnClickListener{
findNavController().navigate(R.id.action_bossFragment_to_homeFragment)
}
progressBar = view.findViewById(R.id.progressBar)
image = view.findViewById(R.id.imageBoss)
sensorManager = requireActivity().getSystemService(Context.SENSOR_SERVICE) as SensorManager
accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
var boss = Generator.generateBoss();
progressBar.max = boss.maxlife;
progressBar.progress = boss.life;
image.setImageResource(boss.image)
// Créez un écouteur de capteur d'accéléromètre pour écouter les secousses
accelerometerEventListener = object : SensorEventListener {
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
// Ne faites rien ici
}
override fun onSensorChanged(event: SensorEvent?) {
val acceleration = sqrt(
event!!.values[0].pow(2) + event.values[1].pow(2) + event.values[2].pow(2)
)
if(boss.life <= 0){
val item = Generator.generateLootBoss(boss.possibleLoot);
println(item);
player.addItem(item);
boss = Generator.generateBoss();
println(boss);
image.setImageResource(boss.image)
val vibrator = context?.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
vibrator.vibrate(100)
}
if (acceleration > 40) {
// Le téléphone a été secoué, mettre à jour la barre de chargement ici
boss.takeDamage((acceleration/80).toInt());
progressBar.progress = boss.life;
}
}
}
// Enregistrez l'écouteur de capteur d'accéléromètre
sensorManager.registerListener(
accelerometerEventListener,
accelerometer,
SensorManager.SENSOR_DELAY_GAME
)
// Retournez la vue de fragment
return view
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
val activity = requireActivity()
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
override fun onDestroy() {
super.onDestroy()
// Désenregistrez l'écouteur de capteur d'accéléromètre lorsque le fragment est détruit
sensorManager.unregisterListener(accelerometerEventListener)
val activity = requireActivity()
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
}
}

@ -1,6 +1,6 @@
package com.example.shakecraft
import android.annotation.SuppressLint
import android.content.Context
import android.content.pm.ActivityInfo
import android.hardware.Sensor
@ -16,16 +16,11 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.TextView
import androidx.fragment.app.activityViewModels
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.navigation.fragment.findNavController
import com.example.shakecraft.data.Stub
import com.example.shakecraft.model.Generator
import com.example.shakecraft.model.Item
import com.example.shakecraft.model.Player
import com.example.shakecraft.viewmodel.MainViewModel
import kotlin.math.pow
import kotlin.math.sqrt
@ -35,102 +30,99 @@ class CollectFragment() : Fragment() {
private lateinit var accelerometer: Sensor
private lateinit var accelerometerEventListener: SensorEventListener
private lateinit var progressBar: ProgressBar
private lateinit var buttonBack: TextView
val viewModel : MainViewModel by activityViewModels<MainViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
var player = (activity as MainActivity).currentPlayer
// Récupérez une référence à la ProgressBar dans la vue
val view = inflater.inflate(R.layout.fragment_collect, container, false)
// Initialize views
initializeViews(view)
// Set up accelerometer listener
viewModel.currentPlayer.value?.let { setUpAccelerometerListener(view, it) }
// Set up activity orientation
setUpActivityOrientation()
// Return fragment view
return view
}
private fun initializeViews(view: View) {
progressBar = view.findViewById(R.id.progressBar)
buttonBack = view.findViewById<TextView>(R.id.backbutton)
buttonBack.setOnClickListener{
val buttonCollect = view.findViewById<TextView>(R.id.backbutton)
buttonCollect.setOnClickListener{
findNavController().navigate(R.id.action_collectFragment_to_homeFragment)
}
}
private fun setUpActivityOrientation(){
val activity = requireActivity()
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
private fun displayToast(view: View, item: Item){
val maVue = view.findViewById<View>(R.id.toast)
val image = maVue.findViewById<ImageView>(R.id.imageViewLoot)
val name = maVue.findViewById<TextView>(R.id.nameLoot)
val xp = maVue.findViewById<TextView>(R.id.xpRewarded)
maVue.visibility = View.VISIBLE
image.setImageResource(item.type.image)
name.text = item.type.name
xp.text = item.type.xpReward.toString()
maVue.postDelayed({
maVue.visibility = View.GONE
}, 3000)
}
private fun setUpAccelerometerListener(view: View, currentPlayer: Player) {
progressBar = view.findViewById(R.id.progressBar)
sensorManager = requireActivity().getSystemService(Context.SENSOR_SERVICE) as SensorManager
accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
// Créez un écouteur de capteur d'accéléromètre pour écouter les secousses
accelerometerEventListener = object : SensorEventListener {
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
// Do nothing
// Ne faites rien ici
}
@SuppressLint("ServiceCast")
override fun onSensorChanged(event: SensorEvent?) {
val acceleration = sqrt(event!!.values[0].pow(2) + event.values[1].pow(2) + event.values[2].pow(2))
val acceleration = sqrt(
event!!.values[0].pow(2) + event.values[1].pow(2) + event.values[2].pow(2)
)
if(progressBar.progress == 100){
val item = Generator.generateLootCollection();
println(item);
//Vibration to signal collect of the resource
player.addItem(item);
progressBar.progress = 0;
val vibrator = context?.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
vibrator.vibrate(100)
// Generate a resource item and XP reward
val item = Generator.generateLootCollection()
viewModel.addItem(item)
currentPlayer.gainXp(item.type.xpReward)
//reset to 0 the progress bar
progressBar.progress = 0
// Show loot toast view for 3 seconds
displayToast(view,item)
val maVue = view.findViewById<View>(R.id.toast)
val image = maVue.findViewById<ImageView>(R.id.imageViewLoot)
val name = maVue.findViewById<TextView>(R.id.nameLoot)
val xp = maVue.findViewById<TextView>(R.id.xpRewarded)
maVue.visibility = View.VISIBLE
image.setImageResource(item.image)
name.text = item.name
maVue.postDelayed({
maVue.visibility = View.GONE
}, 3000)
}
if (acceleration > 40) {
// raise the progress bar based on acceleration value
progressBar.progress += (acceleration/20).toInt()
// Le téléphone a été secoué, mettre à jour la barre de chargement ici
progressBar.progress += (acceleration/20).toInt() // Incrémente la progression de la barre de 10 unités
}
}
}
// Register accelerometer sensor earphone with manager
// Enregistrez l'écouteur de capteur d'accéléromètre
sensorManager.registerListener(
accelerometerEventListener,
accelerometer,
SensorManager.SENSOR_DELAY_GAME
)
// Retournez la vue de fragment
return view
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
val activity = requireActivity()
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
override fun onDestroy() {
super.onDestroy()
// Unregister the accelerometer sensor listener when the fragment is destroyed
// Désenregistrez l'écouteur de capteur d'accéléromètre lorsque le fragment est détruit
sensorManager.unregisterListener(accelerometerEventListener)
val activity = requireActivity()
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED

@ -0,0 +1,47 @@
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.Button
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.navigation.fragment.findNavController
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"
/**
* A simple [Fragment] subclass.
* Use the [HomeFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class HomeFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_home,container,false)
val buttonCollect = view.findViewById<ConstraintLayout>(R.id.buttonCollect)
buttonCollect.setOnClickListener{
findNavController().navigate(R.id.action_homeFragment_to_collectFragment)
}
val buttonBoss = view.findViewById<ConstraintLayout>(R.id.buttonBoss)
buttonBoss.setOnClickListener{
findNavController().navigate(R.id.action_homeFragment_to_bossFragment)
}
return view
}
}

@ -0,0 +1,38 @@
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 androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.shakecraft.data.Stub
import com.example.shakecraft.model.Player
import com.example.shakecraft.view.adapter.AdapterInventory
class InventoryFragment() : Fragment( ) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
var player = (activity as MainActivity).currentPlayer
val view = inflater.inflate(R.layout.fragment_inventory, container, false)
val recyclerView: RecyclerView = view.findViewById(R.id.recyclerviewInventory)
with(recyclerView) {
layoutManager = LinearLayoutManager(view.context)
adapter = AdapterInventory(player.items)
}
return view
}
}

@ -0,0 +1,51 @@
package com.example.shakecraft
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.annotation.RequiresApi
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import androidx.navigation.findNavController
import androidx.navigation.ui.setupWithNavController
import com.example.shakecraft.data.Stub
import com.google.android.material.bottomnavigation.BottomNavigationView
class MainActivity : AppCompatActivity() {
var currentPlayer = Stub().currentPlayer
@RequiresApi(Build.VERSION_CODES.R)
private fun hideSystemUI() {
WindowCompat.setDecorFitsSystemWindows(window, false)
WindowInsetsControllerCompat(window,
window.decorView.findViewById(android.R.id.content)).let { controller ->
controller.hide(WindowInsetsCompat.Type.systemBars())
controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
}
private lateinit var bottomNav : BottomNavigationView
@RequiresApi(Build.VERSION_CODES.R)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
hideSystemUI()
setContentView(R.layout.activity_main)
bottomNav = findViewById(R.id.bottomNavigationView)
val navController = findNavController(R.id.fragment)
bottomNav.setupWithNavController(navController)
}
}

@ -0,0 +1,59 @@
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
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"
/**
* A simple [Fragment] subclass.
* Use the [PlusFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class PlusFragment : Fragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_plus, container, false)
}
companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment PlusFragment.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(param1: String, param2: String) =
PlusFragment().apply {
arguments = Bundle().apply {
putString(ARG_PARAM1, param1)
putString(ARG_PARAM2, param2)
}
}
}
}

@ -0,0 +1,22 @@
package com.example.shakecraft.data
import com.example.shakecraft.R
import com.example.shakecraft.model.Item
import com.example.shakecraft.model.Player
class Stub {
fun load() : List<Item>{
val items : MutableList<Item> = mutableListOf<Item>()
items.add(Item(name = "Beech Log", rarity = 0, stack = 1, R.drawable.ic_anvil));
items.add(Item(name = "Bronze Ore", rarity = 0, stack = 1, R.drawable.ic_anvil));
items.add(Item(name = "Iron Ore", rarity = 0, stack = 1, R.drawable.ic_anvil));
items.add(Item(name = "Diamond", rarity = 0, stack = 1, R.drawable.ic_anvil));
return items;
}
var currentPlayer : Player = Player("Winker",0);
}

@ -0,0 +1,19 @@
package com.example.shakecraft.model
import com.example.shakecraft.R
class Boss (
var name: String,
var life: Int,
var maxlife: Int,
var image: Int,
){
val possibleLoot: List<Pair<Item, Double>> = listOf(
Pair(Item(name = "Monster Bones", rarity = 0, stack = 1, R.drawable.monster_bones), 0.7),
Pair(Item(name = "Monster Eye", rarity = 0, stack = 1, R.drawable.monster_eyes), 0.25),
Pair(Item(name = "Treasure Key", rarity = 0, stack = 1, R.drawable.treasure_key), 0.05),
)
fun takeDamage(strength: Int) {
this.life -= strength
}
}

@ -1,4 +1,5 @@
package com.example.shakecraft.model
import com.example.shakecraft.R
import kotlin.random.Random
@ -7,10 +8,10 @@ class Generator {
companion object {
fun generateLootCollection(): Item {
val possibleLoot: List<Pair<Item, Double>> = listOf(
Pair(Item(type = ITEMS.BEECH_LOG.itemtype), 0.6),
Pair(Item(type = ITEMS.BRONZE_ORE.itemtype), 0.25),
Pair(Item(type = ITEMS.IRON_ORE.itemtype), 0.10),
Pair(Item(type = ITEMS.DIAMOND.itemtype), 0.05),
Pair(Item(name = "Beech Log", rarity = 0, stack = 1, R.drawable.log2), 0.6),
Pair(Item(name = "Bronze Ore", rarity = 0, stack = 1, R.drawable.bronze_ore), 0.25),
Pair(Item(name = "Iron Ore", rarity = 0, stack = 1, R.drawable.iron_ore), 0.10),
Pair(Item(name = "Diamond", rarity = 0, stack = 1, R.drawable.diamond), 0.05),
)
val rand = Random.nextDouble()
@ -42,30 +43,11 @@ class Generator {
fun generateBoss(): Boss {
val possibleBoss: List<Pair<Boss, Double>> = listOf(
Pair(Boss(name = "Margit the Fell Omen", life = 150.0, maxlife = 150, image = R.drawable.boss, xpReward = 100, possibleLoot = listOf(
Pair(Item(type = ITEMS.MONSTER_BONES.itemtype), 0.7),
Pair(Item(type = ITEMS.MONSTER_EYE.itemtype), 0.3),
)), 0.5),
Pair(Boss(name = "Godrick the Grafted", life = 200.0, maxlife = 200, image = R.drawable.skeleton, xpReward = 130, possibleLoot = listOf(
Pair(Item(type = ITEMS.MONSTER_BONES.itemtype), 0.6),
Pair(Item(type = ITEMS.MONSTER_EYE.itemtype), 0.3),
Pair(Item(type = ITEMS.TREASURE_KEY.itemtype), 0.1),
)), 0.2),
Pair(Boss(name = "Red Wolf of Radagon", life = 250.0, maxlife = 250, image = R.drawable.halberdier, xpReward = 210, possibleLoot = listOf(
Pair(Item(type = ITEMS.MONSTER_BONES.itemtype), 0.6),
Pair(Item(type = ITEMS.MONSTER_EYE.itemtype), 0.3),
Pair(Item(type = ITEMS.TREASURE_KEY.itemtype), 0.1),
)), 0.15),
Pair(Boss(name = "Old Banshee", life = 300.0, maxlife = 300, image = R.drawable.banshee, xpReward = 300, possibleLoot = listOf(
Pair(Item(type = ITEMS.MONSTER_BONES.itemtype), 0.4),
Pair(Item(type = ITEMS.MONSTER_EYE.itemtype), 0.4),
Pair(Item(type = ITEMS.TREASURE_KEY.itemtype), 0.2),
)), 0.10),
Pair(Boss(name = "Margit the Fell Omen", life = 500.0, maxlife = 500, image = R.drawable.lich, xpReward = 500, possibleLoot = listOf(
Pair(Item(type = ITEMS.MONSTER_BONES.itemtype), 0.4),
Pair(Item(type = ITEMS.MONSTER_EYE.itemtype), 0.3),
Pair(Item(type = ITEMS.TREASURE_KEY.itemtype), 0.3),
)), 0.05),
Pair(Boss(name = "Margit the Fell Omen", life = 150, maxlife = 150, image = R.drawable.boss), 0.5),
Pair(Boss(name = "Godrick the Grafted", life = 200, maxlife = 200, image = R.drawable.skeleton), 0.2),
Pair(Boss(name = "Red Wolf of Radagon", life = 250, maxlife = 250, image = R.drawable.halberdier), 0.15),
Pair(Boss(name = "Old Banshee", life = 300, maxlife = 300, image = R.drawable.banshee), 0.10),
Pair(Boss(name = "Margit the Fell Omen", life = 500, maxlife = 500, image = R.drawable.lich), 0.05),
)
val rand = Random.nextDouble()

@ -0,0 +1,12 @@
package com.example.shakecraft.model
import android.media.Image
data class Item(
var name: String,
var rarity: Int,
var stack: Int,
var image: Int,
)

@ -0,0 +1,32 @@
package com.example.shakecraft.model
class Player(val pseudo: String, var xp: Int = 0) {
var level: Int = 1
private set
val items: MutableList<Item> = mutableListOf()
fun addItem(item: Item) {
var findItem = items.find { it.name == item.name }
if(findItem!= null){
findItem.stack += 1;
}
else{items.add(item)}
}
fun removeItem(item: Item) {
items.remove(item)
}
fun increaseXp(amount: Int) {
xp += amount
if (xp >= 100 * level) {
levelUp()
}
}
private fun levelUp() {
level++
println("$pseudo a atteint le niveau $level !")
}
}

@ -6,16 +6,17 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.Adapter
import com.example.shakecraft.R
import com.example.shakecraft.model.Item
import com.example.shakecraft.view.viewholder.ViewHolderInventory
class AdapterBossLoot(private val possibleLoot: List<Pair<Item, Double>>) : RecyclerView.Adapter<AdapterBossLoot.ViewHolder>() {
class AdapterInventory(private val inventory: List<Item>) : RecyclerView.Adapter<AdapterInventory.ViewHolder>() {
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val textView: TextView
val textViewDropRate: TextView
val textViewNumber: TextView
var imageView: ImageView
@ -23,27 +24,26 @@ class AdapterBossLoot(private val possibleLoot: List<Pair<Item, Double>>) : Recy
// Define click listener for the ViewHolder's View
textView = view.findViewById(R.id.item_name)
textViewDropRate = view.findViewById(R.id.item_stock)
textViewNumber = view.findViewById(R.id.item_stock)
imageView = view.findViewById(R.id.item_image)
}
fun bind(item: Pair<Item, Double>) {
textView.text = item.first.type.name
textViewDropRate.text = (item.second*100).toString()
imageView.setImageResource(item.first.type.image)
fun bind(item: Item) {
textView.text = item.name
textViewNumber.text = item.stack.toString()
imageView.setImageResource(item.image)
}
}
override fun getItemCount() = possibleLoot.size
override fun getItemCount() = inventory.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.list_loot, parent, false)
.inflate(R.layout.list_item, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
val item : Pair<Item, Double> = possibleLoot[position]
val item : Item = inventory[position]
viewHolder.bind(item)
}

@ -0,0 +1,3 @@
package com.example.shakecraft.view.viewholder
class ViewHolderInventory(inflate: Any?) {
}

Before

Width:  |  Height:  |  Size: 573 KiB

After

Width:  |  Height:  |  Size: 573 KiB

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save