Skip to content

Commit ee17e81

Browse files
committed
Script coding and summary
1 parent 70d84e6 commit ee17e81

18 files changed

Lines changed: 157 additions & 108 deletions

File tree

Assets/Models/Animations/Controllers/Character.controller

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,13 @@ AnimatorStateMachine:
212212
m_ChildStates:
213213
- serializedVersion: 1
214214
m_State: {fileID: 5568523654710940590}
215-
m_Position: {x: 380, y: -60, z: 0}
215+
m_Position: {x: 390, y: -30, z: 0}
216216
- serializedVersion: 1
217217
m_State: {fileID: 7833005877581471439}
218-
m_Position: {x: 370, y: 40, z: 0}
218+
m_Position: {x: 380, y: 70, z: 0}
219219
- serializedVersion: 1
220220
m_State: {fileID: 7763939431748962746}
221-
m_Position: {x: 360, y: 130, z: 0}
221+
m_Position: {x: 380, y: 140, z: 0}
222222
m_ChildStateMachines: []
223223
m_AnyStateTransitions: []
224224
m_EntryTransitions:
@@ -327,37 +327,37 @@ AnimatorController:
327327
m_DefaultFloat: 0
328328
m_DefaultInt: 0
329329
m_DefaultBool: 0
330-
m_Controller: {fileID: 0}
330+
m_Controller: {fileID: 9100000}
331331
- m_Name: Idle
332332
m_Type: 9
333333
m_DefaultFloat: 0
334334
m_DefaultInt: 0
335335
m_DefaultBool: 0
336-
m_Controller: {fileID: 0}
336+
m_Controller: {fileID: 9100000}
337337
- m_Name: Defence
338338
m_Type: 9
339339
m_DefaultFloat: 0
340340
m_DefaultInt: 0
341341
m_DefaultBool: 0
342-
m_Controller: {fileID: 0}
342+
m_Controller: {fileID: 9100000}
343343
- m_Name: Death
344344
m_Type: 9
345345
m_DefaultFloat: 0
346346
m_DefaultInt: 0
347347
m_DefaultBool: 0
348-
m_Controller: {fileID: 0}
348+
m_Controller: {fileID: 9100000}
349349
- m_Name: isDead
350350
m_Type: 4
351351
m_DefaultFloat: 0
352352
m_DefaultInt: 0
353353
m_DefaultBool: 0
354-
m_Controller: {fileID: 0}
354+
m_Controller: {fileID: 9100000}
355355
- m_Name: DeathID
356356
m_Type: 3
357357
m_DefaultFloat: 0
358358
m_DefaultInt: 0
359359
m_DefaultBool: 0
360-
m_Controller: {fileID: 0}
360+
m_Controller: {fileID: 9100000}
361361
m_AnimatorLayers:
362362
- serializedVersion: 5
363363
m_Name: Base Layer

Assets/Prefabs/Resources/Actions/Attack.prefab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ MonoBehaviour:
111111
m_Script: {fileID: 11500000, guid: e3d567823f61d174f96a5cfce27af6bd, type: 3}
112112
m_Name:
113113
m_EditorClassIdentifier:
114+
Flag: 0
114115
_linePrefab: {fileID: 96369850693869566, guid: 3d768cbf806a3c949a21c5b4a845cd4d, type: 3}
115116
_dragSensivity: 1.2
116-
_attackValue: -3
117117
--- !u!1 &741530052143649649
118118
GameObject:
119119
m_ObjectHideFlags: 0

Assets/Scripts/Actions/Action.cs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using UnityEngine;
1+
using UnityEngine;
22

33
public enum Flag
44
{
@@ -7,6 +7,9 @@ public enum Flag
77
DEFENDING
88
}
99

