-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChartExample.cpp
147 lines (116 loc) · 4.02 KB
/
ChartExample.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Fill out your copyright notice in the Description page of Project Settings.
#include "ChartExample.h"
// 100px 200 metre leftStick
// under 500px 10sn koysam 100 px arasi 2sn
void UChartExample::NativeConstruct()
{
Super::NativeConstruct();
FPortObserver::Attach(this);
int32 LeftArrayVal[] = { 800, 600, 400, 200, 0 };
LeftStickValues.Append(LeftArrayVal, ARRAY_COUNT(LeftArrayVal));
int32 UnderArrayVal[] = { 0, 2, 4, 6, 8, 10 };
UnderStickValues.Append(UnderArrayVal, ARRAY_COUNT(UnderArrayVal));
}
void UChartExample::NativeDestruct()
{
FPortObserver::Detach(this);
}
/*
int UniversalXEffect = 0;
int UniversalYEffect = 0;
*/
int OldCenteredPosition = 400;
int CounterComp = 10;
int InCounter;
void UChartExample::Update(const RocketData Data, EListenerType AvionicType, const float DTime)
{
if (AvionicType != MainAvionic) return;
if (DTime == -1) return;
SetCounter(GetCounter() + DTime);
InCounter = static_cast<int>(GetCounter());
float FakeCounter = GetCounter();
if (InCounter >= 10)
{
FakeCounter = FMath::Fmod(FakeCounter, 10);
FakeCounter = FMath::Fmod(FakeCounter, 2);
FakeCounter += 8;
}
if (InCounter % 2 == 0 && InCounter >= CounterComp)
{
InCounter += 2;
CounterComp = InCounter;
LinesArray.RemoveAll([](const FVector2D Vector)
{
return Vector.X >= 1480 && Vector.X < 1580;
});
for (int64 Index = 0; Index != LinesArray.Num(); ++Index)
{
FVector2D Vector = LinesArray[Index];
LinesArray[Index] = FVector2D(Vector.X - 100, Vector.Y);
}
UnderStickValues.RemoveAt(0);
UnderStickValues.Add(InCounter);
}
FakeCounter = ((FakeCounter * 10) * 5) + 1480;
float AltitudeGraph = 420 - ((Data.MainData.altitude - OldCenteredPosition + 400) / 2.0f);
LinesArray.Add(FVector2D(FakeCounter, AltitudeGraph));
LeftStickValues.Reset();
int CenteredPosition = static_cast<int>(Data.MainData.altitude / 200) * 200;
if (CenteredPosition < 400) CenteredPosition = 400;
for (int i = 4; i >= 0; i--) {
if (i == 2) continue;
LeftStickValues.Add(CenteredPosition + ((i - 2) * 200));
}
LeftStickValues.Insert(CenteredPosition, 2);
if (OldCenteredPosition != 0 && CenteredPosition != OldCenteredPosition)
{
const bool InFall = OldCenteredPosition > CenteredPosition;
for (int64 Index = 0; Index != LinesArray.Num(); ++Index)
{
FVector2D Vector = LinesArray[Index];
LinesArray[Index] = FVector2D(Vector.X, Vector.Y +
(OldCenteredPosition > CenteredPosition ? -100 : +100));
}
LinesArray.RemoveAll([&](const FVector2D Vector)
{
return Vector.Y < 20 || Vector.Y > 420;
});
}
OldCenteredPosition = CenteredPosition;
/*
AallahiminsallahGameModeBase::ChartExample->SetCounter(AallahiminsallahGameModeBase::ChartExample->GetCounter() + DeltaTime);
FakeCounter = AallahiminsallahGameModeBase::ChartExample->GetCounter();
FakeCounter = ((FakeCounter * 10) * 5) + 1480; //X
FakeAltitude2 = 420 - ((FakeAltitude) / 2.0f); //Y
FakeAltitude += FMath::RandRange(-5.0f, 7.0f);
if (FakeAltitude >= 700)
{
fall = true;
}
if (fall)
{
FakeAltitude -= FMath::RandRange(0.0f, 15.0f);
}
if (FakeAltitude <= 10)
{
fall = false;
}
if (AallahiminsallahGameModeBase::ChartExample->LinesArray.Num() > 50)
{
FVector2D VectorPop = AallahiminsallahGameModeBase::ChartExample->LinesArray.HeapTop();
AallahiminsallahGameModeBase::ChartExample->LinesArray.RemoveAt(0);
float XEffect = VectorPop.X - 1480;
float YEffect = 420 - VectorPop.Y;
for (int64 Index = 0; Index != AallahiminsallahGameModeBase::ChartExample->LinesArray.Num(); ++Index)
{
FVector2D Vector = AallahiminsallahGameModeBase::ChartExample->LinesArray[Index];
AallahiminsallahGameModeBase::ChartExample->LinesArray[Index] = FVector2D(Vector.X - XEffect, Vector.Y + YEffect);
}
UniversalXEffect += XEffect;
UniversalYEffect += YEffect;
}
AallahiminsallahGameModeBase::ChartExample->SetLeftStickValue(FVector2D(FakeAltitude, FakeAltitude2 + UniversalYEffect));
AallahiminsallahGameModeBase::ChartExample->LinesArray.Add(FVector2D(FakeCounter - UniversalXEffect,
FakeAltitude2 + UniversalYEffect));
*/
}