public static void CreateObj(Type type, Vector3 pos, Vector3 ang, int clId, int uId) { //Create the go hl.Peer peer = hl.GetPeerForUID(clId); Obj obj = new Obj(); obj.type = type; obj.go = Instantiate(PrefabLibrary.GetPrefabForType(type)); obj.go.transform.position = pos; obj.go.transform.localEulerAngles = ang; obj.ownedByClId = clId; obj.uId = uId; obj.goal = pos; switch (type) { case Type.Marine: obj.isUnit = true; //This obj is a unit, and can be selected. //create selectionCircle obj.selectionCircle = (GameObject)Instantiate(xa.de.selectionCirclePrefab, pos, new Quaternion(0, 0, 0, 0)); obj.selectionCircle.transform.parent = obj.go.transform; obj.selectionCircle.transform.localPosition = Vector3.zero; obj.selectionCircle.SetActive(false); obj.textMesh = obj.go.GetComponentInChildren <TextMesh>(); obj.textMesh.text = ""; //uId: " + obj.uId + "\nClId: " + obj.ownedByClId; obj.go.GetComponent <Info>().uId = obj.uId; obj.animator = obj.go.GetComponent <Info>().animator; int[] cost = GetCostForType(type); obj.popCost = cost[0]; obj.moneyCost = cost[1]; obj.muntionsCost = cost[2]; obj.fuelCost = cost[3]; obj.priorityValue = 1; obj.health = 100; break; } objs.Add(obj); }
public static void CreateObj(Type type, Vector3 pos, Vector3 ang, int clId, int uId) { //Create the go Obj obj = new Obj(); obj.type = type; obj.go = (GameObject)Instantiate(PrefabLibrary.GetPrefabForType(type), pos, new Quaternion(0, 0, 0, 0)); obj.go.transform.localEulerAngles = ang; obj.ownedByClId = clId; obj.uId = uId; obj.goal = pos; switch (type) { case Type.CommandPod: obj.isUnit = true; //This obj is a unit, and can be selected. //create selectionCircle obj.selectionCircle = (GameObject)Instantiate(xa.de.selectionCirclePrefab, pos, new Quaternion(0, 0, 0, 0)); obj.selectionCircle.transform.parent = obj.go.transform; obj.selectionCircle.transform.localPosition = Vector3.zero; obj.selectionCircle.SetActive(false); obj.textMesh = obj.go.GetComponentInChildren <TextMesh>(); obj.textMesh.text = "uId: " + obj.uId + "\nClId: " + obj.ownedByClId; obj.go.GetComponent <Info>().uId = obj.uId; obj.mainBodyRenderers = obj.go.GetComponent <Info>().mainBodyRenderers; InitGrid(obj); CreateGridSqPrefabs(obj); Vector2 gridPos = GlobalPosToGridXY(obj, obj.go.transform.position); obj.gridPos = gridPos; //Debug.Log("GridPos: " + gridPos); RegisterOnGrid(obj, obj, gridPos); //Register this unit on its own grid TurnOffGrid(obj); //Turns off this grid, since it was probably created as visible. //TurnOnAllValidGridSquares(obj); break; case Type.HullBlock: obj.go.GetComponent <Info>().uId = obj.uId; obj.mainBodyRenderers = obj.go.GetComponent <Info>().mainBodyRenderers; obj.textMesh = obj.go.GetComponentInChildren <TextMesh>(); obj.textMesh.text = "gridXY"; break; case Type.Engine: obj.go.GetComponent <Info>().uId = obj.uId; obj.mainBodyRenderers = obj.go.GetComponent <Info>().mainBodyRenderers; obj.textMesh = obj.go.GetComponentInChildren <TextMesh>(); obj.textMesh.text = "gridXY"; break; case Type.Gun: obj.go.GetComponent <Info>().uId = obj.uId; obj.mainBodyRenderers = obj.go.GetComponent <Info>().mainBodyRenderers; obj.textMesh = obj.go.GetComponentInChildren <TextMesh>(); obj.textMesh.text = "gridXY"; obj.range = 15; obj.firingConeAngle = 15; break; } objs.Add(obj); }