Skip to content

Commit

Permalink
feat: new weapon
Browse files Browse the repository at this point in the history
round shot weapon can purchased in the shop
  • Loading branch information
MrXMrQ committed Aug 16, 2024
1 parent 990eb1d commit 61e59e9
Show file tree
Hide file tree
Showing 15 changed files with 636 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &227399658643498932
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5488743611133324747}
- component: {fileID: 7549832020881850003}
m_Layer: 0
m_Name: player_projectile_round_shot
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5488743611133324747
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 227399658643498932}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 126.49457, y: 589.6237, z: -2.5083663}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7549832020881850003
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 227399658643498932}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b8128b909ad1b948a7af997009d8669, type: 3}
m_Name:
m_EditorClassIdentifier:
default_projectile: {fileID: 6289194308112020401, guid: 184e53708a9fbf44db2da85a2173e207, type: 3}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions Assets/Scripts/Asteroids/Projectiles/ProjectileRoundShot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using UnityEngine;

public class ProjectileRoundShot : MonoBehaviour
{
[SerializeField] GameObject default_projectile;

void Start()
{
RoundShot();
}

private void RoundShot()
{
InstanceProjectile(default_projectile, new Vector2(1, 1));
InstanceProjectile(default_projectile, new Vector2(1, -1));
InstanceProjectile(default_projectile, new Vector2(-1, 1));
InstanceProjectile(default_projectile, new Vector2(-1, -1));
InstanceProjectile(default_projectile, Vector2.right);
InstanceProjectile(default_projectile, Vector2.left);
InstanceProjectile(default_projectile, Vector2.down);
InstanceProjectile(default_projectile, Vector2.up);
}

private void InstanceProjectile(GameObject projectile, Vector2 move_direction)
{
ProjctileDefaultLogic projectile_script = projectile.GetComponent<ProjctileDefaultLogic>();

if (projectile_script != null)
{
projectile_script.SetMoveDirection(move_direction);
Instantiate(projectile, transform.position, Quaternion.identity);
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Asteroids/Projectiles/ProjectileRoundShot.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Assets/Scripts/Save System/GameData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class GameData
public bool dual_shot_unlocked;
public bool trippl_shot_unlocked;
public bool sniper_unlocked;
public bool round_shot_unlocked;

//* ability stats
public string ability_scriptableobject_path;
Expand Down Expand Up @@ -45,6 +46,7 @@ public GameData(
bool dual_shot_unlocked,
bool trippl_shot_unlocked,
bool sniper_unlocked,
bool round_shot_unlocked,

string ability_scriptableobject_path,
bool boss_dash_unlocked,
Expand All @@ -71,6 +73,7 @@ public GameData(
this.dual_shot_unlocked = dual_shot_unlocked;
this.trippl_shot_unlocked = trippl_shot_unlocked;
this.sniper_unlocked = sniper_unlocked;
this.round_shot_unlocked = round_shot_unlocked;

this.ability_scriptableobject_path = ability_scriptableobject_path;
this.boss_dash_unlocked = boss_dash_unlocked;
Expand Down Expand Up @@ -100,6 +103,7 @@ public GameData(GameData game_data)
dual_shot_unlocked = game_data.dual_shot_unlocked;
trippl_shot_unlocked = game_data.trippl_shot_unlocked;
sniper_unlocked = game_data.sniper_unlocked;
round_shot_unlocked = game_data.round_shot_unlocked;

ability_scriptableobject_path = game_data.ability_scriptableobject_path;
boss_dash_unlocked = game_data.boss_dash_unlocked;
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Save System/SaveSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static class SaveSystem
static bool DUAL_SHOT_UNLOCKED;
static bool TRIPPLE_SHOT_UNLOCKED;
static bool SNIPER_UNLOCKED;
static bool ROUND_SHOT_UNLOCKED;

//* ability stats
static string ABILITY_PREFAB_PATH = "Scriptableobjects/Abilities/dash_ability";
Expand Down Expand Up @@ -80,6 +81,7 @@ public static GameData Load()
DUAL_SHOT_UNLOCKED,
TRIPPLE_SHOT_UNLOCKED,
SNIPER_UNLOCKED,
ROUND_SHOT_UNLOCKED,

ABILITY_PREFAB_PATH,
BOSS_DASH_UNLOCKED,
Expand Down
27 changes: 27 additions & 0 deletions Assets/Scripts/Shop/Cards/Weapons/04_round_shot_weapon.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8243da5405db3e84b9d83a1e6b8a39d0, type: 3}
m_Name: 04_round_shot_weapon
m_EditorClassIdentifier:
card_name: ROUND SHOT
upgrade_type: 6
cost_multiplier: 0
upgrade_value: 0
max_upgrade_stat: 0
current_stat: 0
upgrade_cost: 0
weapon_prefab_path: Prefabs/Player Projectiles/player_projectile_round_shot
weapon_cost: 10000
is_unlocked_weapon: 1
ability_scriptableobject_path:
ability_cost: 0
is_unlocked_ability: 0

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 08dd5a6ddfdd25a4f95d18e9f7d48570, type: 3}
m_Name: 04_dual_weapon
m_Name: 05_dual_weapon
m_EditorClassIdentifier:
card_name: DUAL SHOT
upgrade_type: 6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4e8fa5a345c9e842b94d9a858e21f75, type: 3}
m_Name: 05_tripple_shot_weapon
m_Name: 06_tripple_shot_weapon
m_EditorClassIdentifier:
card_name: TRIPPLE SHOT
upgrade_type: 6
Expand Down
45 changes: 45 additions & 0 deletions Assets/Scripts/Shop/Scriptes/Weapon/RoundShotCard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using UnityEngine;

[CreateAssetMenu(fileName = "_weapon", menuName = "Card/Weapon/Round Shot")]
public class RoundShotCard : Card, IWeapon
{
int total_score;
string current_path;

public void Load(GameData game_data)
{
is_unlocked_weapon = game_data.round_shot_unlocked;
total_score = game_data.total_score;
current_path = game_data.weapon_prefab_path;
}

public void Unlock(GameData game_data)
{
if (total_score >= weapon_cost && !is_unlocked_weapon)
{
total_score -= weapon_cost;
current_path = weapon_prefab_path;
is_unlocked_weapon = true;

Save(game_data);
}
else
{
Debug.LogWarning("not enought scroe points or is unlocked");
}
}

public void Equip(GameData gameData)
{
current_path = weapon_prefab_path;
Save(gameData);
}

private void Save(GameData game_data)
{
game_data.round_shot_unlocked = is_unlocked_weapon;
game_data.total_score = total_score;
game_data.weapon_prefab_path = current_path;
SaveSystem.Save(game_data);
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Shop/Scriptes/Weapon/RoundShotCard.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 61e59e9

Please sign in to comment.