void OnTriggerEnter2D(Collider2D collision) { if (!LightSource.InLight(player.transform.position)) { PlayerData.Damage(GlobalConstants.enemyDamage); } }
// Update is called once per frame void Update() { if (LightSource.InLight(gameObject.transform.position)) { Destroy(gameObject); } }
// Update is called once per frame void Update() { if (PositionMath.playerInteractedWith(match.transform.position)) { Destroy(match); PlayerData.Matches++; return; } timePassed += Time.deltaTime; if (timePassed > GlobalConstants.MatchLifetime && !LightSource.InLight(transform.position)) { Destroy(match); return; } }
public static Vector3 findLocationToSpawn(int counter) { float x, y; x = Random.Range(-GlobalConstants.MapWidth, GlobalConstants.MapWidth); y = Random.Range(-GlobalConstants.MapHeight, GlobalConstants.MapHeight); Vector3 Position = new Vector3(x, y); if (!LightSource.InLight(Position) && (Position - getPlayerPosition()).magnitude > GlobalConstants.PlayerNoSpawnRange) { return(Position); } if (counter > 100) { return(Position); } return(findLocationToSpawn(counter + 1)); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { OnMouseDown(); } if ((target - player.transform.position).magnitude < GlobalConstants.PlayerStoppingDist) { rbody.velocity = Vector2.zero; player.GetComponent <SpriteRenderer> ().sprite = idle.GetComponent <SpriteRenderer> ().sprite; player.GetComponent <Animator> ().runtimeAnimatorController = idle.GetComponent <Animator> ().runtimeAnimatorController; } if (!LightSource.InLight(player.transform.position)) { PlayerData.Damage(GlobalConstants.playerDarkDPS * Time.deltaTime); } else { PlayerData.Heal(GlobalConstants.healthInLightDPS * Time.deltaTime); } }