Пример #1
0
 public static void ClearAffectedList()
 {
     foreach (GameObject go in AffectedParts)
     {
         go.GetComponent <ConnectionScanning>().enabled = false;
         go.GetComponent <MeshRenderer>().material      = UnaffectedMat;
         go.GetComponent <PartBehaviour>().enabled      = false;
         go.GetComponent <ConstantForce>().force        = Vector3.zero;
     }
     FreeParts.AddRange(AffectedParts);
     AffectedParts.Clear();
 }
Пример #2
0
    public static List <GameObject> ChangeAffectedNumber(int num)
    {
        CompareObjectDistance compDist = new CompareObjectDistance();
        Comparer <GameObject> defComp  = compDist;

        if (num - 1 > affectedParts.Count)
        {
            freeParts.Sort(compDist);

            List <GameObject> transition = new List <GameObject>();
            foreach (GameObject go in freeParts)
            {
                if (num - 1 >= affectedParts.Count)
                {
                    if (typeFilter.ContainsKey(go.GetComponent <Part>().TemplateID))//TypeFilter.Contains(go.GetComponent<Part>().Name))
                    {
                        AffectPart(go);
                        transition.Add(go);
                    }
                }
                else
                {
                    break;
                }
            }
            foreach (GameObject go in transition)
            {
                freeParts.Remove(go);
            }
        }
        else
        {
            affectedParts.Sort(compDist);

            for (int i = affectedParts.Count - 1; i >= 0; --i)
            {
                if (num < affectedParts.Count)
                {
                    GameObject go = affectedParts[i];
                    go.GetComponent <ConnectionScanning>().enabled = false;
                    go.GetComponent <PartBehaviour>().enabled      = false;
                    go.GetComponent <MeshRenderer>().material      = MaterialHolder.UnaffectedMat;
                    go.GetComponent <ConstantForce>().force        = Vector3.zero;
                    affectedParts.Remove(go);
                    FreeParts.Add(go);
                }
            }
        }

        return(affectedParts);
    }
Пример #3
0
    public static void ClearAffectedList()
    {
        for (int i = AffectedParts.Count - 1; i >= 0; --i)
        {
            GameObject go = AffectedParts[i];

            if (go == null)
            {
                AffectedParts.RemoveAt(i);
                continue;
            }

            go.GetComponent <ConnectionScanning>().enabled = false;
            go.GetComponent <MeshRenderer>().material      = MaterialHolder.UnaffectedMat;
            go.GetComponent <PartBehaviour>().enabled      = false;
            go.GetComponent <ConstantForce>().force        = Vector3.zero;
        }
        FreeParts.AddRange(AffectedParts);
        AffectedParts.Clear();
    }