92
Assets/Materials/Rot.mat
Normal file
92
Assets/Materials/Rot.mat
Normal file
@@ -0,0 +1,92 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Rot
|
||||
m_Shader: {fileID: 10761, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailTex:
|
||||
m_Texture: {fileID: 2800000, guid: b668c3366a5190040b384e638deeca4a, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2800000, guid: b668c3366a5190040b384e638deeca4a, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.316
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0.057
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _Strength: 0.283
|
||||
- _UVSec: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
BIN
Assets/Pictures/Blueprint_Background.jpg
Normal file
BIN
Assets/Pictures/Blueprint_Background.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 MiB |
BIN
Assets/Pictures/FeuerTail.png
Normal file
BIN
Assets/Pictures/FeuerTail.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 353 B |
BIN
Assets/Pictures/FoodIcon.png
Normal file
BIN
Assets/Pictures/FoodIcon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
Assets/Pictures/MilitaryIcon.png
Normal file
BIN
Assets/Pictures/MilitaryIcon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
80
Assets/Pictures/New Material.mat
Normal file
80
Assets/Pictures/New Material.mat
Normal file
@@ -0,0 +1,80 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: New Material
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
BIN
Assets/Pictures/ScienceIcon.png
Normal file
BIN
Assets/Pictures/ScienceIcon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.3 KiB |
BIN
Assets/Pictures/Tech_BGR.png
Normal file
BIN
Assets/Pictures/Tech_BGR.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 182 B |
46
Assets/PreFabs/Clock.prefab
Normal file
46
Assets/PreFabs/Clock.prefab
Normal file
@@ -0,0 +1,46 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &3188509044605999864
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6261394630258406887}
|
||||
- component: {fileID: 2019202285392842739}
|
||||
m_Layer: 0
|
||||
m_Name: Clock
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &6261394630258406887
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3188509044605999864}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 3.4563024, y: -1.3916305, z: -0.30401358}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &2019202285392842739
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3188509044605999864}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0128bb3b379e8144eae3b33ceb9c4bfd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
47
Assets/PreFabs/GameManager.prefab
Normal file
47
Assets/PreFabs/GameManager.prefab
Normal file
@@ -0,0 +1,47 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &6876722328111270485
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4199248806934553299}
|
||||
- component: {fileID: 7964589156323440753}
|
||||
m_Layer: 0
|
||||
m_Name: GameManager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &4199248806934553299
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6876722328111270485}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 3.4563024, y: -1.3916305, z: -0.30401358}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &7964589156323440753
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6876722328111270485}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d3b0135fe7978d64aa5acd5b3b207b35, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clock: {fileID: 0}
|
||||
38
Assets/PreFabs/RepeatableTech_IU_Container.prefab
Normal file
38
Assets/PreFabs/RepeatableTech_IU_Container.prefab
Normal file
@@ -0,0 +1,38 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &2720154582977778304
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2720154582977778307}
|
||||
m_Layer: 6
|
||||
m_Name: RepeatableTech_IU_Container
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &2720154582977778307
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2720154582977778304}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 1, y: 0.5}
|
||||
m_AnchorMax: {x: 1, y: 0.5}
|
||||
m_AnchoredPosition: {x: -17, y: 10}
|
||||
m_SizeDelta: {x: 20, y: 15}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
3709
Assets/Scenes/SampleScene.unity
Normal file
3709
Assets/Scenes/SampleScene.unity
Normal file
File diff suppressed because it is too large
Load Diff
183
Assets/Scripts/Buildings/ABuilding.cs
Normal file
183
Assets/Scripts/Buildings/ABuilding.cs
Normal file
@@ -0,0 +1,183 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBuilding
|
||||
{
|
||||
public abstract class ABuilding : IBuilding
|
||||
{
|
||||
//----------------------------------------------------------------------------
|
||||
// private object variables
|
||||
|
||||
private int _runningCost = 0;
|
||||
private int _scienceCapacity = 0;
|
||||
private int _foodCapacity = 0;
|
||||
private int _industrialCapacity = 0;
|
||||
private int _moneyCapacity = 0;
|
||||
|
||||
private int _militaryPower = 0;
|
||||
|
||||
private bool _isRunning = true;
|
||||
|
||||
private ABuilding.BuildingID _iD = 0;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
public enum BuildingID
|
||||
{
|
||||
Farm,
|
||||
Smeltery,
|
||||
Armory,
|
||||
Spaceport,
|
||||
Market,
|
||||
University
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Getters
|
||||
|
||||
public int GetRunningCost()
|
||||
{
|
||||
if (_isRunning)
|
||||
{
|
||||
return _runningCost;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetScienceCapacity()
|
||||
{
|
||||
if (_isRunning)
|
||||
{
|
||||
return _scienceCapacity;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetFoodCapacity()
|
||||
{
|
||||
if (_isRunning)
|
||||
{
|
||||
return _foodCapacity;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetIndustrialCapacity()
|
||||
{
|
||||
if (_isRunning)
|
||||
{
|
||||
return _industrialCapacity;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetMoneyCapacity()
|
||||
{
|
||||
if (_isRunning)
|
||||
{
|
||||
return _moneyCapacity;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetMilitaryPower()
|
||||
{
|
||||
if (_isRunning)
|
||||
{
|
||||
return _militaryPower;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRunning()
|
||||
{
|
||||
return _isRunning;
|
||||
}
|
||||
|
||||
public ABuilding.BuildingID GetId()
|
||||
{
|
||||
return _iD;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Setters
|
||||
|
||||
public void SetRunningCost(int newRunningCost)
|
||||
{
|
||||
if (newRunningCost > 0)
|
||||
{
|
||||
_runningCost = newRunningCost;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetScienceCapacity(int newScienceCapacity)
|
||||
{
|
||||
if (newScienceCapacity >= 0)
|
||||
{
|
||||
_scienceCapacity = newScienceCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetFoodCapacity(int newFoodCapacity)
|
||||
{
|
||||
if (newFoodCapacity >= 0)
|
||||
{
|
||||
_foodCapacity = newFoodCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetIndustrialCapacity(int newIndustrialCapacity)
|
||||
{
|
||||
_industrialCapacity = newIndustrialCapacity;
|
||||
}
|
||||
|
||||
public void SetMoneyCapacity(int newMoneyCapacity)
|
||||
{
|
||||
if (newMoneyCapacity >= 0)
|
||||
{
|
||||
_moneyCapacity = newMoneyCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetMilitaryPower(int newMilitaryPower)
|
||||
{
|
||||
if (newMilitaryPower >= 0)
|
||||
{
|
||||
_militaryPower = newMilitaryPower;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetRunning(bool newRunning)
|
||||
{
|
||||
_isRunning = newRunning;
|
||||
}
|
||||
|
||||
public void SetId(ABuilding.BuildingID newId)
|
||||
{
|
||||
_iD = newId;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
44
Assets/Scripts/Buildings/BuildingBuilder.cs
Normal file
44
Assets/Scripts/Buildings/BuildingBuilder.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBuilding
|
||||
{
|
||||
public static class BuildingBuilder
|
||||
{
|
||||
public static ABuilding Build(ABuilding.BuildingID eBuilding)
|
||||
{
|
||||
switch (eBuilding)
|
||||
{
|
||||
case ABuilding.BuildingID.Farm:
|
||||
{
|
||||
return new Farm();
|
||||
}
|
||||
|
||||
case ABuilding.BuildingID.Smeltery:
|
||||
{
|
||||
return new Smeltery();
|
||||
}
|
||||
|
||||
case ABuilding.BuildingID.Armory:
|
||||
{
|
||||
return new Armory();
|
||||
}
|
||||
|
||||
case ABuilding.BuildingID.Spaceport:
|
||||
{
|
||||
return new Spaceport();
|
||||
}
|
||||
|
||||
case ABuilding.BuildingID.Market:
|
||||
{
|
||||
return new Market();
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
169
Assets/Scripts/Buildings/BuildingManager.cs
Normal file
169
Assets/Scripts/Buildings/BuildingManager.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBuilding
|
||||
{
|
||||
/// <summary>
|
||||
/// Class <c>BuildingManager</c> contains functions to sum up values from buidlings at star system.
|
||||
/// </summary>
|
||||
public class BuildingManager
|
||||
{
|
||||
Dictionary<int, List<IBuilding>> doPlayerBuildings = new Dictionary<int, List<IBuilding>>();
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>GetAllValues</c> sums up the running cost of all buildings at star system of player.
|
||||
/// <param><c>iId</c> is the id of a player.</param>
|
||||
/// <returns>Returns <c>all values</c> of all buildings at star system of player.</returns>
|
||||
/// More efficient because it iterates only once through list instead of 6 times.
|
||||
/// </summary>
|
||||
public BuildingValues GetAllValues(int iId)
|
||||
{
|
||||
BuildingValues oValues = new BuildingValues();
|
||||
List<IBuilding> loBuildings = doPlayerBuildings[iId];
|
||||
foreach (var oBuilding in loBuildings)
|
||||
{
|
||||
oValues.RunningCost += oBuilding.GetRunningCost();
|
||||
oValues.ScienceCapacity += oBuilding.GetScienceCapacity();
|
||||
oValues.FoodCapacity += oBuilding.GetFoodCapacity();
|
||||
oValues.IndustrialCapacity += oBuilding.GetIndustrialCapacity();
|
||||
oValues.MoneyCapacity += oBuilding.GetMoneyCapacity();
|
||||
oValues.MilitaryPower += oBuilding.GetMilitaryPower();
|
||||
}
|
||||
return oValues;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>GetRunningCost</c> sums up the running cost of all buildings at star system of player.
|
||||
/// <param><c>iId</c> is the id of a player.</param>
|
||||
/// <returns>Returns <c>running cost</c> of all buildings at star system of player.</returns>
|
||||
/// </summary>
|
||||
public int GetRunningCost(int iId)
|
||||
{
|
||||
int iRunningCost = 0;
|
||||
List<IBuilding> loBuildings = doPlayerBuildings[iId];
|
||||
foreach (var oBuilding in loBuildings)
|
||||
{
|
||||
iRunningCost += oBuilding.GetRunningCost();
|
||||
}
|
||||
return iRunningCost;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>GetScienceCapacity</c> sums up the science capacity of all buildings at star system of player.
|
||||
/// <param><c>iId</c> is the id of a player.</param>
|
||||
/// <returns>Returns <c>science capacity</c> of all buildings at star system of player.</returns>
|
||||
/// </summary>
|
||||
public int GetScienceCapacity(int iId)
|
||||
{
|
||||
int iScienceCapacity = 0;
|
||||
List<IBuilding> loBuildings = doPlayerBuildings[iId];
|
||||
foreach (var oBuilding in loBuildings)
|
||||
{
|
||||
iScienceCapacity += oBuilding.GetScienceCapacity();
|
||||
}
|
||||
return iScienceCapacity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>GetFoodCapacity</c> sums up the food capacity of all buildings at star system of player.
|
||||
/// <param><c>iId</c> is the id of a player.</param>
|
||||
/// <returns>Returns <c>food capacity</c> of all buildings at star system of player.</returns>
|
||||
/// </summary>
|
||||
public int GetFoodCapacity(int iId)
|
||||
{
|
||||
int iFoodCapacity = 0;
|
||||
List<IBuilding> loBuildings = doPlayerBuildings[iId];
|
||||
foreach (var oBuilding in loBuildings)
|
||||
{
|
||||
iFoodCapacity += oBuilding.GetFoodCapacity();
|
||||
}
|
||||
return iFoodCapacity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>GetIndustrialCapacity</c> sums up the industrial capacity of all buildings at star system of player.
|
||||
/// <param><c>iId</c> is the id of a player.</param>
|
||||
/// <returns>Returns <c>industrial capacity</c> of all buildings at star system of player.</returns>
|
||||
/// </summary>
|
||||
public int GetIndustrialCapacity(int iId)
|
||||
{
|
||||
int iIndustrialCapacity = 0;
|
||||
List<IBuilding> loBuildings = doPlayerBuildings[iId];
|
||||
foreach (var oBuilding in loBuildings)
|
||||
{
|
||||
iIndustrialCapacity += oBuilding.GetIndustrialCapacity();
|
||||
}
|
||||
return iIndustrialCapacity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>GetMoneyCapacity</c> sums up the money capacity of all buildings at star system of player.
|
||||
/// <param><c>iId</c> is the id of a player.</param>
|
||||
/// <returns>Returns <c>money capacity</c> of all buildings at star system of player.</returns>
|
||||
/// </summary>
|
||||
public int GetMoneyCapacity(int iId)
|
||||
{
|
||||
int iMoneyCapacity = 0;
|
||||
List<IBuilding> loBuildings = doPlayerBuildings[iId];
|
||||
foreach (var oBuilding in loBuildings)
|
||||
{
|
||||
iMoneyCapacity += oBuilding.GetMoneyCapacity();
|
||||
}
|
||||
return iMoneyCapacity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>GetMilitaryCapacity</c> sums up the military capacity of all buildings at star system of player.
|
||||
/// <param><c>iId</c> is the id of a player.</param>
|
||||
/// <returns>Returns <c>military capacity</c> of all buildings at star system of player.</returns>
|
||||
/// </summary>
|
||||
public int GetMilitaryPower(int iId)
|
||||
{
|
||||
int iMilitaryPower = 0;
|
||||
List<IBuilding> loBuildings = doPlayerBuildings[iId];
|
||||
foreach (var oBuilding in loBuildings)
|
||||
{
|
||||
iMilitaryPower += oBuilding.GetMilitaryPower();
|
||||
}
|
||||
return iMilitaryPower;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>BuildNewBuilding</c> checks if building already exists, if not creates a new building and adds it to list.
|
||||
/// <param><c>iPlayerId</c> is the id of a player.</param>
|
||||
/// <param><c>eBuildingId</c> is the id of a building.</param>
|
||||
/// </summary>
|
||||
public void BuildNewBuilding(int iPlayerId, ABuilding.BuildingID eBuildingId)
|
||||
{
|
||||
List<IBuilding> loBuildings = doPlayerBuildings[iPlayerId];
|
||||
foreach (var oBuilding in loBuildings)
|
||||
{
|
||||
if (oBuilding.GetId() == eBuildingId)
|
||||
{
|
||||
// TODO throw exception
|
||||
}
|
||||
}
|
||||
loBuildings.Add(BuildingBuilder.Build(eBuildingId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>DestroyBuilding</c> checks if building exists, if it exists, deletes it from list, if not, returns value of Remove(null).
|
||||
/// <param><c>iPlayerId</c> is the id of a player.</param>
|
||||
/// <param><c>eBuildingId</c> is the id of a building.</param>
|
||||
/// </summary>
|
||||
public void DestroyBuilding(int iPlayerId, ABuilding.BuildingID eBuildingId)
|
||||
{
|
||||
List<IBuilding> loBuildings = doPlayerBuildings[iPlayerId];
|
||||
IBuilding building = null;
|
||||
foreach (var oBuilding in loBuildings)
|
||||
{
|
||||
if (oBuilding.GetId() == eBuildingId)
|
||||
{
|
||||
building = oBuilding;
|
||||
}
|
||||
}
|
||||
//TODO what does Remove return? handle
|
||||
loBuildings.Remove(building);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Assets/Scripts/Buildings/BuildingValues.cs
Normal file
25
Assets/Scripts/Buildings/BuildingValues.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBuilding
|
||||
{
|
||||
/// <summary>
|
||||
/// Class <c>BuildingValues</c> is a container to transport data.
|
||||
/// <value></value>
|
||||
/// <value>RunningCost is the running cost of a building.</value>
|
||||
/// <value>ScienceCapacity is the amount of science produced by the building.</value>
|
||||
/// <value>FoodCapacity is the amount of food produced by the building.</value>
|
||||
/// <value>IndustrialCapacity is the amount of industry produced by the building.</value>
|
||||
/// <value>MoneyCapacity is the amount of money produced by the building.</value>
|
||||
/// <value>MilitaryPower is the amount of military produced by the building.</value>
|
||||
/// </summary>
|
||||
public class BuildingValues
|
||||
{
|
||||
public int RunningCost = 0;
|
||||
public int ScienceCapacity = 0;
|
||||
public int FoodCapacity = 0;
|
||||
public int IndustrialCapacity = 0;
|
||||
public int MoneyCapacity = 0;
|
||||
public int MilitaryPower = 0;
|
||||
}
|
||||
}
|
||||
14
Assets/Scripts/Buildings/Food/Farm.cs
Normal file
14
Assets/Scripts/Buildings/Food/Farm.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBuilding
|
||||
{
|
||||
public class Farm : ABuilding
|
||||
{
|
||||
public Farm()
|
||||
{
|
||||
SetFoodCapacity(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
76
Assets/Scripts/Buildings/IBuilding.cs
Normal file
76
Assets/Scripts/Buildings/IBuilding.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBuilding
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface <c>IBuilding</c> defines the functions for the buildings.
|
||||
/// <param><c>iId</c> is the id of a player.</param>
|
||||
/// <returns>Returns <c>all values</c> of all buildings at star system of player.</returns>
|
||||
/// More efficient because it iterates only once through list instead of 6 times.
|
||||
/// </summary>
|
||||
public interface IBuilding
|
||||
{
|
||||
//----------------------------------------------------------------------------
|
||||
// Getters
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>GetRunningCost</c> returns the running cost if the building is running.
|
||||
/// </summary>
|
||||
public int GetRunningCost();
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>GetScienceCapacity</c> returns the amount of science the building produces if it is running.
|
||||
/// </summary>
|
||||
public int GetScienceCapacity();
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>GetFoodCapacity</c> returns the amount of food the building produces if it is running.
|
||||
/// </summary>
|
||||
public int GetFoodCapacity();
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>GetIndustrialCapacity</c> returns the amount of industrial the building produces if it is running.
|
||||
/// </summary>
|
||||
public int GetIndustrialCapacity();
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>GetMoneyCapacity</c> returns the amount of money the building produces if it is running.
|
||||
/// </summary>
|
||||
public int GetMoneyCapacity();
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>GetMilitaryPower</c> returns the amount of power the building produces if it is running.
|
||||
/// </summary>
|
||||
public int GetMilitaryPower();
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>IsRunning</c> returns true if the building is running, false if the building is not running.
|
||||
/// </summary>
|
||||
public bool IsRunning();
|
||||
|
||||
/// <summary>
|
||||
/// Function <c>GetId</c> returns id of building.
|
||||
/// </summary>
|
||||
public ABuilding.BuildingID GetId();
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Setters
|
||||
|
||||
public void SetRunningCost(int newRunningCost);
|
||||
public void SetScienceCapacity(int newScienceCapacity);
|
||||
public void SetFoodCapacity(int newFoodCapacity);
|
||||
public void SetIndustrialCapacity(int newIndustrialCapacity);
|
||||
public void SetMoneyCapacity(int newMoneyCapacity);
|
||||
public void SetMilitaryPower(int newMilitaryPower);
|
||||
|
||||
public void SetRunning(bool newRunning);
|
||||
|
||||
public void SetId(ABuilding.BuildingID newId);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
13
Assets/Scripts/Buildings/Industry/Smeltery.cs
Normal file
13
Assets/Scripts/Buildings/Industry/Smeltery.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBuilding
|
||||
{
|
||||
public class Smeltery : ABuilding
|
||||
{
|
||||
public Smeltery()
|
||||
{
|
||||
SetIndustrialCapacity(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/Scripts/Buildings/Military/Armory.cs
Normal file
13
Assets/Scripts/Buildings/Military/Armory.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBuilding
|
||||
{
|
||||
public class Armory : ABuilding
|
||||
{
|
||||
public Armory()
|
||||
{
|
||||
SetMilitaryPower(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Assets/Scripts/Buildings/Misc/Spaceport.cs
Normal file
10
Assets/Scripts/Buildings/Misc/Spaceport.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBuilding
|
||||
{
|
||||
public class Spaceport : ABuilding
|
||||
{
|
||||
public Spaceport() { }
|
||||
}
|
||||
}
|
||||
16
Assets/Scripts/Buildings/Money/Market.cs
Normal file
16
Assets/Scripts/Buildings/Money/Market.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBuilding
|
||||
{
|
||||
/// <summary>
|
||||
/// Class <c>Market</c> defines the class for market.
|
||||
/// </summary>
|
||||
public class Market : ABuilding
|
||||
{
|
||||
public Market()
|
||||
{
|
||||
SetMoneyCapacity(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/Scripts/Buildings/Science/University.cs
Normal file
13
Assets/Scripts/Buildings/Science/University.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBuilding
|
||||
{
|
||||
public class University : ABuilding
|
||||
{
|
||||
public University()
|
||||
{
|
||||
SetScienceCapacity(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Assets/Scripts/Clock.cs
Normal file
30
Assets/Scripts/Clock.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Clock : MonoBehaviour
|
||||
{
|
||||
// Array ref to player managers
|
||||
public GameManager gameManager { private get; set; }
|
||||
|
||||
public float DayTime = 10.0f;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
// callUpdateGame will be called once each n seconds
|
||||
InvokeRepeating("callUpdateGame", 0.0f, DayTime);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){}
|
||||
|
||||
// calls update game
|
||||
private void callUpdateGame()
|
||||
{
|
||||
if (gameManager != null)
|
||||
{
|
||||
gameManager.updateGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
55
Assets/Scripts/GameManager.cs
Normal file
55
Assets/Scripts/GameManager.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
// Array will contain objects which contain all information about all players
|
||||
public PlayerManager[] playerManagers { get; private set; }
|
||||
|
||||
// Clock which counts seconds until new day and updates playerManagers at new day
|
||||
public Clock clock;
|
||||
|
||||
public ScienceManager sm;
|
||||
|
||||
public int numberOfPlayers { get; set; }
|
||||
|
||||
void Awake()
|
||||
{
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
initPlayerManagers(1);
|
||||
clock.gameManager = this;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){}
|
||||
|
||||
// Initializes numberOfPlayers player managers and puts them into array
|
||||
public void initPlayerManagers(int numberOfPlayers)
|
||||
{
|
||||
this.playerManagers = new PlayerManager[numberOfPlayers];
|
||||
for (int i = 0; i < numberOfPlayers; i++)
|
||||
{
|
||||
this.playerManagers[i] = new PlayerManager(sm);
|
||||
}
|
||||
}
|
||||
|
||||
// Updates game
|
||||
public void updateGame()
|
||||
{
|
||||
if (playerManagers != null)
|
||||
{
|
||||
// Simulate day for each player
|
||||
foreach (var playerManager in playerManagers)
|
||||
{
|
||||
playerManager.simulateDay();
|
||||
}
|
||||
}
|
||||
// TODO update view, do we need to update view?
|
||||
}
|
||||
}
|
||||
94
Assets/Scripts/PlayerManager.cs
Normal file
94
Assets/Scripts/PlayerManager.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class PlayerManager
|
||||
{
|
||||
// Contains all star systems of player
|
||||
//private List<GameObject> starSystems = new List<GameObject>();
|
||||
|
||||
// Contains all fleets of player
|
||||
//private List<GameObject> fleets = new List<GameObject>();
|
||||
|
||||
private ScienceManager _scienceManager;
|
||||
|
||||
public int ScienceAcumulated; // this int has to be moved to player manager later
|
||||
|
||||
public enum PlayerColor
|
||||
{
|
||||
None,
|
||||
Red,
|
||||
Blue,
|
||||
Green,
|
||||
Yellow
|
||||
}
|
||||
|
||||
public PlayerColor PlayerColor2
|
||||
{
|
||||
get
|
||||
{
|
||||
return _playerColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
_playerColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
private PlayerColor _playerColor;
|
||||
|
||||
|
||||
// Player values
|
||||
public PlayerValues PlayerAttributes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_playerAttributes == null)
|
||||
{
|
||||
_playerAttributes = new PlayerValues();
|
||||
}
|
||||
return new PlayerValues();
|
||||
}
|
||||
set
|
||||
{
|
||||
_playerAttributes = value;
|
||||
}
|
||||
}
|
||||
|
||||
private PlayerValues _playerAttributes;
|
||||
|
||||
public PlayerManager(ScienceManager sm)
|
||||
{
|
||||
this._scienceManager = sm;
|
||||
this._playerAttributes = new PlayerValues();
|
||||
}
|
||||
|
||||
// Called by clock over game manager, once per day
|
||||
public void simulateDay()
|
||||
{
|
||||
//if (starSystems != null)
|
||||
//{
|
||||
// Add resources for each part of each starSystem which belongs to this player
|
||||
//foreach (var starSystem in starSystems)
|
||||
//{
|
||||
// int playerID = this._playerAttributes.id;
|
||||
// // StarSystem.getComponent<Script>().getMoney();
|
||||
// this._playerAttributes.money += (1 + ScienceManager.repeatableWealth) * ((StarSystem)starSystem).getMoney(playerID);
|
||||
|
||||
// this._playerAttributes.science += ((StarSystem)starSystem).getScience(playerID);
|
||||
// this._playerAttributes.power += ((StarSystem)starSystem).getPower(playerID);
|
||||
// this._playerAttributes.food += ((StarSystem)starSystem).getFood(playerID);
|
||||
// this._playerAttributes.industrialCapacity += ((StarSystem)starSystem).getIC(playerID);
|
||||
this._playerAttributes.science += 5;
|
||||
_scienceManager.UpdateScience(this._playerAttributes.science);
|
||||
this._playerAttributes.science = _scienceManager.PublicScienceAcumulated;
|
||||
//}
|
||||
//}
|
||||
}
|
||||
|
||||
// Deletes overhanded referrence from fleets list
|
||||
// If not null
|
||||
//public void deleteFleet(ref GameObject fleet)
|
||||
//{
|
||||
// this.fleets.Remove(fleet);
|
||||
//}
|
||||
}
|
||||
36
Assets/Scripts/PlayerValues.cs
Normal file
36
Assets/Scripts/PlayerValues.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
public class PlayerValues
|
||||
{
|
||||
// Player id
|
||||
public int id { get; set; }
|
||||
|
||||
// Player values
|
||||
public int money { get; set; }
|
||||
public int science { get; set; }
|
||||
public int power { get; set; }
|
||||
public int food { get; set; }
|
||||
public int industrialCapacity { get; set; }
|
||||
|
||||
// Default constructor
|
||||
public PlayerValues()
|
||||
{
|
||||
this.id = 0;
|
||||
|
||||
this.money = 0;
|
||||
this.science = 0;
|
||||
this.power = 0;
|
||||
this.food = 0;
|
||||
this.industrialCapacity = 0;
|
||||
}
|
||||
|
||||
// Constructor to init values
|
||||
public PlayerValues(int id, int newMoney, int newScience, int newPower, int newFood, int newIC)
|
||||
{
|
||||
this.id = id;
|
||||
|
||||
this.money = newMoney;
|
||||
this.science = newScience;
|
||||
this.power = newPower;
|
||||
this.food = newFood;
|
||||
this.industrialCapacity = newIC;
|
||||
}
|
||||
}
|
||||
239
Assets/Scripts/ScienceManager.cs
Normal file
239
Assets/Scripts/ScienceManager.cs
Normal file
@@ -0,0 +1,239 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Reflection.Emit;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
public class ScienceManager : MonoBehaviour
|
||||
{
|
||||
public int ScienceCostCurrentTech;
|
||||
public GameObject ScienceUI;
|
||||
public Text AccScienceLabel;
|
||||
|
||||
public static int TechnologiesTotal = 4;
|
||||
public Tech[] techs = new Tech[TechnologiesTotal];
|
||||
|
||||
|
||||
public Text CostText;
|
||||
public Text[] TechQueueUIArr = new Text[4];
|
||||
public Text[] TechLevelLabels = new Text[4];
|
||||
|
||||
public List<Tech> TechQueue = new();
|
||||
public int Amount = 0;
|
||||
|
||||
private int ScienceAcumulated = 0;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
techs[0] = new Tech(1,1, "IndustryTech");
|
||||
techs[1] = new Tech(1,1, "WealthTech");
|
||||
techs[2] = new Tech(1,1, "ScienceTech");
|
||||
techs[3] = new Tech(1,1, "FoodTech");
|
||||
UpdateScience(0);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Amount = techs.Length ;
|
||||
}
|
||||
/// <summary>
|
||||
/// blend in/out science window
|
||||
/// </summary>
|
||||
public void SwitchScienceUI()
|
||||
{
|
||||
if (ScienceUI.activeInHierarchy == true)
|
||||
{
|
||||
ScienceUI.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScienceUI.SetActive(true);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// increase tech level
|
||||
/// reduce acumulated Science
|
||||
/// remove Tech from TechQueue
|
||||
/// </summary>
|
||||
public void UpdateScience(int actualScience)
|
||||
{
|
||||
this.ScienceAcumulated = actualScience;
|
||||
if ( this.TechQueue.Count > 0 )
|
||||
{
|
||||
ScienceCostCurrentTech = this.CalcScienceCost(this.TechQueue[0]);
|
||||
if (ScienceCostCurrentTech <= this.ScienceAcumulated)
|
||||
{
|
||||
for (int i = 0; i < this.techs.Length; i++)
|
||||
{
|
||||
if (String.Equals(TechQueue[0].Name, techs[i].Name))
|
||||
{
|
||||
techs[i].Level++;
|
||||
}
|
||||
}
|
||||
this.ScienceAcumulated -= ScienceCostCurrentTech;
|
||||
this.RemoveTechFromQueue(true);
|
||||
Debug.Log("TechQueue Count: " + TechQueue.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Nicht genug Science Punkte");
|
||||
}
|
||||
}
|
||||
UpdateScienceUI();
|
||||
}
|
||||
|
||||
public int PublicScienceAcumulated => this.ScienceAcumulated;
|
||||
|
||||
/// <summary>
|
||||
/// calculates the cost of next level of tech based on base cost and level
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
public int CalcScienceCost(Tech t)
|
||||
{
|
||||
int lvl = t.Level;
|
||||
int result = (lvl * lvl )* t.Cost;
|
||||
//Debug.Log("Cost:" + result);
|
||||
ScienceCostCurrentTech = result;
|
||||
Debug.Log("Result: " + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculates the cost of next level of tech based on base cost and level
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
public int CalcScienceCost(Tech t, int InQueue)
|
||||
{
|
||||
int lvl = t.Level + InQueue;
|
||||
int result = (lvl * lvl) * t.Cost;
|
||||
//Debug.Log("Cost:" + result);
|
||||
ScienceCostCurrentTech = result;
|
||||
Debug.Log("Result: " + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public void AddToQueue(String name)
|
||||
{
|
||||
|
||||
//safequard agains queue overlfow
|
||||
if (TechQueue.Count >= 4)
|
||||
{
|
||||
Debug.Log("Queue full");
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < this.techs.Length; i++)
|
||||
{
|
||||
|
||||
if (String.Equals(name, techs[i].Name))
|
||||
{
|
||||
Debug.Log("i: " + i);
|
||||
TechQueue.Add(this.techs[i]);
|
||||
}
|
||||
}
|
||||
UpdateScienceUI();
|
||||
Debug.Log("TechQueue.Count: " + TechQueue.Count);
|
||||
}
|
||||
/// <summary>
|
||||
/// first=true is first element, first=false is last index
|
||||
/// </summary>
|
||||
/// <param name="first"></param>
|
||||
public void RemoveTechFromQueue(bool first)
|
||||
{
|
||||
//safeguard against TechQueue underflow
|
||||
if (TechQueue.Count < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (first == true)
|
||||
{
|
||||
//remove first
|
||||
TechQueue.RemoveAt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//remove last
|
||||
TechQueue.RemoveAt(TechQueue.Count-1);
|
||||
}
|
||||
UpdateScienceUI();
|
||||
}
|
||||
public void UpdateQueueText()
|
||||
{
|
||||
|
||||
//empty queue ui
|
||||
for (int i = 0; i < TechQueueUIArr.Length; i++)
|
||||
{
|
||||
TechQueueUIArr[i].text = "--";
|
||||
}
|
||||
// fill queue ui
|
||||
|
||||
for (int i = 0; i < TechQueue.Count ; i++)
|
||||
{
|
||||
Debug.Log("TechQueue.Count: " + TechQueue.Count);
|
||||
TechQueueUIArr[i].text = TechQueue[i].Name;
|
||||
}
|
||||
}
|
||||
public void UpdateScienceUI()
|
||||
{
|
||||
UpdateQueueText();
|
||||
AccScienceLabel.text = ScienceAcumulated.ToString();
|
||||
for (int i = 0; i < TechLevelLabels.Length; i++)
|
||||
{
|
||||
TechLevelLabels[i].text = techs[i].Level.ToString();
|
||||
}
|
||||
CostText.text = ScienceCostCurrentTech.ToString();
|
||||
}
|
||||
public void ResetPoints()
|
||||
{
|
||||
this.ScienceAcumulated += 20;
|
||||
UpdateScienceUI();
|
||||
}
|
||||
public void DisplayCostReset()
|
||||
{
|
||||
CostText.text = "0";
|
||||
}
|
||||
public void DisplayCost(String name)
|
||||
{
|
||||
int NumberOcc = 0;
|
||||
for (int i = 0; i < this.TechQueue.Count; i++)
|
||||
{
|
||||
if (String.Equals(TechQueue[i].Name, name))
|
||||
{
|
||||
NumberOcc++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.techs.Length; i++)
|
||||
{
|
||||
if (String.Equals(name, techs[i].Name))
|
||||
{
|
||||
CostText.text = CalcScienceCost(techs[i], NumberOcc).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Tech
|
||||
{
|
||||
public int Cost;
|
||||
public int Level;
|
||||
public String Name;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="c"></param>
|
||||
/// <param name="l"></param>
|
||||
/// <param name="n"></param>
|
||||
public Tech(int c, int l, String n)
|
||||
{
|
||||
this.Cost = c;
|
||||
this.Level = l;
|
||||
this.Name = n;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user