First upload/change
This commit is contained in:
djkato 2020-07-07 00:56:25 +02:00
parent 3f1d559825
commit d9f1e4c8b3
21 changed files with 2139 additions and 0 deletions

BIN
Build/Ceed.exe Normal file

Binary file not shown.

6
Code/App.config Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

108
Code/Ceed.csproj Normal file
View file

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{620469D7-2681-47A7-9572-F0833596F9ED}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Ceed__c___speed___lightSpeed_</RootNamespace>
<AssemblyName>Ceed %28c - speed __lightSpeed%29</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>C:\Users\djkato\source\CeedPublish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>69D7AE3C70A42E77F0500C8472DC5456AC045D0E</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>Ceed %28c - speed __lightSpeed%29_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CeedMain\Renderer.cs" />
<Compile Include="CeedMain\SolarSystem.cs" />
<Compile Include="CeedMain\PirateShip.cs" />
<Compile Include="CeedMain\Planet.cs" />
<Compile Include="CeedMain\PlayerShip.cs" />
<Compile Include="CeedMain\ShipTemplate.cs" />
<Compile Include="CeedMain\Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SpaceShooter\Asteroid.cs" />
<Compile Include="SpaceShooter\GameLogic.cs" />
<Compile Include="SpaceShooter\Pirate.cs" />
<Compile Include="SpaceShooter\Projectile.cs" />
<Compile Include="SpaceShooter\Render.cs" />
<Compile Include="SpaceShooter\SpaceShooterMain.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Content Include="SpaceShooter\Assets.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

17
Code/Ceed.csproj.user Normal file
View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory />
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
<PropertyGroup>
<EnableSecurityDebugging>false</EnableSecurityDebugging>
</PropertyGroup>
</Project>

25
Code/Ceed.sln Normal file
View file

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29424.173
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ceed", "Ceed.csproj", "{620469D7-2681-47A7-9572-F0833596F9ED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{620469D7-2681-47A7-9572-F0833596F9ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{620469D7-2681-47A7-9572-F0833596F9ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{620469D7-2681-47A7-9572-F0833596F9ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{620469D7-2681-47A7-9572-F0833596F9ED}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9E12DDD1-E615-4820-80E0-0D75A25EE98F}
EndGlobalSection
EndGlobal

259
Code/CeedMain/Main.cs Normal file
View file

@ -0,0 +1,259 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SpaceShooter;
namespace CeedMain
{
class Program
{
static void Main()
{
int gameStartAction = 0;
//GAMELOOP
while (true)
{
int turnNumber = 0;
Console.SetWindowSize(124, 50);
//MAIN MENU
if (turnNumber == 0)
{
gameStartAction = Renderer.GameStartMenu(false);
}
if (gameStartAction == 2)
{
gameStartAction = Renderer.GameStartMenu(true);
}
if (gameStartAction == 3)
{
break;
}
if (gameStartAction == 1)
{
while (true)//GAME STARTS HERE
{
bool IWANTTOLEAVE = false;
//INIT PLAYERSHIP
PlayerShip playerShip = new PlayerShip
{
shipHealth = 20,
shipAttackDmg = 1,
shipSpeed = 1,
scannerAmount = 5,
fuelAmount = 20,
Money = 0,
totalDestroyedAsteroids = 0,
totalKilledPirateAmnt = 0
};
while (true) //SYSTEM STATS HERE
{
//setup console
Console.SetWindowSize(124, 50);
//increment explred systems
playerShip.exploredSystemsAmount++;
//INIT SOLAR SYSTEM
SolarSystem newSolarSystem = new SolarSystem
{
hasAsteroids = SolarSystem.GetRandomBool(),
planetAmount = SolarSystem.SetPlanetAmount(),
hasElectricClouds = SolarSystem.GetRandomBool(),
name = SolarSystem.GenerateName(),
hostility = 0
};
//CREATE AND STORE PLANETS ON A LIST
for (int i = 0; i < newSolarSystem.planetAmount; i++)
{
Planet newPlanet = new Planet
{
areResources = Planet.SetResources(),
isFuel = Planet.SetFuel(),
occupiedByLiving = Planet.SetOccupation(),
name = Planet.GenerateName(),
isDiscovered = false
};
//IF THERES INTELIGENT LIFE(newplnt.living==2) SET ITS HOSTILITY AND UPDATE SYSTEMS HOSTILITY TO THE NEW HIGHEST ONE
if (newPlanet.occupiedByLiving == 2)
{
newPlanet.hostility = Planet.SetHostility();
if (newPlanet.hostility > newSolarSystem.hostility)
{
newSolarSystem.hostility = newPlanet.hostility;
}
}
else
{
newPlanet.hostility = 0;
}
//IF PRIMITIVE LIFE = FUEL.TRUE; IF INTELIGENT LIFE=RESORUCES.TRUE, FUEL.TRUE
if (newPlanet.occupiedByLiving == 1)
{
newPlanet.isFuel = true;
}
else if (newPlanet.occupiedByLiving == 2)
{
newPlanet.isFuel = true;
newPlanet.areResources = true;
}
newSolarSystem.planetsList.Add(newPlanet);
}
//GAME STARTS HERE
while (true)
{
Console.SetWindowSize(124, 50);
if (playerShip.fuelAmount <= 0 || playerShip.shipHealth <= 0)
{
Console.BackgroundColor = ConsoleColor.DarkMagenta;
Console.ForegroundColor = ConsoleColor.White;
Console.Clear();
Console.WriteLine();
Console.WriteLine("You ran out of either HP or Fuel, so you lost!");
Console.WriteLine("Press any key to go to main menu...");
Console.ReadKey();
IWANTTOLEAVE = true;
break;
}
//IF ITS THE 5TH TURN, ADD SHOP TO SOLARSYSTEM
if (playerShip.exploredSystemsAmount % 3 == 0)
{
newSolarSystem.shop = true;
}
//RENDER GUI
int input1 = Renderer.ChooseAction(newSolarSystem, newSolarSystem.planetsList, playerShip);
//PLAYER WANTS EXPLORE
if (input1 == 1)
{
Console.WriteLine();
Console.WriteLine("type the index number of the planet you want to explore[ENTER]...");
int input2 = Convert.ToInt32(Console.ReadLine()); //GETS PLAYERS INDEX OF EXPLORE
// CHECKS IF THE PLANET CAN BE EXPLORED
if (newSolarSystem.planetsList[input2].isDiscovered)
{
newSolarSystem.planetsList[input2].isExplored = true;
//IF PLANET HAS FUEL, ADD FUEL TO SHIP
if (newSolarSystem.planetsList[input2].isFuel)
{
playerShip.fuelAmount += Planet.AddRandomFuelAmount();
newSolarSystem.planetsList[input2].isFuel = false;
}
//STARTS MINIGAME IF HOSTILITY > 0
if(newSolarSystem.planetsList[input2].hostility > 0 || newSolarSystem.hasAsteroids)
{
playerShip = SpaceShooter.MainProgram.ShooterMain(playerShip, newSolarSystem, input2);
}
if (newSolarSystem.planetsList[input2].areResources)
{
newSolarSystem.planetsList[input2].areResources = false;
playerShip.scannerAmount += 1;
}
}
// IF THE PLAYERS INDEX ISNT EPLOREABLE
else
{
Console.WriteLine();
Console.WriteLine("You cant explore this planet, you havent discovered it yet");
Console.WriteLine("Press Any key to continue...");
Console.ReadKey();
}
}
else if (input1 == 2) //PLAYER WANTS TO SCAN
{
if (playerShip.scannerAmount > 0)
{
playerShip.scannerAmount -= 1;
int[] scanIndexes = PlayerShip.GetScanIndexes(newSolarSystem); //RETURNS ARRAY OF RANDOM INDEXES TO SCAN
foreach (int a in scanIndexes) //MAKES INDEXES DISCOVERED
{
newSolarSystem.planetsList[a].isDiscovered = true;
}
}
else
{
Console.WriteLine("You dont have enough Scanners!");
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}
}
else if (input1 == 3) //PLAYER WANDERS
{
int randomPlanetIndex = newSolarSystem.planetsList.IndexOf(newSolarSystem.planetsList[PlayerShip.Wander(newSolarSystem)]);
playerShip = SpaceShooter.MainProgram.ShooterMain(playerShip,newSolarSystem , randomPlanetIndex);
newSolarSystem.planetsList[randomPlanetIndex].isDiscovered = true;
newSolarSystem.planetsList[randomPlanetIndex].isExplored = true;
if (newSolarSystem.planetsList[randomPlanetIndex].isFuel)
{
playerShip.fuelAmount += Planet.AddRandomFuelAmount();
newSolarSystem.planetsList[randomPlanetIndex].isFuel = false;
}
if (newSolarSystem.planetsList[randomPlanetIndex].areResources)
{
playerShip.scannerAmount += 1;
newSolarSystem.planetsList[randomPlanetIndex].areResources = false;
}
playerShip.fuelAmount -= 3;
}
else if (input1 == 4) //NEW GALAXY
{
playerShip.fuelAmount -= 10;
break;
}
else if(input1 == 5)//SHOP
{
playerShip = Renderer.Shop(playerShip);
}
else if(input1 == 6)
{
IWANTTOLEAVE = true;
break;
}
}
if(IWANTTOLEAVE)
{
break;
}
}
if (IWANTTOLEAVE)
{
IWANTTOLEAVE = false;
break;
}
}
}
}
}
}
}

View file

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CeedMain
{
class PirateShip : ShipTemplate
{
}
}

93
Code/CeedMain/Planet.cs Normal file
View file

@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CeedMain
{
class Planet
{
private static readonly Random _random = new Random();
public string name;
public bool isExplored;
public int hostility; //0 = peaceful ... 5 = deadly
public int occupiedByLiving; //0 == no;1==primitive;2==intelligent
public bool isFuel;
public bool areResources;
public bool isDiscovered;
public static int AddRandomFuelAmount()
{
return (_random.Next(1, 5));
}
public static int SetOccupation()
{
int tmp = _random.Next(0, 2);
if (tmp == 1)
{
return _random.Next(1, 3);
}
else
{
return 0;
}
}
public static bool SetFuel()
{
int tmp = _random.Next(0, 2);
if (tmp == 1)
{
return true;
}
else
{
return false;
}
}
public static bool SetResources()
{
int tmp = _random.Next(0, 2);
if (tmp == 1)
{
return true;
}
else
{
return false;
}
}
public static int SetHostility()
{
int tmp = _random.Next(1, 6);
return tmp;
}
public static string GenerateName()
{
char[] chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
int letterLength = _random.Next(1, 10);
string name = "";
int i;
for (int f = 0; f < letterLength; f++)
{
i = _random.Next(chars.Length);
name += Char.ToString(chars[i]);
}
return name;
}
}
}

View file

@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CeedMain
{
class PlayerShip : ShipTemplate
{
private static readonly Random _random = new Random();
public int scannerAmount;
public int fuelAmount;
public int exploredSystemsAmount;
public int Money;
//SpaceShooter vars
public int totalKilledPirateAmnt = 0;
public int totalDestroyedAsteroids = 0;
public int killedPirateAmnt = 0;
public bool isFiring = false;
public int shipPosY = SpaceShooter.Render.yGridSize * 2 / 3;
public int shipPosX = SpaceShooter.Render.xGridSize / 2;
public string[,] shipModel = new string[4, 10];
//OG methods
public static int[] GetScanIndexes(SolarSystem newSolarSytem)
{
var scanAmnt = _random.Next(0, newSolarSytem.planetAmount);
int[] scanIndexs = new int[scanAmnt];
for (int i = 0; i < scanAmnt; i++)
{
scanIndexs[i] = _random.Next(0, newSolarSytem.planetAmount);
}
return scanIndexs;
}
public static int Wander(SolarSystem newSolarSystem)
{
return (_random.Next(0, newSolarSystem.planetAmount));
}
//SpaceShooter Methods
public static string[,] SetShipModel()
{
string[,] shipGraphic = new string[4, 10];
shipGraphic[0, 0] = " ";
shipGraphic[0, 1] = " ";
shipGraphic[0, 2] = " ";
shipGraphic[0, 3] = " ";
shipGraphic[0, 4] = "_";
shipGraphic[0, 5] = "_";
shipGraphic[0, 6] = " ";
shipGraphic[0, 7] = " ";
shipGraphic[0, 8] = " ";
shipGraphic[0, 9] = " ";
shipGraphic[1, 0] = " ";
shipGraphic[1, 1] = " ";
shipGraphic[1, 2] = " ";
shipGraphic[1, 3] = "/";
shipGraphic[1, 4] = " ";
shipGraphic[1, 5] = " ";
shipGraphic[1, 6] = @"\";
shipGraphic[1, 7] = " ";
shipGraphic[1, 8] = " ";
shipGraphic[1, 9] = " ";
shipGraphic[2, 0] = "|";
shipGraphic[2, 1] = " ";
shipGraphic[2, 2] = "_";
shipGraphic[2, 3] = "|";
shipGraphic[2, 4] = " ";
shipGraphic[2, 5] = " ";
shipGraphic[2, 6] = "|";
shipGraphic[2, 7] = "_";
shipGraphic[2, 8] = " ";
shipGraphic[2, 9] = "|";
shipGraphic[3, 0] = "|";
shipGraphic[3, 1] = "=";
shipGraphic[3, 2] = "|";
shipGraphic[3, 3] = "_";
shipGraphic[3, 4] = "|";
shipGraphic[3, 5] = "|";
shipGraphic[3, 6] = "_";
shipGraphic[3, 7] = "|";
shipGraphic[3, 8] = "=";
shipGraphic[3, 9] = "|";
return shipGraphic;
}
}
}

413
Code/CeedMain/Renderer.cs Normal file
View file

@ -0,0 +1,413 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace CeedMain
{
class Renderer
{
public static int GameStartMenu(bool gameContinuePressed)
{
Console.BackgroundColor = ConsoleColor.DarkMagenta;
Console.Clear();
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Welcome to");
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("CeeD");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine();
Console.WriteLine("Game Rules: The point of the game is to explore as many Solar Systems as possible. Each system has");
Console.WriteLine("a random amount of Fuel and Resources. Fuel gives you fuel, and Resources give you Scanners, which");
Console.WriteLine("is an ability to randomly scout out planets, and find out of their details.");
Console.WriteLine("When you start a new game, youll see that you dont know any of the planets, and thats becaue you");
Console.WriteLine("Havent discovered their location yet, you just see they exist. You use the scanner to find where they are,");
Console.WriteLine("and if they are worth exploring. Exploring means going to the planet and taking its Resources and Fuel, but");
Console.WriteLine("be warned, some planets have intelligent life, and can be Hazardous. If you explore a dangerous planet, youll");
Console.WriteLine("take damage, try to not die! If you run out of scanners, you can use Wander, but that consumes fuel, which is limited");
Console.WriteLine("too. Every fuel reserve gives you between 1-5 fuel.");
Console.WriteLine("When referencing Planets, Index refers to the number inside the square brackets, for example:");
Console.WriteLine("RANDOMNAME[1] <- in that case index is 1");
Console.WriteLine("When using actions, press the index number after it, in the case of Explore, type numbers after it n press enter to submit.");
Console.WriteLine("Minigame Controls:");
Console.WriteLine("Movement: WASD");
Console.WriteLine("Shoot: Spacebar");
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Try not to die, Good luck ;)");
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Start new game [SPACE]");
Console.WriteLine();
Console.WriteLine();
if (gameContinuePressed == true)
{
Console.WriteLine("CURRENTLY UNSUPPORTED!");
}
else
{
Console.WriteLine("Continue game [L]");
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Close game at any time: CTRL + C");
var input = Console.ReadKey();
if (input.Key == ConsoleKey.Spacebar)
{
return (1);
}
if (input.Key == ConsoleKey.L)
{
return (2);
}
if (input.Key == ConsoleKey.Escape)
{
return (3);
}
else
{
return (0);
}
}
/*public static int SystemScreen(int scannerAmount, int fuelAmount, string systemName)
{
Console.BackgroundColor = ConsoleColor.DarkMagenta;
Console.Clear();
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine();
Console.WriteLine("Welcome to System " + systemName);
Console.WriteLine();
Console.WriteLine();
if (scannerAmount > 0)
{
Console.WriteLine("Scan System(-1 Scanner{Currently have: " + scannerAmount + ") [1]");
}
Console.WriteLine();
if (fuelAmount > 2)
{
Console.WriteLine("Explore System(-2 Fuel{Currently have: " + fuelAmount + ") [2]");
}
Console.WriteLine();
Console.WriteLine("Strand [3]");
Console.WriteLine();
Console.WriteLine("RageQuit [ESC]");
while (true)
{
var input = Console.ReadKey();
if (input.Key == ConsoleKey.NumPad1)
{
return (1);
}
if (input.Key == ConsoleKey.NumPad2)
{
return (2);
}
if (input.Key == ConsoleKey.NumPad3)
{
return (3);
}
if (input.Key == ConsoleKey.Escape)
{
return (4);
}
else
{
}
}
}*/ //DEAD CODE
public static void DebugScan(SolarSystem newSolarSytem, List<Planet> planetList)
{
Console.BackgroundColor = ConsoleColor.DarkMagenta;
Console.Clear();
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Scan results of the system " + newSolarSytem.name + ":");
string hostilityConverted = "";
switch (newSolarSytem.hostility) //Draw Hostility
{
case 0:
hostilityConverted = "Peaceful";
break;
case 1:
hostilityConverted = "Passive";
break;
case 2:
hostilityConverted = "Cautious";
break;
case 3:
hostilityConverted = "Scary";
break;
case 4:
hostilityConverted = "Dangerous";
break;
case 5:
hostilityConverted = "Deadly";
break;
}
Console.WriteLine();
Console.WriteLine("System is " + hostilityConverted);
if (newSolarSytem.hasAsteroids == true)
{
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("System contains Asteroid fields");
}
if (newSolarSytem.hasAsteroids == true)
{
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("System has electric field disturbences present");
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("There are " + newSolarSytem.planetAmount + " planets:");
Console.WriteLine();
Console.WriteLine("-name | hostility | Resources | Fuel | Occupied");
foreach (Planet a in planetList)
{
Console.WriteLine();
Console.Write("- " + a.name);
Console.Write("| " + a.hostility);
Console.Write(" | " + a.areResources);
Console.Write(" | " + a.isFuel);
Console.Write(" | " + a.occupiedByLiving);
a.isDiscovered = true;
}
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("press any key to continue..");
Console.WriteLine();
Console.ReadKey();
}
public static int ChooseAction(SolarSystem newSolarSystem, List<Planet> planetList, PlayerShip playerShip)
{
Console.BackgroundColor = ConsoleColor.DarkMagenta;
Console.ForegroundColor = ConsoleColor.White;
Console.Clear();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Welcome to System " + newSolarSystem.name + ", What would you like to do?");
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Your ship data:");
Console.WriteLine();
Console.WriteLine("-Systems Explored: " + playerShip.exploredSystemsAmount);
Console.WriteLine("-Fuel: " + playerShip.fuelAmount);
Console.WriteLine("-Health: " + playerShip.shipHealth);
Console.WriteLine("-Money: " + playerShip.Money + "đ");
Console.WriteLine("-Scanner Amount: " + playerShip.scannerAmount);
Console.WriteLine("-Total ships destroyed: " + playerShip.totalKilledPirateAmnt);
Console.WriteLine("-total asteroids destroyed: " + playerShip.totalDestroyedAsteroids);
Console.WriteLine();
Console.WriteLine();
if (newSolarSystem.hasAsteroids)
{
Console.WriteLine("Solar System has asteroid belts, be wary!");
}
Console.WriteLine();
if (newSolarSystem.shop)
{
Console.WriteLine("Enter Shop[B/5]");
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("There are " + newSolarSystem.planetAmount + " planets:");
Console.WriteLine();
Console.WriteLine();
for (int i = 0; i < newSolarSystem.planetAmount; i++)
{
if (planetList[i].isDiscovered == true)
{
string consoleOutput = "-" + planetList[i].name + "[" + i + "]";
if (planetList[i].hostility > 0)
{
consoleOutput += " |hostility:" + planetList[i].hostility;
}
if (planetList[i].isFuel)
{
consoleOutput += " |Fuel:" + planetList[i].isFuel;
}
if (planetList[i].areResources)
{
consoleOutput += " |Resources:" + planetList[i].areResources;
}
if (planetList[i].isExplored)
{
consoleOutput += "! HAS BEEN EXPLORED !";
}
Console.WriteLine(consoleOutput);
}
else
{
Console.WriteLine("-" + "???");
}
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Explore[E/1]");
Console.WriteLine();
Console.WriteLine("Scan[S/2]");
Console.WriteLine();
Console.WriteLine("Wander[W/3]");
Console.WriteLine();
Console.WriteLine("Move to next System(uses 10 fuel)[4,Q]");
Console.WriteLine();
Console.WriteLine("Ragequit[ESC]");
while (true) //WAIT FOR INPUT
{
var input = Console.ReadKey();
if (input.Key == ConsoleKey.NumPad1 || input.Key == ConsoleKey.E)
{
return 1;
}
else if (input.Key == ConsoleKey.NumPad2 || input.Key == ConsoleKey.S)
{
return (2);
}
else if (input.Key == ConsoleKey.NumPad3 || input.Key == ConsoleKey.W)
{
return (3);
}
else if (input.Key == ConsoleKey.NumPad4 || input.Key == ConsoleKey.Q)
{
return (4);
}
else if (input.Key == ConsoleKey.NumPad5 || input.Key == ConsoleKey.B)
{
return (5);
}
else if (input.Key == ConsoleKey.Escape)
{
return (6);
}
}
}
public static PlayerShip Shop(PlayerShip playerShip)
{
while (true)
{
Console.BackgroundColor = ConsoleColor.DarkMagenta;
Console.ForegroundColor = ConsoleColor.White;
Console.Clear();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Welcome to the shop!");
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Your ship data:");
Console.WriteLine();
Console.WriteLine("-Systems Explored: " + playerShip.exploredSystemsAmount);
Console.WriteLine("-Fuel: " + playerShip.fuelAmount);
Console.WriteLine("-Health: " + playerShip.shipHealth);
Console.WriteLine("-Money: " + playerShip.Money + "đ");
Console.WriteLine("-Scanner Amount: " + playerShip.scannerAmount);
Console.WriteLine("-Total ships destroyed: " + playerShip.totalKilledPirateAmnt);
Console.WriteLine("-total asteroids destroyed: " + playerShip.totalDestroyedAsteroids);
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Fix ship(+1hp, -5đ)[1]");
Console.WriteLine();
Console.WriteLine("Buy 1 Scanner(10đ)[2]");
Console.WriteLine();
Console.WriteLine("Buy 1 Fuel(2đ)[3]");
Console.WriteLine();
Console.WriteLine("Exit[ESC]");
var input = Console.ReadKey();
if (input.Key == ConsoleKey.NumPad1)
{
if (playerShip.Money >= 5)
{
if (playerShip.shipHealth <= 20)
{
playerShip.Money -= 5;
playerShip.shipHealth += 1;
}
else
{
Console.WriteLine("Youre at full health/out of money!");
Console.ReadKey();
}
}
}
else if (input.Key == ConsoleKey.NumPad2)
{
if (playerShip.Money >= 10)
{
playerShip.Money -= 10;
playerShip.scannerAmount += 1;
}
else
{
Console.WriteLine("Youre out of money!");
Console.ReadKey();
}
}
else if (input.Key == ConsoleKey.NumPad3 || input.Key == ConsoleKey.W)
{
if (playerShip.Money >= 2)
{
playerShip.Money -= 2;
playerShip.fuelAmount += 1;
}
else
{
Console.WriteLine("Youre out of money!");
Console.ReadKey();
}
}
else if (input.Key == ConsoleKey.Escape)
{
return playerShip;
}
}
}
}
}

View file

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CeedMain
{
class ShipTemplate
{
public int shipSpeed;
public int shipAttackDmg;
public int shipHealth;
}
}

View file

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CeedMain
{
class SolarSystem
{
private static readonly Random _random = new Random();
public List<Planet> planetsList = new List<Planet>();
public string name;
public int hostility; //0 = peaceful ... 5 = deadly
public int planetAmount;
public int occupiedByLiving; //0 == no;1==primitive;2==intelligent
public bool hasAsteroids;
public bool shop;
public bool hasElectricClouds;
public static string GenerateName()
{
char[] chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
int letterLength = _random.Next(1, 5);
int numberLength = _random.Next(1, 10);
string name = "";
int i;
for (int f = 0; f < letterLength; f++)
{
i = _random.Next(chars.Length);
name += Char.ToString(chars[i]);
}
name += "-";
for (int f = 0; f < numberLength; f++)
{
name += _random.Next(0, 9).ToString();
}
return (name);
}
public static int SetPlanetAmount()
{
return (_random.Next(2, 13));
}
public static int SetMoonAmount()
{
return (_random.Next(0, 6));
}
public static bool GetRandomBool()
{
var temp = _random.Next(0, 2);
if (temp == 0)
{
return false;
}
if (temp == 1)
{
return true;
}
else { return false; }
}
}
}

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Ceed (c - speed __lightSpeed)")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Ceed (c - speed __lightSpeed)")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("620469d7-2681-47a7-9572-f0833596f9ed")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,25 @@
ENEMY SHIP
__||__
|=\ || /=|
\__/
Friendly Ship
__
/ \
| _| |_ |
|=|_||_|=|
Asteroid
___
/ \_
| \
\ /
\___/
Bun
(\ /)
( . .)
c(") (")
--MAKE THE WINDOW POS SHAKE WHEN HIT
--MAKE OPTIONS > B/W MODE FOR FPS IMPROVEMENT, BUT ADD COLORS

View file

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SpaceShooter
{
class Asteroid
{
public static readonly Random _random = new Random();
public int asteroidPosX;
public int asteroidPosY;
public int speed;
public string[,] AsteroidModel = new string[5,7];
public static string[,] SetAsteroidModel()
{
string[,] asteroidGraphic = new string[5,7];
asteroidGraphic[0, 0] = " ";
asteroidGraphic[0, 1] = "_";
asteroidGraphic[0, 2] = "_";
asteroidGraphic[0, 3] = "_";
asteroidGraphic[0, 4] = " ";
asteroidGraphic[0, 5] = " ";
asteroidGraphic[0, 6] = " ";
asteroidGraphic[1, 0] = "/";
asteroidGraphic[1, 1] = " ";
asteroidGraphic[1, 2] = " ";
asteroidGraphic[1, 3] = " ";
asteroidGraphic[1, 4] = @"\";
asteroidGraphic[1, 5] = "_";
asteroidGraphic[2, 0] = "|";
asteroidGraphic[2, 1] = " ";
asteroidGraphic[2, 2] = " ";
asteroidGraphic[2, 3] = " ";
asteroidGraphic[2, 4] = " ";
asteroidGraphic[2, 5] = " ";
asteroidGraphic[2, 6] = @"\";
asteroidGraphic[3, 0] = @"\";
asteroidGraphic[3, 1] = " ";
asteroidGraphic[3, 2] = " ";
asteroidGraphic[3, 3] = " ";
asteroidGraphic[3, 4] = " ";
asteroidGraphic[3, 5] = " ";
asteroidGraphic[3, 6] = "/";
asteroidGraphic[4, 0] = " ";
asteroidGraphic[4, 1] = @"\";
asteroidGraphic[4, 2] = "_";
asteroidGraphic[4, 3] = "_";
asteroidGraphic[4, 4] = "_";
asteroidGraphic[4, 5] = "/";
asteroidGraphic[4, 6] = " ";
return asteroidGraphic;
}
}
}

View file

@ -0,0 +1,70 @@
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SpaceShooter
{
class DEADShip
{
public int killedPirateAmnt = 0;
public bool isFiring = false;
public static int speed;
public int health = 20;
public int shipPosY = Render.yGridSize*2/3 ;
public int shipPosX = Render.xGridSize/2;
public string[,] shipModel = new string[4, 10];
public static string[,] SetShipModel()
{
string[,] shipGraphic= new string[4, 10];
shipGraphic[0, 0] = " ";
shipGraphic[0, 1] = " ";
shipGraphic[0, 2] = " ";
shipGraphic[0, 3] = " ";
shipGraphic[0, 4] = "_";
shipGraphic[0, 5] = "_";
shipGraphic[0, 6] = " ";
shipGraphic[0, 7] = " ";
shipGraphic[0, 8] = " ";
shipGraphic[0, 9] = " ";
shipGraphic[1, 0] = " ";
shipGraphic[1, 1] = " ";
shipGraphic[1, 2] = " ";
shipGraphic[1, 3] = "/";
shipGraphic[1, 4] = " ";
shipGraphic[1, 5] = " ";
shipGraphic[1, 6] = @"\";
shipGraphic[1, 7] = " ";
shipGraphic[1, 8] = " ";
shipGraphic[1, 9] = " ";
shipGraphic[2, 0] = "|";
shipGraphic[2, 1] = " ";
shipGraphic[2, 2] = "_";
shipGraphic[2, 3] = "|";
shipGraphic[2, 4] = " ";
shipGraphic[2, 5] = " ";
shipGraphic[2, 6] = "|";
shipGraphic[2, 7] = "_";
shipGraphic[2, 8] = " ";
shipGraphic[2, 9] = "|";
shipGraphic[3, 0] = "|";
shipGraphic[3, 1] = "=";
shipGraphic[3, 2] = "|";
shipGraphic[3, 3] = "_";
shipGraphic[3, 4] = "|";
shipGraphic[3, 5] = "|";
shipGraphic[3, 6] = "_";
shipGraphic[3, 7] = "|";
shipGraphic[3, 8] = "=";
shipGraphic[3, 9] = "|";
return shipGraphic;
}
}
}

View file

@ -0,0 +1,254 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using CeedMain;
namespace SpaceShooter
{
class GameLogic
{
private static int pirateY = 0;
private static readonly int collisionDistShip = 5;
private readonly static Random _random = new Random();
//SHIP STUFF
public static PlayerShip Controller(PlayerShip _ship)
{
while (true)
{
switch (Console.ReadKey(true).Key)
{
case ConsoleKey.A:
if (_ship.shipPosX > 5)
{ _ship.shipPosX--; }
break;
case ConsoleKey.D:
if (_ship.shipPosX < Render.xGridSize - 5)
{ _ship.shipPosX++; }
break;
case ConsoleKey.W:
if (_ship.shipPosY > 3)
{ _ship.shipPosY--; }
break;
case ConsoleKey.S:
if (_ship.shipPosY < Render.yGridSize - 3)
{ _ship.shipPosY++; }
break;
case ConsoleKey.Spacebar:
_ship.isFiring = true;
break;
}
return _ship;
}
}
//ASTEROID STUFF
public static Asteroid AsteroidGenerator()
{
Asteroid _asteroid = new Asteroid
{
asteroidPosX = _random.Next(-5, Render.xGridSize + 5),
asteroidPosY = 0,
AsteroidModel = Asteroid.SetAsteroidModel(),
speed = _random.Next(1, 3)
};
return _asteroid;
}
public static Asteroid MoveAsteroid(Asteroid _asteroid)
{
_asteroid.asteroidPosY += _asteroid.speed;
return _asteroid;
}
//PIRATE STUFF
public static Pirate PirateLogic(Pirate _pirate, PlayerShip _ship)
{
//FOLLOW PLAYERS X AT OWN SPEED; IF PIRATE.PosX = ship.posX, shoot!
if (_pirate.shipPosY >= Render.yGridSize - 3)
{
_pirate.isOutsideBounds = true;
return _pirate;
}
else
{
_pirate.targetX = _ship.shipPosX;
pirateY++;
if (_pirate.shipPosX > _pirate.targetX && _pirate.shipPosX < _pirate.targetX+3 || _pirate.shipPosX < _pirate.targetX && _pirate.shipPosX > _pirate.targetX - 3)
{
_pirate.isFiringNum += 1;
if(_pirate.isFiringNum % 5 == 0)
{
_pirate.isFiring = true;
}
}
else if (_pirate.shipPosX > _pirate.targetX)
{
_pirate.isFiring = false;
if (pirateY % 5 == 0)
{
_pirate.shipPosX -= _pirate.speed;
}
}
else
{
_pirate.isFiring = false;
if (pirateY % 5 == 0)
{
_pirate.shipPosX += _pirate.speed;
}
}
//MOVES the PIRAte SLOOWLY DOWNWARDS
pirateY++;
if (pirateY % 5 == 0)
{
_pirate.shipPosY += 1;
}
return _pirate;
}
}
//COLISSION STUFF
public static int[] CollisionShipProjectile(PlayerShip _ship, List<Projectile> projectileList)
{
/**output[0] = index of collided element output[1] Damage ship takes **/
int[] output = new int[2];
output[0] = 0;
output[1] = 0;
foreach (Projectile a in projectileList)
{
if (a.shotByPlayer == false)
{
if ((_ship.shipPosX - a.position[1]) * (_ship.shipPosX - a.position[1]) + (_ship.shipPosY - a.position[0]) * (_ship.shipPosY - a.position[0]) < collisionDistShip * collisionDistShip)
{
output[0] = projectileList.IndexOf(a);
output[1] = 1;
break;
}
else
{
output[1] = 0;
}
}
}
return output;
}
public static int[] CollisionShipAsteroid(PlayerShip _ship, List<Asteroid> asteroidList)
{
/**output[0] = index of collided element output[1] Damage ship takes **/
int[] output = new int[2];
output[0] = 0;
output[1] = 0;
foreach (Asteroid a in asteroidList)
{
if ((_ship.shipPosX - a.asteroidPosX) * (_ship.shipPosX - a.asteroidPosX) + (_ship.shipPosY - a.asteroidPosY) * (_ship.shipPosY - a.asteroidPosY) < collisionDistShip * collisionDistShip)
{
output[0] = asteroidList.IndexOf(a);
output[1] = 2;
break;
}
else
{
output[1] = 0;
}
}
return output;
}
public static int[] CollisionShipPirate(PlayerShip _ship, List<Pirate> pirateList)
{
/**output[0] = index of collided element output[1] Damage ship takes **/
int[] output = new int[2];
output[0] = 0;
output[1] = 0;
foreach (Pirate a in pirateList)
{
if ((_ship.shipPosX - a.shipPosX) * (_ship.shipPosX - a.shipPosX) + (_ship.shipPosY - a.shipPosY) * (_ship.shipPosY - a.shipPosY) < collisionDistShip * collisionDistShip)
{
output[0] = pirateList.IndexOf(a);
output[1] = 2;
break;
}
else
{
output[1] = 0;
}
}
return output;
}
public static int[] CollisionPirateProjectile(List<Projectile> projectileList, List<Pirate> pirateList)
{
/**output[0] = index of collided projectile, output[1] Damage ship takes, output[2] Index of pirate **/
int[] output = new int[3];
foreach (Projectile a in projectileList)
{
foreach (Pirate b in pirateList)
{
if (a.shotByPlayer == true)
{
if ((b.shipPosX - a.position[1]) * (b.shipPosX - a.position[1]) + (b.shipPosY - a.position[0]) * (b.shipPosY - a.position[0]) < collisionDistShip * collisionDistShip)
{
output[0] = projectileList.IndexOf(a);
output[1] = 1;
output[2] = pirateList.IndexOf(b);
break;
}
}
else
{
output[1] = 0;
}
}
}
return output;
}
public static int[] CollisionAsteroidProjectile(List<Projectile> projectileList, List<Asteroid> asteroidList)
{
/**output[0] = index of collided projectile, output[1] Damage ship takes, output[2] Index of pirate **/
int[] output = new int[3];
foreach (Projectile a in projectileList)
{
foreach (Asteroid b in asteroidList)
{
if (a.shotByPlayer == true)
{
if ((b.asteroidPosX - a.position[1]) * (b.asteroidPosX - a.position[1]) + (b.asteroidPosY - a.position[0]) * (b.asteroidPosY - a.position[0]) < collisionDistShip * collisionDistShip)
{
output[0] = projectileList.IndexOf(a);
output[1] = 1;
output[2] = asteroidList.IndexOf(b);
break;
}
}
else
{
output[1] = 0;
}
}
}
return output;
}
}
}

View file

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SpaceShooter
{
class Pirate
{
public bool isFiring;
public int isFiringNum = 0;
public int health = 3;
public int shipPosX = Render.xGridSize/2;
public int shipPosY = 2;
public int targetX;
public int speed = 1;
public string[,] shipModel = new string[4, 6];
public bool isOutsideBounds = false;
public static string[,] SetShipModel()
{
string[,] result = new string[3, 10];
result[0, 0] = " ";
result[0, 1] = " ";
result[0, 2] = "_";
result[0, 3] = "_";
result[0, 4] = "|";
result[0, 5] = "|";
result[0, 6] = "_";
result[0, 7] = "_";
result[0, 8] = " ";
result[0, 9] = " ";
result[1, 0] = "|";
result[1, 1] = "=";
result[1, 2] = @"\";
result[1, 3] = " ";
result[1, 4] = "|";
result[1, 5] = "|";
result[1, 6] = " ";
result[1, 7] = "/";
result[1, 8] = "=";
result[1, 9] = "|";
result[2, 0] = " ";
result[2, 1] = " ";
result[2, 2] = " ";
result[2, 3] = @"\";
result[2, 4] = "_";
result[2, 5] = "_";
result[2, 6] = "/";
result[2, 7] = " ";
result[2, 8] = " ";
result[2, 9] = " ";
return result;
}
}
}

View file

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SpaceShooter
{
class Projectile
{
public string[,] positionGrid = new string[Render.yGridSize, Render.xGridSize];
public static int speed = 2;
public int[] position = new int[2];
public bool shotByPlayer;
public bool isOutsideBounds = false;
public static Projectile CreateProjectile(int[] position, bool shotByPlayer)
{
Projectile _projectile = new Projectile();
_projectile.position[0] = position[0];
_projectile.position[1] = position[1];
_projectile.shotByPlayer = shotByPlayer;
_projectile.positionGrid[position[0] - 1, position[1] - 5] = "|";
_projectile.positionGrid[position[0] - 1, position[1] + 4] = "|";
return _projectile;
}
public static Projectile MoveProjectie(Projectile _projectile)
{
if (_projectile.shotByPlayer)
{
_projectile.positionGrid[_projectile.position[0] - 1, _projectile.position[1] - 5] = null;
_projectile.positionGrid[_projectile.position[0] - 1, _projectile.position[1] + 4] = null;
if (_projectile.position[0] < 3 || _projectile.position[0] >= Render.yGridSize-2)
{
_projectile.isOutsideBounds = true;
}
else
{
_projectile.position[0] -= Projectile.speed;
_projectile.positionGrid[_projectile.position[0] - 1, _projectile.position[1] - 5] = "|";
_projectile.positionGrid[_projectile.position[0] - 1, _projectile.position[1] + 4] = "|";
}
}
else
{
_projectile.positionGrid[_projectile.position[0] - 1, _projectile.position[1] - 5] = null;
_projectile.positionGrid[_projectile.position[0] - 1, _projectile.position[1] + 4] = null;
if (_projectile.position[0] < 3 || _projectile.position[0] >= Render.yGridSize - 3)
{
_projectile.isOutsideBounds = true;
}
else
{
_projectile.position[0] += Projectile.speed;
_projectile.positionGrid[_projectile.position[0] - 1, _projectile.position[1] - 5] = "*";
_projectile.positionGrid[_projectile.position[0] - 1, _projectile.position[1] + 4] = "*";
}
}
return _projectile;
}
}
}

247
Code/SpaceShooter/Render.cs Normal file
View file

@ -0,0 +1,247 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Input;
using CeedMain;
namespace SpaceShooter
{
class Render
{
private static StringBuilder sb = new StringBuilder();
private static readonly Random _random = new Random();
public static int xGridSize = 40;
public static int yGridSize = 30;
public string[,] renderGrid = new string[yGridSize, xGridSize];
//Actual code lol
public static string[,] AddBackgroundStars(string[,] _renderGrid)
{
int starAmnt = _random.Next(0, 500);
for (int i = 0; i < starAmnt; i++)
{
_renderGrid[_random.Next(0, yGridSize), _random.Next(0, xGridSize)] = ",";
}
return _renderGrid;
}
public static string[,] AddPositionedElement(string[,] Model, int elementSizeX, int elementSizeY, int elementPosX, int elementPosY)
{
string[,] renderGrid = new string[yGridSize, xGridSize];
for (int i = 0; i < elementSizeY; i++)
{
for (int t = 0; t < elementSizeX; t++)
{
int normalizedElementPosX = Math.Min(xGridSize-((int)Math.Ceiling((float)elementSizeX/2)), Math.Max(((int)Math.Ceiling((float)elementSizeY / 2)), elementPosX));
int normalizedElementPosY = Math.Min(yGridSize - ((int)Math.Ceiling((float)elementSizeY / 2)), Math.Max(((int)Math.Ceiling((float)elementSizeY / 2)), elementPosY));
/**
int normalizedElementPosX = Math.Min(xGridSize - elementSizeX / 2, Math.Max(elementSizeX / 2, elementPosX));
int normalizedElementPosY = Math.Min(yGridSize - elementSizeY / 2, Math.Max(elementSizeY / 2, elementPosY));
**/
renderGrid[i + normalizedElementPosY - elementSizeY / 2, t + normalizedElementPosX- elementSizeX / 2] = Model[i, t];
}
}
return renderGrid;
}
public static void OutputFrame(PlayerShip _ship, string[,] renderGrid, List<Asteroid> asteroidList,List<Projectile> projectileList, List<Pirate> pirateList)
{
//resets main renderLayer to 0
for (int i = 0; i < Render.yGridSize; i++)
{
for (int t = 0; t < Render.xGridSize; t++)
{
renderGrid[i, t] = null;
}
}
//Adds all elements to the render frame buffer
string[,] renderGridBackground = AddBackgroundStars(renderGrid);
string[,] renderGridShip = AddPositionedElement(_ship.shipModel, 10, 4, _ship.shipPosX, _ship.shipPosY);
string[,] renderGridAsteroids = new string[yGridSize, xGridSize];
string[,] renderGridProjectiles = new string[yGridSize, xGridSize];
string[,] renderGridPirates = new string[yGridSize, xGridSize];
//Merges all asteroids into one layer
foreach (Asteroid a in asteroidList)
{
string[,] tempRenderGridAsteroids = AddPositionedElement(a.AsteroidModel, 7, 5, a.asteroidPosX, a.asteroidPosY);
for (int i = 0; i < Render.yGridSize; i++)
{
for (int t = 0; t < Render.xGridSize; t++)
{
if (renderGridAsteroids[i, t] == "" || renderGridAsteroids[i, t] == null)
{
renderGridAsteroids[i, t] = tempRenderGridAsteroids[i, t];
}
}
}
}
//Merges all projectiles into one layer
foreach (Projectile a in projectileList)
{
for (int i = 0; i < Render.yGridSize; i++)
{
for (int t = 0; t < Render.xGridSize; t++)
{
if (renderGridProjectiles[i, t] == null || renderGridProjectiles[i, t] == "")
{
renderGridProjectiles[i, t] = a.positionGrid[i, t];
}
}
}
}
//Merges all pirates into one layer
foreach(Pirate a in pirateList)
{
string[,] tempRenderGridPirates = AddPositionedElement(a.shipModel, 10, 3, a.shipPosX, a.shipPosY);
for (int i = 0; i < Render.yGridSize; i++)
{
for (int t = 0; t < Render.xGridSize; t++)
{
if (renderGridPirates[i, t] == "" || renderGridPirates[i, t] == null)
{
renderGridPirates[i, t] = tempRenderGridPirates[i, t];
}
}
}
}
//Merges all layers into final renderGrid layer
for (int i = 0; i < Render.yGridSize; i++)
{
for (int t = 0; t < Render.xGridSize; t++)
{
if (renderGrid[i, t] == "" || renderGrid[i, t] == null || renderGrid[i, t] == ",")
{
if (renderGrid[i, t] == "" || renderGrid[i, t] == null || renderGrid[i, t] == ",")
{
renderGrid[i, t] = renderGridShip[i, t];
}
}
}
}
for (int i = 0; i < Render.yGridSize; i++)
{
for (int t = 0; t < Render.xGridSize; t++)
{
if (renderGrid[i, t] == "" || renderGrid[i, t] == null || renderGrid[i, t] == ",")
{
renderGrid[i, t] = renderGridPirates[i, t];
}
}
}
for (int i = 0; i < Render.yGridSize; i++)
{
for (int t = 0; t < Render.xGridSize; t++)
{
if (renderGrid[i, t] == "" || renderGrid[i, t] == null)
{
renderGrid[i, t] = renderGridProjectiles[i, t];
}
}
}
for (int i = 0; i < Render.yGridSize; i++)
{
for (int t = 0; t < Render.xGridSize; t++)
{
if (renderGrid[i, t] == "" || renderGrid[i, t] == null)
{
if (renderGrid[i, t] == "" || renderGrid[i, t] == null)
{
renderGrid[i, t] = renderGridAsteroids[i, t];
}
}
}
}
for (int i = 0; i < Render.yGridSize; i++)
{
for (int t = 0; t < Render.xGridSize; t++)
{
if (renderGrid[i, t] == "" || renderGrid[i, t] == null)
{
renderGrid[i, t] = renderGridBackground[i, t];
}
}
}
//ADDS HUD INFO
//hp
renderGrid[yGridSize - 2, xGridSize - 5] = "H";
renderGrid[yGridSize - 2, xGridSize - 4] = "P";
renderGrid[yGridSize - 2, xGridSize - 3] = ":";
renderGrid[yGridSize - 2, xGridSize - 2] = _ship.shipHealth.ToString();
//_ship.killedPirateAmnt
renderGrid[yGridSize - 1, xGridSize - 8] = "K";
renderGrid[yGridSize - 1, xGridSize - 7] = "I";
renderGrid[yGridSize - 1, xGridSize - 6] = "L";
renderGrid[yGridSize - 1, xGridSize - 5] = "L";
renderGrid[yGridSize - 1, xGridSize - 4] = "S";
renderGrid[yGridSize - 1, xGridSize - 3] = ":";
renderGrid[yGridSize - 1, xGridSize - 2] = Convert.ToString(_ship.killedPirateAmnt);
//replaces all nulls with spaces
for (int i = 0; i < yGridSize; i++)
{
for (int t = 0; t < xGridSize; t++)
{
if (renderGrid[i, t] == "" || renderGrid[i, t] == null)
{
renderGrid[i, t] = " ";
}
}
}
//Sets the window to be the size the game needs & centers position
Console.SetWindowSize(xGridSize+3, yGridSize+4);
//Sets up console
sb.Clear();
Console.SetCursorPosition(0, 0);
Console.CursorVisible = false;
//Renders with frame to Console
sb.AppendLine("");
for(int i = 0; i < xGridSize;i++)
{
sb.Append("_");
}
for (int i = 0; i < yGridSize; i++)
{
sb.Append("|");
for (int t = 0; t < xGridSize; t++)
{
sb.Append(renderGrid[i, t]);
}
sb.AppendLine("|");
}
sb.AppendLine("");
for (int i = 0; i < xGridSize; i++)
{
sb.Append("_");
}
Console.WriteLine(sb);
}
}
}

View file

@ -0,0 +1,204 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Input;
using CeedMain;
namespace SpaceShooter
{
class MainProgram
{
private static int pirateShipByHostilityAmount = 0;
private readonly static Random _random = new Random();
public static PlayerShip ShooterMain(PlayerShip _playerShip, SolarSystem _solarSystem, int planetIndex)
{
//initialise console
Console.OutputEncoding = System.Text.Encoding.UTF8;
Render _render = new Render();
Console.Clear();
//setup
Asteroid _asteroids = new Asteroid();
List<Projectile> projectileList = new List<Projectile>();
List<Asteroid> asteroidList = new List<Asteroid>();
List<Pirate> pirateList = new List<Pirate>();
_playerShip.killedPirateAmnt = 0;
//set graphic
_playerShip.shipModel = PlayerShip.SetShipModel();
//THREAD THAT MANAGES INPUT
new Thread(() =>
{
while (true)
{
Thread.CurrentThread.IsBackground = true;
_playerShip = GameLogic.Controller(_playerShip);
}
}).Start();
while (true)
{
//DOES PIRATE STUFF
//makes sure hostility num = amount of pirate ships
if (pirateList.Count <= _solarSystem.planetsList[planetIndex].hostility)
{
int pirateAmnt = _random.Next(0, 15);
if (pirateAmnt == 4)
{
Pirate tempPirate = new Pirate
{
shipPosX = _random.Next(6, 26),
shipModel = Pirate.SetShipModel()
};
pirateList.Add(tempPirate);
}
}
for (int i = 0; i < pirateList.Count; i++)
{
pirateList[i] = GameLogic.PirateLogic(pirateList[i], _playerShip);
if (pirateList[i].isOutsideBounds)
{
pirateList.Remove(pirateList[i]);
}
}
//IF ASTEROIDS IN SYSTEM, PREPARES ASTEROIDS EACH FRAME
if(_solarSystem.hasAsteroids)
{
int asteroidAmnt = _random.Next(0, 20);
if(asteroidAmnt == 3)
{
for (int i = 0; i < asteroidAmnt; i++)
{
Asteroid tempAsteroid = new Asteroid();
tempAsteroid = GameLogic.AsteroidGenerator();
asteroidList.Add(tempAsteroid);
}
}
//move asteroids
for (int i = 0; i < asteroidList.Count; i++)
{
asteroidList[i] = GameLogic.MoveAsteroid(asteroidList[i]);
if (asteroidList[i].asteroidPosY > Render.yGridSize)
{
asteroidList.Remove(asteroidList[i]);
}
}
}
//HANDLE PROJECTILES
//pirate
for (int i = 0; i < pirateList.Count; i++)
{
if (pirateList[i].isFiring)
{
int[] pos = { pirateList[i].shipPosY, pirateList[i].shipPosX };
Projectile _projectile = Projectile.CreateProjectile(pos, false);
projectileList.Add(_projectile);
pirateList[i].isFiring = false;
}
}
//player
if (_playerShip.isFiring)
{
int[] pos = { _playerShip.shipPosY, _playerShip.shipPosX };
Projectile _projectile = Projectile.CreateProjectile(pos, true);
projectileList.Add(_projectile);
_playerShip.isFiring = false;
}
if (projectileList.Count > 0)
{
for (int i = 0; i < projectileList.Count; i++)
{
if (projectileList[i].isOutsideBounds)
{
projectileList.Remove(projectileList[i]);
}
else
{
projectileList[i] = Projectile.MoveProjectie(projectileList[i]);
}
}
}
//COLLISION STUFF
int[] collisionDataShipProjectile = GameLogic.CollisionShipProjectile(_playerShip, projectileList);
if(collisionDataShipProjectile[1] > 0)
{
_playerShip.shipHealth -= collisionDataShipProjectile[1];
projectileList.RemoveAt(collisionDataShipProjectile[0]);
}
int[] collisionDataShipAsteroid = GameLogic.CollisionShipAsteroid(_playerShip, asteroidList);
if (collisionDataShipAsteroid[1] > 0)
{
_playerShip.shipHealth -= collisionDataShipAsteroid[1];
_playerShip.totalDestroyedAsteroids += 1;
asteroidList.RemoveAt(collisionDataShipAsteroid[0]);
}
int[] collisionDataShipPirate = GameLogic.CollisionShipPirate(_playerShip, pirateList);
if (collisionDataShipPirate[1] > 0)
{
_playerShip.shipHealth -= collisionDataShipPirate[1];
pirateList.RemoveAt(collisionDataShipPirate[0]);
_playerShip.totalKilledPirateAmnt += 1;
_playerShip.killedPirateAmnt += 1;
_playerShip.Money += 1;
}
int[] collisionDataPirateProjectile = GameLogic.CollisionPirateProjectile(projectileList, pirateList);
if (collisionDataPirateProjectile[1] > 0)
{
pirateList[collisionDataPirateProjectile[2]].health -= collisionDataPirateProjectile[1];
if(pirateList[collisionDataPirateProjectile[2]].health <= 0)
{
_playerShip.Money += 1;
_playerShip.killedPirateAmnt += 1;
_playerShip.totalKilledPirateAmnt += 1;
pirateList.RemoveAt(collisionDataPirateProjectile[2]);
}
projectileList.RemoveAt(collisionDataPirateProjectile[0]);
}
int[] collisionDataAsteroidProjectile = GameLogic.CollisionAsteroidProjectile(projectileList, asteroidList);
if (collisionDataAsteroidProjectile[1] > 0)
{
asteroidList.RemoveAt(collisionDataAsteroidProjectile[2]);
projectileList.RemoveAt(collisionDataPirateProjectile[0]);
_playerShip.totalDestroyedAsteroids += 1;
_playerShip.Money += 1;
}
if (_playerShip.shipHealth <= 0)
{
return _playerShip;
}
if (_playerShip.killedPirateAmnt >= (_solarSystem.planetsList[planetIndex].hostility* _solarSystem.planetsList[planetIndex].hostility) +1)
{
return _playerShip;
}
//RENDER IT OUT
Render.OutputFrame(_playerShip, _render.renderGrid, asteroidList, projectileList, pirateList);
Thread.Sleep(70);
Console.Clear();
}
}
}
}