// Update is called once per frame void Update() { //je récupère la position du perso persox = Perso.position.x; persoy = Perso.position.y; persoz = Perso.position.z; //je récupère l'état du perso saut = Perso.GetComponent <Controle_Personnage> ().ensaut; //je regarde si le joueur bouge après le plan compensé if ((Input.anyKeyDown) & (fineffetdramatique)) { abouge = true; } //caractéristiques caméra fonction marche sur laquelle est le personnage avant l'effet dramamtique if ((persox <= 5.9F) & (!effetdramatique) & (!fineffetdramatique)) { Quaternion targetRotation = Quaternion.LookRotation(Planete.transform.position - transform.position); // Smoothly rotate towards the target point. transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, smoothTimeregard * Time.deltaTime); transform.position = new Vector3(persox - 2F - (2.7F * 0.1666666F * (persoy + 0.1F)), persoy + 0.9F + (0.1F * (persoy + 0.1F)), persoz); } //caractéristiques caméra fonction marche sur laquelle est le personnage après l'effet dramamtique if ((persox > 6.9F) & (!effetdramatique) & (fineffetdramatique) & (abouge)) { Quaternion targetRotation = Quaternion.LookRotation(Perso.transform.position - transform.position); // Smoothly rotate towards the target point. transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, smoothTimeregard * Time.deltaTime); positionposteffet = new Vector3(persox - 21.1F + (2.8225F * (persox - 5.9F)), persoy + 12.25F + (-0.2666666F * (persoy - 5.9F)), persoz); transform.position = Vector3.Lerp(transform.position, positionposteffet, smoothTimeregard * Time.deltaTime); } //caractéristiques caméra fonction marche sur laquelle est le personnage après l'effet dramamtique if ((persox >= 5.9) & (persox < 6.9F) & (!effetdramatique) & (fineffetdramatique) & (abouge)) { Quaternion targetRotation = Quaternion.LookRotation(Planete.transform.position - transform.position); // Smoothly rotate towards the target point. transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, smoothTimeregard * Time.deltaTime); positionposteffet = new Vector3(persox - 21.1F + (2.8225F * (persox - 5.9F)), persoy + 0.9F + (0.1F * (persoy + 0.1F)), persoz); transform.position = Vector3.Lerp(transform.position, positionposteffet, smoothTimeregard * Time.deltaTime); } //caractéristiques caméra fonction marche sur laquelle est le personnage avant l'effet dramamtique if ((persox < 5.9F) & (!effetdramatique) & (fineffetdramatique) & (abouge)) { Quaternion targetRotation = Quaternion.LookRotation(Perso.transform.position - transform.position); // Smoothly rotate towards the target point. transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, smoothTimeregard * Time.deltaTime); positionposteffet = new Vector3(persox - 2F - (4.7F * (persoy + 0.1F)), persoy + 0.9F + (2F * (persoy + 0.1F)), persoz); transform.position = Vector3.Lerp(transform.position, positionposteffet, smoothTimeregard * Time.deltaTime); } //je fais le plan compensé au sommet de l'escalier if ((Mathf.RoundToInt(persoy) == 6) & (!saut) & (!fineffetdramatique)) { effetdramatique = true; Camera.main.fieldOfView = Camera.main.fieldOfView - smoothTimeeffet * Time.deltaTime; camerapanx = (35.35F * ((Camera.main.fieldOfView - 12.06F) / (Camera.main.fieldOfView + 1.072F))) - 28.52F; camerapany = (-0.0133F * Camera.main.fieldOfView) + 8.4145F; transform.position = new Vector3(camerapanx, camerapany, transform.position.z); } if (Camera.main.fieldOfView - 20F <= 0) { Camera.main.fieldOfView = 20F; fineffetdramatique = true; effetdramatique = false; } }
// Start is called before the first frame update void Awake() { playerMovement = GameObject.FindGameObjectWithTag("Player").GetComponent <Perso>(); }
public static CollSet Read(Reader reader, Perso perso, Pointer offset) { MapLoader l = MapLoader.Loader; //if (Settings.s.platform == Settings.Platform.DC) return null; //l.print("CollSet @ " + offset); CollSet c = new CollSet(perso, offset); c.off_zdxList[CollideType.ZDD] = Pointer.Read(reader); c.off_zdxList[CollideType.ZDE] = Pointer.Read(reader); c.off_zdxList[CollideType.ZDM] = Pointer.Read(reader); c.off_zdxList[CollideType.ZDR] = Pointer.Read(reader); c.off_activationList[CollideType.ZDD] = Pointer.Read(reader); c.off_activationList[CollideType.ZDE] = Pointer.Read(reader); c.off_activationList[CollideType.ZDM] = Pointer.Read(reader); c.off_activationList[CollideType.ZDR] = Pointer.Read(reader); c.off_zones[CollideType.ZDD] = Pointer.Read(reader); c.off_zones[CollideType.ZDE] = Pointer.Read(reader); c.off_zones[CollideType.ZDM] = Pointer.Read(reader); c.off_zones[CollideType.ZDR] = Pointer.Read(reader); if (Settings.s.engineVersion > Settings.EngineVersion.Montreal) { c.privilegedActivations[CollideType.ZDD] = reader.ReadInt32(); c.privilegedActivations[CollideType.ZDE] = reader.ReadInt32(); c.privilegedActivations[CollideType.ZDM] = reader.ReadInt32(); c.privilegedActivations[CollideType.ZDR] = reader.ReadInt32(); } foreach (KeyValuePair <CollideType, Pointer> entry in c.off_zdxList) { Pointer.DoAt(ref reader, entry.Value, () => { //zdxList = LinkedList<CollideMeshObject>.ReadHeader(r1, o1); c.zdxList[entry.Key] = LinkedList <GeometricObjectCollide> .Read(ref reader, entry.Value, (off_element) => { GeometricObjectCollide col = GeometricObjectCollide.Read(reader, off_element, type: entry.Key); col.gao.transform.SetParent(perso.Gao.transform); return(col); }, flags: LinkedList.Flags.ReadAtPointer | (Settings.s.hasLinkedListHeaderPointers ? LinkedList.Flags.HasHeaderPointers : LinkedList.Flags.NoPreviousPointersForDouble), type: LinkedList.Type.Minimize ); }); } foreach (KeyValuePair <CollideType, Pointer> entry in c.off_zones) { Pointer.DoAt(ref reader, entry.Value, () => { //zdxList = LinkedList<CollideMeshObject>.ReadHeader(r1, o1); c.zones[entry.Key] = LinkedList <CollideActivationZone> .Read(ref reader, entry.Value, (off_element) => { return(CollideActivationZone.Read(reader, off_element)); }, flags: (Settings.s.hasLinkedListHeaderPointers ? LinkedList.Flags.HasHeaderPointers : LinkedList.Flags.NoPreviousPointersForDouble), type: LinkedList.Type.Minimize ); }); } foreach (KeyValuePair <CollideType, Pointer> entry in c.off_activationList) { Pointer.DoAt(ref reader, entry.Value, () => { //zdxList = LinkedList<CollideMeshObject>.ReadHeader(r1, o1); c.activationList[entry.Key] = LinkedList <CollideActivation> .Read(ref reader, entry.Value, (off_element) => { return(CollideActivation.Read(reader, off_element, c, entry.Key)); }, flags: (Settings.s.hasLinkedListHeaderPointers ? LinkedList.Flags.HasHeaderPointers : LinkedList.Flags.NoPreviousPointersForDouble), type: LinkedList.Type.Minimize ); }); } return(c); }
// Use this for initialization void Start() { personage = gameObject.GetComponent ("Perso") as Perso; }
// Use this for initialization void Start() { personnage = gameObject.GetComponent ("Perso") as Perso; minion = transform.FindChild ("Minion").gameObject; pauseText = GameObject.Find ("GuiPause"); PauseQuitterText = GameObject.Find ("GuiQuitter"); PauseContinuerText = GameObject.Find ("GuiContinuer"); timeScaleDeBase = Time.timeScale; }
async Task InitPersos() { if (loader != null) { for (int i = 0; i < loader.persos.Count; i++) { detailedState = "Initializing persos: " + i + "/" + loader.persos.Count; await WaitIfNecessary(); Perso p = loader.persos[i]; PersoBehaviour unityBehaviour = p.Gao.AddComponent <PersoBehaviour>(); unityBehaviour.controller = this; if (loader.globals != null && loader.globals.spawnablePersos != null) { if (loader.globals.spawnablePersos.IndexOf(p) > -1) { unityBehaviour.IsAlways = true; unityBehaviour.transform.position = new Vector3(i * 10, -1000, 0); } } if (!unityBehaviour.IsAlways) { if (p.sectInfo != null && p.sectInfo.off_sector != null) { unityBehaviour.sector = sectorManager.sectors.FirstOrDefault(s => s.sector != null && s.sector.SuperObject.offset == p.sectInfo.off_sector); } else { SectorComponent sc = sectorManager.GetActiveSectorWrapper(p.Gao.transform.position); unityBehaviour.sector = sc; } } else { unityBehaviour.sector = null; } unityBehaviour.perso = p; unityBehaviour.Init(); // Scripts if (p.Gao) { if (p.brain != null && p.brain.mind != null && p.brain.mind.AI_model != null) { if (p.brain.mind.AI_model.behaviors_normal != null) { GameObject intelParent = new GameObject("Rule behaviours"); intelParent.transform.parent = p.Gao.transform; Behavior[] normalBehaviors = p.brain.mind.AI_model.behaviors_normal; int iter = 0; foreach (Behavior behavior in normalBehaviors) { string shortName = behavior.GetShortName(p.brain.mind.AI_model, Behavior.BehaviorType.Intelligence, iter); GameObject behaviorGao = new GameObject(shortName); behaviorGao.transform.parent = intelParent.transform; foreach (Script script in behavior.scripts) { GameObject scriptGao = new GameObject("Script"); scriptGao.transform.parent = behaviorGao.transform; ScriptComponent scriptComponent = scriptGao.AddComponent <ScriptComponent>(); scriptComponent.SetScript(script, p); } if (behavior.firstScript != null) { ScriptComponent scriptComponent = behaviorGao.AddComponent <ScriptComponent>(); scriptComponent.SetScript(behavior.firstScript, p); } if (iter == 0) { behaviorGao.name += " (Init)"; } if ((behavior.scripts == null || behavior.scripts.Length == 0) && behavior.firstScript == null) { behaviorGao.name += " (Empty)"; } iter++; } } if (p.brain.mind.AI_model.behaviors_reflex != null) { GameObject reflexParent = new GameObject("Reflex behaviours"); reflexParent.transform.parent = p.Gao.transform; Behavior[] reflexBehaviors = p.brain.mind.AI_model.behaviors_reflex; int iter = 0; foreach (Behavior behavior in reflexBehaviors) { string shortName = behavior.GetShortName(p.brain.mind.AI_model, Behavior.BehaviorType.Reflex, iter); GameObject behaviorGao = new GameObject(shortName); behaviorGao.transform.parent = reflexParent.transform; foreach (Script script in behavior.scripts) { GameObject scriptGao = new GameObject("Script"); scriptGao.transform.parent = behaviorGao.transform; ScriptComponent scriptComponent = scriptGao.AddComponent <ScriptComponent>(); scriptComponent.SetScript(script, p); } if (behavior.firstScript != null) { ScriptComponent scriptComponent = behaviorGao.AddComponent <ScriptComponent>(); scriptComponent.SetScript(behavior.firstScript, p); } if ((behavior.scripts == null || behavior.scripts.Length == 0) && behavior.firstScript == null) { behaviorGao.name += " (Empty)"; } iter++; } } if (p.brain.mind.AI_model.macros != null) { GameObject macroParent = new GameObject("Macros"); macroParent.transform.parent = p.Gao.transform; Macro[] macros = p.brain.mind.AI_model.macros; int iter = 0; foreach (Macro macro in macros) { GameObject behaviorGao = new GameObject(macro.GetShortName(p.brain.mind.AI_model, iter)); behaviorGao.transform.parent = macroParent.transform; ScriptComponent scriptComponent = behaviorGao.AddComponent <ScriptComponent>(); scriptComponent.SetScript(macro.script, p); iter++; } } } } } // Initialize DSGVars after all persos have their perso behaviours for (int i = 0; i < loader.persos.Count; i++) { Perso p = loader.persos[i]; Moddable mod = null; if (p.SuperObject != null && p.SuperObject.Gao != null) { mod = p.SuperObject.Gao.GetComponent <Moddable>(); if (mod != null) { mod.persoBehaviour = p.Gao.GetComponent <PersoBehaviour>(); } } if (p.Gao && p.brain != null && p.brain.mind != null && p.brain.mind.AI_model != null) { // DsgVars if (p.brain.mind.dsgMem != null || p.brain.mind.AI_model.dsgVar != null) { DsgVarComponent dsgVarComponent = p.Gao.AddComponent <DsgVarComponent>(); dsgVarComponent.SetPerso(p); if (mod != null) { mod.dsgVarComponent = dsgVarComponent; } } // Dynam if (p.dynam != null && p.dynam.dynamics != null) { DynamicsMechanicsComponent dynamicsBehaviour = p.Gao.AddComponent <DynamicsMechanicsComponent>(); dynamicsBehaviour.SetDynamics(p.dynam.dynamics); } // Mind if (p.brain != null && p.brain.mind != null) { MindComponent mindComponent = p.Gao.AddComponent <MindComponent>(); mindComponent.Init(p, p.brain.mind); if (mod != null) { mod.mindComponent = mindComponent; } } // Custom Bits if (p.stdGame != null) { CustomBitsComponent c = p.Gao.AddComponent <CustomBitsComponent>(); c.stdGame = p.stdGame; if (Settings.s.engineVersion == Settings.EngineVersion.R3) { c.hasAiCustomBits = true; } c.Init(); } } } } if (loader is OpenSpace.Loader.R2ROMLoader) { OpenSpace.Loader.R2ROMLoader romLoader = loader as OpenSpace.Loader.R2ROMLoader; if (romPersos.Count > 0) { for (int i = 0; i < romPersos.Count; i++) { detailedState = "Initializing persos: " + i + "/" + romPersos.Count; await WaitIfNecessary(); ROMPersoBehaviour unityBehaviour = romPersos[i]; unityBehaviour.controller = this; /*if (loader.globals != null && loader.globals.spawnablePersos != null) { * if (loader.globals.spawnablePersos.IndexOf(p) > -1) { * unityBehaviour.IsAlways = true; * unityBehaviour.transform.position = new Vector3(i * 10, -1000, 0); * } * }*/ if (!unityBehaviour.IsAlways) { SectorComponent sc = sectorManager.GetActiveSectorWrapper(unityBehaviour.transform.position); unityBehaviour.sector = sc; } else { unityBehaviour.sector = null; } /*Moddable mod = null; * if (p.SuperObject != null && p.SuperObject.Gao != null) { * mod = p.SuperObject.Gao.GetComponent<Moddable>(); * if (mod != null) { * mod.persoBehaviour = unityBehaviour; * } * }*/ unityBehaviour.Init(); var iteratorPerso = unityBehaviour.perso; // Of sound brain and AI model? if (iteratorPerso.brain?.Value?.aiModel?.Value != null) { var aiModel = iteratorPerso.brain.Value.aiModel.Value; // DsgVars if (iteratorPerso.brain?.Value?.dsgMem?.Value != null || aiModel.dsgVar?.Value != null) { DsgVarComponent dsgVarComponent = unityBehaviour.gameObject.AddComponent <DsgVarComponent>(); dsgVarComponent.SetPerso(iteratorPerso); } // Comports if (aiModel.comportsIntelligence.Value != null) { aiModel.comportsIntelligence.Value.CreateGameObjects("Rule", unityBehaviour.gameObject, iteratorPerso); } if (aiModel.comportsReflex.Value != null) { aiModel.comportsReflex.Value.CreateGameObjects("Reflex", unityBehaviour.gameObject, iteratorPerso); } } } } if (romLoader.level != null && romLoader.level.spawnablePersos.Value != null && romLoader.level.num_spawnablepersos > 0) { GameObject spawnableParent = new GameObject("Spawnable persos"); for (int i = 0; i < romLoader.level.num_spawnablepersos; i++) { detailedState = "Initializing spawnable persos: " + i + "/" + romLoader.level.num_spawnablepersos; await WaitIfNecessary(); OpenSpace.ROM.SuperObjectDynamic sod = romLoader.level.spawnablePersos.Value.superObjects[i]; GameObject sodGao = sod.GetGameObject(); if (sodGao != null) { ROMPersoBehaviour unityBehaviour = sodGao.GetComponent <ROMPersoBehaviour>(); unityBehaviour.controller = this; unityBehaviour.IsAlways = true; unityBehaviour.transform.SetParent(spawnableParent.transform); unityBehaviour.transform.position = new Vector3(i * 10, -1000, 0); unityBehaviour.transform.rotation = Quaternion.identity; unityBehaviour.transform.localScale = Vector3.one; if (!unityBehaviour.IsAlways) { SectorComponent sc = sectorManager.GetActiveSectorWrapper(unityBehaviour.transform.position); unityBehaviour.sector = sc; } else { unityBehaviour.sector = null; } unityBehaviour.Init(); var iteratorPerso = unityBehaviour.perso; // Of sound brain and AI model? if (iteratorPerso.brain?.Value?.aiModel?.Value != null) { var aiModel = iteratorPerso.brain.Value.aiModel.Value; // DsgVars if (iteratorPerso.brain?.Value?.dsgMem?.Value != null || aiModel.dsgVar?.Value != null) { DsgVarComponent dsgVarComponent = unityBehaviour.gameObject.AddComponent <DsgVarComponent>(); dsgVarComponent.SetPerso(iteratorPerso); } // Comports if (aiModel.comportsIntelligence.Value != null) { aiModel.comportsIntelligence.Value.CreateGameObjects("Rule", unityBehaviour.gameObject, iteratorPerso); } if (aiModel.comportsReflex.Value != null) { aiModel.comportsReflex.Value.CreateGameObjects("Reflex", unityBehaviour.gameObject, iteratorPerso); } } } } } } }
public static CinematicActor Read(Reader reader, Pointer offset) { MapLoader l = MapLoader.Loader; CinematicActor ca = new CinematicActor(offset); if (Settings.s.game == Settings.Game.R3 || Settings.s.game == Settings.Game.Dinosaur) { if (Settings.s.platform != Settings.Platform.PS2) { if (Settings.s.platform == Settings.Platform.GC) { reader.ReadUInt32(); reader.ReadUInt32(); } reader.ReadUInt32(); } } ca.off_a3d = Pointer.Read(reader); reader.ReadUInt32(); ca.name = reader.ReadString(0x100); ca.off_perso = Pointer.Read(reader); ca.off_waitState = Pointer.Read(reader); ca.off_cineState = Pointer.Read(reader); reader.ReadUInt32(); ca.setCustomBitFlag1 = reader.ReadByte(); ca.setCustomBitFlag2 = reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); ca.cineStateRepeatAnimation = reader.ReadByte(); ca.cineStateSpeed = reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); ca.off_IPO = Pointer.Read(reader); reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); ca.hasChangeComport1 = reader.ReadByte(); reader.ReadByte(); ca.off_comport1 = Pointer.Read(reader); ca.hasChangeComport2 = reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); ca.off_comport2 = Pointer.Read(reader); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); ca.hasSnd = reader.ReadBytes(4); for (int i = 0; i < 4; i++) { ca.snd[i] = reader.ReadUInt32(); } reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); ca.off_cinematic = Pointer.Read(reader); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); ca.off_next = Pointer.Read(reader); ca.off_previous = Pointer.Read(reader); ca.off_header = Pointer.Read(reader); //MapLoader.Loader.print(ca.name); ca.anim_ref = l.FromOffsetOrRead <AnimationReference>(reader, ca.off_a3d); ca.perso = Perso.FromOffset(ca.off_perso); ca.waitState = State.FromOffset(ca.off_waitState); ca.cineState = State.FromOffset(ca.off_cineState); return(ca); }
public async void getCount(Perso person) { await adb.InsertPerson(person); }
// Use this for initialization void Start() { personnage = gameObject.GetComponent ("Perso") as Perso; minion = transform.FindChild ("Minion").gameObject; }
// Use this for initialization void Start() { personage = gameObject.GetComponent ("Perso") as Perso; mouv = gameObject.GetComponent ("Mouvement") as Mouvement; }
public string ToString(Perso perso, TranslatedScript.TranslationSettings ts, bool advanced = false) { MapLoader l = MapLoader.Loader; short mask = 0; AITypes aiTypes = Settings.s.aiTypes; Vector3 vector3 = new Vector3 { x = 0, y = 0, z = 0 }; switch (nodeType) { case ScriptNode.NodeType.KeyWord: // KeyWordFunctionPtr if (param < aiTypes.keywordTable.Length) { if (ts.exportMode) { if (aiTypes.keywordTable[param] == "Me") { return "this"; } if (aiTypes.keywordTable[param] == "MainActor") { return "Controller.MainActor"; } if (aiTypes.keywordTable[param] == "Nobody" || aiTypes.keywordTable[param] == "NoInput" || aiTypes.keywordTable[param] == "Nowhere" || aiTypes.keywordTable[param] == "NoGraph" || aiTypes.keywordTable[param] == "NoAction" || aiTypes.keywordTable[param] == "CapsNull") { return "null"; } } return aiTypes.keywordTable[param]; } return "UnknownKeyword_" + param; case ScriptNode.NodeType.Condition: // GetConditionFunctionPtr if (param < aiTypes.conditionTable.Length) { return aiTypes.conditionTable[param]; } return "UnknownCondition_" + param; case ScriptNode.NodeType.Operator: // GetOperatorFunctionPtr if (advanced) { if (param < aiTypes.operatorTable.Length) { return aiTypes.operatorTable[param] + " (" + param + ")"; } } if (param < aiTypes.operatorTable.Length) { return aiTypes.operatorTable[param]; } return "UnknownOperator_" + param; case ScriptNode.NodeType.Function: // GetFunctionFunctionPtr if (param < aiTypes.functionTable.Length) { return aiTypes.functionTable[param]; } return "UnknownFunction_" + param; case ScriptNode.NodeType.Procedure: // ProcedureFunctionReturn if (param < aiTypes.procedureTable.Length) { return aiTypes.procedureTable[param]; } return "UnknownProcedure_" + param; case ScriptNode.NodeType.MetaAction: // meta action if (param < aiTypes.metaActionTable.Length) { return aiTypes.metaActionTable[param]; } return "UnknownMetaAction_" + param; case ScriptNode.NodeType.BeginMacro: return "BeginMacro"; case ScriptNode.NodeType.EndMacro: return "EndMacro"; case ScriptNode.NodeType.Field: if (param < aiTypes.fieldTable.Length) { return aiTypes.fieldTable[param]; } return "UnknownField_" + param; case ScriptNode.NodeType.DsgVarRef: // Dsg Var if (perso != null && perso.brain != null && perso.brain.mind != null) { Mind mind = perso.brain.mind; if (mind.dsgMem != null && mind.dsgMem.dsgVar != null) { if (param < mind.dsgMem.dsgVar.dsgVarInfos.Length) { return mind.dsgMem.dsgVar.dsgVarInfos[param].NiceVariableName; } } else if (mind.AI_model != null && mind.AI_model.dsgVar != null) { if (param < mind.AI_model.dsgVar.dsgVarInfos.Length) { return mind.AI_model.dsgVar.dsgVarInfos[param].NiceVariableName; } } } return "dsgVar_" + param; case ScriptNode.NodeType.Constant: if (advanced) return "Constant: " + BitConverter.ToInt32(BitConverter.GetBytes(param), 0); return BitConverter.ToInt32(BitConverter.GetBytes(param), 0).ToString(); case ScriptNode.NodeType.Real: NumberFormatInfo nfi = new NumberFormatInfo() { NumberDecimalSeparator = "." }; if (advanced) return "Real: " + BitConverter.ToSingle(BitConverter.GetBytes(param), 0).ToString(nfi); return BitConverter.ToSingle(BitConverter.GetBytes(param), 0).ToString(nfi)+"f"; case ScriptNode.NodeType.Button: // Button/entryaction EntryAction ea = EntryAction.FromOffset(param_ptr); if (ea == null) { return "ERR_ENTRYACTION_NOTFOUND"; } string eaName = (advanced ? ea.ToString() : ea.ToBasicString()); if (advanced) return "Button: " + eaName + "(" + param_ptr + ")"; if (!ts.expandEntryActions && ea!=null) { return "\""+ea.ExportName+"\""; } return eaName; case ScriptNode.NodeType.ConstantVector: return "Constant Vector: " + "0x" + param.ToString("x8"); // TODO: get from address case ScriptNode.NodeType.Vector: return "new Vector3"; // TODO: same case ScriptNode.NodeType.Mask: mask = (short)param; // TODO: as short if(advanced) return "Mask: " + (mask).ToString("x4"); if (ts.exportMode) { return "\"" + (mask).ToString("x4") + "\""; } return "Mask(" + (mask).ToString("x4") + ")"; case ScriptNode.NodeType.ModuleRef: if(advanced) return "ModuleRef: " + "0x" + (param).ToString("x8"); return "GetModule(" + (int)param + ")"; case ScriptNode.NodeType.DsgVarId: if(advanced) return "DsgVarId: " + "0x" + (param).ToString("x8"); return "DsgVarId(" + param + ")"; case ScriptNode.NodeType.String: string str = "ERR_STRING_NOTFOUND"; if (l.strings.ContainsKey(param_ptr)) str = l.strings[param_ptr]; if (advanced) return "String: " + param_ptr + " (" + str + ")"; return "\"" + str + "\""; case ScriptNode.NodeType.LipsSynchroRef: return "LipsSynchroRef: " + param_ptr; case ScriptNode.NodeType.FamilyRef: if(advanced) return "FamilyRef: " + param_ptr; Family f = Family.FromOffset(param_ptr); if (f != null) { return "GetFamily(\"" + f.name + "\")"; } else { return "Family.FromOffset(\"" + param_ptr + "\")"; } case ScriptNode.NodeType.PersoRef: Perso argPerso = Perso.FromOffset(param_ptr); if (argPerso != null && perso!=null && argPerso.offset == perso.offset) { if (advanced) return "PersoRef: this"; return "this"; } string persoName = argPerso == null ? "ERR_PERSO_NOTFOUND" : argPerso.fullName; if (advanced) return "PersoRef: " + param_ptr + " (" + persoName + ")"; if (argPerso?.brain?.mind?.AI_model!=null ) { AIModel aiModel = argPerso.brain.mind.AI_model; // Make sure to add a cast in case the AI Model is accessed return "(("+aiModel.name+")GetPerso(\"" + argPerso.namePerso + "\"))"; } return "GetPerso(\"" + argPerso.namePerso + "\")"; case ScriptNode.NodeType.ActionRef: State state = State.FromOffset(param_ptr); string stateName = state == null ? "ERR_STATE_NOTFOUND" : state.ShortName; if (advanced) return "ActionRef: " + param_ptr + " " + stateName; if (ts.useStateIndex) { return "GetAction("+state.index.ToString()+")"; } return stateName; case ScriptNode.NodeType.SuperObjectRef: if(advanced) return "SuperObjectRef: " + param_ptr; SuperObject so = SuperObject.FromOffset(param_ptr); if (so != null) { return "GetSuperObject(\"" + so.Gao.name + "\")"; } else { return "SuperObject.FromOffset(\"" + param_ptr + "\")"; } case ScriptNode.NodeType.WayPointRef: if(advanced) return "WayPointRef: " + param_ptr; return "WayPoint.FromOffset(\"" + param_ptr + "\")"; case ScriptNode.NodeType.TextRef: if (l.localization == null) return "TextRef"; if (advanced) return "TextRef: " + param + " (" + l.localization.GetTextForHandleAndLanguageID((int)param, 0) + ")"; if (ts.expandStrings) { return "\"" + l.localization.GetTextForHandleAndLanguageID((int)param, 0) + "\""; // Preview in english } else { return "new TextReference(" + (int)param + ")"; } case ScriptNode.NodeType.ComportRef: Behavior comportRef = l.FromOffset<Behavior>(param_ptr); if (comportRef == null) { if (advanced) return "ComportRef: " + param_ptr + " (null)"; return "null"; } else { return comportRef.ShortName; //string type = comportRef.type == Behavior.BehaviorType.Normal ? "normalBehavior" : "reflexBehavior"; //return type + "[" + script.behaviorOrMacro.aiModel.GetBehaviorIndex(comportRef) + "]"; } case ScriptNode.NodeType.SoundEventRef: if(advanced) return "SoundEventRef: " + (int)param; return "SoundEvent.FromID(0x" + ((int)param).ToString("X8") + ")"; case ScriptNode.NodeType.ObjectTableRef: if (advanced) return "ObjectTableRef: " + param_ptr; if (ts.useHashIdentifiers) { string objectListJson = ObjectList.FromOffset(param_ptr).ToJSON(); string objectListHash = HashUtils.MD5Hash(objectListJson); return "ObjectList.FromHash(\"" + objectListHash + "\")"; } return "ObjectTable.FromOffset(\"" + param_ptr + "\")"; case ScriptNode.NodeType.GameMaterialRef: if (advanced) return "GameMaterialRef: " + param_ptr; if (ts.useHashIdentifiers) { string gmtJson = GameMaterial.FromOffset(param_ptr).ToJSON(); string gmtHash = HashUtils.MD5Hash(gmtJson); return "GameMaterial.FromHash(\"" + gmtHash + "\")"; } return "GameMaterial.FromOffset(\"" + param_ptr + "\")"; case ScriptNode.NodeType.ParticleGenerator: return "ParticleGenerator: " + "0x" + (param).ToString("x8"); case ScriptNode.NodeType.VisualMaterial: if (advanced) return "VisualMaterial: " + param_ptr; if (ts.useHashIdentifiers) { string vmtJson = VisualMaterial.FromOffset(param_ptr).ToJSON(); string vmtHash = HashUtils.MD5Hash(vmtJson); return "VisualMaterial.FromHash(\"" + vmtHash + "\")"; } return "VisualMaterial.FromOffset(\"" + param_ptr + "\")"; case ScriptNode.NodeType.ModelRef: // ModelCast if (advanced) return "AIModel: " + param_ptr; AIModel model = l.FromOffset<AIModel>(param_ptr); return model != null ? model.name : "null"; case ScriptNode.NodeType.DataType42: if(advanced) return "EvalDataType42: " + "0x" + (param).ToString("x8"); return "EvalDataType42(" + "0x" + (param).ToString("x8") + ")"; case ScriptNode.NodeType.CustomBits: if(advanced) return "CustomBits: " + "0x" + (param).ToString("x8"); if (ts.exportMode) { return "0x"+(param).ToString("x8"); } return "CustomBits(" + "0x" + (param).ToString("x8") + ")"; case ScriptNode.NodeType.Caps: if(advanced) return "Caps: " + "0x" + (param).ToString("x8"); if (ts.exportMode) { return "0x" + (param).ToString("x8"); } return "Caps(" + "0x" + (param).ToString("x8") + ")"; case ScriptNode.NodeType.SubRoutine: if (advanced) return "Eval SubRoutine: " + param_ptr; Macro macro = l.FromOffset<Macro>(param_ptr); if (macro == null) { return "null"; } return "evalMacro(" + macro.ShortName + ");"; case ScriptNode.NodeType.Null: return "null"; case ScriptNode.NodeType.GraphRef: if(advanced) return "Graph: " + "0x" + (param).ToString("x8"); return "Graph.FromOffset(\"" + param_ptr + "\")"; } return "unknown"; }
private async Task Rule_1_Go() { // script 0 await Macro_4(); if (Input.GetButtonDown("Fire1")) { if (!(Boolean_10)) { await Macro_3(); if (Perso_5 != null) { Boolean_10 = true; Perso_7 = Perso_5; } } else { if (!(Boolean_11)) { await Macro_3(); if (Perso_5 != null) { Boolean_11 = true; Perso_8 = Perso_5; } } else { if (!(Boolean_12)) { await Macro_3(); if (Perso_5 != null) { Boolean_12 = true; Perso_9 = Perso_5; } } } } } // script 1 if (this.Cond_IsTimeElapsed(Int_17, 3000)) { this.fn_p_stJFFTXTProcedure(0, new Vector3(Int_0, Int_1, Int_19), "/o600:e", 255); this.Proc_ChangeOneCustomBit(29, false); } else { if (Boolean_18) { this.fn_p_stJFFTXTProcedure(0, new Vector3(Int_0, Int_1, Int_19), "/o600:e", 255); Boolean_18 = false; } else { this.fn_p_stJFFTXTProcedure(0, new Vector3(0, 0, 0), "/o600:e", 0); Boolean_18 = true; } } // script 2 if (globalRandomizer % 2 == 0 && (this.Cond_IsCustomBitSet(28))) { //this.GetPerso("StdCamer").SOUND_SendSoundRequest(SoundEvent(122465640)); //this.GetPerso("StdCamer").SOUND_SetVolumeAnim(120); if (Int_16_Lives == 0) { //SOUND_SendSoundRequest(SoundEvent(122618424)); Int_6 = this.Func_GetTime(); await Macro_6(); Int_0 = 0; this.Proc_ChangeOneCustomBit(30, true); //Proc_FactorAnimationFrameRate(1); smRule.SetState(Rule_4_End); //Proc_ChangeMyComportAndMyReflex(JFF2000.Rule[4]["MIC_jff_jump"], JFF2000.Reflex[0]["MIC_jff_rien"]); smReflex.SetState(Reflex_0_Rien); //Proc_ChangeMyComportAndMyReflex(JFF2000.Rule[4]["MIC_jff_jump"], JFF2000.Reflex[0]["MIC_jff_rien"]); } Int_16_Lives -= 1; if (((JFF2000)(Perso_3)).Int_23 < 25) { Perso_5 = this.Func_GenerateObject(typeof(AGO2000), this.GetPerso("StdCamer").Position()); if (Perso_5 != null) { await Macro_1(); ((AGO2000)(Perso_5)).Perso_4 = Perso_3; ((AGO2000)(Perso_5)).Int_5_TextLayer = Int_15; ((AGO2000)(Perso_5)).Int_0_X = Int_0; ((AGO2000)(Perso_5)).Int_1_Y = Int_1; ((AGO2000)(Perso_5)).Int_2 = 7; ((AGO2000)(Perso_5)).Int_22 = 2; ((AGO2000)(Perso_5)).Int_23_Size = Int_19; ((AGO2000)(Perso_5)).Int_19 = 1; } } this.Proc_ChangeOneCustomBit(28, false); this.Proc_ChangeOneCustomBit(29, true); Int_17 = this.Func_GetTime(); } // script 3 if (Input.GetButtonDown("Jump") && Int_22_Jumps > 0) { Int_22_Jumps -= 1; Int_21 = 0; Int_0 += Int_19; Int_1 += Int_19; this.Proc_ChangeOneCustomBit(29, true); //this.GetPerso("StdCamer").SOUND_SendSoundRequest(SoundEvent(122523024)); //this.GetPerso("StdCamer").SOUND_SetVolumeAnim(120); smRule.SetState(Rule_2_Jump); } // script 4 await Macro_0(); await Macro_10(); }
public static List <SuperObject> Read(EndianBinaryReader reader, Pointer off_so, bool parseSiblings = true, bool parseChildren = true, SuperObject parent = null) { MapLoader l = MapLoader.Loader; List <SuperObject> superObjects = new List <SuperObject>(); if (IsParsed(off_so)) { return(null); } bool isFirstNode = true; bool hasNextBrother = false; bool isValidNode = true; while (isFirstNode || (hasNextBrother && parseSiblings)) { SuperObject so = new SuperObject(off_so); superObjects.Add(so); // Local list of superobjects (only this & siblings) l.superObjects.Add(so); // Global list of superobjects (all) if (parent != null) { parent.children.Add(so); so.parent = parent; } hasNextBrother = false; so.type = reader.ReadUInt32(); so.off_data = Pointer.Read(reader); so.off_child_first = Pointer.Read(reader); so.off_child_last = Pointer.Read(reader); so.num_children = reader.ReadUInt32(); so.off_brother_next = Pointer.Read(reader); so.off_brother_prev = Pointer.Read(reader); so.off_parent = Pointer.Read(reader); so.off_matrix = Pointer.Read(reader); //R3Pointer.Read(reader); // a copy of the matrix right after, at least in R3GC Vector3 pos = Vector3.zero; Vector3 scale = Vector3.one; Quaternion rot = Quaternion.identity; if (so.off_matrix != null) { Pointer curPos = Pointer.Goto(ref reader, so.off_matrix); so.matrix = Matrix.Read(reader, so.off_matrix); pos = so.matrix.GetPosition(convertAxes: true); rot = so.matrix.GetRotation(convertAxes: true); scale = so.matrix.GetScale(convertAxes: true); Pointer.Goto(ref reader, curPos); } switch (so.type) { case 0x20: // IPO Pointer.Goto(ref reader, so.off_data); so.data = IPO.Read(reader, so.off_data, so); break; case 0x40: // IPO l.print("IPO with code 0x40 at offset " + String.Format("0x{0:X}", so.offset.offset)); Pointer.Goto(ref reader, so.off_data); so.data = IPO.Read(reader, so.off_data, so); break; case 0x02: // e.o. Pointer.Goto(ref reader, so.off_data); so.data = Perso.Read(reader, so.off_data, so); break; case 0x01: // world superobject so.data = World.New(so); //print("parsing world superobject with " + num_children + " children"); break; case 0x04: // sector Pointer.Goto(ref reader, so.off_data); so.data = Sector.Read(reader, so.off_data, so); break; default: l.print("Unknown SO type " + so.type + " at offset " + String.Format("0x{0:X}", so.offset.offset)); isValidNode = false; break; } if (so.Gao != null) { if (parent != null) { so.Gao.transform.parent = parent.Gao.transform; } so.Gao.transform.localPosition = pos; so.Gao.transform.localRotation = rot; so.Gao.transform.localScale = scale; } isFirstNode = false; if (isValidNode) { if (parseChildren && so.num_children > 0 && so.off_child_first != null) { //if (type == 0x01) print("parsing children now"); Pointer off_current = Pointer.Goto(ref reader, so.off_child_first); SuperObject.Read(reader, so.off_child_first, true, true, so); //R3Pointer.Goto(ref reader, off_current); } if (so.off_brother_next != null && !IsParsed(so.off_brother_next)) { hasNextBrother = true; Pointer.Goto(ref reader, so.off_brother_next); off_so = so.off_brother_next; } } } return(superObjects); }
public void Init(Perso perso, Mind mind) { this.perso = perso; this.mind = mind; }
void Start() { me = new Perso(gameObject, Filler, Camera.main); // InitalRotation = Armature.transform.localRotation; }
private async Task Rule_6_MIC_en4_go() { // Script 0 if (Int_17 == 0) { Int_0_X += (Int_8_XSpeed * Int_26); Int_1_Y += (Int_9_YSpeed * Int_26); if (Int_9_YSpeed > 0) { Int_9_YSpeed += Int_26; if (Int_1_Y >= ((JFF2000)(Perso_4)).Int_1) { Int_17 += 1; } } else { Int_9_YSpeed -= Int_26; if (Int_1_Y <= ((JFF2000)(Perso_4)).Int_1) { Int_17 += 1; } } if (Int_17 == 1) { if (((JFF2000)(Perso_4)).Int_23 <= 26) { Perso_6 = this.Func_GenerateObject(GetType(), this.GetPerso("StdCamer").Position()); if (Perso_6 != null) { await Macro_4(); ((AGO2000)(Perso_6)).Perso_4 = Perso_4; ((AGO2000)(Perso_6)).Int_5_TextLayer = Int_13; ((AGO2000)(Perso_6)).Int_0_X = Int_0_X; ((AGO2000)(Perso_6)).Int_1_Y = Int_1_Y; ((AGO2000)(Perso_6)).Int_8_XSpeed = (-8 - ((JFF2000)(Perso_4)).Int_31); ((AGO2000)(Perso_6)).Int_9_YSpeed = 0; ((AGO2000)(Perso_6)).Int_2 = 3; //this.GetPerso("StdCamer").SOUND_SendSoundRequest(SoundEvent(122947080)); //this.GetPerso("StdCamer").SOUND_SetVolumeAnim(30); } } } } else { Int_0_X += (Int_8_XSpeed * Int_26); if (Int_8_XSpeed >= -(15 + ((JFF2000)(Perso_4)).Int_31)) { Int_8_XSpeed -= Int_26; } Int_1_Y += (Int_9_YSpeed * Int_26); if (Int_9_YSpeed > 0) { if (Int_9_YSpeed <= 2) { Int_9_YSpeed = 0; } else { Int_9_YSpeed -= 3; } } else { if (Int_9_YSpeed >= -2) { Int_9_YSpeed = 0; } else { Int_9_YSpeed += 3; } } } // Script 1 if (Int_0_X < -200) { await Macro_8(); } else { await Macro_7(); } // Script 2 await Macro_12(); Int_7_ScoreValue = 5; await Macro_6(); }
public string GetExportableDsgVarValueString(DsgVarValue val) { string value = ""; switch (val.type) { default: value = val.ToString(); break; case DsgVarType.GameMaterial: value = HashUtils.MD5Hash(val.valueGameMaterial?.ToJSON()); break; case DsgVarType.VisualMaterial: value = HashUtils.MD5Hash(val.valueVisualMaterial?.ToJSON()); break; case DsgVarType.Perso: value = val.valuePerso?.namePerso; break; case DsgVarType.PersoArray: List <string> persoNames = new List <string>(); foreach (DsgVarValue child in val.valueArray) { Perso perso = child.valuePerso; if (perso != null) { persoNames.Add(perso.namePerso); } else { persoNames.Add("NullPointer"); } } value = "{ " + string.Join(", ", persoNames) + " }"; break; case DsgVarType.WayPointArray: // TODO break; case DsgVarType.TextArray: // TODO: check goto default; //break; case DsgVarType.TextRefArray: // TODO: check goto default; case DsgVarType.GraphArray: break; case DsgVarType.SOLinksArray: break; case DsgVarType.SoundEventArray: // TODO: check goto default; case DsgVarType.VisualMatArray: break; case DsgVarType.Way: break; case DsgVarType.ActionArray: // TODO break; case DsgVarType.SuperObjectArray: // TODO break; } return(value); }
public BasicEnnemi(Perso m, GameObject t) { me = m; Target = t; }
public void UpdateLivePreview() { Reader reader = MapLoader.Loader.livePreviewReader; foreach (SuperObject so in MapLoader.Loader.superObjects) { if (!(so.data is Perso)) { continue; } if (so.off_matrix == null) { continue; } Pointer.Goto(ref reader, so.off_matrix); so.matrix = Matrix.Read(MapLoader.Loader.livePreviewReader, so.off_matrix); if (so.data != null && so.data.Gao != null) { so.data.Gao.transform.localPosition = so.matrix.GetPosition(convertAxes: true); so.data.Gao.transform.localRotation = so.matrix.GetRotation(convertAxes: true); so.data.Gao.transform.localScale = so.matrix.GetScale(convertAxes: true); if (so.data is Perso) { Perso perso = (Perso)so.data; PersoBehaviour pb = perso.Gao.GetComponent <PersoBehaviour>(); if (pb != null) { Pointer.Goto(ref reader, perso.p3dData.offset); perso.p3dData.UpdateCurrentState(reader); // State offset changed? if (perso.p3dData.stateCurrent != null) { pb.SetState(perso.p3dData.stateCurrent.index); pb.autoNextState = true; } } MindComponent mc = perso.Gao.GetComponent <MindComponent>(); if (mc != null) { Mind mind = mc.mind; Pointer.DoAt(ref reader, mind.Offset, () => { mind.UpdateCurrentBehaviors(reader); }); } DsgVarComponent dsgVarComponent = perso.Gao.GetComponent <DsgVarComponent>(); if (dsgVarComponent != null) { dsgVarComponent.SetPerso(perso); } CustomBitsComponent customBitsComponent = perso.Gao.GetComponent <CustomBitsComponent>(); if (customBitsComponent != null) { Pointer.Goto(ref reader, perso.off_stdGame); perso.stdGame = StandardGame.Read(reader, perso.off_stdGame); customBitsComponent.stdGame = perso.stdGame; customBitsComponent.Init(); } DynamicsMechanicsComponent dnComponent = perso.Gao.GetComponent <DynamicsMechanicsComponent>(); if (dnComponent != null) { Pointer.DoAt(ref reader, perso.off_dynam, () => { perso.dynam = Dynam.Read(reader, perso.off_dynam); }); dnComponent.SetDynamics(perso.dynam.dynamics); } } } } Perso camera = loader.persos.FirstOrDefault(p => p != null && p.namePerso.Equals("StdCamer")); if (camera != null) { SuperObject cameraSO = camera.SuperObject; Pointer.Goto(ref reader, cameraSO.off_matrix); cameraSO.matrix = Matrix.Read(reader, cameraSO.off_matrix); camera.Gao.transform.localPosition = cameraSO.matrix.GetPosition(convertAxes: true); camera.Gao.transform.localRotation = cameraSO.matrix.GetRotation(convertAxes: true); camera.Gao.transform.localScale = cameraSO.matrix.GetScale(convertAxes: true); Camera.main.transform.position = camera.Gao.transform.position; Camera.main.transform.rotation = camera.Gao.transform.rotation * Quaternion.Euler(0, 180, 0); } }
public BasicEnnemi(Perso m, GameObject t, GradientNavigation n) { me = m; Target = t; n = nav; }
public string ToString(Perso perso) { if (scriptNode != null) { string firstChildNode = (this.children.Count > 0 && this.children[0] != null) ? this.children[0].ToString() : "null"; string secondChildNode = (this.children.Count > 1 && this.children[1] != null) ? this.children[1].ToString() : "null"; string prefix = (ts.printAddresses ? "{" + scriptNode.offset.ToString() + "}" : ""); AITypes aiTypes = Settings.s.aiTypes; uint param = scriptNode.param; switch (scriptNode.nodeType) { case ScriptNode.NodeType.KeyWord: string keyword = param < aiTypes.keywordTable.Length ? aiTypes.keywordTable[param] : ""; switch (keyword) { // If keywords case "If": return(prefix + "if ({condition})".Replace("{condition}", firstChildNode)); case "IfNot": return(prefix + "if (!({condition}))".Replace("{condition}", firstChildNode)); case "If2": return(prefix + "if (globalRandomizer % 2 == 0 && ({condition}))".Replace("{condition}", firstChildNode)); case "If4": return(prefix + "if (globalRandomizer % 4 == 0 && ({condition}))".Replace("{condition}", firstChildNode)); case "If8": return(prefix + "if (globalRandomizer % 8 == 0 && ({condition}))".Replace("{condition}", firstChildNode)); case "If16": return(prefix + "if (globalRandomizer % 16 == 0 && ({condition}))".Replace("{condition}", firstChildNode)); case "If32": return(prefix + "if (globalRandomizer % 32 == 0 && ({condition}))".Replace("{condition}", firstChildNode)); case "If64": return(prefix + "if (globalRandomizer % 64 == 0 && ({condition}))".Replace("{condition}", firstChildNode)); case "IfNot2": return(prefix + "if (globalRandomizer % 2 != 0 && ({condition}))".Replace("{condition}", firstChildNode)); case "IfNot4": return(prefix + "if (globalRandomizer % 4 != 0 && ({condition}))".Replace("{condition}", firstChildNode)); case "IfNot8": return(prefix + "if (globalRandomizer % 8 != 0 && ({condition}))".Replace("{condition}", firstChildNode)); case "IfNot16": return(prefix + "if (globalRandomizer % 16 != 0 && ({condition}))".Replace("{condition}", firstChildNode)); case "IfNot32": return(prefix + "if (globalRandomizer % 32 != 0 && ({condition}))".Replace("{condition}", firstChildNode)); case "IfNot64": return(prefix + "if (globalRandomizer % 64 != 0 && ({condition}))".Replace("{condition}", firstChildNode)); case "IfDebug": return(prefix + "if (debug && {condition})".Replace("{condition}", firstChildNode)); case "IfNotU64": return(prefix + "if (!u64)\n{\n{childNodes}\n}\n".Replace("{childNodes}", string.Join("\n", Array.ConvertAll <Node, String>(this.children.ToArray(), x => x.ToString())))); // Then case "Then": return(prefix + "{\n{childNodes}\n}\n".Replace("{childNodes}", string.Join("\n", Array.ConvertAll <Node, String>(this.children.ToArray(), x => x.ToString())))); // Else case "Else": return(prefix + "else\n{\n{childNodes}\n}\n".Replace("{childNodes}", string.Join("\n", Array.ConvertAll <Node, String>(this.children.ToArray(), x => x.ToString())))); default: return(prefix + scriptNode.ToString(perso, ts.settings)); } case ScriptNode.NodeType.Condition: string cond = param < aiTypes.conditionTable.Length ? aiTypes.conditionTable[param] : ""; switch (cond) { // Boolean conditions: case "Cond_And": return(prefix + firstChildNode + " && " + secondChildNode); case "Cond_Or": return(prefix + firstChildNode + " || " + secondChildNode); case "Cond_Not": return(prefix + "!" + "(" + firstChildNode + ")"); case "Cond_XOR": return(prefix + firstChildNode + " != " + secondChildNode); // XOR // Real (float) comparisons: case "Cond_Equal": return(prefix + firstChildNode + " == " + secondChildNode); case "Cond_Different": return(prefix + firstChildNode + " != " + secondChildNode); case "Cond_Lesser": return(prefix + firstChildNode + " < " + secondChildNode); case "Cond_Greater": return(prefix + firstChildNode + " > " + secondChildNode); case "Cond_LesserOrEqual": return(prefix + firstChildNode + " <= " + secondChildNode); case "Cond_GreaterOrEqual": return(prefix + firstChildNode + " >= " + secondChildNode); // Button condition: /*case 44: * case 45: * case 46: * case 47: * return prefix + firstChildNode;*/ default: if (firstChildNode != null) { return(prefix + scriptNode.ToString(perso, ts.settings) + "(" + string.Join(", ", Array.ConvertAll <Node, String>(this.children.ToArray(), x => x.ToString())) + ")"); } else { return(prefix + scriptNode.ToString(perso, ts.settings) + "()"); } } case ScriptNode.NodeType.Function: string function = param < aiTypes.functionTable.Length ? aiTypes.functionTable[param] : ""; string ternaryCheck = ""; switch (function) { // Ternary real operators (e.g. x > y ? true : false) case "Func_TernInf": case "Func_TernSup": case "Func_TernEq": case "Func_TernInfEq": case "Func_TernSupEq": switch (function) { case "Func_TernInf": ternaryCheck = " < "; break; case "Func_TernSup": ternaryCheck = " > "; break; case "Func_TernEq": ternaryCheck = " == "; break; case "Func_TernInfEq": ternaryCheck = " <= "; break; case "Func_TernSupEq": ternaryCheck = " >= "; break; } if (this.children.Count >= 4) { return(prefix + "((" + this.children[0] + ternaryCheck + this.children[1] + ") ? " + this.children[2] + " : " + this.children[3] + ")"); } else { return("ERROR"); } case "Func_TernOp": // conditional ternary operator (cond ? true : false) string childCast1 = ""; string childCast2 = ""; if (this.children[1].scriptNode.nodeType == ScriptNode.NodeType.DsgVarRef && this.children[2].scriptNode.nodeType == ScriptNode.NodeType.Real) { childCast1 = "(float)"; } if (this.children[2].scriptNode.nodeType == ScriptNode.NodeType.DsgVarRef && this.children[1].scriptNode.nodeType == ScriptNode.NodeType.Real) { childCast2 = "(float)"; } return(prefix + "((" + this.children[0] + ") ? " + childCast1 + this.children[1] + " : " + childCast2 + this.children[2] + ")"); default: string func = scriptNode.ToString(perso, ts.settings); return(prefix + func + "(" + string.Join(", ", Array.ConvertAll <Node, String>(this.children.ToArray(), x => x.ToString())) + ")"); } case ScriptNode.NodeType.Procedure: string procedure = param < aiTypes.procedureTable.Length ? aiTypes.procedureTable[param] : ""; switch (procedure) { case "Proc_Loop": return(prefix + "for(int i = 0; i < " + firstChildNode + "; i++)\n{"); case "Proc_EndLoop": return(prefix + "}\n"); case "Proc_Break": return(prefix + "break;\n"); default: string proc = scriptNode.ToString(perso, ts.settings); return(prefix + proc + "(" + string.Join(", ", Array.ConvertAll <Node, String>(this.children.ToArray(), x => x.ToString())) + ");"); } case ScriptNode.NodeType.Operator: string op = param < aiTypes.operatorTable.Length ? aiTypes.operatorTable[param] : ""; Pointer persoPtr = null; switch (op) { // scalar: case "Operator_Plus": return("(" + firstChildNode + (children[1].scriptNode.param >= 0 ? " + " : "") + secondChildNode + ")"); case "Operator_Minus": case "Operator_UnaryMinus": if (children.Count > 1) { return("(" + firstChildNode + " - " + secondChildNode + ")"); } else { return("-" + firstChildNode); } case "Operator_Mul": return("(" + firstChildNode + " * " + secondChildNode + ")"); case "Operator_Div": return("(" + firstChildNode + " / " + secondChildNode + ")"); case "Operator_Mod": return("(" + firstChildNode + " % " + secondChildNode + ")"); // affect: case "Operator_PlusAffect": case "Operator_PlusPlusAffect": return(children.Count > 1 ? (firstChildNode + " += " + secondChildNode + ";") : firstChildNode + "++" + ";"); case "Operator_MinusAffect": case "Operator_MinusMinusAffect": return(children.Count > 1 ? (firstChildNode + " -= " + secondChildNode + ";") : firstChildNode + "--" + ";"); case "Operator_MulAffect": return(firstChildNode + " *= " + secondChildNode + ";"); case "Operator_DivAffect": return(firstChildNode + " /= " + secondChildNode + ";"); case "Operator_Affect": return(firstChildNode + " = " + secondChildNode + ";"); case "Operator_Dot": // dot operator persoPtr = this.children[0].scriptNode.param_ptr; if (persoPtr != null) { Perso firstNodePerso = Perso.FromOffset(persoPtr); /*if (firstNodePerso != null) { * string secondChildNodeWithDifferentContext = (this.children.Count > 1 && this.children[1] != null) ? this.children[1].ToString(firstNodePerso) : "null"; * return firstChildNode + "." + secondChildNodeWithDifferentContext; * } else {*/ return(firstChildNode + "." + this.children[1].ToString(null)); //} } return(firstChildNode + "." + secondChildNode); case ".X": return(firstChildNode + ".x"); // vector case ".Y": return(firstChildNode + ".y"); // vector case ".Z": return(firstChildNode + ".z"); // vector case "Operator_VectorPlusVector": return(firstChildNode + " + " + secondChildNode); case "Operator_VectorMinusVector": return(firstChildNode + " - " + secondChildNode); case "Operator_VectorMulScalar": return(firstChildNode + " * " + secondChildNode); case "Operator_VectorDivScalar": return(firstChildNode + " / " + secondChildNode); case "Operator_VectorUnaryMinus": return("-" + firstChildNode); case ".X:=": return(firstChildNode + ".x = " + secondChildNode + ";"); // vector case ".Y:=": return(firstChildNode + ".y = " + secondChildNode + ";"); // vector case ".Z:=": return(firstChildNode + ".z = " + secondChildNode + ";"); // vector case "Operator_Ultra": // Ultra operator (execute code for different object) return(firstChildNode + ".{code}".Replace("{code}", secondChildNode)); case "Operator_ModelCast": return("((" + firstChildNode + ")(" + secondChildNode + "))"); case "Operator_Array": return(firstChildNode + "[" + secondChildNode + "]"); default: string proc = "(" + scriptNode.param + ")" + scriptNode.ToString(perso, ts.settings); return(prefix + proc + "(" + string.Join(", ", Array.ConvertAll <Node, String>(this.children.ToArray(), x => x.ToString())) + ");"); } case ScriptNode.NodeType.Field: if (firstChildNode != null) { return(prefix + scriptNode.ToString(perso, ts.settings) + "(" + string.Join(", ", Array.ConvertAll <Node, String>(this.children.ToArray(), x => x.ToString())) + ")"); } else { return(prefix + scriptNode.ToString(perso, ts.settings)); } case ScriptNode.NodeType.Vector: case ScriptNode.NodeType.ConstantVector: return(prefix + scriptNode.ToString(perso, ts.settings) + "(" + string.Join(", ", Array.ConvertAll <Node, String>(this.children.ToArray(), x => x.ToString())) + ")"); case ScriptNode.NodeType.MetaAction: return(prefix + scriptNode.ToString(perso, ts.settings) + "(" + string.Join(", ", Array.ConvertAll <Node, String>(this.children.ToArray(), x => x.ToString())) + ");"); case ScriptNode.NodeType.SubRoutine: if (ts.expandMacros) { Macro macro = MapLoader.Loader.FromOffset <Macro>(scriptNode.param_ptr); if (macro != null) { string macroString = "// evalMacro(" + macro.ShortName + ");"; macroString += Environment.NewLine; TranslatedScript macroScript = new TranslatedScript(macro.script, perso); macroScript.expandMacros = true; macroString += macroScript.ToString(); macroString += Environment.NewLine + "// end macro"; return(macroString); } } return(prefix + scriptNode.ToString(perso, ts.settings)); default: return(prefix + scriptNode.ToString(perso, ts.settings)); } } else // Root node returns all children concatenated { string result = ""; foreach (Node child in this.children) { result += child.ToString() + '\n'; } return(result); } }
public EDsgVar GetExportableDsgVar(DsgVarInfoEntry infoEntry) { EDsgVar d = new EDsgVar(); d.type = infoEntry.type; if (infoEntry.value == null) { return(d); } switch (infoEntry.type) { default: d.value = infoEntry.value; break; case DsgVarInfoEntry.DsgVarType.None: break; case DsgVarInfoEntry.DsgVarType.List: // TODO: figure out lists break; case DsgVarInfoEntry.DsgVarType.Comport: // TODO: comport break; case DsgVarInfoEntry.DsgVarType.Action: // TODO: action break; case DsgVarInfoEntry.DsgVarType.Input: // TODO: check if this works //d.value = infoEntry.value break; case DsgVarInfoEntry.DsgVarType.SoundEvent: // TODO: check break; case DsgVarInfoEntry.DsgVarType.Light: // TODO: check break; case DsgVarInfoEntry.DsgVarType.GameMaterial: d.value = HashUtils.MD5Hash(GameMaterial.FromOffset((Pointer)(infoEntry.value)).ToJSON()); break; case DsgVarInfoEntry.DsgVarType.VisualMaterial: d.value = HashUtils.MD5Hash(VisualMaterial.FromOffset((Pointer)(infoEntry.value)).ToJSON()); break; case DsgVarInfoEntry.DsgVarType.Perso: d.value = Perso.FromOffset((Pointer)(infoEntry.value))?.namePerso; break; case DsgVarInfoEntry.DsgVarType.Waypoint: // TODO d.value = ((Pointer)infoEntry.value).ToString(); break; case DsgVarInfoEntry.DsgVarType.Graph: // TODO d.value = ((Pointer)infoEntry.value).ToString(); break; case DsgVarInfoEntry.DsgVarType.Text: // TODO: check goto default; case DsgVarInfoEntry.DsgVarType.SuperObject: // TODO: check break; case DsgVarInfoEntry.DsgVarType.SOLinks: // TODO break; case DsgVarInfoEntry.DsgVarType.PersoArray: List <string> persoNames = new List <string>(); foreach (object persoPointer in (object[])infoEntry.value) { if (persoPointer == null) { continue; } if (!(persoPointer is Pointer)) { persoNames.Add("Not a valid pointer: " + (persoPointer).ToString()); // TODO: fix continue; } Perso perso = Perso.FromOffset((Pointer)persoPointer); if (perso != null) { persoNames.Add(perso.namePerso); } else { persoNames.Add("NullPointer"); } } break; case DsgVarInfoEntry.DsgVarType.WayPointArray: // TODO break; case DsgVarInfoEntry.DsgVarType.TextArray: // TODO: check goto default; //break; case DsgVarInfoEntry.DsgVarType.TextRefArray: // TODO: check goto default; case DsgVarInfoEntry.DsgVarType.Array6: break; case DsgVarInfoEntry.DsgVarType.Array9: break; case DsgVarInfoEntry.DsgVarType.SoundEventArray: // TODO: check goto default; case DsgVarInfoEntry.DsgVarType.Array11: break; case DsgVarInfoEntry.DsgVarType.Way: break; case DsgVarInfoEntry.DsgVarType.ActionArray: // TODO break; case DsgVarInfoEntry.DsgVarType.SuperObjectArray: // TODO break; } return(d); }
void Start() { healthBarlenght = Screen.width / 2; personnage = GameObject.Find("Personnage").GetComponent("Perso") as Perso; }
public CollSet(Perso perso, Pointer offset) { this.perso = perso; this.offset = offset; }
// Use this for initialization void Start() { joueur = GameObject.Find ("Personnage").GetComponent ("Perso") as Perso; }
// Use this for initialization void Start() { personnage = gameObject.GetComponent ("Perso") as Perso; HAUTEURINIT = transform.position.y; minion = transform.FindChild ("Minion").gameObject; pauseText = GameObject.Find ("GuiPause"); PauseQuitterText = GameObject.Find ("GuiQuitter"); PauseContinuerText = GameObject.Find ("GuiContinuer"); timeScaleDeBase = Time.timeScale; //NBR, ajout gameObject MinionPause minionPause = GameObject.Find ("MinionContinuer"); minionQuitter = GameObject.Find ("MinionQuitter"); minionPause.SetActive (false); minionQuitter.SetActive (false); }