void Update() { Vector2 pos; TileNode next = aiMovement.NextNode(); if (next == null) { pos = new Vector2(aiMovement.transform.position.x, aiMovement.transform.position.y - 1.0f); } else { var size = aiMovement.tileSize; pos = new Vector2((float)next.x, -(float)next.y) * size; } if (Mathf.Abs(transform.position.y - lastYPos) > 0.01f || forceDownCount > 100) { sidewaysCount = 0; forceDownCount = 0; } else { sidewaysCount++; } lastYPos = transform.position.y; if (sidewaysCount > 100) { forceDownCount++; pos = new Vector2(aiMovement.transform.position.x, aiMovement.transform.position.y - 1.0f); } Vector2 direction = (pos - (Vector2)transform.position).normalized; direction.y = Mathf.Clamp(direction.y, -1, 0); drillAttackCooldown.Frequency = (1.0f / resources.DrillSpeed) * baseCooldown; UpdateDrillRotation(direction); if (drillAttackCooldown.Check(Time.time)) { DoDrillAttack(direction); } }
void Update() { Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 direction = (mousePosition - (Vector2)transform.position).normalized; direction.y = Mathf.Clamp(direction.y, -1, 0); drillAttackCooldown.Frequency = (1.0f / resources.DrillSpeed) * baseCooldown; UpdateDrillRotation(direction); bool drillButtonDown = Input.GetButton("Fire1"); if (drillAttackCooldown.Check(Time.time) && drillButtonDown) { DoDrillAttack(direction); } }
public void Punch(Vector2 dir) { if (punchCooldown == null) { punchCooldown = new Cooldown(missCooldownTime); } if (!punchCooldown.Check()) { return; } if (gameObject.activeSelf) { return; } // fx and stuff gameObject.SetActive(true); punchCooldown.SetCooldown(missCooldownTime); StartCoroutine(ExtendFist(dir)); }
private void Update() { //check cooldown speakCD.Check(); playSoundCD.Check(); //check position if (Vector3.Distance(transform.position, transform.parent.position) > 200) { ResetPosition(); } //check neighbors foreach (GameObject t in ThingManager.main.AllThings) { float dist = Vector3.Distance(transform.position, t.transform.position); if (dist < settings.neighborDetectorRadius) { if (!neighborList.Contains(t)) { neighborList.Add(t); OnMeetingSomeone(t); } } else { if (neighborList.Contains(t)) { neighborList.Remove(t); OnLeavingSomeone(t); } } } TTTUpdate(); }
void Update() { talkCDer.Check(); sparkCDer.Check(); }