Daily upload on 20221019.

This commit is contained in:
Youmu Konpaku
2022-10-20 02:11:34 +08:00
parent 01de763a28
commit ef34fcf3c1
50 changed files with 231 additions and 18 deletions
@@ -137,9 +137,35 @@ namespace StgSharp_Entity
{
}
public void ChangeVelocity()
/// <summary>
/// 修改自身路径,修改条件由外部逻辑判断触发
/// </summary>
public void ChangeVelocity(float[] newXSpeed,float[] newYSpeed)
{
if (newXSpeed != null)
{
if (newXSpeed.Length == 10)
{
this._xVelocity = newXSpeed;
}
else
{
throw new Exception("The amount of parameters should be 10!");
}
}
if (newYSpeed != null)
{
if (newYSpeed.Length == 10)
{
this._yVelocity = newYSpeed;
}
else
{
throw new Exception("The amount of parameters should be 10!");
}
}
}
}
}
@@ -0,0 +1,181 @@
using OpenTK;
using OpenTK.Input;
using StgSharp_Entity;
using StgSharp_Logic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp_Entity
{
internal class Player:LinkedTarget
{
private uint gameTick;
private uint beginTick;
private readonly float _velocityHigh;
private readonly float _vHighCorner;
public float VelocityHigh
{
get { return _velocityHigh; }
}
private readonly float _velocityLow;
private readonly float _vLowCorner;
public float VelocityLow
{
get { return _velocityLow; }
}
private float _xLocation;
public float XLocation
{
get { return _xLocation; }
set { _xLocation = value; }
}
public float _yLocation;
public float YLocation
{
get { return _yLocation; }
set { _yLocation = value; }
}
private KeyboardState _keyboardState;
public KeyboardState KeyboardState
{
get { return _keyboardState; }
set { _keyboardState = value; }
}
public Player(float velocityHigh,float velocityLow,KeyboardState keyboardState)
{
this._velocityHigh = velocityHigh;
this._vHighCorner = velocityHigh / 1.4142136f;
this._velocityLow = velocityLow;
this._vLowCorner = velocityLow / 1.4142136f;
this._keyboardState = keyboardState;
}
public void Action()
{
if (_keyboardState.IsAnyKeyDown)
{
Move();
}
}
/// <summary>
/// 自机移动的简单方法
/// </summary>
public void Move()
{
if (_keyboardState.IsKeyDown(Key.ShiftLeft))
{
if (_keyboardState.IsKeyDown(Key.Up))
{
if (_keyboardState.IsKeyDown(Key.Left))
{
this._yLocation += _vLowCorner;
this._xLocation -= _vLowCorner;
}
else if (_keyboardState.IsKeyDown(Key.Right))
{
this._yLocation += _vLowCorner;
this._xLocation += _vLowCorner;
}
else
{
this._yLocation += _velocityLow;
}
}
else if (_keyboardState.IsKeyDown(Key.Down))
{
if (_keyboardState.IsKeyDown(Key.Left))
{
this._yLocation -= _vLowCorner;
this._xLocation -= _vLowCorner;
}
else if (_keyboardState.IsKeyDown(Key.Right))
{
this._yLocation -= _vLowCorner;
this._xLocation += _vLowCorner;
}
else
{
this._yLocation -= _velocityLow;
}
}
}
else
{
if (_keyboardState.IsKeyDown(Key.Up))
{
if (_keyboardState.IsKeyDown(Key.Left))
{
this._yLocation += _vHighCorner;
this._xLocation -= _vHighCorner;
}
else if (_keyboardState.IsKeyDown(Key.Right))
{
this._yLocation += _vHighCorner;
this._xLocation += _vHighCorner;
}
else
{
this._yLocation += _velocityHigh;
}
}
else if (_keyboardState.IsKeyDown(Key.Down))
{
if (_keyboardState.IsKeyDown(Key.Left))
{
this._yLocation -= _vHighCorner;
this._xLocation -= _vHighCorner;
}
else if (_keyboardState.IsKeyDown(Key.Right))
{
this._yLocation -= _vHighCorner;
this._xLocation += _vHighCorner;
}
else
{
this._yLocation -= _velocityHigh;
}
}
}
}
public void UseSkill(KeyboardState key)
{
if (key.IsKeyDown(Key.X))
{
}
}
public void LaunchBullet(KeyboardState key)
{
}
public void Die()
{
}
}
}
@@ -45,6 +45,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Bullet.cs" />
<Compile Include="Player.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@@ -1 +1 @@
9f3d72d61544f629ca17662eb1b4507364353c8b
2d5905d44084acf7b24064935643d53ef7c88707