Skip to content

Commit

Permalink
Nightly Saturday.
Browse files Browse the repository at this point in the history
  • Loading branch information
LanceJZ committed Dec 3, 2017
1 parent 3564011 commit ae2ac6d
Show file tree
Hide file tree
Showing 15 changed files with 249 additions and 45 deletions.
57 changes: 57 additions & 0 deletions Shadow and Planet/Content/Content.mgcb
Original file line number Diff line number Diff line change
Expand Up @@ -811,3 +811,60 @@
/processorParam:TextureFormat=Compressed
/build:Models/SandP-Pirate.obj

#begin Models/cube - pirate.3DS
/importer:OpenAssetImporter
/processor:ModelProcessor
/processorParam:ColorKeyColor=0,0,0,0
/processorParam:ColorKeyEnabled=True
/processorParam:DefaultEffect=BasicEffect
/processorParam:GenerateMipmaps=True
/processorParam:GenerateTangentFrames=False
/processorParam:PremultiplyTextureAlpha=True
/processorParam:PremultiplyVertexColors=True
/processorParam:ResizeTexturesToPowerOfTwo=False
/processorParam:RotationX=0
/processorParam:RotationY=0
/processorParam:RotationZ=0
/processorParam:Scale=1
/processorParam:SwapWindingOrder=False
/processorParam:TextureFormat=Compressed
/build:Models/cube - pirate.3DS

#begin Models/SandP-Missile.obj
/importer:OpenAssetImporter
/processor:ModelProcessor
/processorParam:ColorKeyColor=0,0,0,0
/processorParam:ColorKeyEnabled=True
/processorParam:DefaultEffect=BasicEffect
/processorParam:GenerateMipmaps=True
/processorParam:GenerateTangentFrames=False
/processorParam:PremultiplyTextureAlpha=True
/processorParam:PremultiplyVertexColors=True
/processorParam:ResizeTexturesToPowerOfTwo=False
/processorParam:RotationX=0
/processorParam:RotationY=0
/processorParam:RotationZ=0
/processorParam:Scale=1
/processorParam:SwapWindingOrder=False
/processorParam:TextureFormat=Compressed
/build:Models/SandP-Missile.obj

#begin Models/SandP-PlayerFlame.obj
/importer:OpenAssetImporter
/processor:ModelProcessor
/processorParam:ColorKeyColor=0,0,0,0
/processorParam:ColorKeyEnabled=True
/processorParam:DefaultEffect=BasicEffect
/processorParam:GenerateMipmaps=True
/processorParam:GenerateTangentFrames=False
/processorParam:PremultiplyTextureAlpha=True
/processorParam:PremultiplyVertexColors=True
/processorParam:ResizeTexturesToPowerOfTwo=False
/processorParam:RotationX=0
/processorParam:RotationY=0
/processorParam:RotationZ=0
/processorParam:Scale=1
/processorParam:SwapWindingOrder=False
/processorParam:TextureFormat=Compressed
/build:Models/SandP-PlayerFlame.obj

8 changes: 8 additions & 0 deletions Shadow and Planet/Content/Models/SandP-Missile.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# MagicaVoxel @ Ephtracy

newmtl palette
illum 1
Ka 0.000 0.000 0.000
Kd 1.000 1.000 1.000
Ks 0.000 0.000 0.000
map_Kd SandP-Missile.png
Binary file added Shadow and Planet/Content/Models/SandP-Missile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions Shadow and Planet/Content/Models/SandP-PlayerFlame.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# MagicaVoxel @ Ephtracy

