void Update() { hit = Physics2D.Linecast(transform.position, PlayerController.PlayerPosition, layerMask); if (hit.collider.tag == "Wall" || (hit.collider.tag == "Player" && hit.distance > detectionRadius)) { if (detectedPlayer) { detectedPlayer = false; if (attack) { attack.StopShooting(); } animate.AnimateToColor(Palette.EnemyColor, color, .3f); } return; } else { if (!detectedPlayer) { detectedPlayer = true; if (attack) { attack.StartShooting(); } animate.AnimateToColor(color, Palette.EnemyColor, .1f); } } }
void Update() { RaycastHit2D hit = Physics2D.Linecast(transform.position, PlayerController.PlayerPosition, layerMask); if (hit.collider.tag == "Wall" || (hit.collider.tag == "Player" && hit.distance > detectionRadius)) { MoveToStart(); if (detectedPlayer) { detectedPlayer = false; animate.AnimateToColor(Palette.EnemyColor, Color.yellow, .3f); } return; } else { MoveToPlayer(); if (!detectedPlayer) { detectedPlayer = true; animate.AnimateToColor(Color.yellow, Palette.EnemyColor, .1f); if (!shooting) { StartCoroutine("Co_Shoot"); } } } }
public void Die() { ResourceManager.self.PlaySound(SFX.birdCall); GameObject.Instantiate(featherVfx, transform.position, Quaternion.identity); timeSinceLastMessage = -999f; model.pigeon.sprite = ResourceManager.self.GetPigeonSprite(playerIndex, PigeonPose.Hurt); ResetVisuals(); animate.AnimateToColor(model.pigeon.color, Color.red, 5.0f, Animate.RepeatMode.Once); Invoke("DestroySelf", 2.0f); onDeath(this); }
public void EnactRoutine() { currentColor.a -= .05f; playbackRate -= .1f; if (playbackRate <= 0) { Destroy(this.gameObject); } active = true; positionIndex = 0; transform.position = new Vector3(positions [positionIndex], positions [positionIndex + 1], 0); animate.AnimateToColor(Palette.Invisible, currentColor, .3f); }
public void Initialize(GhostAIStats stats) { this.stats = stats; stats.self = this; NotificationMaster.playerObservers.Add(this); float aggro = stats.Aggressiveness(); if (aggro > 0) { attack = gameObject.AddComponent <GhostAttack>(); GetComponent <GhostAttack> ().Initialize(stats); } movement = gameObject.GetComponent <GhostMovement>(); movement.Initialize(stats); detectionRadius = Room.bounds.extents.x; transform.localScale = new Vector3(stats.size, stats.size, 1); size = GetComponent <SpriteRenderer>().bounds.extents; transform.position = movement.GetSpawnPosition(size); movement.startPosition = transform.position; layerMask = 1 << LayerMask.NameToLayer("Wall") | 1 << LayerMask.NameToLayer("Player"); GetComponent <SpriteRenderer>().sortingOrder = (int)(1.0f / size.magnitude * 1000); AdjustColors(aggro); animate = GetComponent <Animate>(); animate.AnimateToColor(Palette.Invisible, color, .3f); }
void Start() { detectionRadius = Room.bounds.extents.x; size = GetComponent <SpriteRenderer>().bounds.extents; startPosition = GetSpawnPosition(); transform.position = startPosition; layerMask = 1 << LayerMask.NameToLayer("Wall") | 1 << LayerMask.NameToLayer("Player"); animate = GetComponent <Animate>(); animate.AnimateToColor(Palette.Invisible, Color.yellow, .3f); }
private void SpawnPlayer() { _velocity = new Vector2(); inputDisabled = true; GetComponent <SpriteRenderer>().color = Palette.Invisible; /*Vector3 newPosition = Vector3.zero; * RaycastHit2D hit; * // Uhh this is hacky but whatever * for(int i = 0; i < 5; i++) { * hit = Physics2D.Linecast (transform.position + new Vector3(0, playerExtents.y, 0), newPosition - new Vector3(0, playerExtents.y * 2, 0), 1 << LayerMask.NameToLayer("Wall")); * if (hit.collider) { * newPosition.y = hit.transform.position.y + hit.transform.GetComponent<SpriteRenderer> ().bounds.extents.y + playerExtents.y; * transform.position = newPosition; * break; * } * }*/ _animate.AnimateToColor(Palette.Invisible, Palette.PlayerColor, .5f); Invoke("EnableInput", .5f); }