Merge branch 'DevelopmentX' into PlayerLog
This commit is contained in:
commit
dd47d58851
35 changed files with 686 additions and 211 deletions
91
MonogameLibrary/UI/Elements/HoverWindow.cs
Normal file
91
MonogameLibrary/UI/Elements/HoverWindow.cs
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using MonogameLibrary.UI.Base;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using MonogameLibrary.UI.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using Microsoft.Xna.Framework.Content;
|
||||||
|
|
||||||
|
namespace MonogameLibrary.UI.Elements;
|
||||||
|
|
||||||
|
public class HoverWindow : DrawableUIElement
|
||||||
|
{
|
||||||
|
public string tagItem;
|
||||||
|
public string discriptions;
|
||||||
|
public Dictionary<string, int> resourcesNeededToCraft;
|
||||||
|
private List<Label> Labels = new List<Label>();
|
||||||
|
public float scale2;
|
||||||
|
public string fontName2;
|
||||||
|
public Color fontColor2;
|
||||||
|
public string itemTextureName1;
|
||||||
|
private DrawableUIElement icon;
|
||||||
|
private Label itemName;
|
||||||
|
private Label discription;
|
||||||
|
private int labelIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public HoverWindow(UIManager manager, int layerIndex = 0, string textureName = "") : base(manager, layerIndex, textureName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialize(ContentManager content)
|
||||||
|
{
|
||||||
|
icon = new DrawableUIElement(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(rectangle.X + rectangle.Width / 20, rectangle.Y + rectangle.Width / 20, rectangle.Width / 5, rectangle.Width / 5),
|
||||||
|
mainColor = Color.White, textureName = itemTextureName1
|
||||||
|
};
|
||||||
|
icon.LoadTexture(content);
|
||||||
|
itemName = new Label(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(rectangle.X + rectangle.Width / 20 + rectangle.Width / 5 + rectangle.Width / 20, rectangle.Y + rectangle.Width / 10, rectangle.Width / 3 * 2, rectangle.Width / 5 ),
|
||||||
|
fontColor = fontColor2, text = tagItem, scale = scale2, fontName = fontName2, mainColor = Color.Transparent, textAligment = TextAligment.Left
|
||||||
|
};
|
||||||
|
itemName.LoadTexture(content);
|
||||||
|
discription = new Label(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(rectangle.X + rectangle.Width / 20, rectangle.Y + rectangle.Width / 20 + rectangle.Width / 5 + rectangle.Width / 20, rectangle.Width / 5, rectangle.Width / 5),
|
||||||
|
fontColor = fontColor2, text = discriptions, scale = scale2 / 1.5f, fontName = fontName2, mainColor = Color.Transparent, textAligment = TextAligment.Left
|
||||||
|
};
|
||||||
|
discription.LoadTexture(content);
|
||||||
|
foreach (var resource in resourcesNeededToCraft)
|
||||||
|
{
|
||||||
|
Label res = new Label(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(rectangle.X + rectangle.Width / 2 - rectangle.Width / 3 / 2, rectangle.Y + rectangle.Width / 20 + rectangle.Width / 5 + rectangle.Width / 5 + rectangle.Width / 20 + (rectangle.Width / 10 + rectangle.Width / 40) * labelIndex, rectangle.Width / 3, rectangle.Width / 10),
|
||||||
|
fontColor = fontColor2, text = resource.Key + " " + resource.Value, scale = scale2, fontName = fontName2, mainColor = Color.Transparent
|
||||||
|
};
|
||||||
|
res.LoadTexture(content);
|
||||||
|
Labels.Add(res);
|
||||||
|
labelIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void LoadTexture(ContentManager content)
|
||||||
|
{
|
||||||
|
base.LoadTexture(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
labelIndex = 0;
|
||||||
|
icon.rectangle = new Rectangle(rectangle.X + rectangle.Width / 20, rectangle.Y + rectangle.Width / 20, rectangle.Width / 5, rectangle.Width / 5);
|
||||||
|
itemName.rectangle = new Rectangle(rectangle.X + rectangle.Width / 20 + rectangle.Width / 5 + rectangle.Width / 20,
|
||||||
|
rectangle.Y + rectangle.Width / 10, rectangle.Width / 3 * 2, rectangle.Width / 5);
|
||||||
|
discription.rectangle = new Rectangle(rectangle.X + rectangle.Width / 20,
|
||||||
|
rectangle.Y + rectangle.Width / 20 + rectangle.Width / 5 + rectangle.Width / 20, rectangle.Width / 5,
|
||||||
|
rectangle.Width / 5);
|
||||||
|
foreach (var label in Labels)
|
||||||
|
{
|
||||||
|
label.rectangle = new Rectangle(rectangle.X + rectangle.Width / 2 - rectangle.Width / 3 / 2,
|
||||||
|
rectangle.Y + rectangle.Width / 20 + rectangle.Width / 5 + rectangle.Width / 5 + rectangle.Width / 20 +
|
||||||
|
(rectangle.Width / 10 + rectangle.Width / 40) * labelIndex, rectangle.Width / 3, rectangle.Width / 10);
|
||||||
|
labelIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,10 +9,11 @@ using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
|
||||||
namespace MonogameLibrary.UI.Elements;
|
namespace MonogameLibrary.UI.Elements;
|
||||||
|
|
||||||
public class ItemDisplayButton : DrawableUIElement
|
public class ItemDisplayButton : Button
|
||||||
{
|
{
|
||||||
public int count;
|
public int count;
|
||||||
public string itemTextureName;
|
public string itemTextureName;
|
||||||
|
@ -23,6 +24,11 @@ public class ItemDisplayButton : DrawableUIElement
|
||||||
public string text1;
|
public string text1;
|
||||||
public float scale1;
|
public float scale1;
|
||||||
private DrawableUIElement icon;
|
private DrawableUIElement icon;
|
||||||
|
private HoverState presentState = HoverState.None;
|
||||||
|
private HoverWindow hoverWindow = null;
|
||||||
|
private ContentManager content;
|
||||||
|
public string discriptions1;
|
||||||
|
public Dictionary<string, int> resourcesNeededToCraft1;
|
||||||
|
|
||||||
|
|
||||||
public ItemDisplayButton(UIManager manager) : base(manager)
|
public ItemDisplayButton(UIManager manager) : base(manager)
|
||||||
|
@ -51,6 +57,7 @@ public class ItemDisplayButton : DrawableUIElement
|
||||||
|
|
||||||
public override void LoadTexture(ContentManager content)
|
public override void LoadTexture(ContentManager content)
|
||||||
{
|
{
|
||||||
|
this.content = content;
|
||||||
icon.LoadTexture(content);
|
icon.LoadTexture(content);
|
||||||
base.LoadTexture(content);
|
base.LoadTexture(content);
|
||||||
if (itemTextureName == "")
|
if (itemTextureName == "")
|
||||||
|
@ -72,6 +79,47 @@ public class ItemDisplayButton : DrawableUIElement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (hoverState == HoverState.Hovering)
|
||||||
|
{
|
||||||
|
if (presentState != hoverState)
|
||||||
|
{
|
||||||
|
hoverWindow = new HoverWindow(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(Mouse.GetState().Position.X, Mouse.GetState().Position.Y, rectangle.Width, rectangle.Height * 10),
|
||||||
|
mainColor = Color.Gray,
|
||||||
|
tagItem = text1,
|
||||||
|
discriptions = discriptions1,
|
||||||
|
resourcesNeededToCraft = resourcesNeededToCraft1,
|
||||||
|
fontColor2 = fontColor1,
|
||||||
|
fontName2 = fontName1,
|
||||||
|
scale2 = scale1,
|
||||||
|
itemTextureName1 = itemTextureName
|
||||||
|
};
|
||||||
|
hoverWindow.Initialize(content);
|
||||||
|
hoverWindow.LoadTexture(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
hoverWindow.rectangle.X = Mouse.GetState().Position.X;
|
||||||
|
hoverWindow.rectangle.Y = Mouse.GetState().Position.Y;
|
||||||
|
hoverWindow.Update(gameTime);
|
||||||
|
}
|
||||||
|
else if (hoverState == HoverState.None)
|
||||||
|
{
|
||||||
|
if (presentState != hoverState)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
presentState = hoverState;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Draw(SpriteBatch _spriteBatch)
|
public override void Draw(SpriteBatch _spriteBatch)
|
||||||
{
|
{
|
||||||
base.Draw(_spriteBatch);
|
base.Draw(_spriteBatch);
|
|
@ -9,6 +9,7 @@ using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
|
||||||
namespace MonogameLibrary.UI.Elements;
|
namespace MonogameLibrary.UI.Elements;
|
||||||
|
|
||||||
|
@ -23,6 +24,12 @@ public class ItemDisplayLabel : DrawableUIElement
|
||||||
public string text1;
|
public string text1;
|
||||||
public float scale1;
|
public float scale1;
|
||||||
private DrawableUIElement icon;
|
private DrawableUIElement icon;
|
||||||
|
private HoverState presentState = HoverState.None;
|
||||||
|
private HoverWindow hoverWindow = null;
|
||||||
|
public string discriptions1;
|
||||||
|
public Dictionary<string, int> resourcesNeededToCraft1;
|
||||||
|
public HoverState hoverState = HoverState.None;
|
||||||
|
private ContentManager content;
|
||||||
|
|
||||||
|
|
||||||
public ItemDisplayLabel(UIManager manager) : base(manager)
|
public ItemDisplayLabel(UIManager manager) : base(manager)
|
||||||
|
@ -51,6 +58,7 @@ public class ItemDisplayLabel : DrawableUIElement
|
||||||
|
|
||||||
public override void LoadTexture(ContentManager content)
|
public override void LoadTexture(ContentManager content)
|
||||||
{
|
{
|
||||||
|
this.content = content;
|
||||||
icon.LoadTexture(content);
|
icon.LoadTexture(content);
|
||||||
base.LoadTexture(content);
|
base.LoadTexture(content);
|
||||||
if (itemTextureName == "")
|
if (itemTextureName == "")
|
||||||
|
@ -72,8 +80,71 @@ public class ItemDisplayLabel : DrawableUIElement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
if (rectangle.Intersects(new Rectangle(Mouse.GetState().Position, Point.Zero)))
|
||||||
|
{
|
||||||
|
hoverState = HoverState.Hovering;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hoverState = HoverState.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hoverState == HoverState.Hovering)
|
||||||
|
{
|
||||||
|
if (presentState != hoverState)
|
||||||
|
{
|
||||||
|
if (resourcesNeededToCraft1 == null)
|
||||||
|
{
|
||||||
|
resourcesNeededToCraft1 = new Dictionary<string, int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
hoverWindow = new HoverWindow(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(Mouse.GetState().Position.X, Mouse.GetState().Position.Y, rectangle.Width, rectangle.Height * 10),
|
||||||
|
mainColor = Color.Gray,
|
||||||
|
tagItem = text1,
|
||||||
|
discriptions = discriptions1,
|
||||||
|
resourcesNeededToCraft = resourcesNeededToCraft1,
|
||||||
|
fontColor2 = fontColor1,
|
||||||
|
fontName2 = fontName1,
|
||||||
|
scale2 = scale1,
|
||||||
|
itemTextureName1 = itemTextureName
|
||||||
|
};
|
||||||
|
hoverWindow.Initialize(content);
|
||||||
|
hoverWindow.LoadTexture(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
hoverWindow.rectangle.X = Mouse.GetState().Position.X;
|
||||||
|
hoverWindow.rectangle.Y = Mouse.GetState().Position.Y;
|
||||||
|
hoverWindow.Update(gameTime);
|
||||||
|
}
|
||||||
|
else if (hoverState == HoverState.None)
|
||||||
|
{
|
||||||
|
if (presentState != hoverState)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
presentState = hoverState;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Draw(SpriteBatch _spriteBatch)
|
public override void Draw(SpriteBatch _spriteBatch)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (hoverState == HoverState.None)
|
||||||
|
{
|
||||||
|
_spriteBatch.Draw(texture, rectangle, Color.White);
|
||||||
|
}
|
||||||
|
else if (hoverState == HoverState.Hovering)
|
||||||
|
{
|
||||||
|
_spriteBatch.Draw(texture, rectangle, new Color(211, 211, 211));
|
||||||
|
}
|
||||||
base.Draw(_spriteBatch);
|
base.Draw(_spriteBatch);
|
||||||
|
_spriteBatch.Draw(texture, rectangle, Color.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,6 +34,13 @@
|
||||||
/processorParam:TextureFormat=Compressed
|
/processorParam:TextureFormat=Compressed
|
||||||
/build:Fonts/Font3.spritefont
|
/build:Fonts/Font3.spritefont
|
||||||
|
|
||||||
|
#begin Fonts/Font4.spritefont
|
||||||
|
/importer:FontDescriptionImporter
|
||||||
|
/processor:FontDescriptionProcessor
|
||||||
|
/processorParam:PremultiplyAlpha=True
|
||||||
|
/processorParam:TextureFormat=Compressed
|
||||||
|
/build:Fonts/Font4.spritefont
|
||||||
|
|
||||||
#begin MapData/TileMaps/main.tmj
|
#begin MapData/TileMaps/main.tmj
|
||||||
/copy:MapData/TileMaps/main.tmj
|
/copy:MapData/TileMaps/main.tmj
|
||||||
|
|
||||||
|
|
64
ZoFo/Content/Fonts/Font4.spritefont
Normal file
64
ZoFo/Content/Fonts/Font4.spritefont
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
This file contains an xml description of a font, and will be read by the XNA
|
||||||
|
Framework Content Pipeline. Follow the comments to customize the appearance
|
||||||
|
of the font in your game, and to change the characters which are available to draw
|
||||||
|
with.
|
||||||
|
-->
|
||||||
|
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
|
||||||
|
<Asset Type="Graphics:FontDescription">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Modify this string to change the font that will be imported.
|
||||||
|
-->
|
||||||
|
<FontName>Troubleside-lgjxX.ttf</FontName>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Size is a float value, measured in points. Modify this value to change
|
||||||
|
the size of the font.
|
||||||
|
-->
|
||||||
|
<Size>50</Size>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Spacing is a float value, measured in pixels. Modify this value to change
|
||||||
|
the amount of spacing in between characters.
|
||||||
|
-->
|
||||||
|
<Spacing>0</Spacing>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
UseKerning controls the layout of the font. If this value is true, kerning information
|
||||||
|
will be used when placing characters.
|
||||||
|
-->
|
||||||
|
<UseKerning>true</UseKerning>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
|
||||||
|
and "Bold, Italic", and are case sensitive.
|
||||||
|
-->
|
||||||
|
<Style>Regular</Style>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
If you uncomment this line, the default character will be substituted if you draw
|
||||||
|
or measure text that contains characters which were not included in the font.
|
||||||
|
-->
|
||||||
|
<!-- <DefaultCharacter>*</DefaultCharacter> -->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
CharacterRegions control what letters are available in the font. Every
|
||||||
|
character from Start to End will be built and made available for drawing. The
|
||||||
|
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
|
||||||
|
character set. The characters are ordered according to the Unicode standard.
|
||||||
|
See the documentation for more information.
|
||||||
|
-->
|
||||||
|
<CharacterRegions>
|
||||||
|
<CharacterRegion>
|
||||||
|
<Start>32</Start>
|
||||||
|
<End>127</End>
|
||||||
|
</CharacterRegion>
|
||||||
|
<CharacterRegion>
|
||||||
|
<Start>А</Start>
|
||||||
|
<End>ј</End>
|
||||||
|
</CharacterRegion>
|
||||||
|
</CharacterRegions>
|
||||||
|
</Asset>
|
||||||
|
</XnaContent>
|
BIN
ZoFo/Content/Fonts/Troubleside-lgjxX.ttf
Normal file
BIN
ZoFo/Content/Fonts/Troubleside-lgjxX.ttf
Normal file
Binary file not shown.
|
@ -1,78 +1,49 @@
|
||||||
{
|
{
|
||||||
"Map/SizeTest": {
|
|
||||||
"height": 4300,
|
|
||||||
"width": 2
|
|
||||||
},
|
|
||||||
"activeFile": "TileMaps/main.tmj",
|
"activeFile": "TileMaps/main.tmj",
|
||||||
"expandedProjectPaths": [
|
"expandedProjectPaths": [
|
||||||
|
"TileMaps",
|
||||||
|
"Templates",
|
||||||
".",
|
".",
|
||||||
"TileSets",
|
"TileSets"
|
||||||
"TileMaps"
|
|
||||||
],
|
],
|
||||||
"fileStates": {
|
"fileStates": {
|
||||||
"": {
|
|
||||||
"scaleInDock": 1
|
|
||||||
},
|
|
||||||
"TileMaps/TileSets/TileSet 1.tsj": {
|
|
||||||
"scaleInDock": 1
|
|
||||||
},
|
|
||||||
"TileMaps/main.tmj": {
|
"TileMaps/main.tmj": {
|
||||||
"scale": 0.33,
|
"scale": 0.75,
|
||||||
"selectedLayer": 1,
|
"selectedLayer": 1,
|
||||||
"viewCenter": {
|
"viewCenter": {
|
||||||
"x": 1010.6060606060606,
|
"x": 1860.6666666666665,
|
||||||
"y": 553.0303030303031
|
"y": 871.3333333333333
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"TileMaps/main.tmj#IconSet": {
|
|
||||||
"dynamicWrapping": true,
|
|
||||||
"scaleInEditor": 1
|
|
||||||
},
|
|
||||||
"TileSets/CollisionTileSet.tsj": {
|
|
||||||
"scaleInDock": 0.75,
|
|
||||||
"scaleInEditor": 1
|
|
||||||
},
|
|
||||||
"TileSets/IconSet.tsj": {
|
"TileSets/IconSet.tsj": {
|
||||||
"dynamicWrapping": true
|
"dynamicWrapping": true,
|
||||||
|
"scaleInDock": 1,
|
||||||
|
"scaleInEditor": 1
|
||||||
},
|
},
|
||||||
"TileSets/TileSet 1.tsj": {
|
"TileSets/TileSet 1.tsj": {
|
||||||
"dynamicWrapping": false,
|
"dynamicWrapping": false,
|
||||||
"scaleInDock": 1,
|
"scaleInDock": 1.5,
|
||||||
"scaleInEditor": 1.5
|
"scaleInEditor": 3
|
||||||
},
|
},
|
||||||
"TileSets/TilesetNature.tsj": {
|
"TileSets/TilesetNature.tsj": {
|
||||||
"dynamicWrapping": false
|
"scaleInDock": 1.5,
|
||||||
"scaleInDock": 1
|
|
||||||
},
|
|
||||||
"TileSets/WallSet.tsj": {
|
|
||||||
"scaleInDock": 1,
|
|
||||||
"scaleInEditor": 1
|
"scaleInEditor": 1
|
||||||
},
|
},
|
||||||
"TileSets/tileset 1 collision.tsj": {
|
"TileSets/tileset 1 collision.tsj": {
|
||||||
"scaleInDock": 1
|
"scaleInDock": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"last.imagePath": "D:/C#/Я смотрел ваши ХАКАТОНЫ/ZoFo/ZoFo/Content/Textures/icons",
|
|
||||||
"last.objectTemplatePath": "D:/C#/Я смотрел ваши ХАКАТОНЫ/ZoFo/ZoFo/Content/MapData/Templates",
|
|
||||||
"openFiles": [
|
"openFiles": [
|
||||||
|
"TileMaps/main.tmj",
|
||||||
|
"TileSets/IconSet.tsj",
|
||||||
"TileSets/TileSet 1.tsj",
|
"TileSets/TileSet 1.tsj",
|
||||||
"TileMaps/main.tmj"
|
"TileSets/TilesetNature.tsj"
|
||||||
],
|
],
|
||||||
"project": "MapSession.tiled-project",
|
"project": "MapSession.tiled-project",
|
||||||
"recentFiles": [
|
"recentFiles": [
|
||||||
|
"TileSets/TilesetNature.tsj",
|
||||||
"TileSets/TileSet 1.tsj",
|
"TileSets/TileSet 1.tsj",
|
||||||
"TileMaps/main.tmj",
|
"TileSets/IconSet.tsj",
|
||||||
"TileSets/CollisionTileSet.tsj",
|
"TileMaps/main.tmj"
|
||||||
"TileSets/WallSet.tsj"
|
]
|
||||||
],
|
|
||||||
"stampsFolder": "D:/C#/Я смотрел ваши ХАКАТОНЫ/ZoFo/ZoFo/Content/MapData/TileStamps",
|
|
||||||
"tileset.embedInMap": false,
|
|
||||||
"tileset.lastUsedFormat": "json",
|
|
||||||
"tileset.margin": 0,
|
|
||||||
"tileset.spacing": 0,
|
|
||||||
"tileset.tileSize": {
|
|
||||||
"height": 16,
|
|
||||||
"width": 16
|
|
||||||
},
|
|
||||||
"tileset.type": 1
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"id":"zombie_attack","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":64,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":5}],"textureFrameInterval":0,"framesCount":3,"isCycle":true,"offset":"0, 0"}
|
{"id":"zombie_attack","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":64,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":5}],"textureFrameInterval":0,"framesCount":3,"isCycle":false,"offset":"0, 0"}
|
||||||
|
|
|
@ -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":5}],"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":30}],"textureFrameInterval":0,"framesCount":8,"isCycle":true,"offset":"0, 0"}
|
||||||
|
|
|
@ -23,7 +23,6 @@ using System.Web;
|
||||||
using ZoFo.GameCore.GUI;
|
using ZoFo.GameCore.GUI;
|
||||||
using ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
|
using ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
|
||||||
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
|
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
|
||||||
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies;
|
|
||||||
using ZoFo.GameCore.Graphics;
|
using ZoFo.GameCore.Graphics;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
@ -93,6 +92,7 @@ namespace ZoFo.GameCore
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
Player myPlayer;
|
||||||
List<MapObject> mapObjects = new List<MapObject>();
|
List<MapObject> mapObjects = new List<MapObject>();
|
||||||
List<GameObject> gameObjects = new List<GameObject>();
|
List<GameObject> gameObjects = new List<GameObject>();
|
||||||
List<Player> players = new List<Player>();
|
List<Player> players = new List<Player>();
|
||||||
|
@ -111,6 +111,13 @@ namespace ZoFo.GameCore
|
||||||
}
|
}
|
||||||
|
|
||||||
networkManager.SendData();//set to ticks
|
networkManager.SendData();//set to ticks
|
||||||
|
if (myPlayer != null)
|
||||||
|
GraphicsComponent.CameraPosition =
|
||||||
|
((GraphicsComponent.CameraPosition.ToVector2() *0.9f +
|
||||||
|
(myPlayer.position + myPlayer.graphicsComponent.ObjectDrawRectangle.Size.ToVector2() / 2 - AppManager.Instance.CurentScreenResolution.ToVector2() / (2 * GraphicsComponent.scaling)
|
||||||
|
) * 0.1f
|
||||||
|
) )
|
||||||
|
.ToPoint();
|
||||||
}
|
}
|
||||||
internal void Draw(SpriteBatch spriteBatch)
|
internal void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
|
@ -140,45 +147,47 @@ namespace ZoFo.GameCore
|
||||||
(update as UpdateTileCreated).tileSetName
|
(update as UpdateTileCreated).tileSetName
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
//else if (update is UpdateStopObjectCreated)
|
else if (update is UpdateStopObjectCreated)
|
||||||
//{
|
{
|
||||||
// stopObjects.Add(
|
stopObjects.Add(
|
||||||
// new StopObject(
|
new StopObject(
|
||||||
// (update as UpdateStopObjectCreated).Position,
|
(update as UpdateStopObjectCreated).Position,
|
||||||
// (update as UpdateStopObjectCreated).Size.ToVector2(),
|
(update as UpdateStopObjectCreated).Size.GetPoint().ToVector2(),
|
||||||
// (update as UpdateStopObjectCreated).sourceRectangle,
|
(update as UpdateStopObjectCreated).sourceRectangle.GetRectangle(),
|
||||||
// (update as UpdateStopObjectCreated).tileSetName
|
(update as UpdateStopObjectCreated).tileSetName,
|
||||||
// ));
|
(update as UpdateStopObjectCreated).collisions.Select(x => x.GetRectangle()).ToArray()
|
||||||
//}
|
));
|
||||||
|
}
|
||||||
else if (update is UpdateGameObjectCreated)
|
else if (update is UpdateGameObjectCreated)
|
||||||
{
|
{
|
||||||
GameObject created_gameObject;
|
GameObject created_gameObject;
|
||||||
if ((update as UpdateGameObjectCreated).GameObjectType == "EntittyForAnimationTests")
|
if((update as UpdateGameObjectCreated).GameObjectType == "Player")
|
||||||
gameObjects.Add(new EntittyForAnimationTests((update as UpdateGameObjectCreated).position));
|
|
||||||
if ((update as UpdateGameObjectCreated).GameObjectType == "Player")
|
|
||||||
{
|
{
|
||||||
created_gameObject = new Player((update as UpdateGameObjectCreated).position);
|
created_gameObject = new Player((update as UpdateGameObjectCreated).position);
|
||||||
players.Add(created_gameObject as Player);
|
players.Add(created_gameObject as Player);
|
||||||
|
myPlayer = players[0];
|
||||||
gameObjects.Add(created_gameObject);
|
gameObjects.Add(created_gameObject);
|
||||||
}
|
}
|
||||||
if ((update as UpdateGameObjectCreated).GameObjectType == "Ammo")
|
else if((update as UpdateGameObjectCreated).GameObjectType == "Ammo")
|
||||||
gameObjects.Add(new Ammo((update as UpdateGameObjectCreated).position));
|
gameObjects.Add(new Ammo((update as UpdateGameObjectCreated).position));
|
||||||
if ((update as UpdateGameObjectCreated).GameObjectType == "Zombie")
|
else if((update as UpdateGameObjectCreated).GameObjectType == "Zombie")
|
||||||
gameObjects.Add(new Zombie((update as UpdateGameObjectCreated).position));
|
gameObjects.Add(new Zombie((update as UpdateGameObjectCreated).position));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Type t = Type.GetType("ZoFo.GameCore.GameObjects." + (update as UpdateGameObjectCreated).GameObjectType);
|
||||||
|
GameObject gameObject = Activator.CreateInstance(t, (update as UpdateGameObjectCreated).position) as GameObject;
|
||||||
|
if (gameObject is Entity)
|
||||||
|
(gameObject as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity);
|
||||||
|
gameObjects.Add(gameObject);
|
||||||
|
}
|
||||||
(gameObjects.Last() as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity);
|
(gameObjects.Last() as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity);
|
||||||
//var a = Assembly.GetAssembly(typeof(GameObject));
|
|
||||||
//gameObjects.Add( TODO reflection
|
|
||||||
//Activator.CreateInstance(Type.GetType("ZoFo.GameCore.GameObjects.Entities.EntittyForAnimationTests")
|
|
||||||
///*(update as UpdateGameObjectCreated).GameObjectType*/, new []{ new Vector2(100, 100) })
|
|
||||||
//as GameObject
|
|
||||||
//);
|
|
||||||
}
|
}
|
||||||
else if (update is UpdatePosition)
|
else if (update is UpdatePosition)
|
||||||
{
|
{
|
||||||
var ent = FindEntityById(update.IdEntity);
|
var ent = FindEntityById(update.IdEntity);
|
||||||
|
|
||||||
|
if (ent != null)
|
||||||
ent.position = (update as UpdatePosition).NewPosition;
|
ent.position = (update as UpdatePosition).NewPosition;
|
||||||
}
|
}
|
||||||
else if (update is UpdateAnimation)
|
else if (update is UpdateAnimation)
|
||||||
|
|
|
@ -19,17 +19,20 @@ namespace ZoFo.GameCore.GUI;
|
||||||
public class BaseGUI : AbstractGUI
|
public class BaseGUI : AbstractGUI
|
||||||
{
|
{
|
||||||
private DrawableUIElement menuBackground;
|
private DrawableUIElement menuBackground;
|
||||||
private List<ItemDisplayLabel> ItemDisplayButtonsList;
|
private List<ItemDisplayLabel> ItemDisplayLabelsList;
|
||||||
|
private List<ItemDisplayButton> ItemDisplayButtonsList;
|
||||||
private int buttonIndex = 0;
|
private int buttonIndex = 0;
|
||||||
private string textureName;
|
private string textureName;
|
||||||
|
|
||||||
protected override void CreateUI()
|
protected override void CreateUI()
|
||||||
{
|
{
|
||||||
ItemDisplayButtonsList = new List<ItemDisplayLabel>();
|
ItemDisplayLabelsList = new List<ItemDisplayLabel>();
|
||||||
|
ItemDisplayButtonsList = new List<ItemDisplayButton>();
|
||||||
int width = AppManager.Instance.CurentScreenResolution.X;
|
int width = AppManager.Instance.CurentScreenResolution.X;
|
||||||
int height = AppManager.Instance.CurentScreenResolution.Y;
|
int height = AppManager.Instance.CurentScreenResolution.Y;
|
||||||
Dictionary<string, int> playerItems = AppManager.Instance.playerData.items;
|
Dictionary<string, int> playerItems = AppManager.Instance.playerData.items;
|
||||||
Dictionary<string, ItemInfo> items = AppManager.Instance.ItemManager.tagItemPairs;
|
Dictionary<string, ItemInfo> items = AppManager.Instance.ItemManager.tagItemPairs;
|
||||||
|
int numberCraftItem = 0;
|
||||||
|
|
||||||
menuBackground = new DrawableUIElement(Manager)
|
menuBackground = new DrawableUIElement(Manager)
|
||||||
{
|
{
|
||||||
|
@ -46,69 +49,112 @@ public class BaseGUI : AbstractGUI
|
||||||
fontName = "Fonts\\Font"
|
fontName = "Fonts\\Font"
|
||||||
});
|
});
|
||||||
|
|
||||||
DrawableUIElement baseHudBack = new DrawableUIElement(Manager)
|
DrawableUIElement baseItemBack = new DrawableUIElement(Manager)
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(width / 2 - (int)(width / 1.5) / 2, height / 2 - (int)(height / 1.5) / 2,
|
rectangle = new Rectangle(width / 2 - (height / 16 + (int)(width / 2.5)) / 2,
|
||||||
(int)(width / 1.5), (int)(height / 1.5)),
|
height / 2 - (int)(height / 1.5) / 2,
|
||||||
|
height / 40 + width / 5, (int)(height / 1.5)),
|
||||||
mainColor = Color.LightGray
|
mainColor = Color.LightGray
|
||||||
};
|
};
|
||||||
Elements.Add(baseHudBack);
|
Elements.Add(baseItemBack);
|
||||||
|
DrawableUIElement baseCraftBack = new DrawableUIElement(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(width / 2 + height / 160, height / 2 - (int)(height / 1.5) / 2,
|
||||||
|
height / 40 + width / 5, (int)(height / 1.5)),
|
||||||
|
mainColor = Color.LightGray
|
||||||
|
};
|
||||||
|
Elements.Add(baseCraftBack);
|
||||||
|
|
||||||
//player itams
|
//player itams
|
||||||
foreach (var item in playerItems)
|
foreach (var item in playerItems)
|
||||||
{
|
{
|
||||||
textureName = AppManager.Instance.ItemManager.GetItemInfo(item.Key).textureName;
|
if (item.Value > 0)
|
||||||
|
{
|
||||||
|
ItemInfo itemInfo = AppManager.Instance.ItemManager.GetItemInfo(item.Key);
|
||||||
var temp = new ItemDisplayLabel(Manager)
|
var temp = new ItemDisplayLabel(Manager)
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(width / 2 - (int)(width / 1.5) / 2 + height / 80,
|
rectangle = new Rectangle(width / 2 - (height / 16 + (int)(width / 2.5)) / 2 + height / 80,
|
||||||
height / 2 - (int)(height / 1.5) / 2 + height / 80 + (height / 20 + height / 80) * (buttonIndex),
|
height / 2 - (int)(height / 1.5) / 2 + height / 80 +
|
||||||
|
(height / 20 + height / 80) * (buttonIndex),
|
||||||
(int)(width / 5), (int)(height / 20)),
|
(int)(width / 5), (int)(height / 20)),
|
||||||
text1 = item.Key,
|
text1 = item.Key,
|
||||||
scale1 = 0.4f,
|
scale1 = 0.4f,
|
||||||
count = item.Value,
|
count = item.Value,
|
||||||
itemTextureName = textureName,
|
itemTextureName = itemInfo.textureName,
|
||||||
fontColor1 = Color.White,
|
fontColor1 = Color.White,
|
||||||
mainColor = Color.Gray,
|
mainColor = Color.Gray,
|
||||||
fontName1 = "Fonts\\Font3"
|
fontName1 = "Fonts\\Font4",
|
||||||
|
discriptions1 = itemInfo.description,
|
||||||
|
resourcesNeededToCraft1 = itemInfo.resourcesNeededToCraft
|
||||||
};
|
};
|
||||||
Elements.Add(temp);
|
Elements.Add(temp);
|
||||||
temp.Initialize();
|
temp.Initialize();
|
||||||
temp.LoadTexture(AppManager.Instance.Content);
|
temp.LoadTexture(AppManager.Instance.Content);
|
||||||
ItemDisplayButtonsList.Add(temp);
|
ItemDisplayLabelsList.Add(temp);
|
||||||
|
|
||||||
buttonIndex++;
|
buttonIndex++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// craftable items
|
// craftable items
|
||||||
buttonIndex = 0;
|
buttonIndex = 0;
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
ItemInfo itemInfo = AppManager.Instance.ItemManager.GetItemInfo(item.Key);
|
ItemInfo itemInfo = AppManager.Instance.ItemManager.GetItemInfo(item.Key);
|
||||||
|
|
||||||
if (itemInfo.isCraftable)
|
if (itemInfo.isCraftable)
|
||||||
{
|
{
|
||||||
var temp = new ItemDisplayLabel(Manager)
|
Dictionary<string, int> needToCraft =
|
||||||
|
AppManager.Instance.ItemManager.GetItemInfo(item.Key).resourcesNeededToCraft;
|
||||||
|
numberCraftItem = playerItems[needToCraft.Keys.First()] / needToCraft.Values.First();
|
||||||
|
foreach (var itemNeedToCraft in needToCraft)
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(width / 2 - (int)(width / 1.5) / 2 + height / 40 + width / 5,
|
int xValue = playerItems[itemNeedToCraft.Key] / itemNeedToCraft.Value;
|
||||||
|
if (numberCraftItem > xValue)
|
||||||
|
{
|
||||||
|
numberCraftItem = xValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numberCraftItem > 0)
|
||||||
|
{
|
||||||
|
var temp = new ItemDisplayButton(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(
|
||||||
|
width / 2 - (height / 16 + (int)(width / 2.5)) / 2 + height / 20 + width / 5,
|
||||||
height / 2 - (int)(height / 1.5) / 2 + height / 80 +
|
height / 2 - (int)(height / 1.5) / 2 + height / 80 +
|
||||||
(height / 20 + height / 80) * (buttonIndex),
|
(height / 20 + height / 80) * (buttonIndex),
|
||||||
(int)(width / 5), (int)(height / 20)),
|
(int)(width / 5), (int)(height / 20)),
|
||||||
text1 = item.Key,
|
text1 = item.Key,
|
||||||
scale1 = 0.4f,
|
scale1 = 0.4f,
|
||||||
count = 0,
|
count = numberCraftItem,
|
||||||
itemTextureName = itemInfo.textureName,
|
itemTextureName = itemInfo.textureName,
|
||||||
fontColor1 = Color.White,
|
fontColor1 = Color.White,
|
||||||
mainColor = Color.Gray,
|
mainColor = Color.Gray,
|
||||||
fontName1 = "Fonts\\Font3"
|
fontName1 = "Fonts\\Font4",
|
||||||
|
discriptions1 = itemInfo.description,
|
||||||
|
resourcesNeededToCraft1 = itemInfo.resourcesNeededToCraft
|
||||||
};
|
};
|
||||||
Elements.Add(temp);
|
Elements.Add(temp);
|
||||||
temp.Initialize();
|
temp.Initialize();
|
||||||
temp.LoadTexture(AppManager.Instance.Content);
|
temp.LoadTexture(AppManager.Instance.Content);
|
||||||
ItemDisplayButtonsList.Add(temp);
|
ItemDisplayButtonsList.Add(temp);
|
||||||
|
temp.LeftButtonPressed += () =>
|
||||||
|
{
|
||||||
|
AppManager.Instance.playerData.CraftItem(item.Key);
|
||||||
|
AppManager.Instance.SetGUI(new BaseGUI());
|
||||||
|
};
|
||||||
|
|
||||||
buttonIndex++;
|
buttonIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Button bTExit = new Button(Manager)
|
Button bTExit = new Button(Manager)
|
||||||
{
|
{
|
||||||
|
@ -123,5 +169,19 @@ public class BaseGUI : AbstractGUI
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
|
foreach (var item in ItemDisplayButtonsList)
|
||||||
|
{
|
||||||
|
if (item.Update(gameTime))
|
||||||
|
{
|
||||||
|
AppManager.Instance.SetGUI(new BaseGUI());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var item in ItemDisplayLabelsList)
|
||||||
|
{
|
||||||
|
if (item.Update(gameTime))
|
||||||
|
{
|
||||||
|
AppManager.Instance.SetGUI(new BaseGUI());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,6 +12,7 @@ using ZoFo.GameCore.GameManagers.ItemManager;
|
||||||
using ZoFo.GameCore.GUI;
|
using ZoFo.GameCore.GUI;
|
||||||
using static System.Collections.Specialized.BitVector32;
|
using static System.Collections.Specialized.BitVector32;
|
||||||
using MonogameLibrary.UI.Base;
|
using MonogameLibrary.UI.Base;
|
||||||
|
using ZoFo.GameCore.GameManagers.AssetsManager;
|
||||||
using ZoFo.GameCore.GameObjects;
|
using ZoFo.GameCore.GameObjects;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameManagers
|
namespace ZoFo.GameCore.GameManagers
|
||||||
|
@ -40,6 +41,7 @@ namespace ZoFo.GameCore.GameManagers
|
||||||
public ItemManager.ItemManager ItemManager;
|
public ItemManager.ItemManager ItemManager;
|
||||||
public SettingsManager SettingsManager;
|
public SettingsManager SettingsManager;
|
||||||
public SoundManager SoundManager;
|
public SoundManager SoundManager;
|
||||||
|
public AssetManager AssetManager;
|
||||||
|
|
||||||
public AnimationBuilder animationBuilder { get; set; }
|
public AnimationBuilder animationBuilder { get; set; }
|
||||||
|
|
||||||
|
@ -56,6 +58,7 @@ namespace ZoFo.GameCore.GameManagers
|
||||||
Content.RootDirectory = "Content";
|
Content.RootDirectory = "Content";
|
||||||
IsMouseVisible = true;
|
IsMouseVisible = true;
|
||||||
|
|
||||||
|
server = new Server();
|
||||||
playerData = new PlayerData();
|
playerData = new PlayerData();
|
||||||
ItemManager = new ItemManager.ItemManager();
|
ItemManager = new ItemManager.ItemManager();
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
@ -63,6 +66,7 @@ namespace ZoFo.GameCore.GameManagers
|
||||||
SettingsManager = new SettingsManager();
|
SettingsManager = new SettingsManager();
|
||||||
SettingsManager.LoadSettings();
|
SettingsManager.LoadSettings();
|
||||||
SoundManager = new SoundManager();
|
SoundManager = new SoundManager();
|
||||||
|
AssetManager = new AssetManager();
|
||||||
SoundManager.LoadSounds();
|
SoundManager.LoadSounds();
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,7 +105,7 @@ namespace ZoFo.GameCore.GameManagers
|
||||||
protected override void Update(GameTime gameTime)
|
protected override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
|
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
|
||||||
Keyboard.GetState().IsKeyDown(Keys.Escape)) { server.CloseConnection(); Exit(); }
|
Keyboard.GetState().IsKeyDown(Keys.Escape)) { server?.CloseConnection(); Exit(); }
|
||||||
|
|
||||||
|
|
||||||
// debugHud.Set("key", "value");
|
// debugHud.Set("key", "value");
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace ZoFo.GameCore.GameManagers.AssetsManager;
|
||||||
|
|
||||||
|
public class AssetContainer
|
||||||
|
{
|
||||||
|
public List<string> Animations;
|
||||||
|
public string IdleAnimation;
|
||||||
|
}
|
18
ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs
Normal file
18
ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace ZoFo.GameCore.GameManagers.AssetsManager;
|
||||||
|
|
||||||
|
public class AssetManager
|
||||||
|
{
|
||||||
|
public AssetContainer Zombie = new()
|
||||||
|
{
|
||||||
|
Animations = ["zombie_damaged", "zombie_walk", "zombie_idle", "zombie_attack", "zombie_death"],
|
||||||
|
IdleAnimation = "zombie_walk"
|
||||||
|
};
|
||||||
|
|
||||||
|
public AssetContainer Player = new()
|
||||||
|
{
|
||||||
|
Animations = [ "player_look_down" ],
|
||||||
|
IdleAnimation = "player_look_down"
|
||||||
|
};
|
||||||
|
}
|
|
@ -30,9 +30,10 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// минимальный накоп изменения перед перевдижением
|
/// минимальный накоп изменения перед перевдижением
|
||||||
/// </summary>
|
/// </summary>
|
||||||
const float minimalValueToChange = 4;
|
const float minimalValueToChange = 0;
|
||||||
public void CheckComponentCollision(CollisionComponent componentOfEntity)
|
public void CheckComponentCollision(CollisionComponent componentOfEntity)
|
||||||
{
|
{
|
||||||
|
//ADD CHECKSPEED TODO
|
||||||
var entity = componentOfEntity.gameObject as LivingEntity;
|
var entity = componentOfEntity.gameObject as LivingEntity;
|
||||||
//for (int i = 0; i < ObjectsWithCollisions.Count; i++)
|
//for (int i = 0; i < ObjectsWithCollisions.Count; i++)
|
||||||
//{
|
//{
|
||||||
|
@ -74,7 +75,8 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
entity.position.X += entity.velocity.X; //update player position
|
entity.position.X += (int)entity.velocity.X; //update player position
|
||||||
|
//entity.position.X = (float)Math.Round(entity.position.X, 2);
|
||||||
newRect.X = tryingRectX.X;//значение по X для нового РЕК приравниваем к значению испытуемого РЕК
|
newRect.X = tryingRectX.X;//значение по X для нового РЕК приравниваем к значению испытуемого РЕК
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +114,8 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
entity.position.Y += entity.velocity.Y;
|
entity.position.Y += (int)entity.velocity.Y;
|
||||||
|
//entity.position.Y = (float)Math.Round(entity.position.Y, 2);
|
||||||
newRect.Y = tryingRectY.Y;//значение по X для нового РЕК приравниваем к значению испытуемого РЕК
|
newRect.Y = tryingRectY.Y;//значение по X для нового РЕК приравниваем к значению испытуемого РЕК
|
||||||
}
|
}
|
||||||
entity.velocity.Y = 0;
|
entity.velocity.Y = 0;
|
||||||
|
@ -224,8 +227,8 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
|
||||||
{
|
{
|
||||||
public static Rectangle SetOrigin(this Rectangle rectangle, Vector2 origin)
|
public static Rectangle SetOrigin(this Rectangle rectangle, Vector2 origin)
|
||||||
{
|
{
|
||||||
rectangle.X = (int)origin.X;
|
rectangle.X += (int)origin.X;
|
||||||
rectangle.Y = (int)origin.Y;
|
rectangle.Y += (int)origin.Y;
|
||||||
return rectangle;
|
return rectangle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,6 +155,7 @@ namespace ZoFo.GameCore.GameManagers
|
||||||
if (keyBoardState.IsKeyDown(Keys.Left) || keyBoardState.IsKeyDown(Keys.A))
|
if (keyBoardState.IsKeyDown(Keys.Left) || keyBoardState.IsKeyDown(Keys.A))
|
||||||
{
|
{
|
||||||
InputMovementDirection += new Vector2(-1, 0);
|
InputMovementDirection += new Vector2(-1, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
ConvertVector2ToState(InputMovementDirection);
|
ConvertVector2ToState(InputMovementDirection);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -14,16 +14,18 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
||||||
public string textureName;
|
public string textureName;
|
||||||
Texture2D itemTexture;
|
Texture2D itemTexture;
|
||||||
public bool isCraftable;
|
public bool isCraftable;
|
||||||
|
public string description;
|
||||||
public Dictionary<string, int> resourcesNeededToCraft;
|
public Dictionary<string, int> resourcesNeededToCraft;
|
||||||
public ItemInfo (string tag)
|
public ItemInfo (string tag)
|
||||||
{
|
{
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
}
|
}
|
||||||
public ItemInfo(string tag,string textureName,bool isCraftable, Dictionary<string, int> resourcesNeededToCraft)
|
public ItemInfo(string tag, string description, string textureName, bool isCraftable, Dictionary<string, int> resourcesNeededToCraft)
|
||||||
{
|
{
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.textureName = textureName;
|
this.textureName = textureName;
|
||||||
|
|
||||||
|
this.description = description;
|
||||||
this.isCraftable = isCraftable;
|
this.isCraftable = isCraftable;
|
||||||
this.resourcesNeededToCraft = resourcesNeededToCraft;
|
this.resourcesNeededToCraft = resourcesNeededToCraft;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,13 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
tagItemPairs = new Dictionary<string, ItemInfo>();
|
tagItemPairs = new Dictionary<string, ItemInfo>();
|
||||||
tagItemPairs.Add("wood", new ItemInfo("wood","Textures\\Test\\wood",false,null));
|
tagItemPairs.Add("wood", new ItemInfo("wood", "бревна кусок", "Textures\\Test\\wood",false,null));
|
||||||
tagItemPairs.Add("rock", new ItemInfo("rock", "Textures\\Test\\rock", false, null));
|
tagItemPairs.Add("rock", new ItemInfo("rock", "пять галек", "Textures\\Test\\rock", false, null));
|
||||||
tagItemPairs.Add("steel", new ItemInfo("steel", "Textures\\Test\\steel", false, null));
|
tagItemPairs.Add("steel", new ItemInfo("steel", "метал, метал, \nжелезо, метал", "Textures\\Test\\steel", false, null));
|
||||||
tagItemPairs.Add("pickaxe", new ItemInfo("steel", "Textures\\Test\\pickaxe", true, new Dictionary<string, int>()
|
tagItemPairs.Add("pickaxe", new ItemInfo("steel", "прямой путь к \nстановлению каменьщиком", "Textures\\Test\\pickaxe", true, new Dictionary<string, int>()
|
||||||
{
|
{
|
||||||
{"wood", 2},
|
{"wood", 2},
|
||||||
{"Steel", 3}
|
{"steel", 3}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,14 +35,24 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
||||||
{
|
{
|
||||||
items[item.Key] -= item.Value;
|
items[item.Key] -= item.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (items.Keys.Contains(itemTag))
|
||||||
|
{
|
||||||
|
items[itemTag] += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
items.Add(itemTag, 1);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void LoadPlayerData()
|
public void LoadPlayerData()
|
||||||
{
|
{
|
||||||
//TODO
|
//TODO
|
||||||
items = new Dictionary<string, int>();
|
items = new Dictionary<string, int>();
|
||||||
items.Add("wood", 2);
|
items.Add("wood", 5);
|
||||||
items.Add("steel", 110);
|
items.Add("steel", 110);
|
||||||
items.Add("rock", 6);
|
items.Add("rock", 6);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
||||||
var databytes = Encoding.UTF8.GetBytes(data);
|
var databytes = Encoding.UTF8.GetBytes(data);
|
||||||
foreach (Socket socket in clients)
|
foreach (Socket socket in clients)
|
||||||
{
|
{
|
||||||
clients[0].SendAsync(databytes, SocketFlags.Partial);
|
clients[0].SendAsync(databytes);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 200 && i< datasToSend.Count; i++)
|
for (int i = 0; i < 200 && i< datasToSend.Count; i++)
|
||||||
updates.RemoveAt(0);
|
updates.RemoveAt(0);
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ZoFo.GameCore.GameManagers.NetworkManager.SerializableDTO;
|
||||||
|
|
||||||
|
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
|
||||||
|
{
|
||||||
|
internal class UpdateStopObjectCreated : UpdateData
|
||||||
|
{
|
||||||
|
public UpdateStopObjectCreated() { UpdateType = "UpdateStopObjectCreated"; }
|
||||||
|
public Texture2D TextureTile { get; set; }
|
||||||
|
public Vector2 Position { get; set; }
|
||||||
|
public SerializablePoint Size { get; set; }
|
||||||
|
public SerializableRectangle sourceRectangle { get; set; }
|
||||||
|
public string tileSetName { get; set; }
|
||||||
|
public SerializableRectangle[] collisions { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ZoFo.GameCore.Graphics;
|
using ZoFo.GameCore.Graphics;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities
|
namespace ZoFo.GameCore.GameObjects
|
||||||
{
|
{
|
||||||
internal class EntittyForAnimationTests : Entity
|
internal class EntittyForAnimationTests : Entity
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,14 +6,14 @@ using Microsoft.Xna.Framework.Graphics;
|
||||||
using ZoFo.GameCore.GameManagers;
|
using ZoFo.GameCore.GameManagers;
|
||||||
using ZoFo.GameCore.GameManagers.CollisionManager;
|
using ZoFo.GameCore.GameManagers.CollisionManager;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities
|
namespace ZoFo.GameCore.GameObjects
|
||||||
{
|
{
|
||||||
public abstract class Entity : GameObject
|
public abstract class Entity : GameObject
|
||||||
{
|
{
|
||||||
//public override GraphicsComponent graphicsComponent => null;
|
//public override GraphicsComponent graphicsComponent => null;
|
||||||
public CollisionComponent collisionComponent { get; protected set; }
|
public CollisionComponent collisionComponent { get; protected set; }
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
static int totalEntitiesCreated = 0;
|
static int totalEntitiesCreated = 1;
|
||||||
protected Entity(Vector2 position) : base(position)
|
protected Entity(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
Id = totalEntitiesCreated;
|
Id = totalEntitiesCreated;
|
||||||
|
|
|
@ -11,7 +11,7 @@ using ZoFo.GameCore.Graphics;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using ZoFo.GameCore.GUI;
|
using ZoFo.GameCore.GUI;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
|
namespace ZoFo.GameCore.GameObjects
|
||||||
{
|
{
|
||||||
class Ammo:Collectable
|
class Ammo:Collectable
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@ using ZoFo.GameCore.GameManagers;
|
||||||
using ZoFo.GameCore.GameManagers.CollisionManager;
|
using ZoFo.GameCore.GameManagers.CollisionManager;
|
||||||
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
|
namespace ZoFo.GameCore.GameObjects;
|
||||||
public class Collectable : Interactable
|
public class Collectable : Interactable
|
||||||
{
|
{
|
||||||
protected static readonly string _path = "Textures/icons/Collectables/";
|
protected static readonly string _path = "Textures/icons/Collectables/";
|
||||||
|
|
|
@ -5,7 +5,7 @@ using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
||||||
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player;
|
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player;
|
||||||
using ZoFo.GameCore.Graphics;
|
using ZoFo.GameCore.Graphics;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities.Interactables;
|
namespace ZoFo.GameCore.GameObjects;
|
||||||
|
|
||||||
public class Interactable : Entity
|
public class Interactable : Entity
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Reflection;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies;
|
namespace ZoFo.GameCore.GameObjects;
|
||||||
public class Enemy : LivingEntity
|
public class Enemy : LivingEntity
|
||||||
{
|
{
|
||||||
protected float speed;
|
protected float speed;
|
||||||
|
|
|
@ -1,23 +1,37 @@
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.VisualBasic;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ZoFo.GameCore.GameManagers;
|
using ZoFo.GameCore.GameManagers;
|
||||||
|
using ZoFo.GameCore.GameManagers.CollisionManager;
|
||||||
|
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
||||||
|
using ZoFo.GameCore.GameManagers.AssetsManager;
|
||||||
using ZoFo.GameCore.Graphics;
|
using ZoFo.GameCore.Graphics;
|
||||||
|
using ZoFo.GameCore.GUI;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies
|
namespace ZoFo.GameCore.GameObjects
|
||||||
{
|
{
|
||||||
class Zombie : Enemy
|
class Zombie : Enemy
|
||||||
{
|
{
|
||||||
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "zombie_damaged","zombie_walk","zombie_idle","zombie_attack","zombie_death" }, "zombie_walk");
|
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "zombie_damaged", "zombie_walk", "zombie_idle", "zombie_attack", "zombie_death" }, "zombie_walk");
|
||||||
|
public bool isAttacking;
|
||||||
public Zombie(Vector2 position) : base(position)
|
public Zombie(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
health = 5;
|
health = 5;
|
||||||
speed =2;
|
speed = 0.5f;
|
||||||
collisionComponent.stopRectangle = new Rectangle(0, 0, 52, 100);
|
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30);
|
||||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 100, 100);
|
collisionComponent.stopRectangle = new Rectangle(10, 20, 10, 10);
|
||||||
|
isAttacking = false;
|
||||||
|
StartAnimation("zombie_walk");
|
||||||
|
collisionComponent.isTrigger = true;
|
||||||
|
collisionComponent.hasCollision = true;
|
||||||
|
(graphicsComponent as AnimatedGraphicsComponent).actionOfAnimationEnd += EndAttack;
|
||||||
|
collisionComponent.OnTriggerZone += OnPlayerClose;
|
||||||
|
collisionComponent.triggerRectangle = new Rectangle(-5, -5, 40, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
|
@ -25,18 +39,39 @@ namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies
|
||||||
Vector2 duration = Vector2.Normalize(
|
Vector2 duration = Vector2.Normalize(
|
||||||
AppManager.Instance.server.players[0].position - position
|
AppManager.Instance.server.players[0].position - position
|
||||||
);
|
);
|
||||||
velocity+=new Vector2(duration.X * speed, duration.Y*speed);
|
|
||||||
if (Random.Shared.NextDouble() > 0.9)
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!isAttacking) { velocity += new Vector2(duration.X * speed, duration.Y * speed); }
|
||||||
|
|
||||||
|
}
|
||||||
|
public void OnPlayerClose(GameObject sender)
|
||||||
{
|
{
|
||||||
|
|
||||||
StartAnimation("zombie_damaged");
|
|
||||||
}
|
if(!isAttacking)
|
||||||
if (Random.Shared.NextDouble() > 0.9)
|
|
||||||
{
|
{
|
||||||
|
StartAnimation("zombie_attack");
|
||||||
StartAnimation("zombie_idle");
|
isAttacking = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public void EndAttack(string a)
|
||||||
|
{
|
||||||
|
var damagedPlayers=AppManager.Instance.server.collisionManager.GetPlayersInZone(collisionComponent.triggerRectangle.SetOrigin(position));
|
||||||
|
//TODO ДАМАЖИТЬ ИГРОКОВ В ЗОНЕ
|
||||||
|
if (damagedPlayers.Length>0) { DebugHUD.DebugLog("End of" + a);
|
||||||
|
AppManager.Instance.server.DeleteObject(this);
|
||||||
|
}
|
||||||
|
isAttacking = false;
|
||||||
|
}
|
||||||
|
public override void Draw(SpriteBatch spriteBatch)
|
||||||
|
{
|
||||||
|
DrawDebugRectangle(spriteBatch, collisionComponent.triggerRectangle.SetOrigin(position), Color.Blue);
|
||||||
|
base.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ using ZoFo.GameCore.GameManagers;
|
||||||
using ZoFo.GameCore.GameManagers.CollisionManager;
|
using ZoFo.GameCore.GameManagers.CollisionManager;
|
||||||
using ZoFo.GameCore.Graphics;
|
using ZoFo.GameCore.Graphics;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities;
|
namespace ZoFo.GameCore.GameObjects;
|
||||||
public class LivingEntity : Entity
|
public class LivingEntity : Entity
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -43,9 +43,9 @@ public class LivingEntity : Entity
|
||||||
Vector2 prevPosition_forClient;
|
Vector2 prevPosition_forClient;
|
||||||
public override void Draw(SpriteBatch spriteBatch)
|
public override void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
if ((position - prevPosition_forClient).X< 0)
|
if ((position - prevPosition_forClient).X < 0)
|
||||||
graphicsComponent.Flip = SpriteEffects.FlipHorizontally;
|
graphicsComponent.Flip = SpriteEffects.FlipHorizontally;
|
||||||
else if((position - prevPosition_forClient).X > 0)
|
else if ((position - prevPosition_forClient).X > 0)
|
||||||
graphicsComponent.Flip = SpriteEffects.None;
|
graphicsComponent.Flip = SpriteEffects.None;
|
||||||
base.Draw(spriteBatch);
|
base.Draw(spriteBatch);
|
||||||
prevPosition_forClient = position;
|
prevPosition_forClient = position;
|
||||||
|
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player
|
namespace ZoFo.GameCore.GameObjects
|
||||||
{
|
{
|
||||||
class LootData
|
class LootData
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using ZoFo.GameCore.GameManagers;
|
using ZoFo.GameCore.GameManagers;
|
||||||
|
using ZoFo.GameCore.GameManagers.AssetsManager;
|
||||||
using ZoFo.GameCore.GameManagers.CollisionManager;
|
using ZoFo.GameCore.GameManagers.CollisionManager;
|
||||||
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
|
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
|
||||||
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
||||||
|
@ -11,7 +12,7 @@ using ZoFo.GameCore.Graphics;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using ZoFo.GameCore.GUI;
|
using ZoFo.GameCore.GUI;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player;
|
namespace ZoFo.GameCore.GameObjects;
|
||||||
|
|
||||||
public class Player : LivingEntity
|
public class Player : LivingEntity
|
||||||
{
|
{
|
||||||
|
@ -23,17 +24,17 @@ public class Player : LivingEntity
|
||||||
//public bool IsTryingToShoot { get; set; }
|
//public bool IsTryingToShoot { get; set; }
|
||||||
private float speed;
|
private float speed;
|
||||||
private int health;
|
private int health;
|
||||||
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "player_look_down", "player_running_top_rotate" }, "player_look_down");
|
|
||||||
|
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AppManager.Instance.AssetManager.Player);
|
||||||
|
|
||||||
private LootData lootData;
|
private LootData lootData;
|
||||||
public bool IsTryingToInteract { get; set; }
|
public bool IsTryingToInteract { get; set; }
|
||||||
public bool IsTryingToShoot { get; set; }
|
public bool IsTryingToShoot { get; set; }
|
||||||
public Player(Vector2 position) : base(position)
|
public Player(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 100, 100);
|
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30);
|
||||||
collisionComponent.stopRectangle = new Rectangle(0, 0, 100, 100);
|
collisionComponent.stopRectangle = new Rectangle(0, 20, 30, 10);
|
||||||
speed = 10;
|
speed = 5;
|
||||||
IsTryingToInteract = false;
|
|
||||||
IsTryingToShoot = false;
|
|
||||||
|
|
||||||
StartAnimation("player_look_down");
|
StartAnimation("player_look_down");
|
||||||
}
|
}
|
||||||
|
@ -74,7 +75,7 @@ public class Player : LivingEntity
|
||||||
}
|
}
|
||||||
public void MovementLogic()
|
public void MovementLogic()
|
||||||
{
|
{
|
||||||
velocity = InputPlayerRotation * speed;
|
velocity += InputPlayerRotation * speed;
|
||||||
}
|
}
|
||||||
public void HandleNewInput(UpdateInput updateInput)
|
public void HandleNewInput(UpdateInput updateInput)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@ using ZoFo.GameCore.GameManagers;
|
||||||
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
||||||
using ZoFo.GameCore.Graphics;
|
using ZoFo.GameCore.Graphics;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.MapObjects
|
namespace ZoFo.GameCore.GameObjects
|
||||||
{
|
{
|
||||||
public class MapObject : GameObject
|
public class MapObject : GameObject
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,25 @@ namespace ZoFo.GameCore.GameObjects.MapObjects
|
||||||
(graphicsComponent as StaticGraphicsComponent).LoadContent();
|
(graphicsComponent as StaticGraphicsComponent).LoadContent();
|
||||||
this.sourceRectangle = sourceRectangle;
|
this.sourceRectangle = sourceRectangle;
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор для объектов с карты с анимациями, REDO
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <param name="size"></param>
|
||||||
|
/// <param name="sourceRectangle"></param>
|
||||||
|
/// <param name="textureName"></param>
|
||||||
|
/// <param name="sourceRectangles"></param>
|
||||||
|
/// <param name="frameSize"></param>
|
||||||
|
public MapObject(Vector2 position, Vector2 size, Rectangle sourceRectangle, string textureName, Rectangle sourceRectangles, int frameSize) : base(position)
|
||||||
|
{
|
||||||
|
//graphicsComponent for source
|
||||||
|
(graphicsComponent as StaticGraphicsComponent)._textureName = textureName;
|
||||||
|
(graphicsComponent as StaticGraphicsComponent).BuildComponent(textureName);
|
||||||
|
(graphicsComponent as StaticGraphicsComponent).ObjectDrawRectangle = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y);
|
||||||
|
(graphicsComponent as StaticGraphicsComponent).LoadContent();
|
||||||
|
this.sourceRectangle = sourceRectangle;
|
||||||
|
|
||||||
}
|
}
|
||||||
public override void Draw(SpriteBatch spriteBatch)
|
public override void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using ZoFo.GameCore.GameManagers;
|
using ZoFo.GameCore.GameManagers;
|
||||||
|
using ZoFo.GameCore.GameManagers.AssetsManager;
|
||||||
using ZoFo.GameCore.GUI;
|
using ZoFo.GameCore.GUI;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.Graphics
|
namespace ZoFo.GameCore.Graphics
|
||||||
|
@ -60,7 +61,17 @@ namespace ZoFo.GameCore.Graphics
|
||||||
private int interval;
|
private int interval;
|
||||||
private int lastInterval;
|
private int lastInterval;
|
||||||
private Rectangle sourceRectangle;
|
private Rectangle sourceRectangle;
|
||||||
|
public AnimatedGraphicsComponent(AssetContainer asset)
|
||||||
|
{
|
||||||
|
Build(asset.Animations, asset.IdleAnimation);
|
||||||
|
}
|
||||||
|
|
||||||
public AnimatedGraphicsComponent(List<string> animationsId, string neitralAnimationId)
|
public AnimatedGraphicsComponent(List<string> animationsId, string neitralAnimationId)
|
||||||
|
{
|
||||||
|
Build(animationsId, neitralAnimationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Build(List<string> animationsId, string neitralAnimationId)
|
||||||
{
|
{
|
||||||
//this._spriteBatch = _spriteBatch;
|
//this._spriteBatch = _spriteBatch;
|
||||||
currentFrame = 0;
|
currentFrame = 0;
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace ZoFo.GameCore.Graphics;
|
||||||
public abstract class GraphicsComponent
|
public abstract class GraphicsComponent
|
||||||
{
|
{
|
||||||
public Rectangle ObjectDrawRectangle;
|
public Rectangle ObjectDrawRectangle;
|
||||||
public static int scaling = 1;
|
public static int scaling = 3;
|
||||||
public string mainTextureName;//TODO костыль - пофиксить
|
public string mainTextureName;//TODO костыль - пофиксить
|
||||||
|
|
||||||
public SpriteEffects Flip = SpriteEffects.None;
|
public SpriteEffects Flip = SpriteEffects.None;
|
||||||
|
|
|
@ -17,7 +17,6 @@ using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
||||||
using ZoFo.GameCore.GameObjects;
|
using ZoFo.GameCore.GameObjects;
|
||||||
using ZoFo.GameCore.GameObjects.Entities;
|
using ZoFo.GameCore.GameObjects.Entities;
|
||||||
using ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
|
using ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
|
||||||
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies;
|
|
||||||
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player;
|
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player;
|
||||||
using ZoFo.GameCore.GameObjects.MapObjects;
|
using ZoFo.GameCore.GameObjects.MapObjects;
|
||||||
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
|
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
|
||||||
|
@ -137,10 +136,10 @@ namespace ZoFo.GameCore
|
||||||
|
|
||||||
//AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(0, 0)));
|
//AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(0, 0)));
|
||||||
AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(740, 140)));
|
AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(740, 140)));
|
||||||
AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1000, 1000)));
|
for (int i = 0; i < 20; i++)
|
||||||
AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1300, 1000)));
|
for (int j = 0; j < 20; j++)
|
||||||
AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1500, 1000)));
|
AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1300 + i*70, 1000+j*70)));
|
||||||
AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1700, 1000)));
|
|
||||||
AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(140, 440)));
|
AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(140, 440)));
|
||||||
AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(240, 440)));
|
AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(240, 440)));
|
||||||
}
|
}
|
||||||
|
@ -162,9 +161,9 @@ namespace ZoFo.GameCore
|
||||||
{
|
{
|
||||||
if (ticks == 3) //ОБРАБАТЫВАЕТСЯ 20 РАЗ В СЕКУНДУ
|
if (ticks == 3) //ОБРАБАТЫВАЕТСЯ 20 РАЗ В СЕКУНДУ
|
||||||
{
|
{
|
||||||
foreach (var go in gameObjects)
|
for (int i = 0; i < gameObjects.Count; i++)
|
||||||
{
|
{
|
||||||
go.UpdateLogic();
|
gameObjects[i].UpdateLogic();
|
||||||
}
|
}
|
||||||
collisionManager.ResolvePhysics();
|
collisionManager.ResolvePhysics();
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
|
@ -183,6 +182,22 @@ namespace ZoFo.GameCore
|
||||||
{
|
{
|
||||||
|
|
||||||
gameObjects.Add(gameObject);
|
gameObjects.Add(gameObject);
|
||||||
|
if (gameObject is StopObject)
|
||||||
|
{
|
||||||
|
AddData(new UpdateStopObjectCreated()
|
||||||
|
{
|
||||||
|
Position = (gameObject as StopObject).position,
|
||||||
|
sourceRectangle = new SerializableRectangle((gameObject as StopObject).sourceRectangle),
|
||||||
|
Size = new SerializablePoint((gameObject as StopObject).graphicsComponent.ObjectDrawRectangle.Size),
|
||||||
|
tileSetName = ((gameObject as StopObject).graphicsComponent as StaticGraphicsComponent)._textureName,
|
||||||
|
collisions = (gameObject as StopObject).collisionComponents.Select(x => new SerializableRectangle(x.stopRectangle)).ToArray()
|
||||||
|
});//TODO
|
||||||
|
foreach (var col in (gameObject as StopObject).collisionComponents)
|
||||||
|
{
|
||||||
|
collisionManager.Register(col);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (gameObject is MapObject)
|
if (gameObject is MapObject)
|
||||||
{
|
{
|
||||||
AddData(new UpdateTileCreated()
|
AddData(new UpdateTileCreated()
|
||||||
|
@ -191,25 +206,29 @@ namespace ZoFo.GameCore
|
||||||
sourceRectangle = new SerializableRectangle((gameObject as MapObject).sourceRectangle),
|
sourceRectangle = new SerializableRectangle((gameObject as MapObject).sourceRectangle),
|
||||||
Size = new SerializablePoint((gameObject as MapObject).graphicsComponent.ObjectDrawRectangle.Size),
|
Size = new SerializablePoint((gameObject as MapObject).graphicsComponent.ObjectDrawRectangle.Size),
|
||||||
tileSetName = ((gameObject as MapObject).graphicsComponent as StaticGraphicsComponent)._textureName
|
tileSetName = ((gameObject as MapObject).graphicsComponent as StaticGraphicsComponent)._textureName
|
||||||
});//TODO
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (gameObject is Entity entity)
|
if (gameObject is Entity entity)
|
||||||
{
|
{
|
||||||
AddData(new UpdateGameObjectCreated() { GameObjectType = gameObject.GetType().Name, IdEntity = entity.Id,
|
AddData(new UpdateGameObjectCreated()
|
||||||
position = gameObject.position});
|
{
|
||||||
|
GameObjectType = gameObject.GetType().Name,
|
||||||
|
IdEntity = entity.Id,
|
||||||
|
position = gameObject.position
|
||||||
|
});
|
||||||
collisionManager.Register(entity.collisionComponent);
|
collisionManager.Register(entity.collisionComponent);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
AddData(new UpdateGameObjectCreated() { GameObjectType = gameObject.GetType().Name,
|
AddData(new UpdateGameObjectCreated()
|
||||||
|
{
|
||||||
|
GameObjectType = gameObject.GetType().Name,
|
||||||
position = gameObject.position
|
position = gameObject.position
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (gameObject is Player)
|
if (gameObject is Player)
|
||||||
{
|
|
||||||
players.Add(gameObject as Player);
|
players.Add(gameObject as Player);
|
||||||
}
|
|
||||||
////var elems = gameObject.GetType().GetProperties(System.Reflection.BindingFlags.Public);
|
////var elems = gameObject.GetType().GetProperties(System.Reflection.BindingFlags.Public);
|
||||||
////if (elems.Count()>0) TODO
|
////if (elems.Count()>0) TODO
|
||||||
////{
|
////{
|
||||||
|
@ -231,7 +250,7 @@ namespace ZoFo.GameCore
|
||||||
if (players.Contains(entity))
|
if (players.Contains(entity))
|
||||||
players.Remove(entity as Player);
|
players.Remove(entity as Player);
|
||||||
AddData(new UpdateGameObjectDeleted()
|
AddData(new UpdateGameObjectDeleted()
|
||||||
{ GameObjectType = entity.GetType().Name, IdEntity = entity .Id}
|
{ GameObjectType = entity.GetType().Name, IdEntity = entity.Id }
|
||||||
);
|
);
|
||||||
collisionManager.Deregister(entity.collisionComponent);
|
collisionManager.Deregister(entity.collisionComponent);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue