Skip to content

Commit

Permalink
Init Project.
Browse files Browse the repository at this point in the history
  • Loading branch information
CSaratakij committed May 11, 2018
1 parent 71c3548 commit 40070bf
Show file tree
Hide file tree
Showing 15 changed files with 499 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ICTOOP.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2043
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICTOOP", "ICTOOP\ICTOOP.csproj", "{A336B7F9-11CC-4902-B90A-CD81E53EF542}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A336B7F9-11CC-4902-B90A-CD81E53EF542}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A336B7F9-11CC-4902-B90A-CD81E53EF542}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A336B7F9-11CC-4902-B90A-CD81E53EF542}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A336B7F9-11CC-4902-B90A-CD81E53EF542}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D86F7CBF-A5E3-40D6-BFCA-D753D32562B4}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions ICTOOP/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
</startup>
</configuration>
62 changes: 62 additions & 0 deletions ICTOOP/ICTOOP.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?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>{A336B7F9-11CC-4902-B90A-CD81E53EF542}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ICTOOP</RootNamespace>
<AssemblyName>ICTOOP</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</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>
<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="Lib\Actor.cs" />
<Compile Include="Lib\GameController.cs" />
<Compile Include="Lib\GameObject.cs" />
<Compile Include="Lib\IAttackAble.cs" />
<Compile Include="Lib\IBotBehaviour.cs" />
<Compile Include="Lib\IControlable.cs" />
<Compile Include="Lib\IDamageAble.cs" />
<Compile Include="Lib\Monster.cs" />
<Compile Include="Lib\Player.cs" />
<Compile Include="Lib\Status.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
74 changes: 74 additions & 0 deletions ICTOOP/Lib/Actor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;

namespace ICTOOP.Lib
{
abstract class Actor : GameObject, IAttackAble<Actor>, IDamageAble<float>
{
public uint Level { get; set; }

public Status HealthStat { get; set; }
public Status AttackStat { get; set; }
public Status DefenseStat { get; set; }


public Actor() : base()
{
HealthStat = new Status(0, 0);
AttackStat = new Status(0, 0);
DefenseStat = new Status(0, 0);
}

public Actor(string name) : base(name)
{
HealthStat = new Status(0, 0);
AttackStat = new Status(0, 0);
DefenseStat = new Status(0, 0);
}

public Actor(string name, float health, float maxHealth) : base(name)
{
HealthStat = new Status(health, maxHealth);
AttackStat = new Status(0, 0);
DefenseStat = new Status(0, 0);
}

public void LevelUp()
{
Level += 1;
}

public virtual void Attack(Actor actor)
{
string format = "{0} is attacking [ {1} ].";
Console.WriteLine(string.Format(format, Name, actor.Name));
actor.ReceiveDamage(AttackStat.Current);
}

public void ReceiveDamage(float value)
{
if (value < DefenseStat.Current) { return; }
HealthStat.Remove(value - DefenseStat.Current);

if (HealthStat.IsEmpty)
{
GameController.GameOver();
}
}

public override string ToString()
{
string format = @"{0} :
Health : {1}
Attack : {2}
Defense : {3}";

return string.Format(
format,
Name,
HealthStat.Current,
AttackStat.Current,
DefenseStat.Current
);
}
}
}
40 changes: 40 additions & 0 deletions ICTOOP/Lib/GameController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace ICTOOP.Lib
{
class GameController
{
public delegate void Func();

public static event Func OnGameStart;
public static event Func OnGameOver;

public static bool IsGameStart { get { return isGameStart; } private set => isGameStart = value; }


static bool isGameStart;


static void FireEvent_OnGameStart()
{
OnGameStart?.Invoke();
}

static void FireEvent_OnGameOver()
{
OnGameOver?.Invoke();
}

public static void GameStart()
{
if (isGameStart) { return; }
isGameStart = true;
FireEvent_OnGameStart();
}

public static void GameOver()
{
if (!isGameStart) { return; }
isGameStart = false;
FireEvent_OnGameOver();
}
}
}
9 changes: 9 additions & 0 deletions ICTOOP/Lib/GameObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace ICTOOP.Lib
{
class GameObject
{
public string Name { get; set; }
public GameObject() => Name = string.Empty;
public GameObject(string name) => Name = name;
}
}
7 changes: 7 additions & 0 deletions ICTOOP/Lib/IAttackAble.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace ICTOOP.Lib
{
interface IAttackAble<T>
{
void Attack(T target);
}
}
10 changes: 10 additions & 0 deletions ICTOOP/Lib/IBotBehaviour.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace ICTOOP.Lib
{
interface IBotBehaviour
{
void AttackNearbyEnemy();
void AvoidObstacle();
void AvoidHit();
void MoveToTarget();
}
}
7 changes: 7 additions & 0 deletions ICTOOP/Lib/IControlable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace ICTOOP.Lib
{
interface IControlable
{
void InputHandler();
}
}
7 changes: 7 additions & 0 deletions ICTOOP/Lib/IDamageAble.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace ICTOOP.Lib
{
interface IDamageAble<T>
{
void ReceiveDamage(T value);
}
}
42 changes: 42 additions & 0 deletions ICTOOP/Lib/Monster.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;

namespace ICTOOP.Lib
{
class Monster : Actor, IBotBehaviour
{
public Monster() : base()
{

}

public Monster(string name) : base(name)
{

}

public Monster(string name, float health, float maxHealth) : base(name, health, maxHealth)
{

}

public void AttackNearbyEnemy()
{
Console.WriteLine(Name + " about to attack a nearby enemy..");
}

public void AvoidHit()
{
Console.WriteLine(Name + " about to avoid a hit..");
}

public void AvoidObstacle()
{
Console.WriteLine(Name + " about to avoid an obstacl..");
}

public void MoveToTarget()
{
Console.WriteLine(Name + " about to move to target..");
}
}
}
27 changes: 27 additions & 0 deletions ICTOOP/Lib/Player.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;

namespace ICTOOP.Lib
{
class Player : Actor, IControlable
{
public Player() : base()
{

}

public Player(string name) : base(name)
{

}

public Player(string name, float health, float maxHealth) : base(name, health, maxHealth)
{

}

public void InputHandler()
{

}
}
}
40 changes: 40 additions & 0 deletions ICTOOP/Lib/Status.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace ICTOOP.Lib
{
class Status
{
float _maximum;
float _current;

public float Maximum => _maximum;
public float Current => _current;

public bool IsEmpty => _current <= 0;


public Status(float current, float maximum)
{
_current = current;
_maximum = maximum;
}

public void Clear()
{
_current = 0;
}

public void FullRestore()
{
_current = _maximum;
}

public void Restore(float value)
{
_current = (_current + value) > _maximum ? _maximum : (_current + value);
}

public void Remove(float value)
{
_current = (_current - value) < 0 ? 0 : (_current - value);
}
}
}
Loading

0 comments on commit 40070bf

Please sign in to comment.