Bonjour,
J'ai l'ensemble de classe "SpellEffect" :
J'ai également la classe "Timer" :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public abstract class SpellEffect: IEquatable<SpellEffect> { //_____ PRIVATE PROPERTIES _______________________________________________________________ protected Timer _duration = null; protected bool _isStarted = false; // ... //_____ PUBLIC METHODES _______________________________________________________________ /* ------------------------------------------------------------------------------------------------------------------------- * Start the duration of the spell effect * ------------------------------------------------------------------------------------------------------------------------- */ public void start () { this._isStarted = true; if (this._duration != null) { this._duration.start(); } } // ... } [Serializable] public abstract class SpellEffect_Feature: SpellEffect { // ... public virtual float Value { get { float result = 0f; if (this._isStarted && this._duration != null) { if (!this._duration.IsUp && this.isUp()) { this._iteration.start(); result = this.getCriticalValue(this._value); } }else if (this._isStarted) { result = this.getCriticalValue(this._value); // Set a timer to ended the spell Effect this._duration = new Timer(); } return result; } } // ... } using SpellsNS; using System; using System.Collections.Generic; [Serializable] public class SpellEffect_Harmfull : SpellEffect_Feature { //_____ ACCESSEURS _______________________________________________________________ public override float Value { get { return -base.Value; } } //_____ CONSTRUCTEURS _____________________________________________________________ public SpellEffect_Harmfull (string id, float value, string featureName, CriticalChance criticalChance = null, Element spellElement = null, List<FeatureRatio> featureRatios = null, float duration = 0f, float iteration = 0.5f, SpellsEffectsList endEffects = null ) :base(id, value, featureName, spellElement, criticalChance, featureRatios, duration, iteration, endEffects, TargetedFeatureValue.CurrentValue){} public SpellEffect_Harmfull (SpellEffect_Harmfull spellEffect_Harmfull) :base (spellEffect_Harmfull){} }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 using UnityEngine; [System.Serializable] public class Timer { //_____ PRIVATE PROPERTIES _______________________________________________________________ private float _interval; private bool _isUp = true; private float _nextUp = 0f; //_____ ACCESSEURS _______________________________________________________________ public bool IsUp { get{ // If the timer is not up, we check if it should be if (!this._isUp && this._nextUp <= Time.time) { this._isUp = true; } return this._isUp; } } public float Interval { get { return this._interval; } set { // The _interval can't have a negative value if (value > 0) { this._interval = value; } else { this._interval = 0f; } this.reset(); } } //_____ CONSTRUCTEURS _____________________________________________________________ public Timer (float interval = 0f) { this.Interval = interval; } //_____ METHODES __________________________________________________________________ /* ------------------------------------------------------------------------------------------------------------------------- * Set Up the next up time after "_interval" second * ------------------------------------------------------------------------------------------------------------------------- */ public void start () { if (this.IsUp && this._interval > 0f) { this._isUp = false; this._nextUp = Time.time + this._interval; } } /* ------------------------------------------------------------------------------------------------------------------------- * Return the remaining number of second before the next up * ------------------------------------------------------------------------------------------------------------------------- */ public float getRemainingSecond () { float result = 0f; if (!this.IsUp) { result = this._nextUp - Time.time; } return result; } /* ------------------------------------------------------------------------------------------------------------------------- * Reset the timer * ------------------------------------------------------------------------------------------------------------------------- */ public void reset () { this._isUp = true; this._nextUp = 0f; } }
Lors de l'appel de la fonction "SpellEffect.start()", quand j'affecte la valeur "true" à la propriété "this._isStarted" ça initialise la propriété "this._duration" avec la valeur "new Timer()".
Je ne comprends pas pourquoi car il n'y a aucune raison et que cette propriété avait la valeur "null" avant cette modification de valeur.
Voici en image ce que ça donne dans mon debugueur :
Au début de la fontion :
Pièce jointe 432281
Après l'affectation de valeur :
Pièce jointe 432284
En sachant que je suis en mode pas à pas et qu'il n'y a aucune étape de plus entre les deux.
A savoir que le test "if (this._duration != null) {}" n'est pas encore exécutée car le débogueur vient juste de se positionner dessus.
Avez-vous une idée du pourquoi du comment ?
D'avance merci pour votre aide.![]()
Partager