コード例 #1
0
    public static bool controlledBySamePlayer(GameObject go1, GameObject go2)
    {//2022-02-10: copied from ownedBySamePlayer()
        //Get go1's team token
        TeamToken tt1 = go1.FindComponent <TeamToken>();
        //Get go2's team token
        TeamToken tt2 = go2.FindComponent <TeamToken>();

        //If both have a team token
        if (tt1 && tt2)
        {
            //easy, just compare their controllers
            return(tt1.controlledBySamePlayer(tt2));
        }
        //If neither has a team token
        else if (!tt1 && !tt2)
        {
            //not controlled at all
            return(false);
        }
        //If one or either has a team token, but not both
        else
        {
            //one's not controlled at all,
            //therefore not controlled by same player
            return(false);
        }
    }