Skip to content

Commit f312929

Browse files
committed
first commit
1 parent 999fcca commit f312929

File tree

10 files changed

+248
-0
lines changed

10 files changed

+248
-0
lines changed

.idea/.idea.Loading_Scene_Manager-Netcode/.idea/.gitignore

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.Loading_Scene_Manager-Netcode/.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.Loading_Scene_Manager-Netcode/.idea/indexLayout.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.Loading_Scene_Manager-Netcode/.idea/misc.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Loading_Scene_Manager-Netcode.sln

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Loading_Scene_Manager-Netcode", "Loading_Scene_Manager-Netcode\Loading_Scene_Manager-Netcode.csproj", "{CA05BE5F-1B6E-46C3-9CF9-3AD8121446CD}"
4+
EndProject
5+
Global
6+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7+
Debug|Any CPU = Debug|Any CPU
8+
Release|Any CPU = Release|Any CPU
9+
EndGlobalSection
10+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
11+
{CA05BE5F-1B6E-46C3-9CF9-3AD8121446CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
12+
{CA05BE5F-1B6E-46C3-9CF9-3AD8121446CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
13+
{CA05BE5F-1B6E-46C3-9CF9-3AD8121446CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
14+
{CA05BE5F-1B6E-46C3-9CF9-3AD8121446CD}.Release|Any CPU.Build.0 = Release|Any CPU
15+
EndGlobalSection
16+
EndGlobal
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
4+
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
5+
<PropertyGroup>
6+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8+
<ProjectGuid>{CA05BE5F-1B6E-46C3-9CF9-3AD8121446CD}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>Loading_Scene_Manager_Netcode</RootNamespace>
12+
<AssemblyName>Loading_Scene_Manager_Netcode</AssemblyName>
13+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System"/>
37+
<Reference Include="System.Core"/>
38+
<Reference Include="System.Xml"/>
39+
<Reference Include="UnityEngine">
40+
<HintPath>/Applications/Unity/Hub/Editor/2022.3.7f1/Unity.app/Contents/Managed/UnityEngine.dll</HintPath>
41+
</Reference>
42+
</ItemGroup>
43+
<ItemGroup>
44+
<Compile Include="MonoBehaviour1.cs"/>
45+
<Compile Include="Properties\AssemblyInfo.cs"/>
46+
</ItemGroup>
47+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
48+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
49+
Other similar extension points exist, see Microsoft.Common.targets.
50+
<Target Name="BeforeBuild">
51+
</Target>
52+
<Target Name="AfterBuild">
53+
</Target>
54+
-->
55+
56+
</Project>
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
using System;
2+
using System.Collections;
3+
using _Utility;
4+
using Unity.Netcode;
5+
using UnityEngine;
6+
using UnityEngine.SceneManagement;
7+
8+
namespace _Managers
9+
{
10+
public enum SceneName : byte
11+
{
12+
Bootstrap, // not used
13+
Menu,
14+
CharacterSelection, // todo: Karakter seçme ekranında ise Hero belirli özelliklerini kullanmicak. onuda bu Enum ile saglarsın
15+
GamePlay,
16+
}
17+
18+
public class LoadingSceneManager : NetworkBehaviour
19+
{
20+
public SceneName ActiveScene => _activeScene;
21+
private SceneName _activeScene;
22+
23+
public static LoadingSceneManager Instance { get; private set; }
24+
25+
public virtual void Awake()
26+
{
27+
if (Instance == null)
28+
{
29+
Instance = this;
30+
DontDestroyOnLoad(this);
31+
}
32+
else
33+
{
34+
Destroy(gameObject);
35+
}
36+
}
37+
38+
public void Init()
39+
{
40+
NetworkManager.Singleton.SceneManager.OnLoadComplete -= OnLoadComplete;
41+
NetworkManager.Singleton.SceneManager.OnLoadComplete += OnLoadComplete;
42+
}
43+
44+
public void LoadScene(SceneName sceneToLoad, bool isNetworkSceneActive = true)
45+
{
46+
StartCoroutine(Loading(sceneToLoad, isNetworkSceneActive));
47+
}
48+
49+
private IEnumerator Loading(SceneName sceneToLoad, bool isNetworkSceneActive = true)
50+
{
51+
LoadingFadeEffect.Instance.FadeIn();
52+
53+
yield return new WaitUntil(() => LoadingFadeEffect.CanLoadScene == true);
54+
55+
if (isNetworkSceneActive == true)
56+
LoadSceneNetwork(sceneToLoad);
57+
else
58+
LoadSceneLoacal(sceneToLoad);
59+
60+
yield return new WaitForSeconds(1f);
61+
62+
LoadingFadeEffect.Instance.FadeOut();
63+
}
64+
65+
private void LoadSceneLoacal(SceneName sceneToLoad)
66+
{
67+
SceneManager.LoadScene(sceneToLoad.ToString(), LoadSceneMode.Single);
68+
switch (sceneToLoad) // Sahne yüklendikten sonra çalışmasını istedigin şeyleri yaz
69+
{
70+
case SceneName.Menu:
71+
// todo: OwnerSceneInit (Müzik çalabilir)
72+
break;
73+
}
74+
}
75+
76+
private void LoadSceneNetwork(SceneName sceneToLoad)
77+
{
78+
if (NetworkManager.Singleton.IsServer)
79+
NetworkManager.Singleton.SceneManager.LoadScene(sceneToLoad.ToString(), LoadSceneMode.Single);
80+
}
81+
82+
// Burdaki fonksiyon = O sahne Serverda herkes tarafından yüklendikten sonra ortak olan şeyleri yapıcak. (ServerSceneInit)
83+
private void OnLoadComplete(ulong clientıd, string scenename, LoadSceneMode loadscenemode)
84+
{
85+
if (!NetworkManager.Singleton.IsServer)
86+
return;
87+
88+
Enum.TryParse(scenename, out _activeScene);
89+
90+
if (!ClientConnection.Instance.CanClientConnect(clientıd)) // baglanabilir ise True döner.
91+
return;
92+
93+
94+
switch (_activeScene)
95+
{
96+
case SceneName.CharacterSelection:
97+
CharacterSelectionManager.Instance.ServerSceneInit(clientıd);
98+
break;
99+
case SceneName.GamePlay:
100+
GamePlayManager.Instance.ServerSceneInit(clientıd);
101+
break;
102+
}
103+
}
104+
}
105+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
// General Information about an assembly is controlled through the following
5+
// set of attributes. Change these attribute values to modify the information
6+
// associated with an assembly.
7+
[assembly: AssemblyTitle("Loading_Scene_Manager_Netcode")]
8+
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyProduct("Loading_Scene_Manager_Netcode")]
12+
[assembly: AssemblyCopyright("Copyright © 2023")]
13+
[assembly: AssemblyTrademark("")]
14+
[assembly: AssemblyCulture("")]
15+
16+
// Setting ComVisible to false makes the types in this assembly not visible
17+
// to COM components. If you need to access a type in this assembly from
18+
// COM, set the ComVisible attribute to true on that type.
19+
[assembly: ComVisible(false)]
20+
21+
// The following GUID is for the ID of the typelib if this project is exposed to COM
22+
[assembly: Guid("CA05BE5F-1B6E-46C3-9CF9-3AD8121446CD")]
23+
24+
// Version information for an assembly consists of the following four values:
25+
//
26+
// Major Version
27+
// Minor Version
28+
// Build Number
29+
// Revision
30+
//
31+
// You can specify all the values or you can default the Build and Revision Numbers
32+
// by using the '*' as shown below:
33+
// [assembly: AssemblyVersion("1.0.*")]
34+
[assembly: AssemblyVersion("1.0.0.0")]
35+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// <autogenerated />
2+
using System;
3+
using System.Reflection;
4+
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]

0 commit comments

Comments
 (0)