public void StartGame() { for(int i=0; i<actorCount; ++i) { int rangeVal = Random.Range(0,actorTypes.Count); ActorType actorType = actorTypes[rangeVal]; Actor spawn = SpawnBoss.Instance.Spawn(actorType); spawn.OnDead += HandleDeadActor; if( captain == null && isControllable ) { captain = spawn; if( captain.brain != null ) { captain.brain.SetAI(isAI); } } else { grunts.Add(spawn); if( spawn.brain != null ) { spawn.brain.SetAI(true); } } } }
public void GotoWater(Actor focalActor) { controls.SetModeSurface(false); boatCamera.SetActiveFocus(false, focalActor); fishCamera.SetActiveFocus(true, focalActor); VectorLine.SetCamera3D(fishCamera.thisCamera); }
public void SetActiveFocus(bool val, Actor focalActor) { if( fish != null ) { fish.OnFacingChange = null; } Fish focalFish = focalActor as Fish; fish = focalFish; if( fish != null ) { fish.OnFacingChange = HandleFacingChange; target = fish.transform; } if( val ) { thisCamera.rect = focusRect; thisCamera.depth = 0; } else { thisCamera.rect = pipRect; thisCamera.depth = 1; } }
public void Despawn(Actor despawned) { Stack<GameObject> pool = poolDictionary[despawned.actorType]; despawned.gameObject.SetActive(false); despawned.transform.parent = this.transform; pool.Push(despawned.gameObject); despawned.AfterDespawn(); }
public override void Consume(Actor other) { int caughtWeight = other.weight; for(int i=other.attached.Count-1; i>=0; --i) { Actor child = other.attached[i]; caughtWeight += child.weight; base.Consume(child); } ModifyFood(caughtWeight); base.Consume(other); }
public void SetActiveFocus(bool val, Actor focalActor) { Boat focalBoat = focalActor as Boat; boat = focalBoat; if( val ) { thisCamera.rect = focusRect; thisCamera.depth = 0; } else { thisCamera.rect = pipRect; thisCamera.depth = 1; } }
public override void Consume(Actor other) { if( other != hook ) { return; } int caughtWeight = 0; for(int i=other.attached.Count-1; i>=0; --i) { Actor child = other.attached[i]; caughtWeight += child.weight; base.Consume(child); } if( caughtWeight > 0 || other.lifeTime > 2f ) { waitHookTimer.Reset(); ModifyFood(caughtWeight); hook = null; base.Consume(other); } }
void HandleDeadActor(Actor actor) { if( actor == captain ) { captainLives--; if( captainLives == 0 ) { Debug.Log("Game over"); } else { captain = SpawnBoss.Instance.Spawn(actor.actorType); if( captain.brain != null ) { captain.brain.SetAI(isAI); } } } else { grunts.Remove(actor); lives--; if( lives == 0 ) { Debug.Log("Dry"); } else { Actor spawn = SpawnBoss.Instance.Spawn(actor.actorType); grunts.Add(spawn); if( spawn.brain != null ) { spawn.brain.SetAI(true); } } } }
public Actor Spawn(Actor prototype) { return Spawn(prototype.actorType); }
public void RemoveActor(Actor actor) { allActors.Remove(actor); }
public virtual void HandleTrigger(Actor other, float offset) { if( other == null || !Utils.CanInteract(this, other)) { return; } if( CanEat(other) ) { Attach(other, offset); } }
public void Detach() { if( attachParent != null ) { attachParent.attached.Remove(this); this.attachParent = null; this.body.SetCollidable( !this.IsAttached ); } }
public virtual void Consume(Actor other) { other.attached.Clear(); SpawnBoss.Instance.Despawn(other); }
public bool CanEat(Actor other) { return other.weight >= eatWeightMin && other.weight <= eatWeightMax; }
public virtual void Attach(Actor other, float offset) { if( attached.Contains(other) ) { Debug.Log("double attach"); return; } attached.Add(other); other.attachParent = this; other.attachOffset = offset; other.body.SetCollidable( !other.IsAttached ); }
public static float FearDesire(Actor self, Actor other) { return other.CanEat(self) ? 6f : 0f; }
public static bool CanInteract(Actor a, Actor b) { return CanInteract(a.actorType, b.actorType); }
public static float FoodDesire(Actor self, Actor other) { return self.CanEat(other) ? 6f : 0f; }
public override void Attach(Actor other, float offset) { other.eatenTimer.Duration = eatSpeed; other.eatenTimer.Reset(); base.Attach(other, offset); }
public override void Attach(Actor other, float offset) { Consume(other); }
public static float FriendDesire(Actor self, Actor other) { return self.actorType == other.actorType ? 4f : 0f; }
public static float Range(Actor self, Actor other) { return (self.transform.position - other.transform.position).magnitude; }
public static Direction GetDirection(Actor self, Actor other) { Vector3 diff = other.transform.position - self.transform.position; float angle = Mathf.Atan2(diff.z, diff.y)*Mathf.Rad2Deg; if( angle < 0 ) { angle += 360; } if( angle < 30f) { return Direction.NORTH; } if( angle < 60f) { return Direction.NORTHEAST; } if( angle < 120f) { return Direction.EAST; } if( angle < 150f) { return Direction.SOUTHEAST; } if( angle < 210f) { return Direction.SOUTH; } if( angle < 240f) { return Direction.SOUTHWEST; } if( angle < 300f) { return Direction.WEST; } if( angle < 330f) { return Direction.NORTHWEST; } if( angle < 360f) { return Direction.NORTH; } return Direction.CENTER; }
public int AddActor(Actor actor) { allActors.Add(actor); return nextActorUID++; }