private void RemoveMemoryLocation(int index) { Debug.Log("Layer " + absoluteLayerNumber + ": Removing element at index=" + index); // get a reference to the location to be removed MemoryElementController elem = memoryLocations[index]; // remove it from the list memoryLocations.RemoveAt(index); // delete it's game object Destroy(elem.gameObject); //resort the list memoryLocations.Sort(); memoryLocations.TrimExcess(); }
/* Method to animate a packet from the above layer to this layer */ public void AnimateRequest(int address) { // Animate a packet going between the two layers // Create a new packet object at the location of the above memory layer MemoryElementController packet = Instantiate <GameObject>(packetPrefab).GetComponent <MemoryElementController>(); packet.transform.SetPositionAndRotation(transform.position, transform.rotation); packet.Address = address; // set the packet source, destination and speed packet.sourceLayer = this; packet.destinationLayer = layerBelow; packet.sourcePoint = GetPositionOfElement(address); packet.transform.position = packet.sourcePoint; packet.destinationPoint = layerBelow.GetPositionOfElement(address); packet.speed = layerLatency; }
public void AddMemoryLocation(int address) { // check if the layer is full if (memoryLocations.Count >= size) { Debug.Log("Layer " + absoluteLayerNumber + ": Cache full removing element"); //remove an element RemoveMemoryLocation(); } //create the address element MemoryElementController packet = Instantiate <GameObject>(packetPrefab).GetComponent <MemoryElementController>(); packet.Address = address; //add the new element memoryLocations.Add(packet); //set the position of the new element int pos = CheckForAddress(address); Debug.Log("Layer " + absoluteLayerNumber + " Creating element object at index:" + pos + " for address=" + address); packet.transform.SetPositionAndRotation(GetPositionOfElement(address), transform.rotation); }