Esempio n. 1
0
        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);
                    }
                }

            }
        }
Esempio n. 2
0
 public void GotoWater(Actor focalActor)
 {
     controls.SetModeSurface(false);
     boatCamera.SetActiveFocus(false, focalActor);
     fishCamera.SetActiveFocus(true, focalActor);
     VectorLine.SetCamera3D(fishCamera.thisCamera);
 }
Esempio n. 3
0
        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;
            }
        }
Esempio n. 4
0
 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();
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 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;
     }
 }
Esempio n. 7
0
 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);
     }
 }
Esempio n. 8
0
 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);
             }
         }
     }
 }
Esempio n. 9
0
 public Actor Spawn(Actor prototype)
 {
     return Spawn(prototype.actorType);
 }
Esempio n. 10
0
 public void RemoveActor(Actor actor)
 {
     allActors.Remove(actor);
 }
Esempio n. 11
0
 public virtual void HandleTrigger(Actor other, float offset)
 {
     if( other == null || !Utils.CanInteract(this, other))
     {
         return;
     }
     if( CanEat(other) )
     {
         Attach(other, offset);
     }
 }
Esempio n. 12
0
 public void Detach()
 {
     if( attachParent != null )
     {
         attachParent.attached.Remove(this);
         this.attachParent = null;
         this.body.SetCollidable( !this.IsAttached );
     }
 }
Esempio n. 13
0
 public virtual void Consume(Actor other)
 {
     other.attached.Clear();
     SpawnBoss.Instance.Despawn(other);
 }
Esempio n. 14
0
 public bool CanEat(Actor other)
 {
     return other.weight >= eatWeightMin && other.weight <= eatWeightMax;
 }
Esempio n. 15
0
 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 );
 }
Esempio n. 16
0
 public static float FearDesire(Actor self, Actor other)
 {
     return other.CanEat(self) ? 6f : 0f;
 }
Esempio n. 17
0
 public static bool CanInteract(Actor a, Actor b)
 {
     return CanInteract(a.actorType, b.actorType);
 }
Esempio n. 18
0
 public static float FoodDesire(Actor self, Actor other)
 {
     return self.CanEat(other) ? 6f : 0f;
 }
Esempio n. 19
0
 public override void Attach(Actor other, float offset)
 {
     other.eatenTimer.Duration = eatSpeed;
     other.eatenTimer.Reset();
     base.Attach(other, offset);
 }
Esempio n. 20
0
 public override void Attach(Actor other, float offset)
 {
     Consume(other);
 }
Esempio n. 21
0
 public static float FriendDesire(Actor self, Actor other)
 {
     return self.actorType == other.actorType ? 4f : 0f;
 }
Esempio n. 22
0
 public static float Range(Actor self, Actor other)
 {
     return (self.transform.position - other.transform.position).magnitude;
 }
Esempio n. 23
0
 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;
 }
Esempio n. 24
0
 public int AddActor(Actor actor)
 {
     allActors.Add(actor);
     return nextActorUID++;
 }