mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-04-19 21:33:15 +02:00
Removed the old (uncleaned) spell data related classes.
This commit is contained in:
parent
2578bbb0ba
commit
add4ab2b51
@ -1,6 +0,0 @@
|
||||
#include "PlayerLocalSpellData.h"
|
||||
namespace BS {
|
||||
namespace Player {
|
||||
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
#include <System/System.h>
|
||||
|
||||
using namespace System;
|
||||
namespace BS {
|
||||
namespace Player {
|
||||
class PlayerLocalSpellData : public virtual Object
|
||||
{
|
||||
};
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
#include "PlayerLocalTargetNextPrevSpellData.h"
|
||||
namespace BS {
|
||||
namespace Player {
|
||||
PlayerLocalTargetNextPrevSpellData::PlayerLocalTargetNextPrevSpellData(WorldEntity* owner){
|
||||
LAYER = 2048;
|
||||
rch = new Array<RaycastHit>(100);
|
||||
direction = new Vector3((float)0, (float)1, (float)0);
|
||||
enemyTargets = new List_T<WorldEntity>();
|
||||
this->owner = owner;
|
||||
this->tc = owner->GetComponent<TargetComponent>();
|
||||
}
|
||||
void PlayerLocalTargetNextPrevSpellData::Refresh()
|
||||
{
|
||||
WorldEntity* cTarget = this->tc->CTarget;
|
||||
this->enemyTargetindex = 0;
|
||||
this->enemyTargets->Clear();
|
||||
int num = Physics::SphereCastNonAlloc(this->owner->transform->position, (float)20, this->direction, this->rch, (float)0, this->LAYER);
|
||||
for (int i = 0; i < num; i += 1) {
|
||||
RaycastHit* raycastHit = this->rch->GetData(i);
|
||||
WorldEntity* component = raycastHit->collider->gameObject->GetComponent<WorldEntity>();
|
||||
if (!*component == this->owner) {
|
||||
if (*component == *cTarget) {
|
||||
this->enemyTargetindex = i;
|
||||
}
|
||||
this->enemyTargets->Add(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
void PlayerLocalTargetNextPrevSpellData::TargetNextEnemy()
|
||||
{
|
||||
if (this->enemyTargets->Count == 0) {
|
||||
return;
|
||||
}
|
||||
this->enemyTargetindex += 1;
|
||||
if (this->enemyTargetindex >= this->enemyTargets->Count) {
|
||||
this->enemyTargetindex = 0;
|
||||
}
|
||||
this->tc->SetTarget(this->enemyTargets->GetData(this->enemyTargetindex));
|
||||
}
|
||||
void PlayerLocalTargetNextPrevSpellData::TargetPreviousEnemy()
|
||||
{
|
||||
if (this->enemyTargets->Count == 0) {
|
||||
return;
|
||||
}
|
||||
this->enemyTargetindex -= 1;
|
||||
if (this->enemyTargetindex < 0) {
|
||||
this->enemyTargetindex = this->enemyTargets->Count - 1;
|
||||
}
|
||||
this->tc->SetTarget(this->enemyTargets->GetData(this->enemyTargetindex));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
#pragma once
|
||||
#include <System/System.h>
|
||||
#include "PlayerLocalSpellData.h"
|
||||
#include "WorldEntity.h"
|
||||
#include <System/Collections/Generic/List.h>
|
||||
#include "TargetComponent.h"
|
||||
#include "Vector3.h"
|
||||
#include "RaycastHit.h"
|
||||
#include "Physics.h"
|
||||
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace UnityEngine;
|
||||
using namespace System;
|
||||
namespace BS {
|
||||
namespace Player {
|
||||
class PlayerLocalTargetNextPrevSpellData : public virtual PlayerLocalSpellData, public virtual Object
|
||||
{
|
||||
private:
|
||||
List_T<WorldEntity>* enemyTargets;
|
||||
private:
|
||||
int enemyTargetindex;
|
||||
private:
|
||||
WorldEntity* owner;
|
||||
private:
|
||||
TargetComponent* tc;
|
||||
private:
|
||||
Vector3* direction;
|
||||
private:
|
||||
Array<RaycastHit>* rch;
|
||||
private:
|
||||
int LAYER;
|
||||
public:
|
||||
PlayerLocalTargetNextPrevSpellData(WorldEntity* owner);
|
||||
public:
|
||||
void Refresh();
|
||||
public:
|
||||
void TargetNextEnemy();
|
||||
public:
|
||||
void TargetPreviousEnemy();
|
||||
};
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
#include "PlayerSpellCooldownData.h"
|
||||
float PlayerSpellCooldownData::getCooldown(){
|
||||
return this->cooldown;
|
||||
}
|
||||
void PlayerSpellCooldownData::setCooldown(float value)
|
||||
{
|
||||
this->cooldown = value;
|
||||
}
|
||||
float PlayerSpellCooldownData::getRemainingCooldown()
|
||||
{
|
||||
return this->remainingCooldown;
|
||||
}
|
||||
void PlayerSpellCooldownData::setRemainingCooldown(float value)
|
||||
{
|
||||
this->remainingCooldown = value;
|
||||
}
|
||||
PlayerSpellCooldownData::PlayerSpellCooldownData()
|
||||
{
|
||||
}
|
||||
PlayerSpellCooldownData::PlayerSpellCooldownData(int spellId, float cooldown, float remainingCooldown) : PlayerSpellData(spellId)
|
||||
{
|
||||
this->setCooldown(cooldown);
|
||||
this->setRemainingCooldown(remainingCooldown);
|
||||
}
|
||||
void PlayerSpellCooldownData::Update(PlayerSpellDataComponent* psdc)
|
||||
{
|
||||
this->remainingCooldown -= Time::deltaTime;
|
||||
if (this->remainingCooldown <= (float)0) {
|
||||
psdc->RemoveSSpellData(this);
|
||||
}
|
||||
}
|
||||
void PlayerSpellCooldownData::Serialize(JsonWriter* w)
|
||||
{
|
||||
PlayerSpellCooldownData::ToJSON(this, w);
|
||||
}
|
||||
void PlayerSpellCooldownData::ToJSON(PlayerSpellCooldownData* psdc, JsonWriter* w)
|
||||
{
|
||||
w->WritePropertyName(new String("PlayerSpellData"));
|
||||
w->WriteStartObject();
|
||||
w->WritePropertyName(new String("Cooldown"));
|
||||
w->WriteValue(psdc->getCooldown());
|
||||
w->WritePropertyName(new String("RemainingCooldown"));
|
||||
w->WriteValue(psdc->getRemainingCooldown());
|
||||
w->WriteEndObject();
|
||||
}
|
||||
void PlayerSpellCooldownData::FromJSON(PlayerSpellCooldownData* psdc, JsonReader* r)
|
||||
{
|
||||
while (r->Read()) {
|
||||
if (r->TokenType == JsonToken::PropertyName) {
|
||||
String* a = (String*)(r->Value);
|
||||
if (!*a == *(new String("Cooldown"))) {
|
||||
if (*a == *(new String("RemainingCooldown"))) {
|
||||
psdc->setRemainingCooldown((float)(r->ReadAsDouble()->Value));
|
||||
}
|
||||
}
|
||||
else {
|
||||
psdc->setCooldown((float)(r->ReadAsDouble()->Value));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (r->TokenType == JsonToken::EndObject) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
#pragma once
|
||||
#include <System/System.h>
|
||||
#include "PlayerSpellData.h"
|
||||
#include "PlayerSpellDataComponent.h"
|
||||
#include "Time.h"
|
||||
#include "JsonWriter.h"
|
||||
#include "JsonReader.h"
|
||||
#include "JsonToken.h"
|
||||
|
||||
using namespace UnityEngine;
|
||||
using namespace Newtonsoft::Json;
|
||||
using namespace System;
|
||||
//Forward Declaration
|
||||
class PlayerSpellData;
|
||||
|
||||
class PlayerSpellCooldownData : public virtual PlayerSpellData, public virtual Object{
|
||||
private:
|
||||
float cooldown;
|
||||
private:
|
||||
float remainingCooldown;
|
||||
public:
|
||||
float getCooldown();
|
||||
public:
|
||||
void setCooldown(float value);
|
||||
public:
|
||||
float getRemainingCooldown();
|
||||
public:
|
||||
void setRemainingCooldown(float value);
|
||||
public:
|
||||
PlayerSpellCooldownData();
|
||||
public:
|
||||
PlayerSpellCooldownData(int spellId, float cooldown, float remainingCooldown);
|
||||
public:
|
||||
virtual void Update(PlayerSpellDataComponent* psdc);
|
||||
public:
|
||||
virtual void Serialize(JsonWriter* w);
|
||||
public:
|
||||
static void ToJSON(PlayerSpellCooldownData* psdc, JsonWriter* w);
|
||||
public:
|
||||
static void FromJSON(PlayerSpellCooldownData* psdc, JsonReader* r);
|
||||
};
|
@ -1,60 +0,0 @@
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
/// <summary>
|
||||
/// Base SpellData class.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class PlayerSpellData {
|
||||
[SerializeField]
|
||||
int spellId;
|
||||
|
||||
public int SpellId { get { return spellId; } set { spellId = value; } }
|
||||
|
||||
public PlayerSpellData() {}
|
||||
|
||||
public PlayerSpellData(int spellId)
|
||||
{
|
||||
this.spellId = spellId;
|
||||
}
|
||||
|
||||
public virtual void Update(PlayerSpellDataComponent psdc)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Serialize(JsonWriter w)
|
||||
{
|
||||
ToJSON(this, w);
|
||||
}
|
||||
|
||||
public static void ToJSON(PlayerSpellData psdc, JsonWriter w)
|
||||
{
|
||||
w.WritePropertyName("PlayerSpellData");
|
||||
w.WriteStartObject();
|
||||
|
||||
w.WritePropertyName("SpellId");
|
||||
w.WriteValue(psdc.spellId);
|
||||
|
||||
w.WriteEndObject();
|
||||
}
|
||||
|
||||
public static void FromJSON(PlayerSpellData psdc, JsonReader r)
|
||||
{
|
||||
while (r.Read())
|
||||
{
|
||||
if (r.TokenType == JsonToken.PropertyName)
|
||||
{
|
||||
switch ((string)r.Value)
|
||||
{
|
||||
case "SpellId":
|
||||
psdc.spellId = (int)r.ReadAsInt32();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (r.TokenType == JsonToken.EndObject)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user