Skip to content

Commit

Permalink
* Max stack Size
Browse files Browse the repository at this point in the history
* Transfer One (shift)
* Moovinf Files (scripts folder)
  • Loading branch information
dpeter99 committed Aug 11, 2015
1 parent 6db9809 commit 5fdb1fd
Show file tree
Hide file tree
Showing 59 changed files with 577 additions and 595 deletions.
716 changes: 358 additions & 358 deletions Assets/CodeMap1.dgml

Large diffs are not rendered by default.

65 changes: 0 additions & 65 deletions Assets/GUI/Inventory/Inventory.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Assets/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void TogleDualInventory(Inventory other)
}
else if (!(guiHandler.dualinventoryOn))
{
Debug.Log("Opening");
//Debug.Log("Opening");
guiHandler.actionGroup.SetActive(false);
guiHandler.DualInventory.SetOtherInv(other);
guiHandler.DualInventory.gameObject.SetActive(true);
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public void UpdateInventory()
drawedInv[i].GetComponent<DualInventoryElement>().thisinv = player;
drawedInv[i].GetComponent<DualInventoryElement>().index = i;

Debug.Log(inv.inventory[i].GetType());
Debug.Log("Drawed " + i);
//Debug.Log(inv.inventory[i].GetType());
//Debug.Log("Drawed " + i);
#endregion
}
else
Expand Down Expand Up @@ -111,8 +111,8 @@ public void UpdateInventory()
drawedInv[i].GetComponent<DualInventoryElement>().thisinv = other;
drawedInv[i].GetComponent<DualInventoryElement>().index = i;

Debug.Log(inv.inventory[i].GetType());
Debug.Log("Drawed " + i);
//Debug.Log(inv.inventory[i].GetType());
//Debug.Log("Drawed " + i);
#endregion
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void Set(int setAmount)
public void Set(string setName)
{
this.name = setName;
Debug.Log(setName);
//Debug.Log(setName);

nameDisplay.GetComponent<Text>().text = setName.ToString();
}
Expand All @@ -63,7 +63,7 @@ public void Set(Item item)
{
Set(item.amount);

Debug.Log(GameCon.language);
//Debug.Log(GameCon.language);
Set(Language.Get(item, GameCon.language));
}
#endregion
Expand All @@ -72,6 +72,11 @@ public void Set(Item item)
public void Transfer()
{
Debug.Log("Transfer");
if (Input.GetButton("Specific"))
{
thisinv.TransferItemAmount(other, index, 1);
return;
}


other.TransferItem(thisinv, index);
Expand Down
149 changes: 149 additions & 0 deletions Assets/Inventory/Inventory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
using UnityEngine;
using System.Collections;
using System;

[System.Serializable]
public class Inventory
{

public Item[] inventory;

public int size;


public Inventory(int InventorySize)
{
inventory = new Item[InventorySize];
this.size = InventorySize;
}


public Item Add(Item added)
{
int size = added.amount;

foreach (Item item in inventory)
{

if (item != null)
{

if (item.GetType() == added.GetType())
{
Debug.Log(added.GetType());

size = AddAmount(added.amount, item);

Debug.Log("Inventory added: " + item.GetType() + " Amount: " + item.amount);
if (size == 0)
{
return item;
}
added.amount = size;
}
}
}

for (int i = 0; i < 10; i++)
{
if (inventory[i] == null)
{
inventory[i] = added;
return inventory[i];
}
}

return null;

}

public void Remove(int i)
{
inventory[i] = null;
}



public Item Get(int i)
{
return inventory[i];
}

public void TransferItem(Inventory inv, int index)
{
this.Add(inv.Get(index));
inv.Remove(index);
}

public void TransferItemAmount(Inventory Toinv, int Fromindex, int addingAmount)
{



// Toinv.Add(inventory[Fromindex]);

//if (inventory[Fromindex].amount == 0)
//{
// Remove(Fromindex);
//}


Debug.Log(inventory[Fromindex]);

if (inventory[Fromindex].amount - addingAmount < 0)
{
Item addable = (((Item)Activator.CreateInstance(null, inventory[Fromindex].GetType().ToString()).Unwrap()));

addable.amount = (addingAmount - inventory[Fromindex].amount);

Toinv.Add(addable);

Remove(Fromindex);

}
else if (inventory[Fromindex].amount - addingAmount == 0)
{
Item addable = (((Item)Activator.CreateInstance(null, inventory[Fromindex].GetType().ToString()).Unwrap()));

addable.amount = addingAmount;

Toinv.Add(addable);

Remove(Fromindex);
}
else if (inventory[Fromindex].amount - addingAmount > 0)
{
Item addable = (((Item)Activator.CreateInstance(null, inventory[Fromindex].GetType().ToString()).Unwrap()));

addable.amount = addingAmount;

Toinv.Add(addable);

inventory[Fromindex].amount -= addingAmount;

//Remove(Fromindex);
}


;


}

public int AddAmount(int rAmount, Item i)
{
if ((i.amount + rAmount) > (i.maxStackSize))
{
i.amount = i.maxStackSize;
Debug.Log(i.amount);
return (i.amount + rAmount) - i.maxStackSize;
}
else
{
i.amount = i.amount + rAmount;
Debug.Log(i.amount);
return 0;
}

}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Assets/MapLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void MapDraw(Map map, GameObject mapPiece, Sprite[] GeneratedSprit
go.name = "Tile_" + xPos + "_" + yPos;
SpriteRenderer curr = go.GetComponent<SpriteRenderer>();

Debug.Log(xPos + "," + yPos);
//Debug.Log(xPos + "," + yPos);
curr.sprite = GeneratedSprites[((int)map.mapGenerated[xPos, yPos].type)];

curr.transform.parent = showLay.transform;
Expand Down
Binary file modified Assets/Scenes/Start.unity
Binary file not shown.
2 changes: 1 addition & 1 deletion Assets/UnityVS.meta

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

2 changes: 1 addition & 1 deletion Assets/UnityVS/Editor.meta

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

Binary file modified Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll
Binary file not shown.
Binary file not shown.
Binary file modified Assets/UnityVS/Editor/UnityVS.VersionSpecific.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Assets/UnityVS/Editor/UnityVS.VersionSpecific.dll.meta

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

5 changes: 0 additions & 5 deletions Assets/scripts/IInventory.cs

This file was deleted.

12 changes: 0 additions & 12 deletions Assets/scripts/IInventory.cs.meta

This file was deleted.

File renamed without changes.

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

17 changes: 17 additions & 0 deletions Assets/scripts/Items/Item.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



public class Item
{
public int amount;
public int maxStackSize;




}

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class IronOre:Ore
{
public string name = "Iron" + "Ore";


}

File renamed without changes.
11 changes: 7 additions & 4 deletions Assets/scripts/Item.cs → Assets/scripts/Items/Ore/Ore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
using System.Linq;
using System.Text;



public class Item
{
public int amount;

public class Ore : Item
{
public Ore()
{
base.maxStackSize = 4;
}

}

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

File renamed without changes.
Loading

0 comments on commit 5fdb1fd

Please sign in to comment.