Skip to content

Commit

Permalink
Merge pull request #495 from Nashet/ver.0.20
Browse files Browse the repository at this point in the history
better unit selection & upload
  • Loading branch information
Nashet authored Jun 2, 2018
2 parents 64c049d + 229b760 commit 6dfe74c
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 12 deletions.
Binary file modified Assets/EconomicSimulation/ES-base.unity
Binary file not shown.
Binary file modified Assets/EconomicSimulation/Resources/Prefabs/UnitPanel.prefab
Binary file not shown.
2 changes: 1 addition & 1 deletion Assets/EconomicSimulation/Scripts/Logic/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,5 +359,5 @@ public override string ToString()
{
return "Agent "+ cash.Get();
}
}
}
}
10 changes: 1 addition & 9 deletions Assets/EconomicSimulation/Scripts/Logic/Mono/Unit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,7 @@ public class Unit : Hideable, IHasProvince//, IHasCountry//MonoBehaviour,
Animator m_Animator;


private readonly static List<Unit> allUnits = new List<Unit>();

public Army NextArmy
{
get
{
return Game.Player.AllArmies().Where(x => x.Province == Province).Random();
}
}
private readonly static List<Unit> allUnits = new List<Unit>();

public Province Province { get; private set; }

Expand Down
2 changes: 1 addition & 1 deletion Assets/EconomicSimulation/Scripts/Panels/BottomPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class BottomPanel : Window
private void Awake() // used to position other windows
{
MainCamera.bottomPanel = this;
generalText.text = "Prosperity Wars v0.20.4";
generalText.text = "Prosperity Wars v0.20.5";
Hide();
}

Expand Down
26 changes: 26 additions & 0 deletions Assets/EconomicSimulation/Scripts/Utils/ExtendedList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nashet.Utils
{
/// <summary>
/// Remembers and gives next element. Not used now
/// </summary>
public class ExtendedList<T> : List<T>
{
private int nextElement = -1;
public T Next
{
get
{
nextElement++;
if (nextElement == this.Count)
nextElement = 0;
return this[nextElement];
}
}
}
}
13 changes: 13 additions & 0 deletions Assets/EconomicSimulation/Scripts/Utils/ExtendedList.cs.meta

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

13 changes: 13 additions & 0 deletions Assets/EconomicSimulation/Scripts/Utils/Extensions/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,19 @@ public static IEnumerable<T> Yield<T>(this T item)
{
yield return item;
}
public static T Next<T>(this IEnumerable<T> collection, ref int number)
{
if (collection.IsEmpty())
return default(T);
var res = collection.ElementAtOrDefault(number);
if (res == null)
{
number = 0;
res = collection.ElementAtOrDefault(number);
}
number++;
return res;
}
//public static void ForEach<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, Action<TKey, TValue> invokeMe)
//{
// foreach (var keyValue in dictionary)
Expand Down
3 changes: 2 additions & 1 deletion Assets/RTSStyleUnitSelection/Script/SelectionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class SelectionComponent : MonoBehaviour
private static Camera camera; // it's OK
[SerializeField]
private KeyCode AdditionKey;
private int nextArmyToSelect;

private void Start()
{
Expand Down Expand Up @@ -155,7 +156,7 @@ private void SelectUnitOrProvince()
{
var unit = collider.transform.GetComponent<Unit>();

var army = unit.NextArmy;
var army = unit.Province.AllStandingArmies().Where(x => x.getOwner() == Game.Player).Next(ref nextArmyToSelect);
if (army != null)
{
if (Input.GetKey(AdditionKey))
Expand Down
Binary file modified WEBGL/Build/WEBGL.asm.code.unityweb
Binary file not shown.
Binary file modified WEBGL/Build/WEBGL.asm.framework.unityweb
Binary file not shown.
Binary file modified WEBGL/Build/WEBGL.asm.memory.unityweb
Binary file not shown.
Binary file modified WEBGL/Build/WEBGL.data.unityweb
Binary file not shown.

0 comments on commit 6dfe74c

Please sign in to comment.