public static Color getColorFromGamaColor(GamaColor color) { Color newColor = new Color(); var bigint = (int)color.value; var r = (bigint >> 16) & 255; var g = (bigint >> 8) & 255; var b = bigint & 255; newColor.r = r; newColor.b = b; newColor.g = g; return(newColor); }
public static void getEntriesAttributes(Agent gamaAgent, XmlElement item) { float value = 0; float falpha = 0; string name = ""; XmlNodeList xml = item.GetElementsByTagName("entry"); foreach (XmlNode node in xml) { XmlNodeList listNode = node.ChildNodes; int nbr = 0; foreach (XmlNode n in listNode) { nbr++; switch (n.InnerText) { case "NATURE": gamaAgent.nature = listNode.Item(nbr).InnerText; break; case "rotation": gamaAgent.rotation = vector3FromXmlNode(item.ChildNodes); break; case "scale": gamaAgent.scale = vector3FromXmlNode(item.ChildNodes); break; case "type": gamaAgent.type = listNode.Item(nbr).InnerText; break; case "speed": gamaAgent.speed = float.Parse(listNode.Item(nbr).InnerText); break; case "height": gamaAgent.height = float.Parse(listNode.Item(nbr).InnerText); break; case "color": GamaColor color = new GamaColor(); XmlNode no = listNode.Item(nbr); Debug.Log("--> " + no.Name); XmlNode nodeValue = listNode.Item(nbr).ChildNodes[0]; Debug.Log("--> " + nodeValue.Name); XmlNode nodeAlpha = listNode.Item(nbr).ChildNodes[1]; Debug.Log("--> " + nodeAlpha.Name); Debug.Log("--> " + nodeAlpha.Value); Debug.Log("--> " + nodeAlpha.InnerText); Debug.Log("--> " + nodeAlpha.InnerXml); color.value = float.Parse(nodeValue.InnerText); color.falpha = float.Parse(nodeAlpha.InnerText); gamaAgent.color = color; break; default: break; } } } // gamaAgent.color = new GamaColor(value, falpha, name); }
public static void getEntriesAttributes(Agent gamaAgent, XmlElement item) { float value = 0; float falpha = 0; string name = ""; XmlNodeList xml = item.GetElementsByTagName(IGamaConcept.ITEM_ENTRY); foreach (XmlNode node in xml) { XmlNodeList listNode = node.ChildNodes; int nbr = 0; foreach (XmlNode n in listNode) { nbr++; switch (n.InnerText) { case IGamaConcept.ITEM_NATURE: gamaAgent.nature = listNode.Item(nbr).InnerText; break; case IGamaConcept.ITEM_ROTATION: gamaAgent.rotation = vector3FromXmlNode(item.ChildNodes); break; case IGamaConcept.ITEM_SCALE: gamaAgent.scale = vector3FromXmlNode(item.ChildNodes); break; case IGamaConcept.ITEM_TYPE: gamaAgent.type = listNode.Item(nbr).InnerText; break; case IGamaConcept.ITEM_SPEED: gamaAgent.speed = float.Parse(listNode.Item(nbr).InnerText); break; case IGamaConcept.ITEM_HEIGHT: gamaAgent.height = float.Parse(listNode.Item(nbr).InnerText); break; case IGamaConcept.ITEM_COLOR: GamaColor color = new GamaColor(); XmlNode no = listNode.Item(nbr); Debug.Log("--> " + no.Name); XmlNode nodeValue = listNode.Item(nbr).ChildNodes[0]; Debug.Log("--> " + nodeValue.Name); XmlNode nodeAlpha = listNode.Item(nbr).ChildNodes[1]; Debug.Log("--> " + nodeAlpha.Name); Debug.Log("--> " + nodeAlpha.Value); Debug.Log("--> " + nodeAlpha.InnerText); Debug.Log("--> " + nodeAlpha.InnerXml); color.value = float.Parse(nodeValue.InnerText); color.falpha = float.Parse(nodeAlpha.InnerText); gamaAgent.color = color; break; default: break; } } } }