modification graphics

main
Benjamin Kraft 1 year ago
parent de502ca3de
commit e6858c12d8
  1. 19
      Assets/Prefabs/BorderBuff.asset
  2. 8
      Assets/Prefabs/BorderBuff.asset.meta
  3. 19
      Assets/Prefabs/BorderNerf.asset
  4. 8
      Assets/Prefabs/BorderNerf.asset.meta
  5. 90
      Assets/Prefabs/Modification.prefab
  6. 7
      Assets/Prefabs/Modification.prefab.meta
  7. 2
      Assets/Prefabs/Player.prefab
  8. 19
      Assets/Prefabs/SpeedBuff.asset
  9. 8
      Assets/Prefabs/SpeedBuff.asset.meta
  10. 19
      Assets/Prefabs/SpeedNerf.asset
  11. 8
      Assets/Prefabs/SpeedNerf.asset.meta
  12. 14
      Assets/Scenes/Game.unity
  13. 17
      Assets/Scripts/Game/GameManager.cs
  14. 17
      Assets/Scripts/Game/Modification.cs
  15. 15
      Assets/Scripts/Game/ModificationProperties.cs
  16. 3
      Assets/Scripts/Game/ModificationProperties.cs.meta
  17. 11
      Assets/Scripts/GameUI.cs
  18. 6
      Assets/UI Toolkit/PlayerUI.uxml
  19. 4
      Assets/UI Toolkit/game.uss
  20. 1
      Assets/UI Toolkit/player_panel.uss
  21. 2
      ProjectSettings/Physics2DSettings.asset
  22. 6
      ProjectSettings/TagManager.asset

@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4453d1448ec14f5fa81aae3c54f78010, type: 3}
m_Name: BorderBuff
m_EditorClassIdentifier:
type: 1
effect: 1
pickupDuration: 10
activeDuration: 10
image: {fileID: 21300000, guid: 500c6690dd1efa237973d86a4232f5c0, type: 3}

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: df0f24b538b5fed02a7faa3a5e0f121b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4453d1448ec14f5fa81aae3c54f78010, type: 3}
m_Name: BorderNerf
m_EditorClassIdentifier:
type: 0
effect: 1
pickupDuration: 10
activeDuration: 10
image: {fileID: 21300000, guid: 555c4207622e3e429bea3c98ad8ae3f5, type: 3}

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 73dc3bbc93cba37b1b989a9497b680e7
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,90 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7947935438987891319
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7947935438987891323}
- component: {fileID: 7947935438987891317}
- component: {fileID: 7947935438987891316}
- component: {fileID: 5272754659973803181}
m_Layer: 7
m_Name: Modification
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7947935438987891323
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7947935438987891319}
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}
--- !u!114 &7947935438987891317
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7947935438987891319}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1b95f7504787409bb84f5fc3b5e3865f, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &7947935438987891316
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7947935438987891319}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier:
GlobalObjectIdHash: 951099334
AlwaysReplicateAsRoot: 0
DontDestroyWithOwner: 0
AutoObjectParentSync: 1
--- !u!61 &5272754659973803181
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7947935438987891319}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 2, y: 2}
newSize: {x: 2, y: 2}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 2, y: 2}
m_EdgeRadius: 0

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8db15b80a161e4faf9681d9e29b563ce
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -13,7 +13,7 @@ GameObject:
- component: {fileID: 5402279313309450412}
- component: {fileID: 1666507220592599477}
- component: {fileID: 1287955657}
m_Layer: 0
m_Layer: 8
m_Name: Player
m_TagString: Untagged
m_Icon: {fileID: 0}

