Skip to content

Commit

Permalink
Merge pull request #150 from hhzzff/dev
Browse files Browse the repository at this point in the history
feat: ✨ Improved health ui
  • Loading branch information
asdawej authored Mar 29, 2024
2 parents cd37156 + f859185 commit 632dd5f
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 32 deletions.
4 changes: 2 additions & 2 deletions interface/interface_local/Assets/Scenes/Game.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ MonoBehaviour:
m_Intensity: 1
m_LightVolumeIntensity: 1
m_LightVolumeIntensityEnabled: 0
m_ApplyToSortingLayers: 000000004b3dcac2
m_ApplyToSortingLayers: 000000004b3dcac2a58403fc
m_LightCookieSprite: {fileID: 0}
m_DeprecatedPointLightCookieSprite: {fileID: 0}
m_LightOrder: 0
Expand Down Expand Up @@ -1724,7 +1724,7 @@ Canvas:
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 25
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
m_SortingLayerID: -66878299
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &1698811764
Expand Down
13 changes: 7 additions & 6 deletions interface/interface_local/Assets/Scripts/Base/BaseControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class BaseControl : MonoBehaviour
public Vector2[] generatePos = new Vector2[2];
[SerializeField]
public MessageOfBase messageOfBase;
public GameObject obj;
// Start is called before the first frame update
void Start()
{
Expand All @@ -23,16 +24,16 @@ void Update()
switch (interactBase.interactOption)
{
case InteractControl.InteractOption.BuildCivil:
ObjCreater.GetInstance().CreateObj(ShipType.CIVILIAN_SHIP, generatePos[Tool.GetInstance().GetRandom(0, 2)]).GetComponent<ShipControl>()
.messageOfShip.playerTeam = messageOfBase.playerTeam;
obj = ObjCreater.GetInstance().CreateObj(ShipType.CIVILIAN_SHIP, generatePos[Tool.GetInstance().GetRandom(0, 2)]);
obj.GetComponent<ShipControl>().messageOfShip.playerTeam = messageOfBase.playerTeam;
break;
case InteractControl.InteractOption.BuildMilitary:
ObjCreater.GetInstance().CreateObj(ShipType.MILITARY_SHIP, generatePos[Tool.GetInstance().GetRandom(0, 2)]).GetComponent<ShipControl>()
.messageOfShip.playerTeam = messageOfBase.playerTeam;
obj = ObjCreater.GetInstance().CreateObj(ShipType.MILITARY_SHIP, generatePos[Tool.GetInstance().GetRandom(0, 2)]);
obj.GetComponent<ShipControl>().messageOfShip.playerTeam = messageOfBase.playerTeam;
break;
case InteractControl.InteractOption.BuildFlag:
ObjCreater.GetInstance().CreateObj(ShipType.FLAG_SHIP, generatePos[Tool.GetInstance().GetRandom(0, 2)]).GetComponent<ShipControl>()
.messageOfShip.playerTeam = messageOfBase.playerTeam;
obj = ObjCreater.GetInstance().CreateObj(ShipType.FLAG_SHIP, generatePos[Tool.GetInstance().GetRandom(0, 2)]);
obj.GetComponent<ShipControl>().messageOfShip.playerTeam = messageOfBase.playerTeam;
break;
default: break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class InteractBase : MonoBehaviour
public bool tobeSelected, selected;
public GameObject selectedSign, tobeSelectedSign, tobeseObj, seObj;
public Vector2 moveOption, attackOption;
public bool enableMove;
void Update()
{
if (tobeSelected)
Expand Down
39 changes: 23 additions & 16 deletions interface/interface_local/Assets/Scripts/Map/MapControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using System.Collections.Generic;
using UnityEngine;

public class MapControl : MonoBehaviour
public class MapControl : SingletonMono<MapControl>
{
public GameObject mapFa;
public GameObject[] bases = new GameObject[2];
public BaseControl[] bases = new BaseControl[2];
public static uint[,] Map = new uint[50, 50] { { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 0, 0, 0, 0, 0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 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } };
// Start is called before the first frame update
void Start()
Expand All @@ -20,23 +20,30 @@ void DrawMap(uint[,] map)
{
for (int j = 0; j < 50; j++)
{
if ((PlaceType)map[i, j] == PlaceType.HOME)
switch ((PlaceType)map[i, j])
{
if (!bases[0])
bases[0] = ObjCreater.GetInstance().CreateObj((PlaceType)map[i, j], new Vector2(j, 50 - i));
else
bases[1] = ObjCreater.GetInstance().CreateObj((PlaceType)map[i, j], new Vector2(j, 50 - i));
case PlaceType.HOME:
if (!bases[0])
bases[0] = ObjCreater.GetInstance().CreateObj(PlaceType.HOME, new Vector2(j, 50 - i)).GetComponent<BaseControl>();
else
bases[1] = ObjCreater.GetInstance().CreateObj(PlaceType.HOME, new Vector2(j, 50 - i)).GetComponent<BaseControl>();
break;
case PlaceType.RESOURCE:
ObjCreater.GetInstance().CreateObj(PlaceType.HOME, new Vector2(j, 50 - i));
PlaceManager.GetInstance().resource.Add(new Vector2(j, 50 - i));
break;
default:
ObjCreater.GetInstance().CreateObj((PlaceType)map[i, j], new Vector2(j, 50 - i));
break;
}
else
ObjCreater.GetInstance().CreateObj((PlaceType)map[i, j], new Vector2(j, 50 - i));
}
bases[0].messageOfBase.playerTeam = PlayerTeam.BLUE;
bases[1].messageOfBase.playerTeam = PlayerTeam.RED;
}
bases[0].GetComponent<BaseControl>().messageOfBase.playerTeam = PlayerTeam.BLUE;
bases[1].GetComponent<BaseControl>().messageOfBase.playerTeam = PlayerTeam.RED;
}
// Update is called once per frame
void Update()
{
// Update is called once per frame
void Update()
{

}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlaceManager : Singleton<PlaceManager>
{
public List<Vector2> resource;

}

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

Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ void ShipMpve()
{
foreach (InteractBase interactBase in selectedInt)
{
interactBase.enableMove = true;
interactBase.moveOption = Camera.main.ScreenToWorldPoint(Input.mousePosition);
}
}
Expand Down
33 changes: 26 additions & 7 deletions interface/interface_local/Assets/Scripts/Ship/ShipControl.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.iOS;
using UnityEngine;

public class ShipControl : MonoBehaviour
Expand Down Expand Up @@ -37,19 +39,36 @@ void Start()
// Update is called once per frame
void Update()
{
switch (interactBase.interactOption)
{
case InteractControl.InteractOption.Produce:
foreach (Vector2 resourcePos in PlaceManager.GetInstance().resource)
{
if (Tool.GetInstance().CheckBeside(transform.position, resourcePos))
{

}
}
break;
default: break;
}
MoveTowards(interactBase.moveOption);
AttackTowards(interactBase.attackOption);
interactBase.attackOption = Vector2.zero;
}
void MoveTowards(Vector2 pos)
{
if ((pos - (Vector2)transform.position).magnitude > 0.1f)
{
targetQ = DealQ(Mathf.Atan2(pos.y - transform.position.y, pos.x - transform.position.x) * Mathf.Rad2Deg - 90);
SetVQTo((pos - (Vector2)transform.position).normalized * speed);
}
else
SetVQTo(Vector2.zero);
if (interactBase.enableMove)
if ((pos - (Vector2)transform.position).magnitude > 0.1f)
{
targetQ = DealQ(Mathf.Atan2(pos.y - transform.position.y, pos.x - transform.position.x) * Mathf.Rad2Deg - 90);
SetVQTo((pos - (Vector2)transform.position).normalized * speed);
}
else
{
SetVQTo(Vector2.zero);
interactBase.enableMove = false;
}
}
void AttackTowards(Vector2 pos)
{
Expand Down
10 changes: 10 additions & 0 deletions interface/interface_local/Assets/Scripts/Tool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,14 @@ public int GetRandom(int min, int max)
{
return a.Next(min, max);
}
public Vector2 GridToCell(Vector2 grid)
{
return new Vector2(50.5f - grid.y, 0.5f + grid.x);
}
public bool CheckBeside(Vector2 grid, Vector2 cell)
{
if (Mathf.Abs(GridToCell(grid).x - cell.x) + Mathf.Abs(GridToCell(grid).y - cell.y) <= 2)
return true;
return false;
}
}
5 changes: 4 additions & 1 deletion interface/interface_local/ProjectSettings/TagManager.asset
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TagManager:
- Water
- UI
- Interactable
-
- Passable
-
-
-
Expand Down Expand Up @@ -45,3 +45,6 @@ TagManager:
- name: Default
uniqueID: 0
locked: 0
- name: UI
uniqueID: 4228088997
locked: 0

0 comments on commit 632dd5f

Please sign in to comment.