10+
/// <summary>
11+
/// Базовый класс для описания действий
12+
/// </summary>
1013
public abstract class Action : MonoBehaviour
1114
{
1215
public Flag Flag;
@@ -15,18 +18,18 @@ public abstract class Action : MonoBehaviour
1518
[SerializeField]
1619
private float _dragSensivity = 1.2f;
1720

18-
protected Character _target;
21+
protected Character Target;
1922
private LineRenderer _line;
2023
private Camera _mainCamera;
2124
private Vector3 _mouseOffset;
2225
private float _mouseZCoord;
2326
private Vector3 _firstPos;
2427
private Renderer _meshRenderer;
2528
private Transform _childOther;
26-
protected bool _isDraggable = false;
27-
protected bool _isSelfTargeted = false;
28-
protected bool _isEnemyTargeted = false;
29-
protected bool _isAttacking
29+
protected bool IsDraggable = false;
30+
protected bool IsSelfTargeted = false;
31+
protected bool IsEnemyTargeted = false;
32+
protected bool IsAttacking
3033
{
3134
get
3235
{
@@ -45,7 +48,7 @@ private void Awake()
4548

4649
protected void Start()
4750
{
48-
if (!Character.isEnemy(transform.position)) _isDraggable = true;
51+
if (!Character.isEnemy(transform.position)) IsDraggable = true;
4952
}
5053

5154
private Vector3 GetMouseWorldPosition()
@@ -58,7 +61,7 @@ private Vector3 GetMouseWorldPosition()
5861

5962
private void OnMouseDown()
6063
{
61-
if (!_isDraggable) return;
64+
if (!IsDraggable) return;
6265

6366
Cursor.visible = false;
6467
_line = Instantiate(_linePrefab, Vector3.zero, Quaternion.identity).GetComponent<LineRenderer>();
@@ -75,7 +78,7 @@ private void OnMouseDown()
7578

7679
private void OnMouseDrag()
7780
{
78-
if (!_isDraggable) return;
81+
if (!IsDraggable) return;
7982

8083
Vector3 newPos = (GetMouseWorldPosition() + _mouseOffset) * _dragSensivity;
8184
transform.position = new Vector3(newPos.x, _firstPos.y, newPos.z);
@@ -85,7 +88,7 @@ private void OnMouseDrag()
8588

8689
private void OnMouseUp()
8790
{
88-
if (!_isDraggable) return;
91+
if (!IsDraggable) return;
8992

9093
gameObject.AddComponent<Rigidbody>();
9194
Destroy(_line.gameObject);
@@ -94,11 +97,11 @@ private void OnMouseUp()
9497

9598
public void SetTarget(Character target, out bool performable)
9699
{
97-
if (_isSelfTargeted)
100+
if (IsSelfTargeted)
98101
{
99102
if (target.gameObject.Equals(transform.parent.gameObject))
100103
{
101-
_target = target;
104+
Target = target;
102105
performable = true;
103106
}
104107
else
@@ -107,16 +110,16 @@ public void SetTarget(Character target, out bool performable)
107110
performable = false;
108111
}
109112
}
110-
else if (!_isDraggable)
113+
else if (!IsDraggable)
111114
{
112-
_target = target;
115+
Target = target;
113116
performable = true;
114117
}
115-
else if (_isEnemyTargeted)
118+
else if (IsEnemyTargeted)
116119
{
117120
if (Character.isEnemy(target.transform.position))
118121
{
119-
_target = target;
122+
Target = target;
120123
performable = true;
121124
}
122125
else

Assets/Scripts/Actions/Attack.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
using UnityEngine;
1+
using UnityEngine;
22

3+
/// <summary>
4+
/// Класс для действия атаки
5+
/// </summary>
36
public class Attack : Action
47
{
58
[SerializeField]
6-
protected static int _attackValue = -3;
9+
protected static int AttackValue = -3;
710

811
private new void Start()
912
{
1013
base.Start();
11-
_isEnemyTargeted = true;
14+
IsEnemyTargeted = true;
1215
}
1316

1417
public override void PerformAction()
1518
{
16-
_target.GetHealth().ChangeHealth(_attackValue, _isAttacking);
19+
Target.GetHealth().ChangeHealth(AttackValue, IsAttacking);
1720
}
1821

1922
public static int GetAttackValue()
2023
{
21-
return _attackValue;
24+
return AttackValue;
2225
}
2326
}

Assets/Scripts/Actions/Defence.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
1-
using UnityEngine;
1+
using UnityEngine;
22

3+
/// <summary>
4+
/// Класс для действия защиты
5+
/// </summary>
36
public class Defence : Action
47
{
58
[SerializeField]
6-
protected static int _defenceValue = 2;
9+
protected static int DefenceValue = 2;
710
[SerializeField]
811
private int _defenceTurns = 3;
912

1013
private new void Start()
1114
{
1215
base.Start();
13-
_isSelfTargeted = true;
16+
IsSelfTargeted = true;
1417
}
1518

1619
public override void PerformAction()
1720
{
18-
_target.GetAnimator().SetTrigger("Defence");
19-
if (_target.Effects.ContainsKey(Effect.DEFENDED))
21+
Target.GetAnimator().SetTrigger("Defence");
22+
if (Target.Effects.ContainsKey(Effect.DEFENDED))
2023
{
21-
_target.Effects[Effect.DEFENDED] += _defenceTurns;
24+
Target.Effects[Effect.DEFENDED] += _defenceTurns;
2225
}
2326
else
2427
{
25-
_target.Effects[Effect.DEFENDED] = _defenceTurns;
28+
Target.Effects[Effect.DEFENDED] = _defenceTurns;
2629
}
27-
_target.GetHealth().AddArmour(_defenceValue);
30+
Target.GetHealth().AddArmour(DefenceValue);
2831
}
2932

3033
public static int GetDefenceValue()
3134
{
32-
return _defenceValue;
35+
return DefenceValue;
3336
}
3437
}

Assets/Scripts/Actions/Heal.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
1-
using UnityEngine;
1+
using UnityEngine;
22

3+
/// <summary>
4+
/// Класс для действия лечения
5+
/// </summary>
36
public class Heal : Action
47
{
58
[SerializeField]
6-
protected static int _healValue = 1;
9+
protected static int HealValue = 1;
710

811
private new void Start()
912
{
1013
base.Start();
11-
_isSelfTargeted = true;
14+
IsSelfTargeted = true;
1215
}
1316

1417
public override void PerformAction()
1518
{
16-
_target.GetAnimator().SetTrigger("Cast");
17-
_target.Effects.Remove(Effect.POISONED);
18-
_target.GetHealth().ChangeHealth(_healValue, _isAttacking);
19+
Target.GetAnimator().SetTrigger("Cast");
20+
Target.Effects.Remove(Effect.POISONED);
21+
Target.GetHealth().ChangeHealth(HealValue, IsAttacking);
1922
}
2023

2124
public static int GetHealValue()
2225
{
23-
return _healValue;
26+
return HealValue;
2427
}
2528
}

Assets/Scripts/Actions/Poison.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
1-
using UnityEngine;
1+
using UnityEngine;
22

3+
/// <summary>
4+
/// Класс для действия отравления
5+
/// </summary>
36
public class Poison : Action
47
{
58
[SerializeField]
6-
protected static int _poisonValue = -1;
9+
protected static int PoisonValue = -1;
710
[SerializeField]
8-
private int _poisonTunrs = 1;
11+
protected int PoisonTunrs = 1;
912

1013
private new void Start()
1114
{
1215
base.Start();
13-
_isEnemyTargeted = true;
16+
IsEnemyTargeted = true;
1417
}
1518

1619
public override void PerformAction()
1720
{
18-
if (_target.Effects.ContainsKey(Effect.POISONED))
21+
if (Target.Effects.ContainsKey(Effect.POISONED))
1922
{
20-
_target.Effects[Effect.POISONED] += _poisonTunrs;
23+
Target.Effects[Effect.POISONED] += PoisonTunrs;
2124
}
2225
else
2326
{
24-
_target.Effects[Effect.POISONED] = _poisonTunrs;
27+
Target.Effects[Effect.POISONED] = PoisonTunrs;
2528
}
26-
_target.GetHealth().ChangeHealth(_poisonValue, _isAttacking);
29+
Target.GetHealth().ChangeHealth(PoisonValue, IsAttacking);
2730
}
2831

2932
public static int GetPoisonValue()
3033
{
31-
return _poisonValue;
34+
return PoisonValue;
3235
}
3336
}

Assets/Scripts/Animator/CastEnd.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
using System.Collections;
2-
using System.Collections.Generic;
3-
using UnityEngine;
1+
using UnityEngine;
42

3+
/// <summary>
4+
/// Класс для выхода из состояния анимации каста
5+
/// </summary>
56
public class CastEnd : StateMachineBehaviour
67
{
78
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)

Assets/Scripts/Animator/DeathRandom.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
using UnityEngine;
1+
using UnityEngine;
22

3+
/// <summary>
4+
/// Класс для определения анимации смерти
5+
/// </summary>
36
public class DeathRandom : StateMachineBehaviour
47
{
58
override public void OnStateMachineEnter(Animator animator, int stateMachinePathHash)

Assets/Scripts/Character.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System;
33
using UnityEngine;
44

5+
/// <summary>
6+
/// Класс для описания поведения персонажа
7+
/// </summary>
58
public class Character : MonoBehaviour, IHealthCange
69
{
710
public event Action<bool> OnDeath;

0 commit comments

Comments
 (0)