Пример #1
0
    private void SendPawnHome(Pawn pawn)
    {
        HomePoint temp = pawn.owner.firstHomePoint;

        //find empty home spot
        while (temp.occupied != null && temp.next != null)
        {
            temp = (HomePoint)temp.next;
        }
        if (temp == null)
        {
            UnityEngine.Debug.LogError("SendPawnHome - HomePoint is null!");
            return;
        }
        //set current spot to free
        pawn.currentPos.occupied = null;
        ////set home spot to occupied
        //temp.occupied = this;
        //move pawn to position
        if (!pawn.Move(temp))
        {
            UnityEngine.Debug.LogError("SendPawnHome - Move home failed!");
        }
        Database.UpdatePawnData(pawn.data);
    }
Пример #2
0
    public void SetPawnsForStart()
    {
        if (firstHomePoint == null)
        {
            Debug.LogWarning("PlayerColor SetPawnsForStart() - firstPoint == null");
            return;
        }
        HomePoint home = firstHomePoint;

        foreach (Pawn p in pawns)
        {
            p.SetColor();
            p.Move(home);
            if (home.next != null)
            {
                home = (HomePoint)home.next;
            }
            Database.UpdatePawnData(p.data);
        }
    }
Пример #3
0
 private Position FindPosition(Pawn pawn)
 {
     //home positions are from -4 to -1
     if (pawn.data.currentPosId < 0 && pawn.data.currentPosId > -5)
     {
         HomePoint hp = pawn.owner.firstHomePoint;
         while (hp != null)
         {
             if (hp.id == pawn.data.currentPosId)
             {
                 return(hp);
             }
             hp = (HomePoint)hp.next;
         }
         UnityEngine.Debug.LogError("GameScene findPosition - Couldn't find home position from id");
         return(pawn.owner.firstHomePoint);
     }
     //finish positions are from -8 to -5
     else if (pawn.data.currentPosId < -4)
     {
         return(pawn.owner.finishPoints.Find(x => x.id == pawn.data.currentPosId));
     }
     return(allWaypoints.Find(x => x.id == pawn.data.currentPosId));
 }
Пример #4
0
        protected override bool OnUpdate(int tick)
        {
            // Detach special handling if the fairy's five-minute timer is up
            if (Fairy.ai[2] == 7)
            {
                return(false);
            }

            // Prevent despawning
            if (Fairy.ai[3] == 200)
            {
                Fairy.ai[3] = 16;
            }

            // Move toward the home point periodically (or when the player manages to hit us) so that
            // we don't get too far out of position
            if (tick % 360 == 0 || Fairy.life < Fairy.lifeMax)
            {
                Fairy.ai[3]     = -15;
                Fairy.velocity  = (HomePoint - Fairy.Center) * 0.1f;
                Fairy.life      = Fairy.lifeMax;
                Fairy.netUpdate = true;
            }

            // On collision, run the handler and then detach the special handling. We wait until the AI
            // has run for a second before we actually start trying to collide.
            if (OnCollision is object && tick > 60 && tick % 6 == 0)
            {
                var colliding = TShock.Players.Where(p => p is object && p.ConnectionAlive && p.TPlayer.Hitbox.Contains(HomePoint.ToPoint()));
                if (colliding.Any())
                {
                    colliding.ForEach(OnCollision);
                    return(false);
                }
            }

            return(true);
        }