@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4453d1448ec14f5fa81aae3c54f78010, type: 3}
m_Name: SpeedBuff
m_EditorClassIdentifier:
type: 1
effect: 0
pickupDuration: 10
activeDuration: 10
image: {fileID: 21300000, guid: c9633c24081701c6c9ce9884d6524530, type: 3}

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e24dcbc74c0ebdd94acb60adba3415c7
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4453d1448ec14f5fa81aae3c54f78010, type: 3}
m_Name: SpeedNerf
m_EditorClassIdentifier:
type: 0
effect: 0
pickupDuration: 10
activeDuration: 10
image: {fileID: 21300000, guid: 24ca60336f20aee73b5b211b6f6e1a44, type: 3}

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ae5a83823d492d27bbb84006f6e0e8c2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

@ -133,7 +133,7 @@ GameObject:
m_Component:
- component: {fileID: 132613873}
- component: {fileID: 132613874}
m_Layer: 0
m_Layer: 9
m_Name: Left
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -396,7 +396,7 @@ GameObject:
- component: {fileID: 1100318145}
- component: {fileID: 1100318146}
- component: {fileID: 1100318147}
m_Layer: 0
m_Layer: 9
m_Name: Bottom
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -462,7 +462,7 @@ GameObject:
m_Component:
- component: {fileID: 1462314554}
- component: {fileID: 1462314555}
m_Layer: 0
m_Layer: 9
m_Name: Right
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -592,7 +592,7 @@ GameObject:
- component: {fileID: 2069256771}
- component: {fileID: 2069256772}
- component: {fileID: 2069256773}
m_Layer: 0
m_Layer: 9
m_Name: Top
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -680,6 +680,12 @@ MonoBehaviour:
m_EditorClassIdentifier:
ballPrefab: {fileID: 7041796185663956342, guid: d67d5f2db5f0b3d9d8298731f423a9b6, type: 3}
playerPrefab: {fileID: 5402279313309450415, guid: 32b3bb87d3699d314ace59ddb1674875, type: 3}
modificationPrefab: {fileID: 7947935438987891319, guid: 8db15b80a161e4faf9681d9e29b563ce, type: 3}
modifications:
- {fileID: 11400000, guid: e24dcbc74c0ebdd94acb60adba3415c7, type: 2}
- {fileID: 11400000, guid: ae5a83823d492d27bbb84006f6e0e8c2, type: 2}
- {fileID: 11400000, guid: df0f24b538b5fed02a7faa3a5e0f121b, type: 2}
- {fileID: 11400000, guid: 73dc3bbc93cba37b1b989a9497b680e7, type: 2}
--- !u!4 &2109945868
Transform:
m_ObjectHideFlags: 0

