public void StartAction(GameController.Action action, float time, int objID) { currentAction = action; otherID = objID; inAction = 0; actionTimer = time; }
// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody2D>(); // you cannot use a RigidBody without accessing it on the object first started = 0; inAction = 1; actionTimer = 0; cargoID = -1; panelID = -1; otherID = -1; currentAction = GameController.Action.None; gameController = GameObject.Find("GameController").GetComponent <GameController>(); pressedAction = false; pressedMid = false; pressedHigh = false; }
// Update is called once per frame void Update() { Transform action = transform.GetChild(3); Transform actionText = transform.GetChild(4); GetInputs(); if (actionTimer > 0) { actionTimer -= Time.deltaTime; Color temp = action.GetComponent <SpriteRenderer>().color; temp.a = 255; action.GetComponent <SpriteRenderer>().color = temp; actionText.GetComponent <TextMeshPro>().alpha = 255; actionText.GetComponent <TextMeshPro>().text = "" + (int)actionTimer; } else { actionTimer = 0; inAction = 1; Color temp = action.GetComponent <SpriteRenderer>().color; temp.a = 0; action.GetComponent <SpriteRenderer>().color = temp; actionText.GetComponent <TextMeshPro>().alpha = 0; if (currentAction != GameController.Action.None) { if (otherID > -1) { gameController.LoadAction(currentAction, id, otherID); } else { gameController.LoadAction(currentAction, id); } currentAction = GameController.Action.None; } } }
public void StartAction(GameController.Action action, float time) { currentAction = action; inAction = 0; actionTimer = time; }