Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3e02fc3
1 Creating a UI Component Library
sampattuzzi Nov 26, 2020
ed637d9
2 Shops Basic UI Outline
sampattuzzi Nov 26, 2020
0104fd2
Upgrade to 2020.2 beta to avoid Rect Transform dirtying scene bug.
sampattuzzi Nov 27, 2020
209014e
3 Headers
sampattuzzi Dec 2, 2020
011cbbe
4 Row Variants
sampattuzzi Dec 2, 2020
b8b2112
5 Component APIs
sampattuzzi Dec 2, 2020
7d1fa4c
6 Opening Shops
sampattuzzi Dec 2, 2020
9b7f4ea
Missing scene change
sampattuzzi Dec 2, 2020
ef764b5
7 Shop Names & Closing
sampattuzzi Dec 2, 2020
bda94f1
8 Building A Shopping List
sampattuzzi Dec 2, 2020
39a9021
Remove fighter from Shop Keeper prefab
sampattuzzi Dec 3, 2020
57d5192
9 Displaying A ShopItem
sampattuzzi Dec 3, 2020
dd09da2
10 Configuring Stock And Price
sampattuzzi Jan 13, 2021
94a92f4
11 Quantity Widget
sampattuzzi Jan 13, 2021
38af284
12 Preparing A Transaction
sampattuzzi Jan 13, 2021
c7df254
13 Subscribing Shop Updates
sampattuzzi Jan 13, 2021
8aaf214
14 Completing A Transaction
sampattuzzi Jan 14, 2021
91b253f
15 Calculating A Total
sampattuzzi Jan 14, 2021
8e4a111
16 Money Component
sampattuzzi Jan 14, 2021
853bfb0
17 Money UI
sampattuzzi Jan 14, 2021
ad887ac
18 Updating stock
sampattuzzi Jan 14, 2021
e64e481
19 Checking A Transaction
sampattuzzi Jan 14, 2021
94c545a
20 Checking Inventory Space
sampattuzzi Jan 14, 2021
c649ca1
21 Switching To Selling
sampattuzzi Jan 15, 2021
ffffc76
22 Counting Inventory Availability
sampattuzzi Jan 15, 2021
732dcb3
23 Selling Transactions
sampattuzzi Jan 15, 2021
f91981b
24 Setting Filters
sampattuzzi Jan 15, 2021
41d81c0
25 Displaying Filters
sampattuzzi Jan 15, 2021
6e3ebd8
26 Filtering Items
sampattuzzi Jan 15, 2021
8b06658
27 Stock Config Based On Level
sampattuzzi Jan 20, 2021
599cadc
28 Calculating The Price By Level
sampattuzzi Jan 22, 2021
46e393a
29 Replenish Stock By Level
sampattuzzi Jan 22, 2021
1ac3c48
30 Saving Stock
sampattuzzi Jan 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions .gitignore

This file was deleted.

71 changes: 71 additions & 0 deletions RPG Project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/

# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/

# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*

# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*

# Visual Studio cache directory
.vs/

# Gradle cache directory
.gradle/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta

# Unity3D generated file on crash reports
sysinfo.txt

# Builds
*.apk
*.aab
*.unitypackage

# Crashlytics generated file
crashlytics-build.properties

# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*

# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
54 changes: 54 additions & 0 deletions RPG Project/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Unity Editor",
"type": "unity",
"path": "/d:/Documents/Courses/RPG/RPG Redux/RPG Project/Library/EditorInstance.json",
"request": "launch"
},
{
"name": "Windows Player",
"type": "unity",
"request": "launch"
},
{
"name": "OSX Player",
"type": "unity",
"request": "launch"
},
{
"name": "Linux Player",
"type": "unity",
"request": "launch"
},
{
"name": "iOS Player",
"type": "unity",
"request": "launch"
},
{
"name": "Android Player",
"type": "unity",
"request": "launch"
},
{
"name": "Xbox One Player",
"type": "unity",
"request": "launch"
},
{
"name": "PS4 Player",
"type": "unity",
"request": "launch"
},
{
"name": "SwitchPlayer",
"type": "unity",
"request": "launch"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using UnityEngine;
using GameDevTV.Saving;
using RPG.Core;
using System.Collections.Generic;

namespace GameDevTV.Inventories
{
Expand All @@ -19,6 +20,7 @@ public class Inventory : MonoBehaviour, ISaveable, IPredicateEvaluator

// STATE
InventorySlot[] slots;
InventorySlot[] snapshot;

public struct InventorySlot
{
Expand Down Expand Up @@ -50,6 +52,17 @@ public bool HasSpaceFor(InventoryItem item)
return FindSlot(item) >= 0;
}

public void TakeSnapshot()
{
snapshot = (InventorySlot[])slots.Clone();
}

public void RevertSnapshot()
{
slots = snapshot;
snapshot = null;
}

/// <summary>
/// How many slots are in the inventory?
/// </summary>
Expand All @@ -75,10 +88,7 @@ public bool AddToFirstEmptySlot(InventoryItem item, int number)

slots[i].item = item;
slots[i].number += number;
if (inventoryUpdated != null)
{
inventoryUpdated();
}
UpdateObservers();
return true;
}

Expand Down Expand Up @@ -125,10 +135,7 @@ public void RemoveFromSlot(int slot, int number)
slots[slot].number = 0;
slots[slot].item = null;
}
if (inventoryUpdated != null)
{
inventoryUpdated();
}
UpdateObservers();
}

/// <summary>
Expand All @@ -155,10 +162,7 @@ public bool AddItemToSlot(int slot, InventoryItem item, int number)

slots[slot].item = item;
slots[slot].number += number;
if (inventoryUpdated != null)
{
inventoryUpdated();
}
UpdateObservers();
return true;
}

Expand Down Expand Up @@ -220,6 +224,15 @@ private int FindStack(InventoryItem item)
return -1;
}

private void UpdateObservers()
{
if (snapshot != null) return;
if (inventoryUpdated != null)
{
inventoryUpdated();
}
}

[System.Serializable]
private struct InventorySlotRecord
{
Expand Down Expand Up @@ -249,10 +262,7 @@ void ISaveable.RestoreState(object state)
slots[i].item = InventoryItem.GetFromID(slotStrings[i].itemID);
slots[i].number = slotStrings[i].number;
}
if (inventoryUpdated != null)
{
inventoryUpdated();
}
UpdateObservers();
}

public bool? Evaluate(string predicate, string[] parameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public abstract class InventoryItem : ScriptableObject, ISerializationCallbackRe
[SerializeField] Pickup pickup = null;
[Tooltip("If true, multiple items of this type can be stacked in the same inventory slot.")]
[SerializeField] bool stackable = false;
[Tooltip("Default price for buying this item.")]
[SerializeField] float price = 0f;
[Tooltip("Category for this item.")]
[SerializeField] ItemCategory category = ItemCategory.None;


// STATE
static Dictionary<string, InventoryItem> itemLookupCache;
Expand Down Expand Up @@ -103,6 +108,16 @@ public string GetDescription()
return description;
}

public float GetPrice()
{
return price;
}

public ItemCategory GetCategory()
{
return category;
}

// PRIVATE

void ISerializationCallbackReceiver.OnBeforeSerialize()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace GameDevTV.Inventories
{
public enum ItemCategory
{
None,
Armour,
Weapon,
Potion,
Special,
Ability
}
}

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

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

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading