Пример #1
0
    //判断两个对象是否是分身关系
    public bool isCopyRelation(GameObject other)
    {
        if (this.gameObject.tag == "playerCopy" && other.tag == "player")
        {
            PlayerCopyController copyController = other.GetComponent <PlayerCopyController>();

            if (copyController == null)
            {
                return(false);
            }
            if (copyController.getPlayerCopy() == this.gameObject)
            {
                return(true);
            }
        }
        else if (this.gameObject.tag == "player" && other.tag == "playerCopy")
        {
            PlayerCopyController copyController = this.gameObject.GetComponent <PlayerCopyController>();
            if (copyController == null)
            {
                return(false);
            }
            if (copyController.getPlayerCopy() == other)
            {
                return(true);
            }
        }

        return(false);
    }
Пример #2
0
 protected override void DetectPlayers(float detectDistance)
 {
     playersDetected.Clear();
     Collider[] colliders = Physics.OverlapSphere(gameObject.transform.position, playerDetectDistance);
     foreach (Collider collider in colliders)
     {
         PlayerCopyController copyJudge = collider.gameObject.GetComponent <PlayerCopyController>();
         if (copyJudge != null)
         {
             if (copyJudge.getPlayerCopy() == gameObject)
             {
                 continue;
             }
         }
         //if (player.isCopyRelation(collider.gameObject))
         //    continue;
         if (collider.gameObject.CompareTag("player"))
         {
             playersDetected.Add(collider.gameObject);
         }
     }
 }