public void interact() { GameObject interactWith = null; Vector2 direction = new Vector2((currentOrientation == Orientation.LEFT) ? -1 : ((currentOrientation == Orientation.RIGHT) ? 1 : 0), (currentOrientation == Orientation.DOWN) ? -1 : ((currentOrientation == Orientation.UP) ? 1 : 0)); RaycastHit hit = new RaycastHit(); //Debug.DrawLine(this.transform.position, this.transform.position + new Vector3(direction.x,direction.y,0) * 42f); if (Physics.Raycast(this.transform.position, direction, out hit, 1.5f)) { interactWith = hit.collider.gameObject; } else { return; } PNJ interactScript = interactWith.GetComponent <PNJ>(); Hero heroScript = interactWith.GetComponent <Hero>(); if (interactScript != null) { interactScript.printMenu(); return; } else if (heroScript != null) { heroScript.printnextMenu(); return; } }
// Awake est appele avant Start private void Awake() { //Debug.Log("Awake de la classe Jeu."); if (instance != null) { Destroy(gameObject, 0); } else { Debug.Log("Création de l'instance unique de Jeu (Awake)"); _instance = this; _canvasUI = Instantiate(_prefabCanvasUI, Vector2.zero, Quaternion.identity).GetComponent <Canvas>(); _infos = Instantiate(_prefabInfos, Vector2.zero, Quaternion.identity, _canvasUI.transform).GetComponent <Infos>(); _infos.transform.localPosition = Vector2.zero; _dialogue = Instantiate(_prefabDialogue, Vector2.zero, Quaternion.identity, _canvasUI.transform).GetComponent <Dialogue>(); _dialogue.transform.localPosition = Vector2.zero; _musique = Instantiate(_prefabMusique, Vector2.zero, Quaternion.identity).GetComponent <Musique>(); _debogage = Instantiate(_prefabDebogage, Vector2.zero, Quaternion.identity); AjouterPerso(nomJoueur, true); //ajoute le perso en tant que joueur //disparition du PNJ correspondant: PNJ.NoterAbsence(nomJoueur); // Evite la desctructions des elements importants au changement de scene DontDestroyOnLoad(gameObject); //l'instance de Jeu DontDestroyOnLoad(_perso.gameObject); //le personnage du joueur DontDestroyOnLoad(_musique.gameObject); //l'instance qui gere la musique DontDestroyOnLoad(_canvasUI.gameObject); //l'instance du canevas (par extension infos et dialogue) DontDestroyOnLoad(_debogage.gameObject); //l'instance qui gere le debogage } //if+else } //Awake
private bool playerDetected = false; //Permet de savoir si le joueur est proche de cet objet ou non // Use this for initialization void Start() { functions = GameObject.Find("GameManager").GetComponent <MasterScriptOld>(); screenCanvas = GameObject.Find("Screen"); if (objectType == 1) { pnjScript = this.GetComponent <PNJ>(); } else { itemPosition = this.transform.position; } screenManager = screenCanvas.GetComponent <ScreenManager>(); linkedItem = screenCanvas.transform.GetChild(0).GetChild(1).GetChild(1).GetChild(functions.GetChildId(idElement)); }
// Update is called once per frame void Initialisation() { newComponent = gameObject.AddComponent <PNJ>(); newComponent.haveEvent = haveEvent; newComponent.PNJName = realCharacterName; newComponent.negativeQuote = 3; newComponent.transitionQuote = 2; /*PNJ.StickerRedirection sRList = new PNJ.StickerRedirection(); * PNJ.EventRedirection eRList = new PNJ.EventRedirection(); * for(int i = 0; i < stickerRedirection.redirectionList.Count; i++) * { * sRList.stickerGivenList.Add(stickerRedirection.stickerGivenList[i]); * sRList.redirectionList.Add(stickerRedirection.redirectionList[i]); * } * newComponent.stickerRedirection = sRList;*/ //Debug.Log(characterNameReference + "_" + firstDialogKey); InitializeDialogs(); }
public void ChangeDialogueComponent(string modifRef) { DialogueComponent DC = dialogues.Find(x => x.modificationName == modifRef); //Destroy(DC.characterToModify.GetComponent<PNJ>()); //PNJ pnjComponent = DC.newComponent; PNJ oldComponent = DC.characterToModify.GetComponent <PNJ>(); oldComponent.transitionQuote = DC.newComponent.transitionQuote; oldComponent.PNJName = DC.newComponent.PNJName; oldComponent.eventsActivationList = DC.newComponent.eventsActivationList; /*if(DC.newComponent.eventsActivationList.Count > 0) * { * for(int i = 0; i < DC.newComponent.eventsActivationList.Count; i++) * {oldComponent.eventsActivationList.Add(new PNJ.EventsTriggeredByStickers{DC.newComponent.eventsActivationList.})} * }*/ oldComponent.negativeQuote = DC.newComponent.negativeQuote; oldComponent.allDialogs = DC.newComponent.allDialogs; oldComponent.stickerRedirection = DC.newComponent.stickerRedirection; oldComponent.eventRedirection = DC.newComponent.eventRedirection; oldComponent.haveEvent = DC.newComponent.haveEvent; oldComponent.stickerAlreadyGivenList = DC.newComponent.stickerAlreadyGivenList; oldComponent.stickersAlreadyGiven = DC.newComponent.stickersAlreadyGiven; }
// Update is called once per frame void Update() { horizontal = Input.GetAxisRaw(GameController.Instance.horizontal); vertical = Input.GetAxisRaw(GameController.Instance.vertical); if (canMove) { if (horizontal > 0) { GetComponent <SpriteRenderer>().flipX = false; } else if (horizontal < 0) { GetComponent <SpriteRenderer>().flipX = true; } } if (lastTriggerEnter != null) { if (Input.GetButtonDown(GameController.Instance.action)) { if (!GameController.Instance.dialogController.DialogIsRunning()) { if (lastTriggerEnter.GetComponent <PNJ>() && lastTriggerEnter.activeSelf) { canMove = false; PNJ pnj = lastTriggerEnter.GetComponent <PNJ>(); pnj.Interact(); } else if (lastTriggerEnter.GetComponent <TeleportToZone>() && canMove) { lastTriggerEnter.GetComponent <TeleportToZone>().Teleport(); canMove = false; } } else { if (!GameController.Instance.dialogController.InInteraction()) { GameController.Instance.dialogController.NextDialogue(); } else { GameController.Instance.dialogController.ValidateChoice(); firstInteraction = true; } } } else if (GameController.Instance.dialogController.InInteraction()) { if (firstInteraction) { GameController.Instance.dialogController.dialogBoxSystem.MoveSelector(0); firstInteraction = false; } if (vertical == -1) { GameController.Instance.dialogController.dialogBoxSystem.MoveSelector(1); } else if (vertical == 1) { GameController.Instance.dialogController.dialogBoxSystem.MoveSelector(0); } } } }
public CreatePNJStats() { pnjToSave = new PNJ(); tmpStats = new PNJ.Stats(); type = PNJGenerator.Archetype.paysant; }
//Faut finir ca void CreateWindowedPrefab(JsonData data, string filePath) { GameObject hat; GameObject chest; GameObject arms; bool offSetOK = false; PNJGenerator.StatsMinMax statsMinMax = new PNJGenerator.StatsMinMax(); PNJ.Stats stats = new PNJ.Stats(); statsMinMax.strMax = (int)data["strMax"]; statsMinMax.strMin = (int)data["strMin"]; statsMinMax.dexMax = (int)data["dexMax"]; statsMinMax.dexMin = (int)data["dexMin"]; statsMinMax.intelMax = (int)data["intelMax"]; statsMinMax.intelMin = (int)data["intelMin"]; statsMinMax.name = (string)data["name"]; stats.str = Random.Range(statsMinMax.strMin + 1, statsMinMax.strMax + 1); stats.dex = Random.Range(statsMinMax.dexMin + 1, statsMinMax.dexMax + 1); stats.intel = Random.Range(statsMinMax.intelMin + 1, statsMinMax.intelMax + 1); stats.name = PNJ.RandomizeName(5); GameObject emptyGo = Instantiate(PNJGenerator.instance.vide); emptyGo.transform.name = stats.name; emptyGo.AddComponent <PNJ>(); emptyGo.GetComponent <PNJ>().AccStats = stats; emptyGo.GetComponent <PNJ>().hasBeenCreated = true; //str if (stats.str > ((statsMinMax.strMax * 66) / 100)) { //chest = PrefabUtility.CreatePrefab(filePath + "") chest = Instantiate(PNJGenerator.instance.chest1); offSetOK = true; } else if (stats.str > ((statsMinMax.strMax * 33) / 100)) { chest = Instantiate(PNJGenerator.instance.chest2); } else { chest = Instantiate(PNJGenerator.instance.chest3); } //intel if (stats.intel > ((statsMinMax.intelMax * 66) / 100)) { hat = Instantiate(PNJGenerator.instance.head1); } else if (stats.intel > ((statsMinMax.intelMax * 33) / 100)) { hat = Instantiate(PNJGenerator.instance.head2); if (offSetOK) { hat.transform.position += new Vector3(0.0f, 0.25f, 0.0f); } } else { hat = new GameObject(); Debug.LogError("Y'a un blem ici, clique mwa dessus ! Jsuis pas censé rentré là dedans, jle fais pour intellicense"); } //dex if (stats.dex > ((statsMinMax.dexMax * 66) / 100)) { arms = Instantiate(PNJGenerator.instance.arms1); } else if (stats.dex > ((statsMinMax.dexMax * 33) / 100)) { arms = Instantiate(PNJGenerator.instance.arms2); } else { arms = Instantiate(PNJGenerator.instance.arms3); } chest.transform.SetParent(emptyGo.transform); hat.transform.SetParent(emptyGo.transform); arms.transform.SetParent(emptyGo.transform); filePath += emptyGo.name + ".prefab"; PrefabUtility.CreatePrefab(filePath, emptyGo); Destroy(emptyGo); }
public void SetCanInteract(bool aNewState, PNJ aPNJ) { myCanInteract = aNewState; myPNJ = aPNJ; myInteractionButtonGameObject.SetActive(aNewState); }