Skip to content

Commit

Permalink
[198] Inventory Slots eingefügt
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Wendel committed Jul 23, 2015
1 parent 466791e commit 86acc53
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
20 changes: 17 additions & 3 deletions OctoAwesome/OctoAwesome.Runtime/ActorHost.cs
Expand Up @@ -64,7 +64,7 @@ public void Update(GameTime frameTime)
#region Inputverarbeitung

Vector3 externalPower = ((Player.ExternalForce * Player.ExternalForce) / (2 * Player.Mass)) * (float)frameTime.ElapsedGameTime.TotalSeconds;
externalPower *= new Vector3(Math.Sign(Player.ExternalForce.X),Math.Sign(Player.ExternalForce.Y),Math.Sign(Player.ExternalForce.Z));
externalPower *= new Vector3(Math.Sign(Player.ExternalForce.X), Math.Sign(Player.ExternalForce.Y), Math.Sign(Player.ExternalForce.Z));

// Input verarbeiten
Player.Angle += (float)frameTime.ElapsedGameTime.TotalSeconds * Head.X;
Expand All @@ -82,7 +82,7 @@ public void Update(GameTime frameTime)
Vector3 Friction = new Vector3(1, 1, 0.1f) * Player.FRICTION;
Vector3 powerdirection = new Vector3();

powerdirection += externalPower;
powerdirection += externalPower;
powerdirection += (Player.POWER * VelocityDirection);
// if (OnGround && input.JumpTrigger)
if (lastJump)
Expand Down Expand Up @@ -213,7 +213,21 @@ public void Update(GameTime frameTime)
{
IBlock lastBlock = ResourceManager.Instance.GetBlock(planet.Id, lastInteract.Value);
ResourceManager.Instance.SetBlock(planet.Id, lastInteract.Value, null);
Player.Inventory.Add(lastBlock);

if (lastBlock != null)
{
var slot = Player.Inventory.SingleOrDefault(s => s.ItemType == lastBlock.GetType());
if (slot == null)
{
slot = new InventorySlot()
{
ItemType = lastBlock.GetType(),
Amount = 0
};
Player.Inventory.Add(slot);
}
slot.Amount++;
}
lastInteract = null;
}

Expand Down
11 changes: 11 additions & 0 deletions OctoAwesome/OctoAwesome/IResource.cs
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OctoAwesome
{
public interface IResource
{
}
}
13 changes: 13 additions & 0 deletions OctoAwesome/OctoAwesome/InventorySlot.cs
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OctoAwesome
{
public class InventorySlot
{
public Type ItemType { get; set; }
public int Amount { get; set; }
}
}
2 changes: 2 additions & 0 deletions OctoAwesome/OctoAwesome/OctoAwesome.csproj
Expand Up @@ -65,7 +65,9 @@
<Compile Include="IMapGenerator.cs" />
<Compile Include="Index2.cs" />
<Compile Include="Index3.cs" />
<Compile Include="InventorySlot.cs" />
<Compile Include="IPlanet.cs" />
<Compile Include="IResource.cs" />
<Compile Include="IScreenInputSet.cs" />
<Compile Include="Item.cs" />
<Compile Include="IUniverse.cs" />
Expand Down
6 changes: 4 additions & 2 deletions OctoAwesome/OctoAwesome/Player.cs
Expand Up @@ -30,14 +30,16 @@ public sealed class Player : Item

public float Tilt { get; set; }

public int InventorySlots { get; set; }

[XmlIgnore]
public List<IBlock> Inventory { get; set; }
public List<InventorySlot> Inventory { get; set; }

public Player()
{
Position = new Coordinate(0, new Index3(82109, 74365, 45), Vector3.Zero);
Velocity = new Vector3(0, 0, 0);
Inventory = new List<IBlock>();
Inventory = new List<InventorySlot>();
Radius = 0.75f;
Angle = 0f;
Height = 3.5f;
Expand Down

0 comments on commit 86acc53

Please sign in to comment.