示例#1
0
文件: User.cs 项目: threeup/threefish
        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);
                    }
                }

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