newmtl palette
illum 1
Ka 0.000 0.000 0.000
Kd 1.000 1.000 1.000
Ks 0.000 0.000 0.000
map_Kd SandP-PlayerFlame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
9 changes: 7 additions & 2 deletions Shadow and Planet/Engine/AModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class AModel : PositionedObject, IDrawComponent, ILoadContent
{
public XnaModel XNAModel { get; private set; }
public bool Visable { get => m_Visable; set => m_Visable = value; }

public Vector3 DefuseColor = Vector3.Zero;
Texture2D XNATexture;
private Matrix[] ModelTransforms;
private Matrix BaseWorld;
Expand Down Expand Up @@ -101,10 +101,15 @@ public void Draw(GameTime gametime)
foreach (ModelMeshPart meshPart in mesh.MeshParts)
{
BasicEffect effect = (BasicEffect)meshPart.Effect;
effect.Texture = XNATexture ?? effect.Texture; //Replace texture if XNATexture is not null.

//effect.Texture = XNATexture ?? effect.Texture; //Replace texture if XNATexture is not null.
effect.EnableDefaultLighting();
if (DefuseColor != Vector3.Zero)
effect.DiffuseColor = DefuseColor;
effect.PreferPerPixelLighting = true;
effect.World = BaseWorld;
if (XNATexture != null)
effect.Texture = XNATexture;// ?? effect.Texture; //Replace texture if XNATexture is not null.
Services.Camera.Draw(effect);
}

Expand Down
6 changes: 3 additions & 3 deletions Shadow and Planet/Engine/PositionedObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public bool CirclesIntersect(PositionedObject Target)
return false;
}
/// <summary>
/// Returns a Vector2 direction of travel from angle and magnitude.
/// Returns a Vector3 direction of travel from angle and magnitude.
/// </summary>
/// <param name="angle"></param>
/// <param name="magnitude"></param>
Expand Down Expand Up @@ -278,10 +278,10 @@ public Vector2 SetRandomEdge()
Services.RandomMinMax(-Services.WindowHeight * 0.45f, Services.WindowHeight * 0.45f));
}

