granade animation + arrow conttrols + started loading screen

This commit is contained in:
SergoDobro 2024-09-11 23:04:03 +03:00
parent 6d47993988
commit 0cc6b1250a
17 changed files with 316 additions and 199 deletions

View file

@ -459,7 +459,7 @@ namespace AnimatorFileCreatorAdvanced.Core.GUI
{ {
if (!buildDone) return; if (!buildDone) return;
ticksPassed++; ticksPassed++;
if (ticksPassed > 3) if (ticksPassed > 1)
{ {
ticksPassed = 0; ticksPassed = 0;
SetNextFrame(); SetNextFrame();

View file

@ -146,6 +146,9 @@
#begin Textures/Animations/explosion_1.animation #begin Textures/Animations/explosion_1.animation
/copy:Textures/Animations/explosion_1.animation /copy:Textures/Animations/explosion_1.animation
#begin Textures/Animations/OneAnimationPerItem/granade_spinning.animation
/copy:Textures/Animations/OneAnimationPerItem/granade_spinning.animation
#begin Textures/Animations/player_idle_down_mining.animation #begin Textures/Animations/player_idle_down_mining.animation
/copy:Textures/Animations/player_idle_down_mining.animation /copy:Textures/Animations/player_idle_down_mining.animation
@ -383,6 +386,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_running.png /build:Textures/AnimationTextures/Character/hr-level1_running.png
#begin Textures/AnimationTextures/OneAnimationPerItem/granade.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/OneAnimationPerItem/granade.png
#begin Textures/AnimationTextures/Player/Grenade.png #begin Textures/AnimationTextures/Player/Grenade.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -683,6 +698,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/GUI/MenuBackground.jpg /build:Textures/GUI/MenuBackground.jpg
#begin Textures/GUI/mouse_pressed.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/GUI/mouse_pressed.png
#begin Textures/GUI/mouse.png #begin Textures/GUI/mouse.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View file

@ -0,0 +1 @@
{"id":"granade_spinning","textureName":"Textures/AnimationTextures/OneAnimationPerItem/granade","startSpriteRectangle":{"X":0,"Y":0,"Width":256,"Height":256},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":6,"isCycle":true,"offset":"0, 0"}

View file

@ -1 +1 @@
{"id":"player_running","textureName":"Textures/AnimationTextures/Player/Run","startSpriteRectangle":{"X":0,"Y":0,"Width":128,"Height":128},"frameSecond":[{"Item1":0,"Item2":1}],"textureFrameInterval":0,"framesCount":8,"isCycle":true,"offset":"0, 0"} {"id":"player_running","textureName":"Textures/AnimationTextures/Player/Run","startSpriteRectangle":{"X":0,"Y":0,"Width":128,"Height":128},"frameSecond":[{"Item1":0,"Item2":5}],"textureFrameInterval":0,"framesCount":8,"isCycle":true,"offset":"0, 0"}

View file

@ -1 +1 @@
{"id":"zombie_walk","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":32,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":0,"framesCount":8,"isCycle":true,"offset":"0, 0"} {"id":"zombie_walk","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":32,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":0,"framesCount":8,"isCycle":true,"offset":"0, 0"}

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

View file

@ -74,7 +74,7 @@ namespace ZoFo.GameCore
}; };
} }
public void OnDataSend(string data) public void OnDataSend(string data)//А это нужно? 0 использований метода :/
{ {
//List<UpdateTileCreated> updateDatas = JsonSerializer.Deserialize<List<UpdateTileCreated>>(data); //List<UpdateTileCreated> updateDatas = JsonSerializer.Deserialize<List<UpdateTileCreated>>(data);
JArray jToken = JsonConvert.DeserializeObject(data) as JArray; JArray jToken = JsonConvert.DeserializeObject(data) as JArray;
@ -94,7 +94,11 @@ namespace ZoFo.GameCore
} }
public void GameEndedUnexpectedly() { } public void GameEndedUnexpectedly() { }
/// <summary>
/// Подключиться к комнате
/// </summary>
/// <param name="ip"></param>
/// <param name="port"></param>
public void JoinRoom(string ip, int port) public void JoinRoom(string ip, int port)
{ {
networkManager.JoinRoom(ip, port); networkManager.JoinRoom(ip, port);
@ -113,7 +117,11 @@ namespace ZoFo.GameCore
float shakeEffect = 0; float shakeEffect = 0;
public void AddShaking(float power) public void AddShaking(float power)
{ {
shakeEffect += power*3; shakeEffect += power;
if (shakeEffect>10)
{
shakeEffect = 10;
}
} }
public void UpdateShaking() public void UpdateShaking()
{ {

View file

@ -22,6 +22,7 @@ public abstract class AbstractGUI
private bool isStartedPrint = false; private bool isStartedPrint = false;
private bool isPressed = false; private bool isPressed = false;
private Texture2D mouse; private Texture2D mouse;
private Texture2D mouse_pressed;
private MouseState mouseState; private MouseState mouseState;
public AbstractGUI() public AbstractGUI()
@ -40,6 +41,7 @@ public abstract class AbstractGUI
{ {
Manager.LoadContent(AppManager.Instance.Content, "Fonts/Font"); Manager.LoadContent(AppManager.Instance.Content, "Fonts/Font");
mouse = AppManager.Instance.Content.Load<Texture2D>("Textures/GUI/mouse"); mouse = AppManager.Instance.Content.Load<Texture2D>("Textures/GUI/mouse");
mouse_pressed = AppManager.Instance.Content.Load<Texture2D>("Textures/GUI/mouse_pressed");
} }
public virtual void Update(GameTime gameTime) public virtual void Update(GameTime gameTime)
@ -52,7 +54,11 @@ public abstract class AbstractGUI
{ {
Manager.Draw(spriteBatch); Manager.Draw(spriteBatch);
spriteBatch.Begin(); spriteBatch.Begin();
spriteBatch.Draw(mouse, new Rectangle(mouseState.Position.X, mouseState.Position.Y, 20, 40), Color.White); if (Mouse.GetState().LeftButton == ButtonState.Pressed)
spriteBatch.End(); spriteBatch.Draw(mouse_pressed, new Rectangle(mouseState.Position.X, mouseState.Position.Y, 20, 40), Color.White);
else
spriteBatch.Draw(mouse, new Rectangle(mouseState.Position.X, mouseState.Position.Y, 20, 40), Color.White);
spriteBatch.End();
}
} }
}

View file

@ -20,6 +20,7 @@ public class HUD : AbstractGUI
public AbstractGUI overlayGUI; public AbstractGUI overlayGUI;
protected override void CreateUI() protected override void CreateUI()
{ {
int width = AppManager.Instance.CurentScreenResolution.X; int width = AppManager.Instance.CurentScreenResolution.X;
int height = AppManager.Instance.CurentScreenResolution.Y; int height = AppManager.Instance.CurentScreenResolution.Y;

View file

@ -0,0 +1,39 @@
using Microsoft.Xna.Framework;
using MonogameLibrary.UI.Base;
using MonogameLibrary.UI.Elements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using ZoFo.GameCore.GameManagers;
namespace ZoFo.GameCore.GUI
{
internal class LoadingGameScreenGUI : AbstractGUI
{
private DrawableUIElement menuBackground;
protected override void CreateUI()
{
int width = AppManager.Instance.CurentScreenResolution.X;
int height = AppManager.Instance.CurentScreenResolution.Y;
menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White, textureName = "Textures/GUI/background/waiting" };
Elements.Add(menuBackground);
menuBackground.LoadTexture(AppManager.Instance.Content);
var loading = new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 7, (int)(width / 4), (int)(height / 20)),
text = "Loading...", fontColor = Color.White, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts\\Font3" };
Elements.Add(loading);
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
}
}
}

View file

@ -50,7 +50,8 @@ public class SelectModeMenu : AbstractGUI
server.CreateRoom(false); server.CreateRoom(false);
client.JoinYourself(server.MyIp.Port); client.JoinYourself(server.MyIp.Port);
//AppManager.Instance.ChangeState(GameState.HostPlaying); //AppManager.Instance.ChangeState(GameState.HostPlaying);
AppManager.Instance.SetGUI(new HUD()); AppManager.Instance.SetGUI(new HUD() { });
//server.CreateRoom(1); //server.CreateRoom(1);
//client.JoinYourself(); //client.JoinYourself();

View file

@ -57,205 +57,235 @@ namespace ZoFo.GameCore.GameManagers
} }
#region Работа с GamePad #region Работа с GamePad
#region Обработка гейм-пада. Задает Vector2 vectorMovementDirection являющийся вектором отклонения левого стика. #region Обработка гейм-пада. Задает Vector2 vectorMovementDirection являющийся вектором отклонения левого стика.
GamePadState gamePadState = GamePad.GetState(0); GamePadState gamePadState = GamePad.GetState(0);
InputMovementDirection = gamePadState.ThumbSticks.Left; InputMovementDirection = gamePadState.ThumbSticks.Left;
InputAttackDirection = gamePadState.ThumbSticks.Right; InputAttackDirection = gamePadState.ThumbSticks.Right;
#endregion #endregion
#region читы #region читы
if (gamePadState.Triggers.Left >= 0.9 && gamePadState.Triggers.Right >= 0.9) if (gamePadState.Triggers.Left >= 0.9 && gamePadState.Triggers.Right >= 0.9)
_cheatsEnabled = true; _cheatsEnabled = true;
if (_cheatsEnabled) if (_cheatsEnabled)
{ {
if (gamePadState.Buttons.Y == ButtonState.Pressed && lastGamePadState.Buttons.Y == ButtonState.Released) if (gamePadState.Buttons.Y == ButtonState.Pressed && lastGamePadState.Buttons.Y == ButtonState.Released)
InvincibilityCheat = !InvincibilityCheat; InvincibilityCheat = !InvincibilityCheat;
if (gamePadState.Buttons.B == ButtonState.Pressed && lastGamePadState.Buttons.B == ButtonState.Released) if (gamePadState.Buttons.B == ButtonState.Pressed && lastGamePadState.Buttons.B == ButtonState.Released)
CollisionsCheat = !CollisionsCheat; CollisionsCheat = !CollisionsCheat;
//TODO: infinite ammo cheat by gamepad //TODO: infinite ammo cheat by gamepad
} }
#endregion // Cheats #endregion // Cheats
#region set ScopeState #region set ScopeState
ConvertVector2ToState(InputMovementDirection); ConvertVector2ToState(InputMovementDirection);
#endregion #endregion
#region Обработка нажатия выстрела. Вызывает событие ShootEvent #region Обработка нажатия выстрела. Вызывает событие ShootEvent
if (gamePadState.Buttons.X == ButtonState.Pressed && !isShoot) if (gamePadState.Buttons.X == ButtonState.Pressed && !isShoot)
{ {
isShoot = true; isShoot = true;
ShootEvent?.Invoke(); ShootEvent?.Invoke();
Debug.WriteLine("Выстрел"); Debug.WriteLine("Выстрел");
} }
else if (gamePadState.Buttons.X == ButtonState.Released) else if (gamePadState.Buttons.X == ButtonState.Released)
{ {
isShoot = false; isShoot = false;
} }
#endregion #endregion
lastGamePadState = gamePadState; lastGamePadState = gamePadState;
#endregion #endregion
#region Работа с KeyBoard #region Работа с KeyBoard
#region InputAttack with mouse
MouseState mouseState = Mouse.GetState();
AppManager.Instance.debugHud.Set("mouse position", $"({mouseState.X}, {mouseState.Y}");
// TODO: CurentScreenResolution
Vector2 a = (AppManager.Instance.CurentScreenResolution / new Point(2, 2)).ToVector2();
InputAttackDirection = Vector2.Normalize(new Vector2(mouseState.X - a.X, mouseState.Y - a.Y)); #region Состояние клавиатуры
AppManager.Instance.debugHud.Set("AttackDir(normalize)", $"({a.X}, {a.Y})"); KeyboardState keyBoardState = Keyboard.GetState(); // Состояние клавиатуры
#endregion #endregion
#region Состояние клавиатуры #region InputAttack with mouse
KeyboardState keyBoardState = Keyboard.GetState(); // Состояние клавиатуры MouseState mouseState = Mouse.GetState();
#endregion AppManager.Instance.debugHud.Set("mouse position", $"({mouseState.X}, {mouseState.Y}");
#region читы Vector2 a = (AppManager.Instance.CurentScreenResolution / new Point(2, 2)).ToVector2(); //player is always in the centre
if (keyBoardState.IsKeyDown(Keys.LeftShift) && keyBoardState.IsKeyDown(Keys.RightShift))
_cheatsEnabled = true;
if (_cheatsEnabled)
{
if (keyBoardState.IsKeyDown(Keys.I) && lastKeyboardState.IsKeyUp(Keys.I))
InvincibilityCheat = !InvincibilityCheat;
if (keyBoardState.IsKeyDown(Keys.C) && lastKeyboardState.IsKeyUp(Keys.C))
CollisionsCheat = !CollisionsCheat;
if (keyBoardState.IsKeyDown(Keys.N) && lastKeyboardState.IsKeyUp(Keys.N))
InfiniteAmmoCheat = !InfiniteAmmoCheat;
List<Keys> lvls = new List<Keys>() { Keys.D0, Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5, Keys.D6, Keys.D7, Keys.D8, Keys.D9 }; InputAttackDirection = Vector2.Normalize(new Vector2(mouseState.X - a.X, mouseState.Y - a.Y));
AppManager.Instance.debugHud.Set("AttackDir(normalize)", $"({a.X}, {a.Y})");
for (int i = 0; i < lvls.Count; i++) if (keyBoardState.IsKeyDown(Keys.Down))
{ {
//if (keyBoardState.IsKeyDown(lvls[i]) && lastKeyboardState.IsKeyUp(lvls[i])) //TODO InputAttackDirection.Y = 1;
// AppManager.Instance.Restart($"lvl{i}"); }
} else if (keyBoardState.IsKeyDown(Keys.Up))
} InputAttackDirection.Y = -1;
#endregion // Cheats else
InputAttackDirection.Y = 0;
#region Обработка состояния объекта. Задает значение полю scopeState. if (keyBoardState.IsKeyDown(Keys.Right))
if (keyBoardState.IsKeyDown(Keys.Up) || keyBoardState.IsKeyDown(Keys.W)) {
{ InputAttackDirection.X = 1;
InputMovementDirection += new Vector2(0, -1); }
} else if (keyBoardState.IsKeyDown(Keys.Left))
if (keyBoardState.IsKeyDown(Keys.Down) || keyBoardState.IsKeyDown(Keys.S)) InputAttackDirection.X = -1;
{ else
InputMovementDirection += new Vector2(0, 1); InputAttackDirection.X = 0;
}
if (keyBoardState.IsKeyDown(Keys.Right) || keyBoardState.IsKeyDown(Keys.D))
{
InputMovementDirection += new Vector2(1, 0);
}
if (keyBoardState.IsKeyDown(Keys.Left) || keyBoardState.IsKeyDown(Keys.A))
{
InputMovementDirection += new Vector2(-1, 0);
}
ConvertVector2ToState(InputMovementDirection);
#endregion
#region Обработка нажатия выстрела. Вызывает событие ShootEvent #endregion
if ((keyBoardState.IsKeyDown(Keys.P) || keyBoardState.IsKeyDown(Keys.F)) && !isShoot)
{
isShoot = true;
ShootEvent?.Invoke();
Debug.WriteLine("Выстрел");
}
else if (keyBoardState.IsKeyUp(Keys.F))
{
isShoot = false;
}
#endregion
#region Обработка взаимодействия с collectable(например лутом). Вызывает событие OnInteract
if ((keyBoardState.IsKeyDown(Keys.E) || mouseState.LeftButton == ButtonState.Pressed) && !isInteract)
#region читы
if (keyBoardState.IsKeyDown(Keys.LeftShift) && keyBoardState.IsKeyDown(Keys.RightShift))
_cheatsEnabled = true;
if (_cheatsEnabled)
{
if (keyBoardState.IsKeyDown(Keys.I) && lastKeyboardState.IsKeyUp(Keys.I))
InvincibilityCheat = !InvincibilityCheat;
if (keyBoardState.IsKeyDown(Keys.C) && lastKeyboardState.IsKeyUp(Keys.C))
CollisionsCheat = !CollisionsCheat;
if (keyBoardState.IsKeyDown(Keys.N) && lastKeyboardState.IsKeyUp(Keys.N))
InfiniteAmmoCheat = !InfiniteAmmoCheat;
List<Keys> lvls = new List<Keys>() { Keys.D0, Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5, Keys.D6, Keys.D7, Keys.D8, Keys.D9 };
for (int i = 0; i < lvls.Count; i++)
{ {
OnInteract?.Invoke(); //if (keyBoardState.IsKeyDown(lvls[i]) && lastKeyboardState.IsKeyUp(lvls[i])) //TODO
Debug.WriteLine("взаимодействие с Collectable"); // AppManager.Instance.Restart($"lvl{i}");
} }
else if (keyBoardState.IsKeyUp(Keys.E)) }
{ #endregion // Cheats
isInteract = false;
} #region Обработка состояния объекта. Задает значение полю scopeState.
#endregion bool useReverseControls = false;
lastKeyboardState = keyBoardState; if ((keyBoardState.IsKeyDown(Keys.Up) && useReverseControls)
|| (keyBoardState.IsKeyDown(Keys.W) && !useReverseControls))
{
InputMovementDirection += new Vector2(0, -1);
}
if ((keyBoardState.IsKeyDown(Keys.Down) && useReverseControls)
|| (keyBoardState.IsKeyDown(Keys.S) && !useReverseControls))
{
InputMovementDirection += new Vector2(0, 1);
}
if ((keyBoardState.IsKeyDown(Keys.Right) && useReverseControls)
|| (keyBoardState.IsKeyDown(Keys.D) && !useReverseControls))
{
InputMovementDirection += new Vector2(1, 0);
}
if ((keyBoardState.IsKeyDown(Keys.Left) && useReverseControls)
|| (keyBoardState.IsKeyDown(Keys.A) && !useReverseControls))
{
InputMovementDirection += new Vector2(-1, 0);
}
ConvertVector2ToState(InputMovementDirection);
#endregion
#region Обработка нажатия выстрела. Вызывает событие ShootEvent
if ((keyBoardState.IsKeyDown(Keys.P) || keyBoardState.IsKeyDown(Keys.F)) && !isShoot)
{
isShoot = true;
ShootEvent?.Invoke();
Debug.WriteLine("Выстрел");
}
else if (keyBoardState.IsKeyUp(Keys.F))
{
isShoot = false;
}
#endregion
#region Обработка взаимодействия с collectable(например лутом). Вызывает событие OnInteract
if ((keyBoardState.IsKeyDown(Keys.E) || mouseState.LeftButton == ButtonState.Pressed) && !isInteract)
{
OnInteract?.Invoke();
Debug.WriteLine("взаимодействие с Collectable");
}
else if (keyBoardState.IsKeyUp(Keys.E))
{
isInteract = false;
}
#endregion
lastKeyboardState = keyBoardState;
#endregion #endregion
#region ActionEvent #region ActionEvent
if(InputMovementDirection != prevInputMovementDirection || if (InputMovementDirection != prevInputMovementDirection ||
InputAttackDirection != prevInputAttackDirection || InputAttackDirection != prevInputAttackDirection ||
currentScopeState != prevCurrentScopeState) currentScopeState != prevCurrentScopeState)
{ {
ActionEvent?.Invoke(); ActionEvent?.Invoke();
} }
prevInputMovementDirection = InputMovementDirection; prevInputMovementDirection = InputMovementDirection;
prevInputAttackDirection = InputAttackDirection; prevInputAttackDirection = InputAttackDirection;
prevCurrentScopeState = currentScopeState; prevCurrentScopeState = currentScopeState;
#endregion #endregion
DebugHUD.Instance.Set("controls", currentScopeState.ToString()); DebugHUD.Instance.Set("controls", currentScopeState.ToString());
} }
#region работа с ScopeState и Vector2 #region работа с ScopeState и Vector2
/// <summary> /// <summary>
/// возвращает число от -14 до 16, начиная с /// возвращает число от -14 до 16, начиная с
/// </summary> /// </summary>
/// <param name="vector"></param> /// <param name="vector"></param>
/// <returns></returns> /// <returns></returns>
public int ConvertAttackVector2ToState(Vector2 vector){ public int ConvertAttackVector2ToState(Vector2 vector)
int currentSection = (int)Math.Ceiling(Math.Atan2(vector.Y, {
vector.X) * (180 / Math.PI) / 360 * 32); int currentSection = (int)Math.Ceiling(Math.Atan2(vector.Y,
return currentSection; vector.X) * (180 / Math.PI) / 360 * 32);
} return currentSection;
public ScopeState ConvertVector2ToState(Vector2 vector) }
public ScopeState ConvertVector2ToState(Vector2 vector)
{
int currentSection = 0;
if (vector.X == 0f && vector.Y == 0f)
{ {
int currentSection = 0; currentScopeState = ScopeState.Idle;
if(vector.X == 0f && vector.Y == 0f){ }
currentScopeState = ScopeState.Idle; else
} {
else currentSection = (int)Math.Ceiling(Math.Atan2(vector.Y,
{ vector.X) * (180 / Math.PI) / 360 * 16);
currentSection = (int)Math.Ceiling(Math.Atan2(vector.Y,
vector.X) * (180 / Math.PI) / 360 * 16);
switch(currentSection) switch (currentSection)
{ {
case -1: case -1:
currentScopeState = ScopeState.Idle; currentScopeState = ScopeState.Idle;
break; break;
case 0 or 1: case 0 or 1:
currentScopeState = ScopeState.Right; currentScopeState = ScopeState.Right;
break; break;
case 2 or 3: case 2 or 3:
currentScopeState = ScopeState.DownRight; currentScopeState = ScopeState.DownRight;
break; break;
case 4 or 5: case 4 or 5:
currentScopeState = ScopeState.Down; currentScopeState = ScopeState.Down;
break; break;
case 6 or 7: case 6 or 7:
currentScopeState = ScopeState.DownLeft; currentScopeState = ScopeState.DownLeft;
break; break;
case 8 or -7: case 8 or -7:
currentScopeState = ScopeState.Left; currentScopeState = ScopeState.Left;
break; break;
case -6 or -5: case -6 or -5:
currentScopeState = ScopeState.TopLeft; currentScopeState = ScopeState.TopLeft;
break; break;
case -4 or -3: case -4 or -3:
currentScopeState = ScopeState.Top; currentScopeState = ScopeState.Top;
break; break;
case -2 or -1: case -2 or -1:
currentScopeState = ScopeState.TopRight; currentScopeState = ScopeState.TopRight;
break; break;
default: default:
break; break;
} }
DebugHUD.DebugSet("current section", currentSection.ToString()); DebugHUD.DebugSet("current section", currentSection.ToString());
DebugHUD.DebugSet("y", vector.Y.ToString()); DebugHUD.DebugSet("y", vector.Y.ToString());
DebugHUD.DebugSet("x", vector.X.ToString()); DebugHUD.DebugSet("x", vector.X.ToString());
} }
return currentScopeState; return currentScopeState;
} }
public static Vector2 ConvertStateToVector2(ScopeState scopeState) public static Vector2 ConvertStateToVector2(ScopeState scopeState)
{ {

View file

@ -205,7 +205,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
} }
currentDatagrammId++; currentDatagrammId++;
AppManager.Instance.ChangeState(GameState.HostPlaying); AppManager.Instance.ChangeState(GameState.HostPlaying);
AppManager.Instance.SetGUI(new HUD());//// AppManager.Instance.SetGUI(new HUD());//// КАКОЙ В СЕРВЕРЕ ЭТО ПИСАТЬ???
} }
public void CloseConnection() public void CloseConnection()
{ {

View file

@ -22,7 +22,7 @@ namespace ZoFo.GameCore.GameObjects
public Zombie(Vector2 position) : base(position) public Zombie(Vector2 position) : base(position)
{ {
health = 5; health = 5;
speed = 7.5f; speed = 6.5f;
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30); graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30);
collisionComponent.stopRectangle = new Rectangle(10, 20, 10, 10); collisionComponent.stopRectangle = new Rectangle(10, 20, 10, 10);
isAttacking = false; isAttacking = false;

View file

@ -290,12 +290,12 @@ public class Player : LivingEntity
{ {
direction.Normalize(); direction.Normalize();
var rect = collisionComponent.stopRectangle.SetOrigin(position); var rect = collisionComponent.stopRectangle.SetOrigin(position);
int size = 10; int size = 30;
rect.X -= size; rect.X -= size;
rect.Y -= size; rect.Y -= size;
rect.Width += 2 * size; rect.Width += 2 * size;
rect.Height += 2 * size; rect.Height += 2 * size;
rect = rect.SetOrigin(direction * 40 * mult); rect = rect.SetOrigin(direction * 60 * mult);
return rect; return rect;
} }
} }