@ -7,6 +7,7 @@ using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Assertions;
using Object = UnityEngine.Object;
using Random = UnityEngine.Random;
namespace Game {
public class GameManager : NetworkBehaviour {
@ -19,6 +20,8 @@ namespace Game {
public Object ballPrefab;
public Object playerPrefab;
public Object modificationPrefab;
public ModificationProperties[] modifications;
public List<Ball> Balls { get; } = new();
@ -91,6 +94,20 @@ namespace Game {
Tests();
}
private IEnumerator Start() {
while (Application.isPlaying) {
yield return new WaitForSeconds(5);
SpawnModification();
}
}
private void SpawnModification() {
Vector2 pos = new Vector2(Random.Range(Dimensions.Singleton.left, Dimensions.Singleton.right), Random.Range(-2, 2));
ModificationProperties properties = modifications[Random.Range(0, modifications.Length)];
var mod = Instantiate(modificationPrefab, pos, Quaternion.identity).GetComponent<Modification>();
mod.Properties = properties;
}
private void FixedUpdate() {
foreach (var ball in Balls.Where(b => !b.IsAlive))
Destroy(ball.gameObject);

@ -10,15 +10,6 @@ namespace Game {
public enum ModType { Nerf, Buff }
public enum ModEffect { Speed, Border }
public struct ModificationProperties {
public ModType Type { get; set; }
public ModEffect Effect { get; set; }
public float PickupDuration { get; set; }
public float ActiveDuration { get; set; }
}
public class ActiveModification {
public ModificationProperties Properties { get; set; }
@ -26,7 +17,7 @@ namespace Game {
modifications.Add(this);
VisualElement element = GameUI.AddModification(panel, this);
yield return new WaitForSeconds(Properties.ActiveDuration);
yield return new WaitForSeconds(Properties.activeDuration);
element.RemoveFromHierarchy();
modifications.Remove(this);
@ -38,7 +29,8 @@ namespace Game {
public ModificationProperties Properties { get; set; }
private IEnumerator Start() {
yield return new WaitForSeconds(Properties.PickupDuration);
gameObject.AddComponent<SpriteRenderer>().sprite = Properties.image;
yield return new WaitForSeconds(Properties.pickupDuration);
Destroy(gameObject);
}
@ -47,9 +39,8 @@ namespace Game {
if (p != null) {
Destroy(gameObject);
ActiveModification mod = new() {Properties = Properties};
StartCoroutine(mod.Process(p.Panel, p.Modifications));
p.StartCoroutine(mod.Process(p.Panel, p.Modifications));
}
}
}
}

@ -0,0 +1,15 @@
using UnityEngine;
using UnityEngine.Serialization;
namespace Game {
[CreateAssetMenu(fileName = "Data", menuName = "ScriptableObjects/ModificationProperties", order = 0)]
public class ModificationProperties : ScriptableObject {
public ModType type;
public ModEffect effect;
public float pickupDuration;
public float activeDuration;
public Sprite image;
}
}

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4453d1448ec14f5fa81aae3c54f78010
timeCreated: 1681245383

@ -28,9 +28,16 @@ public class GameUI : MonoBehaviour {
// TODO create correct visual element, attach it to panel with background-image and return it
public static VisualElement AddModification(VisualElement playerPanel, ActiveModification modification) {
VisualElement listElement = ModsList(playerPanel, modification.Properties.Type);
VisualElement listElement = ModsList(playerPanel, modification.Properties.type);
return listElement;
VisualElement newElement = new() {
style = {
backgroundImage = Background.FromSprite(modification.Properties.image)
}
};
listElement.Add(newElement);
return newElement;
}
private static VisualElement ModsList(VisualElement player, ModType type) {

@ -1,11 +1,9 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/UI%20Toolkit/styles.uss?fileID=7433441132597879392&amp;guid=a6abab2f6d20ba823bad41d2081810e9&amp;type=3#styles" />
<Style src="project://database/Assets/UI%20Toolkit/player_panel.uss?fileID=7433441132597879392&amp;guid=102b2cb1b84d8883abde9356b92d807e&amp;type=3#player_panel" />
<ui:VisualElement style="flex-direction: row; align-items: stretch; justify-content: space-between; height: 100%; width: 100%;">
<ui:Button text="Left" display-tooltip-when-elided="true" name="btn_left" />
<ui:Button text="Right" display-tooltip-when-elided="true" name="btn_right" />
<ui:VisualElement class="mods_list" />
<ui:Label text="0" display-tooltip-when-elided="true" name="score" />
<ui:VisualElement class="mods_list" />
<ui:Button text="Right" display-tooltip-when-elided="true" name="btn_right" />
</ui:VisualElement>
<ui:Button text="Left" display-tooltip-when-elided="true" name="btn_left" />
</ui:UXML>

@ -1,4 +1,8 @@
.player_panel {
width: 100%;
position: absolute;
flex-direction: row;
align-items: stretch;
justify-content: space-between;
}

@ -2,6 +2,7 @@ Button {
height: auto;
width: 80px;
font-size: 25px;
flex-grow: 0;
}
.mods_list {

@ -53,4 +53,4 @@ Physics2DSettings:
m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432}
m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745}
m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804}
m_LayerCollisionMatrix: fffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
m_LayerCollisionMatrix: 0000000000000000000000008003000000000000000000000000000008000000080000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

@ -12,9 +12,9 @@ TagManager:
- Water
- UI
- Playground
-
-
-
- BallCollectable
- PlayerBoard
- Border
-
-
-

Loading…
Cancel
Save