private GameObject GetUnityObject(InstanceSpecification host) { Entity entity = host as Entity; if (entity != null) { UnityShapeSpecification shape = entity.ActiveShape as UnityShapeSpecification; if (shape != null) { return(shape.EntityGO); } } else { // We have to check if it is an Virtual Human. VirtualHuman human = host as VirtualHuman; entity = human.Body as Entity; if (entity != null) { UnityShapeSpecification shape = entity.ActiveShape as UnityShapeSpecification; if (shape != null) { return(shape.EntityGO); } } } return(null); }
public override void init(Behavior specif, InstanceSpecification host, Dictionary <string, ValueSpecification> p, bool sync) { base.init(specif, host, p, sync); ui = GameObject.Find("Canvas").GetComponent <EE_UI>(); if (Host.name == "PlayerAuto") { agent = GameObject.Find("Player").GetComponent <AgentController>(); } else { agent = GameObject.Find(Host.name).GetComponent <AgentController>(); } foreach (KeyValuePair <string, ValueSpecification> kvp in p) { if (kvp.Key == "Animation") { animation = stringUtils.CleanString(kvp.Value.getStringFromValue()); } } PrintSingleton.Instance.log("==================================== PLAY ANIMATION =========================================="); PrintSingleton.Instance.log(agent.name + " --> " + animation); }
public static void sendSignal(string signalName, InstanceSpecification target) { SendSignalAction action = new SendSignalAction(); action.SignalClass = new Signal(signalName); //string target = "broadcast"; //take any entitty to send the message List <Entity> entities = MascaretApplication.Instance.getEnvironment().getEntities(); Entity entity = entities[0]; foreach (Entity e in entities) { if (e != null) { entity = e; break; } } Action action2 = null; if (action.GetType().ToString() == "Mascaret.SendSignalAction" && target != null) { PrintSingleton.Instance.log("############################ SEND SIGNAL : " + action.SignalClass.name + " to " + target.name + " which is a " + target.Classifier.name); Signal signalC = ((SendSignalAction)(action)).SignalClass; InstanceSpecification signal = new InstanceSpecification(signalC.name, signalC); action2 = new SendSignalAction(); ((SendSignalAction)(action2)).SignalClass = ((SendSignalAction)(action)).SignalClass; ((SendSignalAction)(action2)).Target = new SendSignalTarget(); ((SendSignalAction)(action2)).Target.target = target; ((SendSignalAction)(action2)).Signal = signal; } BehaviorScheduler.Instance.executeBehavior(action2, entity, new Dictionary <string, ValueSpecification>(), false); }
public override void init(Behavior specif, InstanceSpecification host, Dictionary <string, ValueSpecification> p, bool sync) { base.init(specif, host, p, sync); webCom = GameObject.Find("webglCom").GetComponent <webGLCommunication>(); ui = GameObject.Find("Canvas").GetComponent <EE_UI>(); PrintSingleton.Instance.log("==================================== FINAL OPERATION =========================================="); }
public OSDWindow(string entityName) { //this.indice = indice; this.entityName = entityName; mascaret = VRApplication.Instance; Environment env = mascaret.getEnvironment(); InstanceSpecification instance = env.getInstance(this.entityName); Dictionary <string, Slot> ss = instance.Slots; first = true; values = new string[ss.Count]; }
public override void init(Behavior specif, InstanceSpecification host, Dictionary <string, ValueSpecification> p, bool sync) { base.init(specif, host, p, sync); ui = GameObject.Find("Canvas").GetComponent <EE_UI>(); if (Host.name == "PlayerAuto") { agent = GameObject.Find("Player").GetComponent <AgentController>(); } else { agent = GameObject.Find(Host.name).GetComponent <AgentController>(); } foreach (KeyValuePair <string, ValueSpecification> kvp in p) { if (kvp.Key == "Message") { message = stringUtils.CleanString(kvp.Value.getStringFromValue()); } else if (kvp.Key == "Specification") { specification = cleanSpec(stringUtils.CleanString(kvp.Value.getStringFromValue())); } } if (message != "") { string[] s = message.Split('_'); if (stringUtils.checkStringStart(s[0], "AUDIO:", out audioName)) { audioplay = true; message = s[1]; } else { message = s[0]; } } PrintSingleton.Instance.log("====================================SPEAK=========================================="); PrintSingleton.Instance.log(agent.name + " --> " + message); if (agent is AndroidController) { PrintSingleton.Instance.log("STRATEGY --> " + specification); ui.CurrentECAStrategy = specification; } }
public static void OnPlanetChange() { @is = new InstanceSpecification(); @is.Header.Name = "Tournament Creator"; @is.Header.Summary = "Create custom tournament style matches."; @is.Header.Type = (InstanceType)4; @is.Header.CommonSettings.AvatarAvailability = (AvatarAvailability)1; @is.Header.CommonSettings.AvatarDamage = (AvatarDamage)1; @is.Header.CommonSettings.ConstructableCleanUp = 0; //@is.Header.CommonSettings.ConstructableCleanUpSettings.ConstructableCleanUp = 0; @is.Header.CommonSettings.HeartStoneRequirement = 0; @is.Header.CommonSettings.BuildModeRules = (BuildModeRules)1; @is.Header.CommonSettings.SavingOptions = 0; @is.Header.CommonSettings.BlueprintSpawningOptions = (BlueprintSpawningOptions)5; @is.Header.CommonSettings.EnemyBlockDestroyedResourceDrop = 0f; @is.Header.CommonSettings.LocalisedResourceMode = 0; @is.Header.CommonSettings.FogOfWarType = (FogOfWarType)1; @is.Header.CommonSettings.DesignerOptions = 0; @is.Header.CommonSettings.LuckyMechanic = (LuckyMechanic)1; Planet.i.Designers.AddInstance(@is); FactionSpecifications i = FactionSpecifications.i; FactionSpecificationFaction val = new FactionSpecificationFaction(); val.Name = "KING"; val.AbreviatedName = "KING"; val.FleetColors = (Color[])new Color[4] { new Color(1f, 0.843137264f, 0f, 0.5f), new Color(0.854901969f, 0.647058845f, 0.1254902f, 0.5f), new Color(1f, 0.647058845f, 0f, 0.5f), new Color(0.854901969f, 0.549019635f, 0f, 0.5f) }; i.AddNew(val); FactionSpecifications i2 = FactionSpecifications.i; FactionSpecificationFaction val2 = new FactionSpecificationFaction(); val2.Name = "CHAL"; val2.AbreviatedName = "CHAL"; val2.FleetColors = (Color[])new Color[4] { new Color(1f, 0f, 0f, 0.5f), new Color(0.545098066f, 0f, 0f, 0.5f), new Color(0.698039234f, 0.13333334f, 0.13333334f, 0.5f), new Color(1f, 0.3882353f, 0.2784314f, 0.5f) }; i2.AddNew(val2); //get id ? }
public override void init(Behavior specif, InstanceSpecification host, Dictionary <string, ValueSpecification> p, bool sync) { base.init(specif, host, p, sync); agent = (Agent)host; ui = GameObject.Find("Canvas").GetComponent <EE_UI>(); ui.DecisionAgent = agent; if (agent.name == "PlayerAuto") { ui.DecisionAgent = MascaretUtils.getAgent("Player"); } agentC = GameObject.Find(ui.DecisionAgent.name).GetComponent <AgentController>(); ui = GameObject.Find("Canvas").GetComponent <EE_UI>(); }
public override void init(Behavior specif, InstanceSpecification host, Dictionary <string, ValueSpecification> p, bool sync) { base.init(specif, host, p, sync); android = GameObject.Find(host.name).GetComponent <AndroidController>(); foreach (KeyValuePair <string, ValueSpecification> kvp in p) { if (kvp.Key == "Expression") { expression = stringUtils.CleanString(kvp.Value.getStringFromValue()); } } ui = GameObject.Find("Canvas").GetComponent <EE_UI>(); PrintSingleton.Instance.log("==================================== SET FACIAL EXPRESSION ========================================== " + expression); ui.CurrentECAEmotion = expression; }
public override void init(Behavior specif, InstanceSpecification host, Dictionary <string, ValueSpecification> p, bool sync) { base.init(specif, host, p, sync); webCom = GameObject.Find("webglCom").GetComponent <webGLCommunication>(); //0_Flirt,Encourage,Direction_}" foreach (KeyValuePair <string, ValueSpecification> kvp in p) { if (kvp.Key == "Message") { message = stringUtils.CleanString(kvp.Value.getStringFromValue()); } else if (kvp.Key == "Specification") { specification = cleanSpec(stringUtils.CleanString(kvp.Value.getStringFromValue())); } } }
public static void OnPlanetChange() { @is = new InstanceSpecification(); @is.Header.Name = "Tournament Creator"; @is.Header.Summary = "Create custom tournament style matches."; @is.Header.Type = InstanceType.None; @is.Header.CommonSettings.AvatarAvailability = AvatarAvailability.None; @is.Header.CommonSettings.AvatarDamage = AvatarDamage.Off; @is.Header.CommonSettings.ConstructableCleanUp = ConstructableCleanUp.Off; @is.Header.CommonSettings.HeartStoneRequirement = HeartStoneRequirement.None; @is.Header.CommonSettings.BuildModeRules = BuildModeRules.Disabled; @is.Header.CommonSettings.SavingOptions = SavingOptions.None; @is.Header.CommonSettings.BlueprintSpawningOptions = BlueprintSpawningOptions.NoNewVehicles; @is.Header.CommonSettings.EnemyBlockDestroyedResourceDrop = 0f; @is.Header.CommonSettings.LocalisedResourceMode = LocalisedResourceMode.UseCentralStore; @is.Header.CommonSettings.FogOfWarType = FogOfWarType.None; @is.Header.CommonSettings.DesignerOptions = DesignerOptions.Off; @is.Header.CommonSettings.LuckyMechanic = LuckyMechanic.Off; @is.Header.CommonSettings.WarpAbility = WarpAbility.Off; FactionSpecifications.i.AddNew(new FactionSpecificationFaction { Name = "King", AbreviatedName = "K", FleetColors = new Color[] { new Color(1f, 0.84f, 0f, 0.75f), //gold new Color(0.85f, 0.65f, 0.13f, 0.75f), //goldenrod new Color(1f, 0.65f, 0f, 0.75f), //orange new Color(0.85f, 0.55f, 0f, 0.75f) //brown-orange? } }); FactionSpecifications.i.AddNew(new FactionSpecificationFaction { Name = "Challenger", AbreviatedName = "C", FleetColors = new Color[] { new Color(1f, 0f, 0f, 0.75f), //red new Color(0.55f, 0f, 0f, 0.75f), //dark red new Color(0.7f, 0.13f, 0.13f, 0.75f), //fire brick new Color(1f, 0.39f, 0.23f, 0.75f) //tomato } }); Planet.i.Designers.AddInstance(@is); }
private BehaviorExecution GetUnityBehaviourExecution(string typeName, InstanceSpecification host, Dictionary <string, ValueSpecification> p) { BehaviorExecution be = null; // Get the Class and Method names string[] split = typeName.Split('_'); if (split.Length != 2) { return(be); } string className = split[0]; string methodName = split[1]; GameObject unityObject = this.GetUnityObject(host); if (unityObject == null) { return(be); } Component comp = unityObject.GetComponent(className); if (comp == null) { return(be); } Type t = Type.GetType(className); MethodInfo m = t.GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance); be = new UnityBehaviorExecution(comp, m); MethodInfo init = t.GetMethod("AddBehaviorExecution", BindingFlags.Public | BindingFlags.Instance); object[] initparams = new object[] { methodName, be }; init.Invoke(comp, initparams); return(be); }
void DoMyWindow(int windowID) { const int kPropertyNameColumnWidth = 150; const int kValueColumnWidth = 50; const int kBoxHeight = 100; const int kBoxWidth = kPropertyNameColumnWidth + kValueColumnWidth + 30; Environment env = mascaret.getEnvironment(); InstanceSpecification instance = env.getInstance(this.entityName); Dictionary <string, Slot> ss = instance.Slots; // Wrap everything in the designated GUI Area GUILayout.BeginArea(new Rect(15, 17, kBoxWidth, kBoxHeight)); scrollPosition = GUILayout.BeginScrollView(scrollPosition, "", GUILayout.Width(kBoxWidth), GUILayout.Height(kBoxHeight)); GUILayout.BeginVertical(); int xx = 0; foreach (KeyValuePair <string, Slot> s in ss) { string propertyName = s.Value.DefiningProperty.name; //values[xx] = ""; string type = s.Value.DefiningProperty.Type.name; PrintSingleton.Instance.log(propertyName + " is " + type); if (type == "real" || type == "string" || type == "integer" || type == "boolean") { if (type == "real") { LiteralReal r = (LiteralReal)(s.Value.getValue()); double v = r.RValue; if (first) { values[xx] = v.ToString(); } } else if (type == "string") { LiteralString st = (LiteralString)(s.Value.getValue()); string v = st.SValue; if (first) { values[xx] = v; } } else if (type == "integer") { LiteralInteger i = (LiteralInteger)(s.Value.getValue()); int v = i.IValue; if (first) { values[xx] = v.ToString(); } } else if (type == "boolean") { LiteralBoolean b = (LiteralBoolean)(s.Value.getValue()); bool v = b.BValue; if (first) { values[xx] = v.ToString(); } } GUILayout.BeginHorizontal(); GUILayout.Label(propertyName, GUILayout.Width(kPropertyNameColumnWidth)); values[xx] = GUILayout.TextField(values[xx], 25, GUILayout.Width(kValueColumnWidth)); if (type == "real") { s.Value.addValue(new LiteralReal(values[xx])); } xx++; GUILayout.EndHorizontal(); } } GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndArea(); GUI.DragWindow(new Rect(0, 0, 10000, 10000)); first = false; }
public override BehaviorExecution InstanciateOpaqueBehavior(Mascaret.Behavior behavior, string typeName, InstanceSpecification host, Dictionary <string, ValueSpecification> p) { //Type type = Types. GetType( typeName,"Assembly-CSharp"); Type type = Type.GetType(typeName); BehaviorExecution be = null; if (type != null) { be = (BehaviorExecution)(Activator.CreateInstance(type)); } // Use the Unity Monobehaviour method else { be = this.GetUnityBehaviourExecution(typeName, host, p); } if (be != null) { be.init(behavior, host, p, false); } else { PrintSingleton.Instance.log("ERREUR : " + typeName + " not found"); } return(be); }
// Use this for initialization void Start() { VRApplication mascaret = VRApplication.Instance; Dictionary <string, List <Class> > classesList = mascaret.Model.AllClasses; PrintSingleton.Instance.log("==== Printing Class List in Model ========"); foreach (KeyValuePair <string, List <Class> > cl in classesList) { PrintSingleton.Instance.log(" ============================================= "); Class c = cl.Value[0]; PrintSingleton.Instance.log(c.getFullName()); Dictionary <string, Property> props = c.Attributes; foreach (KeyValuePair <string, Property> p in props) { Property property = p.Value; PrintSingleton.Instance.log(" -> " + property.name + " : " + property.Type.name); } Dictionary <string, Behavior> behaviors = c.OwnedBehavior; PrintSingleton.Instance.log(" ----- Behaviors : "); foreach (KeyValuePair <string, Behavior> bhs in behaviors) { PrintSingleton.Instance.log(bhs.Value.getFullName()); StateMachine stm = (StateMachine)bhs.Value; List <Region> regions = stm.Region; Region initialRegion = regions[0]; List <Vertex> vertices = initialRegion.Vertices; foreach (Vertex vertex in vertices) { PrintSingleton.Instance.log(" * " + vertex.name); List <Transition> outgoing = vertex.Outgoing; foreach (Transition t in outgoing) { PrintSingleton.Instance.log(" --> " + t.Target.name); } List <Transition> incoming = vertex.Incoming; foreach (Transition t in incoming) { PrintSingleton.Instance.log(" <-- " + t.Source.name); } if (vertex.GetType().ToString() == "Mascaret.State") { State state = (State)vertex; Operation doOperation = state.DoBehavior; if (doOperation != null) { PrintSingleton.Instance.log(" Do : " + doOperation.getFullName()); } } } } /* * Dictionary<string,InstanceSpecification> entities = c.Instances; * PrintSingleton.Instance.log(" ----- instances : " ); * foreach (KeyValuePair<string, InstanceSpecification> instanceKV in entities) * { * PrintSingleton.Instance.log(instanceKV.Value.getFullName()); * } */ } Dictionary <string, InstanceSpecification> instances = mascaret.getEnvironment().InstanceSpecifications; PrintSingleton.Instance.log("Nb Instances : " + instances.Count); PrintSingleton.Instance.log("==== Printing Entity List in Model ========"); foreach (KeyValuePair <string, InstanceSpecification> instanceKV in instances) { PrintSingleton.Instance.log(" ============================================= "); InstanceSpecification instance = instanceKV.Value; PrintSingleton.Instance.log(instance.getFullName() + " : " + instance.Classifier.getFullName()); Dictionary <string, Slot> slots = instance.Slots; foreach (KeyValuePair <string, Slot> propertyValues in slots) { Slot propertyValue = propertyValues.Value; string propertyName = propertyValue.DefiningProperty.name; ValueSpecification valueSpecif = propertyValue.getValue(); if (valueSpecif != null) { string value = ""; if (valueSpecif.GetType().ToString() == "Mascaret.LiteralInteger") { LiteralInteger integer = valueSpecif as LiteralInteger; int intValue = integer.IValue; value += intValue; } else if (valueSpecif.GetType().ToString() == "Mascaret.InstanceValue") { InstanceValue instanceValue = valueSpecif as InstanceValue; InstanceSpecification instanceSpecif = instanceValue.SpecValue; value = instanceSpecif.getFullName(); } PrintSingleton.Instance.log(" ----> " + propertyName + " = " + value); } else { PrintSingleton.Instance.log(" ----> " + propertyName + " not set"); } } List <StateMachineBehaviorExecution> stmBEs = instance.SmBehaviorExecutions; foreach (StateMachineBehaviorExecution stmBE in stmBEs) { PrintSingleton.Instance.log(" - Execute : " + stmBE.getStateMachine().getFullName()); //PrintSingleton.Instance.log(" * CurrentState : " + stmBE.CurrentState.name); } } }
public override BehaviorExecution InstanciateOpaqueBehavior(Mascaret.Behavior behavior, string typeName, InstanceSpecification host, Dictionary <string, ValueSpecification> p) { Type type = Types.GetType(typeName, "Assembly-CSharp"); BehaviorExecution be = null; if (type != null) { be = (BehaviorExecution)(Activator.CreateInstance(type)); } else { Debug.Log("ERREUR : " + typeName + " not found"); } if (be != null) { be.init(behavior, host, p, false); } return(be); }