public float AimAtTarget(Vector3 origin, Vector3 target, float facingAngle, float magnitude)
public float AimAtTarget(Vector3 target, float facingAngle, float magnitude)
{
float turnVelocity = 0;
float targetAngle = AngleFromVectors(origin, target);
float targetAngle = AngleFromVectors(Position, target);
float targetLessFacing = targetAngle - facingAngle;
float facingLessTarget = facingAngle - targetAngle;

Expand Down
3 changes: 1 addition & 2 deletions Shadow and Planet/Entities/Asteroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public override void LoadContent()

public override void BeginRun()
{
Velocity = new Vector3(Services.RandomMinMax(-10, 10),
Services.RandomMinMax(-10, 10), 0);
Velocity = SetRandomVelocity(25);

base.BeginRun();
}
Expand Down
25 changes: 22 additions & 3 deletions Shadow and Planet/Entities/AsteroidControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ public class AsteroidControl : GameComponent, IBeginable, IUpdateableComponent,
{
List<Asteroid> Asteroids;
List<Chunk> Chunks;
List<Mod> RockRadar;
Player PlayerRef;
PirateControl PiratesRef;

XnaModel RockRadarModel;

public AsteroidControl(Game game, Player player, PirateControl pirate) : base(game)
{
Asteroids = new List<Asteroid>();
Chunks = new List<Chunk>();
RockRadar = new List<Mod>();

PlayerRef = player;
PiratesRef = pirate;
Expand All @@ -43,7 +47,7 @@ public void BeginRun()
for (int i = 0; i < 10; i++)
{
Asteroids.Add(new Asteroid(Game, PlayerRef, PiratesRef));
PlayerRef.ActivateRockRadar();
ActivateRockRadar();

if (Services.RandomMinMax(0, 10) > 5)
{
Expand All @@ -66,12 +70,13 @@ public void BeginRun()

public void LoadContent()
{

RockRadarModel = PlayerRef.Load("cube");
}

public override void Update(GameTime gameTime)
{
CheckOtherAsteroidCollusion();
int i = 0;

foreach (Asteroid rock in Asteroids)
{
Expand All @@ -80,11 +85,24 @@ public override void Update(GameTime gameTime)
rock.Hit = false;
EjectChunk(rock);
}

Vector3 offset = PlayerRef.
SetVelocity(PlayerRef.AngleFromVectors(PlayerRef.Position, rock.Position), 80);
offset.Z = 250;
RockRadar[i].Position = PlayerRef.Position + offset;
i++;
}

base.Update(gameTime);
}

void ActivateRockRadar()
{
RockRadar.Add(new Mod(Game));
RockRadar.Last().SetModel(RockRadarModel);
RockRadar.Last().Scale = 3;
}

void CheckOtherAsteroidCollusion()
{
foreach (Asteroid asteroidA in Asteroids)
Expand Down Expand Up @@ -124,8 +142,9 @@ void EjectChunk(Asteroid rock)
Chunks.Last().PlayerRef = PlayerRef;
}

Chunks[freeChunk].Active = true;
Chunks[freeChunk].Position = rock.Position;
Chunks[freeChunk].Velocity = new Vector3(Services.RandomMinMax(-150, 150), Services.RandomMinMax(-150, 150), 0);
Chunks[freeChunk].Velocity = Chunks[0].SetRandomVelocity(150);
Chunks[freeChunk].RotationVelocity = new Vector3(Services.RandomMinMax(-1, 1), Services.RandomMinMax(-1, 1), 0);
}
}
Expand Down
83 changes: 83 additions & 0 deletions Shadow and Planet/Entities/Missile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Audio;
using XnaModel = Microsoft.Xna.Framework.Graphics.Model;
using System.Collections.Generic;
using System;
using Engine;

namespace Shadow_and_Planet.Entities
{
using Mod = AModel;

public class Missile : Mod
{
PositionedObject TargetRef;
Timer LifeTimer;

public Missile(Game game, Player player) : base(game)
{
TargetRef = player;
LifeTimer = new Timer(game);
}

public override void Initialize()
{
Active = false;
base.Initialize();
LoadContent();
}

public override void LoadContent()
{
LoadModel("SandP-Missile");
BeginRun();
}

public override void BeginRun()
{

base.BeginRun();
}

public override void Update(GameTime gameTime)
{
if (Active)
{
RotationVelocity.Z = AimAtTarget(TargetRef.Position, Rotation.Z, MathHelper.PiOver4 *0.25f);
Velocity = SetVelocityFromAngle(Rotation.Z, 200);

if (LifeTimer.Expired)
{
Active = false;
}
}

base.Update(gameTime);
}

public void Spawn(Vector3 postion, PositionedObject target, float timer)
{
Active = true;
Position = postion;
TargetRef = target;
LifeTimer.Reset(timer);
}

void CheckEdge()
{
if (Position.X > 3000)
Position.X = -3000;

if (Position.X < -3000)
Position.X = 3000;

if (Position.Y > 2000)
Position.Y = -2000;

if (Position.Y < -2000)
Position.Y = 2000;
}
}
}
17 changes: 16 additions & 1 deletion Shadow and Planet/Entities/Pirate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ namespace Shadow_and_Planet.Entities

public class Pirate : Mod
{
List<Missile> Missiles;
Player PlayerRef;
Timer ChaseTimer;
Timer BumpTimer;
Timer FireTimer;

Vector3 NewHeading = Vector3.Zero;

Expand All @@ -26,6 +28,8 @@ public Pirate(Game game, Player player) : base(game)
PlayerRef = player;
ChaseTimer = new Timer(game, 10);
BumpTimer = new Timer(game);
FireTimer = new Timer(game);
Missiles = new List<Missile>();
}

public override void Initialize()
Expand Down Expand Up @@ -61,9 +65,15 @@ public override void Update(GameTime gameTime)
if (ChaseTimer.Expired)
ChasePlayer();

RotationVelocity.Z = AimAtTarget(Position, NewHeading, Rotation.Z, MathHelper.PiOver4);
RotationVelocity.Z = AimAtTarget(NewHeading, Rotation.Z, MathHelper.PiOver4);
Velocity = SetVelocityFromAngle(Rotation.Z, 100);

if (FireTimer.Expired)
{
FireTimer.Reset(Services.RandomMinMax(3, 10));
FireMissile();
}

if (BumpTimer.Enabled)
{
Rotation.X = 0;
Expand Down Expand Up @@ -92,6 +102,11 @@ public void Bumped(Vector3 position, Vector3 velocity)
BumpTimer.Reset(Services.RandomMinMax(2, 6));
}

void FireMissile()
{

}

void CheckEdge()
{
if (Position.X > 3000)
Expand Down
Loading

0 comments on commit ae2ac6d

Please sign in to comment.