View file

@ -14,7 +14,7 @@ namespace ZoFo.GameCore.GameObjects
/// </summary> /// </summary>
public class Granade : GameObject public class Granade : GameObject
{ {
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "explosion_1" }, "explosion_1"); public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "granade_spinning" }, "granade_spinning");
/// <summary> /// <summary>
/// TODO updates with directed effect /// TODO updates with directed effect
@ -26,7 +26,7 @@ namespace ZoFo.GameCore.GameObjects
if (AppManager.Instance.client.myPlayer != null) if (AppManager.Instance.client.myPlayer != null)
this.positionFrom = AppManager.Instance.client.myPlayer.position; this.positionFrom = AppManager.Instance.client.myPlayer.position;
this.positionTo = positionTo; this.positionTo = positionTo;
graphicsComponent.ObjectDrawRectangle = new Rectangle(-30, -30, 60, 60).SetOrigin(position); graphicsComponent.ObjectDrawRectangle = new Rectangle(-15, -15, 30, 30).SetOrigin(position);
AppManager.Instance.SoundManager.StartSound("gun-gunshot-01", Vector2.Zero, Vector2.Zero, 0.5f, (float)(Random.Shared.NextDouble() * 2 - 1)); AppManager.Instance.SoundManager.StartSound("gun-gunshot-01", Vector2.Zero, Vector2.Zero, 0.5f, (float)(Random.Shared.NextDouble() * 2 - 1));
(graphicsComponent as AnimatedGraphicsComponent).actionOfAnimationEnd += _ => (graphicsComponent as AnimatedGraphicsComponent).actionOfAnimationEnd += _ =>
{ {
@ -34,6 +34,8 @@ namespace ZoFo.GameCore.GameObjects
//Delete_OnClient(this); //Delete_OnClient(this);
}; };
graphicsComponent.ObjectDrawRectangle.X = (int)position.X;
graphicsComponent.ObjectDrawRectangle.Y = (int)position.Y;
} }
Vector2 positionFrom; Vector2 positionFrom;
Vector2 positionTo; Vector2 positionTo;
@ -46,7 +48,7 @@ namespace ZoFo.GameCore.GameObjects
position.Y = (2 * positionTo.Y + 2 * positionFrom.Y - 4 * m) * dt * dt + position.Y = (2 * positionTo.Y + 2 * positionFrom.Y - 4 * m) * dt * dt +
(4 * m - positionTo.Y - 3 * positionFrom.Y) * dt + positionFrom.Y; (4 * m - positionTo.Y - 3 * positionFrom.Y) * dt + positionFrom.Y;
if (dt >= 0.9) if (dt >= 1)
{ {
FlightEndedOnServer(); FlightEndedOnServer();
return; return;
@ -72,12 +74,19 @@ namespace ZoFo.GameCore.GameObjects
} }
public override void Update_OnClient() public override void Update_OnClient()
{ {
float m = Math.Min(positionFrom.Y, positionTo.Y)-40;
position.X = (1 - dt) * positionFrom.X + dt * positionTo.X;
position.Y = (2 * positionTo.Y + 2 * positionFrom.Y - 4 * m) * dt * dt +
(4 * m - positionTo.Y - 3 * positionFrom.Y) * dt + positionFrom.Y;
dt += 0.05f;
if (dt >= 1) if (dt >= 1)
{ {
//Granade Finished the flight //Granade Finished the flight
Instantiate_OnClient(new Explosion(position + ExtentionClass.RandomVector()*10)); Instantiate_OnClient(new Explosion(position + ExtentionClass.RandomVector() * 10));
Delete_OnClient(this); Delete_OnClient(this);
base.Update_OnClient();
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
@ -94,12 +103,7 @@ namespace ZoFo.GameCore.GameObjects
return; return;
} }
float m = Math.Min(positionFrom.Y, positionTo.Y)-40;
position.X = (1 - dt) * positionFrom.X + dt * positionTo.X;
position.Y = (2 * positionTo.Y + 2 * positionFrom.Y - 4 * m) * dt * dt +
(4 * m - positionTo.Y - 3 * positionFrom.Y) * dt + positionFrom.Y;
dt += 0.05f;
//position = //position =
//base.Update_OnClient(); //base.Update_OnClient();
@ -121,7 +125,7 @@ namespace ZoFo.GameCore.GameObjects
var rect = graphicsComponent.ObjectDrawRectangle; var rect = graphicsComponent.ObjectDrawRectangle;
rect.X = (int)position.X; rect.X = (int)position.X;
rect.Y = (int)position.Y; rect.Y = (int)position.Y;
int size = 10; int size = 20;
rect.X -= size; rect.X -= size;
rect.Y -= size; rect.Y -= size;
rect.Width += 2 * size; rect.Width += 2 * size;