public void FinalizeLasers(float speed, Material isl_material) { // Turn off lasers that are no longer assigned to the same target for (int lc = 0; lc < maxlasers; lc++) { if (laseron [lc]) { if (!IsAssigned(laserdsts [lc])) { // laser will need to be reassigned laseron[lc] = false; } } } for (int i = 0; i < assignedcount; i++) { SatelliteSP0031 sat = assignedsats [i]; if (!WasAssigned(sat)) { /* destination is a new one - find a laser */ int lasernum = FindFreeLaser(); laseron [lasernum] = true; lasertimes [lasernum] = Time.time; laserdsts [lasernum] = sat; LaserScript ls = (LaserScript)lasers [lasernum].GetComponent(typeof(LaserScript)); ls.SetMaterial(isl_material); } } int oncount = 0; for (int lc = 0; lc < maxlasers; lc++) { if (laseron [lc]) { oncount++; LaserScript ls = (LaserScript)lasers [lc].GetComponent(typeof(LaserScript)); Debug.Assert(this != laserdsts [lc]); if (position() == laserdsts [lc].position()) { Debug.Log("Same pos"); Debug.Log("Me: " + satid.ToString() + " Him: " + laserdsts [lc].satid.ToString()); Debug.Log("My pos: " + position().ToString() + " His pos: " + laserdsts [lc].position().ToString()); } Debug.Assert(position() != laserdsts [lc].position()); ls.SetPos(position(), laserdsts [lc].position()); //ls.SetMaterial (isl_material); } else { LaserScript ls = (LaserScript)lasers [lc].GetComponent(typeof(LaserScript)); ls.SetPos(position(), position()); } } }
bool IsPreAssigned(SatelliteSP0031 s) { for (int i = 0; i < preassignedcount; i++) { if (preassignedsats [i] == s) { return(true); } } return(false); }
bool PreAssign(SatelliteSP0031 s) { if (preassignedcount == LASERS_PER_SAT || s.preassignedcount == LASERS_PER_SAT || IsPreAssigned(s)) { return(false); } Debug.Assert(s.IsPreAssigned(this) == false); SimplePreAssign(s); s.SimplePreAssign(this); return(true); }
public void ColourLink(SatelliteSP0031 nextsat, Material mat) { for (int lc = 0; lc < maxlasers; lc++) { if (laseron [lc]) { if (laserdsts [lc] == nextsat) { LaserScript ls = (LaserScript)lasers [lc].GetComponent(typeof(LaserScript)); ls.SetMaterial(mat); } } } }
bool PreAssign(SatelliteSP0031 s) { if (preassignedcount == LASERS_PER_SAT || s.preassignedcount == LASERS_PER_SAT || IsPreAssigned(s)) { return(false); } Debug.Assert(s.IsPreAssigned(this) == false); if (log_choice == LogChoice.LaserDists) { logfile.WriteLine("dist: " + Dist(s)); logfile.Flush(); } SimplePreAssign(s); s.SimplePreAssign(this); return(true); }
public void SimplePreAssign(SatelliteSP0031 s) { preassignedsats [preassignedcount] = s; preassignedcount++; }
public void SimpleAssign(SatelliteSP0031 s) { assignedsats [assignedcount] = s; assignedcount++; }
public float Dist(SatelliteSP0031 s) { return(Vector3.Distance(position(), s.position())); }
public void AddSat(SatelliteSP0031 newsat) { nearestsats[nearestcount] = newsat; nearestcount++; }