Commit 8d427b4a authored by Maxime's avatar Maxime
Browse files

remove old levels, add toast for easy communication with the user

parent 2392ead0
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" tiledversion="1.7.2" orientation="orthogonal" renderorder="right-down" width="24" height="15" tilewidth="32" tileheight="32" infinite="0" nextlayerid="4" nextobjectid="3">
<tileset firstgid="1" source="tiles.tsx"/>
<layer id="1" name="Calque de Tuiles 1" width="24" height="15">
<data encoding="csv">
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
</data>
</layer>
<objectgroup id="2" name="Calque d'Objets 1">
<object id="2" name="Spawn" x="64" y="416"/>
</objectgroup>
</map>
<menu>
</menu>
\ No newline at end of file
......@@ -45,6 +45,9 @@
<Content Include="Data\Menus\Images\back.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Data\Menus\ingame_menu.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Data\Menus\intro.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
......@@ -112,10 +115,7 @@
<Content Include="Data\Fonts\anonymous_pro.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Data\Levels\level1.tmx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Data\Levels\level2.tmx">
<None Include="Data\Levels\world0.tmx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Data\Particles\background.pex">
......
......@@ -79,6 +79,30 @@ namespace ZZZZZZ.GUI
Console.WriteLine(ex);
}
}
protected void DoAnimationBackward()
{
try
{
if (IsDeleted) return;
Opacity = 1;
if (Text != null) Text.Opacity = 1;
int i = 60;
while (i > 0 && !IsDeleted)
{
Opacity += 0.017f;
if (Text != null) Text.Opacity -= 0.017f;
Thread.Sleep(16);
i--;
}
Opacity = 0;
if (Text != null) Text.Opacity = 0;
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
......@@ -34,7 +34,7 @@ namespace ZZZZZZ.GUI.Navigations
Menu = new MenuXML();
Menu.Load(menu);
if (menu == Assets.Menus.Intro)
Task.Delay(7000).ContinueWith(t => { GameManager.InvokeOnMain(() => GameManager.Current.Navigation.Load(Assets.Menus.Main)); });
Task.Delay(700).ContinueWith(t => { GameManager.InvokeOnMain(() => GameManager.Current.Navigation.Load(Assets.Menus.Main)); });
}
public void ButtonSound()
......
using System;
using System.Collections.Generic;
using System.Text;
using ZZZZZZ.Utils;
namespace ZZZZZZ.GUI.Navigations
{
......@@ -9,30 +10,39 @@ namespace ZZZZZZ.GUI.Navigations
public void SingleplayerWorld0()
{
ButtonSound();
GameManager.Current.LevelManager.Load(Assets.Levels.World0);
Load(Assets.Menus.Ingame);
GameManager.Current.Navigation.Toast.Show("Welcome to ZZZZZZ");
GameManager.Current.Navigation.Toast.Show("Let's begin slowly");
}
public void SingleplayerWorld1()
{
ButtonSound();
Load(Assets.Menus.Ingame);
}
public void SingleplayerWorld2()
{
ButtonSound();
Load(Assets.Menus.Ingame);
}
public void SingleplayerWorld3()
{
ButtonSound();
Load(Assets.Menus.Ingame);
}
public void SingleplayerWorld4()
{
ButtonSound();
Load(Assets.Menus.Ingame);
}
public void SingleplayerWorld5()
{
ButtonSound();
Load(Assets.Menus.Ingame);
}
}
......
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Urho;
using Urho.Gui;
using ZZZZZZ.Utils;
namespace ZZZZZZ.GUI.Toasts
{
public class Toast : Component
{
public Toast(string text = "", float x = 50, float y = 80, float scale = 30) : base(string.Empty, x, y, scale)
private Queue<string> messages;
public Toast(string text = "", float x = 50, float y = 80, float scale = 20) : base(string.Empty, x, y, scale)
{
BlendMode = BlendMode.InvDestAlpha;
Update(false);
SetupText(text);
Visible = false;
messages = new Queue<string>();
}
public void Show(string text)
public void Show(string text, int time = 5000)
{
if (Visible)
{
messages.Enqueue(text);
return;
}
Text.Value = text;
Task.Delay(5000).ContinueWith(t => { GameManager.InvokeOnMain(() => Text.Visible = false); });
Text.SetFont(Application.Current.ResourceCache.GetFont(Assets.Fonts.AnonymousPro), MathHelper.Clamp(ToolBox.FontSize(text, Size.X), 20, 60));
Visible = true;
Task.Run(() => DoAnimation());
Task.Delay(time).ContinueWith(t => DoAnimationBackward());
Task.Delay(time + 1000).ContinueWith(t => { Application.InvokeOnMain(() => Visible = false); });
Task.Delay(time + 1100).ContinueWith(t =>
{
Application.InvokeOnMain(() =>
{
if (messages.Count > 0)
{
Show(messages.Dequeue());
}
});
});
}
}
}
......@@ -66,9 +66,9 @@ namespace ZZZZZZ
BackgroundParticle = new BackgroundParticleEmitter();
BackgroundParticle.Start();
LevelManager = new LevelManager(Scene.CollisionHandler);
}
public bool ConnectToServer(string ip, int port)
{
......@@ -80,10 +80,8 @@ namespace ZZZZZZ
/*Current.RemotePlayerManager = new RemotePlayerManager(new RemoteCharacter(), GameManager.Current.LevelManager);
LevelManager = new LevelManager(Scene.CollisionHandler);
LocalPlayerManager = new LocalPlayerManager(new LocalCharacter(), new KeyboardInput(), LevelManager);
Server.PlayerManager = LocalPlayerManager;
LevelManager.Load();
*/
return result;
}
......
......@@ -24,8 +24,7 @@
public static class Levels
{
public const string BasePath = "Levels/";
public const string Level1 = "Levels/level1.tmx";
public const string Level2 = "Levels/level2.tmx";
public const string World0 = "Levels/world0.tmx";
}
public static class Menus
......@@ -35,6 +34,7 @@
public const string Multiplayer = "Menus/multiplayer_menu.xml";
public const string Singleplayer = "Menus/singleplayer_menu.xml";
public const string Option = "Menus/option_menu.xml";
public const string Ingame = "Menus/ingame_menu.xml";
public static class Images
{
......
......@@ -22,8 +22,8 @@ namespace ZZZZZZ.Worlds
TileMap = Node.CreateComponent<TileMap2D>();
TileMap.TmxFile = Application.ResourceCache.GetTmxFile2D(level);
TileMap.Node.SetPosition2D(new Vector2(-10.5f, -8f));
TileMap.Node.Scale *= 4.3f;
TileMap.Node.SetPosition2D(new Vector2(-12.9f, -7.7f));
TileMap.Node.Scale *= 4.2f;
SetSpawn();
GenerateCollision();
......
......@@ -28,7 +28,7 @@ namespace ZZZZZZ.Worlds
}
public void Load(string level = Assets.Levels.Level1)
public void Load(string level)
{
if (Current != null)
Current.Dispose();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment