Add main menu

This commit is contained in:
Norbi Peti 2020-12-06 23:12:51 +01:00
parent 2a31201cec
commit a26cd1266e
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
12 changed files with 1688 additions and 2 deletions

View file

@ -60,6 +60,8 @@
<Compile Include="Assets\Scripts\EnemyController.cs" /> <Compile Include="Assets\Scripts\EnemyController.cs" />
<Compile Include="Assets\Scripts\EnemySpawner.cs" /> <Compile Include="Assets\Scripts\EnemySpawner.cs" />
<Compile Include="Assets\Scripts\HUDManager.cs" /> <Compile Include="Assets\Scripts\HUDManager.cs" />
<Compile Include="Assets\Scripts\MenuEnemySpawner.cs" />
<Compile Include="Assets\Scripts\MenuHandler.cs" />
<Compile Include="Assets\Scripts\ObjectPool.cs" /> <Compile Include="Assets\Scripts\ObjectPool.cs" />
<Compile Include="Assets\Scripts\OwnCharacterController.cs" /> <Compile Include="Assets\Scripts\OwnCharacterController.cs" />
<Compile Include="Assets\Scripts\Parallaxing.cs" /> <Compile Include="Assets\Scripts\Parallaxing.cs" />

View file

@ -0,0 +1,105 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8350384968352764094
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8350384968352764097}
- component: {fileID: 8350384968352764096}
- component: {fileID: 8350384968352764095}
m_Layer: 0
m_Name: Enemy in menu
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &8350384968352764097
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8350384968352764094}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.52, y: 3.31, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &8350384968352764096
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8350384968352764094}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: -13315653866412880, guid: 22df4be82d91637658b965dd24a4a591, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.27, y: 0.5}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!50 &8350384968352764095
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8350384968352764094}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 0.0001
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 0.01
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0

View file

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

1474
Assets/Scenes/Menu.unity Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5db7f59c637c922828b1acbacc8721cf
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using Random = System.Random;
namespace DefaultNamespace
{
public class MenuEnemySpawner : MonoBehaviour
{
public Rigidbody2D enemyPrefab;
private ObjectPool _pool;
private float _lastSpawnTime;
private List<Rigidbody2D> _enemies = new List<Rigidbody2D>(5);
private Random _random = new Random();
private void Start()
{
enemyPrefab.mass = 0.00001f;
enemyPrefab.gravityScale = 0.01f;
enemyPrefab.freezeRotation = false;
enemyPrefab.angularVelocity = 2f;
_pool = new ObjectPool(enemyPrefab.gameObject, 5);
}
private void Update()
{
if (Time.time - _lastSpawnTime > 2f)
{
var enemy = _pool.GetObject();
enemy.transform.position = transform.position;
enemy.SetActive(true);
_enemies.Add(enemy.GetComponent<Rigidbody2D>());
_lastSpawnTime = Time.time;
}
for (var index = 0; index < _enemies.Count; index++)
{
var enemy = _enemies[index];
enemy.AddTorque(0.11f);
enemy.AddForce(new Vector2(((float) _random.NextDouble() * 20f + 5f) * enemy.mass * enemy.gravityScale,
((float) _random.NextDouble() * 30f + 5f) * enemy.mass * enemy.gravityScale));
if (enemy.position.x > 100 || enemy.position.y > 100)
{
enemy.gameObject.SetActive(false);
_enemies.RemoveAt(index--);
}
}
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cbb86953b54c4eb89d9b670c0c2ba0f7
timeCreated: 1607287661

View file

@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MenuHandler : MonoBehaviour
{
public void StartGame()
{
SceneManager.LoadScene("Main");
}
public void Achievements()
{
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f0ccae453a9d12f6a88508e2c650cf39
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using Random = System.Random; using Random = System.Random;
@ -83,6 +84,9 @@ public class OwnCharacterController : CharacterControllerBase
_animator.SetFloat(Speed, Math.Abs(_rb.velocity.x)); _animator.SetFloat(Speed, Math.Abs(_rb.velocity.x));
_animator.SetBool(Sprint, Input.GetButton("Fire3")); _animator.SetBool(Sprint, Input.GetButton("Fire3"));
if (Input.GetButtonDown("Cancel"))
SceneManager.LoadScene("Menu");
} }
private void CheckpointReached() private void CheckpointReached()

View file

@ -46,7 +46,7 @@ TextureImporter:
alignment: 0 alignment: 0
spritePivot: {x: 0.5, y: 0.5} spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100 spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteBorder: {x: 11, y: 13, z: 12, w: 28}
spriteGenerateFallbackPhysicsShape: 1 spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1 alphaUsage: 1
alphaIsTransparency: 1 alphaIsTransparency: 1

View file

@ -4,5 +4,11 @@
EditorBuildSettings: EditorBuildSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Scenes: [] m_Scenes:
- enabled: 1
path: Assets/Scenes/Menu.unity
guid: 5db7f59c637c922828b1acbacc8721cf
- enabled: 1
path: Assets/Scenes/Main.unity
guid: 2cda990e2423bbf4892e6590ba056729
m_configObjects: {} m_configObjects: {}