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); }
//private Animate animate; public void Start() { timeOpened = Time.time; ghostStats = new GhostAIStats(); NotificationMaster.restartObservers.Add(this); NotificationMaster.ghostDeathObservers.Add(this); NotificationMaster.playerActionObservers.Add(this); //animate = GetComponent <Animate>(); Vector3 point; float distance, minDistance; do { point = Room.GetRandomPointInRoom(); distance = Vector2.Distance(PlayerController.PlayerPosition, point); minDistance = 2.0f; } while (distance < minDistance); transform.position = point; StartCoroutine("C_AnimateSize"); }
public static void SendGhostDeathNotification(GhostAIStats stats) { List <IGhostDeathObserver> toRemove = new List <IGhostDeathObserver> (); foreach (IGhostDeathObserver o in ghostDeathObservers) { if (o.Equals(null)) { toRemove.Add(o); } else { o.GhostDied(stats); } } ghostDeathObservers = ghostDeathObservers.Except(toRemove).ToList(); }
public void SpawnGhost(GhostAIStats stats) { GameObject ghost; if (stats.airTime > .5f) { ghost = GameObject.Instantiate(p_ghost_air); ghost.AddComponent <GhostMovement_Fly>(); } else { ghost = GameObject.Instantiate(p_ghost_ground); ghost.AddComponent <GhostMovement>(); } ghost.transform.SetParent(transform); ghost.GetComponent <GhostAI>().Initialize(stats); children.Add(ghost.GetComponent <GhostAI>()); }
public void Start() { timeOpened = Time.time; ghostStats = new GhostAIStats(); ps = GetComponent <ParticleSystem>(); boxCollider = GetComponent <BoxCollider2D>(); NotificationMaster.restartObservers.Add(this); NotificationMaster.ghostDeathObservers.Add(this); NotificationMaster.playerActionObservers.Add(this); psSizeCurve = new AnimationCurve(); psSizeCurve.AddKey(0.0f, 0.0f); psSizeCurve.AddKey(1.0f, 1.0f); purpleColor = new Color(.4f, 0.0f, 1.0f); gradient = new Gradient(); alphaKeys = new GradientAlphaKey[] { new GradientAlphaKey(1.0f, 0.0f), new GradientAlphaKey(0.0f, 1.0f) }; Vector3 point; float distance, minDistance = 2.0f; RaycastHit2D hit; do { point = Room.GetRandomPointInRoom(); hit = Physics2D.Raycast(point, Vector3.back, 5.0f, 1 << LayerMask.NameToLayer("Wall")); if (hit.collider) { continue; } distance = Vector2.Distance(PlayerController.PlayerPosition, point); } while (distance < minDistance); transform.position = point; StartCoroutine("C_AnimateSize"); }
public void Initialize(GhostAIStats stats) { aggression = stats.Aggressiveness(); chaseSpeed *= ((aggression + .5f) / 2.0f); }
public void GhostDied(GhostAIStats ghost) { children.Remove(ghost.self); }
public void GhostDied(GhostAIStats stats) { ghostStats.ghostsKilled++; ghostStats.killedGhostAggressiveness += stats.Aggressiveness(); }
public void Initialize(GhostAIStats stats) { float aggro = stats.Aggressiveness(); shootCooldown = (1.5f - aggro) * 2; }