-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControlMgr.cs
43 lines (35 loc) · 1.45 KB
/
ControlMgr.cs
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ControlMgr : MonoBehaviour
{
public static ControlMgr inst;
private void Awake()
{
inst = this;
}
// Start is called before the first frame update
void Start()
{
}
public float deltaSpeed = 1;
public float deltaHeading = 2;
// Update is called once per frame
void Update()
{
if (SelectionMgr.inst.selectedEntity != null) {
if (Input.GetKeyUp(KeyCode.UpArrow))
SelectionMgr.inst.selectedEntity.desiredSpeed += deltaSpeed;
if (Input.GetKeyUp(KeyCode.DownArrow))
SelectionMgr.inst.selectedEntity.desiredSpeed -= deltaSpeed;
SelectionMgr.inst.selectedEntity.desiredSpeed =
Utils.Clamp(SelectionMgr.inst.selectedEntity.desiredSpeed, SelectionMgr.inst.selectedEntity.minSpeed, SelectionMgr.inst.selectedEntity.maxSpeed);
if (Input.GetKeyUp(KeyCode.LeftArrow))
SelectionMgr.inst.selectedEntity.desiredHeading -= deltaHeading;
if (Input.GetKeyUp(KeyCode.RightArrow))
SelectionMgr.inst.selectedEntity.desiredHeading += deltaHeading;
SelectionMgr.inst.selectedEntity.desiredHeading = Utils.Degrees360(SelectionMgr.inst.selectedEntity.desiredHeading);
}
}
//------------------------------------------
}