void ChangeState(TypeSequence state, bool inventoryButtonInOnItemView) { this.inventoryButtonInOnItemView = inventoryButtonInOnItemView; switch (state) { case TypeSequence.ITEM_SEARCH: objs.ItemSearch(); break; case TypeSequence.ON_ITEM: screenPreItemFocus = currentState; objs.OnItem(inventoryButtonInOnItemView); break; case TypeSequence.INVENTORY: screenPreInventory = currentState; objs.OnInventory(); break; case TypeSequence.DIALOG: objs.OnDialog(speechControl, progress); break; default: break; } currentState = state; }
public void ItemSearch() { prevType = TypeSequence.ITEM_SEARCH; cameraIsOnTheItem = false; DisableScreens(); inventoryButton.SetActive(true); backButton.SetActive(false); }
void InventoryButton() { inventoryLayer = 0; switch (currentState) { case TypeSequence.ITEM_SEARCH: ChangeState(TypeSequence.INVENTORY, inventoryButtonInOnItemView); break; case TypeSequence.ON_ITEM: switch (focusedItem) { case "retrato": if (progress.Frame) { speechControl.Start(Events.frameCutsceneI); } else { speechControl.Start(Events.frameCutsceneInv); } break; case "oso": if (progress.Bear) { speechControl.Start(Events.bearCutsceneI); } else { speechControl.Start(Events.bearCutsceneInv); } break; case "caja_musica": if (progress.Box) { speechControl.Start(Events.dollCutsceneI); } else { speechControl.Start(Events.dollCutsceneInv); } break; } screenPreInventory = TypeSequence.ON_ITEM; screenPreItemFocus = TypeSequence.ON_ITEM; ChangeState(TypeSequence.DIALOG, true); break; } }
public void OnItem(bool showInventoryButton) { this.showInventoryButton = showInventoryButton; prevType = TypeSequence.ON_ITEM; cameraIsOnTheItem = true; DisableScreens(); inventoryButton2.SetActive(true); if (showInventoryButton) { inventoryOptionOnItemView.SetActive(true); } }
void Continue() { switch (currentState) { case TypeSequence.DIALOG: // it remembers screen pre inventory currentState = objs.NextSpeechAndNewTypeSequence(speechControl, progress); //DisableUIWhileAnimation(ANIMATION_PAUSE_TO_VIEW); break; default: break; } }
private TypeDeclaration ParseType() { TypeDeclaration _result = new TypeDeclaration(); if (this.index == this.tokens.Count) { throw new System.Exception("expected statement, got EOF"); } if (!this.tokens[this.index++].Equals(languageSetting["Type"])) { throw new System.Exception("Type Expected"); } _result.TypeName = this.tokens[this.index++].ToString(); if (!this.tokens[this.index++].Equals(languageSetting["Start"])) { throw new System.Exception("Start Expected"); } this.ParseClassVariable(_result); _result.methodDec = this.ParseMethod(); if (!this.tokens[this.index++].Equals(languageSetting["End"])) { throw new System.Exception("End Expected"); } if (this.index < this.tokens.Count && this.tokens[this.index].Equals(languageSetting["Type"])) { TypeSequence TypeSeq = new TypeSequence(); TypeSeq.First = _result; TypeSeq.Second = this.ParseType(); _result = TypeSeq; } return(_result); }
public TypeSequence NextSpeechAndNewTypeSequence(SpeechControl speechController, Progress progress) { if (currentCharacterInScroll < totalCharactersInText + 15) { if (currentCharacterInScroll < totalCharactersInText) { currentCharacterInScrollf = ( float )totalCharactersInText; currentCharacterInScroll = totalCharactersInText; actionText.maxVisibleCharacters = totalCharactersInText; dialogText.maxVisibleCharacters = totalCharactersInText; } return(TypeSequence.DIALOG); } DisableScreens(); SpeechPackage speechPack = speechController.Continue(); Speech speechHeld = speechPack.speech; if (speechHeld.type == EventType.FIX) { if (speechHeld.dialog == "bear" && progress.Bear == false) { progress.Bear = true; buttonInventory.SetActive(false); threadInventory.SetActive(false); oldBear.SetActive(false); newBear.SetActive(true); progress.heartHeal++; } else if (speechHeld.dialog == "frame" && progress.Frame == false) { progress.Frame = true; photo1Inventory.SetActive(false); photo2Inventory.SetActive(false); oldPortrait.SetActive(false); newPortrait.SetActive(true); progress.heartHeal++; } else if (speechHeld.dialog == "box" && progress.Box == false) { progress.Box = true; ballerinaInventory.SetActive(false); winderInventory.SetActive(false); oldBox.SetActive(false); newBox.SetActive(true); progress.heartHeal++; } else if (speechHeld.dialog == "finale" && progress.Box == false) { ballerinaInventory.SetActive(false); winderInventory.SetActive(false); oldBox.SetActive(false); newBox.SetActive(true); progress.heartHeal++; //FINALE } merry.heart1.SetActive(false); merry.heart2.SetActive(false); merry.heart3.SetActive(false); merry.heart4.SetActive(false); switch (progress.GetHeartStatus()) { case HeartStatus.ONE: merry.heart1.SetActive(true); break; case HeartStatus.TWO: merry.heart2.SetActive(true); break; case HeartStatus.THREE: merry.heart3.SetActive(true); break; case HeartStatus.FOUR: merry.heart4.SetActive(true); break; } speechPack = speechController.Continue(); speechHeld = speechPack.speech; //prevType = TypeSequence.ON_ITEM; // return TypeSequence.ITEM_SEARCH; } if (speechHeld.type == EventType.FINALE) { SceneManager.LoadScene("ED"); } if (!speechPack.isValidSPeech) { if (progress.heartHeal == 3) { progress.heartHeal = 4; speechController.Start(Events.finale); speechPack = speechController.Current(); speechHeld = speechPack.speech; HandleSpeechEvent(speechHeld, progress); return(TypeSequence.DIALOG); } if (prevType == TypeSequence.ON_ITEM) { OnItem(showInventoryButton); return(TypeSequence.ON_ITEM); } else { //TypeSequence.ITEM_SEARCH ItemSearch(); return(TypeSequence.ITEM_SEARCH); } } if (speechHeld.type == EventType.OPEN_INVENTORY) { OnInventory(); prevType = TypeSequence.ON_ITEM; return(TypeSequence.INVENTORY); } if (speechHeld.type == EventType.OPEN_INVENTORY_2ND_STAGE) { OnInventory(); prevType = TypeSequence.ON_ITEM; return(TypeSequence.INVENTORY); } if (speechHeld.type == EventType.AQUIRE_ITEM) { ItemSearch(); progress.GetItem(speechHeld.dialog); prevType = TypeSequence.ON_ITEM; return(TypeSequence.ITEM_SEARCH); } HandleSpeechEvent(speechHeld, progress); return(TypeSequence.DIALOG); }
private void ApplyGrammar(List <ASTNode> nodes, int from = 0, bool allowNoSemicolon = false, params GrammarRule[] additionalPatterns) { int i = from; while (i < nodes.Count) { if (nodes[i] is NopNode) { nodes.RemoveAt(i); // Remove the nopnode -> Should never pass through this method continue; } if (additionalPatterns != null) { bool skipStandard = false; for (int j = 0; j < additionalPatterns.Length; j++) { if (additionalPatterns[j](nodes, ref i)) { skipStandard = true; break; } } if (skipStandard) { i++; continue; } } if (nodes[i].LexicalType == LexTokenType.Keyword) { switch (nodes[i].Content) { case "class": this.ApplyClassGrammar(nodes, ref i); break; case "return": this.ApplyReturnStatementGrammar(nodes, i); break; case "if": this.ApplyIfStatementGrammar(nodes, i); break; case "while": this.ApplyWhileStatementGrammar(nodes, i); break; case "for": this.ApplyForStatementGrammar(nodes, i); break; case "do": this.ApplyDoStatementGrammar(nodes, i); break; case "public": case "private": case "protected": case "external": case "internal": nodes[i] = new AccessModifierNode(nodes[i].Content, nodes[i].Pos); break; case "namespace": this.ApplyNamespaceGrammar(nodes, i); break; default: throw new NotImplementedException(nodes[i].Content); } } else if (TypeSequence <ASTNode, IdentifierNode, IdentifierNode, SeperatorNode> .Match(nodes, i)) // int x; { this.ApplyModifierGrammar(nodes, ref i, out AccessModifierNode accessModifier, out HashSet <StorageModifierNode> storageModifiers); nodes[i] = new VarDeclNode(nodes[i].Pos, nodes[i].ToTypeIdentifier(), nodes[i + 1].Content); this.ApplyModifiers(nodes[i] as VarDeclNode, accessModifier, storageModifiers); this.RemoveNode(nodes, i + 1, 2); } else if (TypeSequence <ASTNode, IdentifierNode, AssignmentNode, SeperatorNode> .Match(nodes, i) || TypeSequence <ASTNode, TypeArrayIdentifierNode, AssignmentNode, SeperatorNode> .Match(nodes, i)) // int x = <expr>; OR int[] x = <expr>; { this.ApplyModifierGrammar(nodes, ref i, out AccessModifierNode accessModifier, out HashSet <StorageModifierNode> storageModifiers); AssignmentNode assignOp = nodes[i + 1] as AssignmentNode; bool doRecursive = true; if (assignOp.Right is ScopeNode initializer) { if (this.ApplyInitializerGrammar(initializer, out IInitializer init)) { assignOp.Update(LeftRight.LHS, assignOp.Left); assignOp.Update(LeftRight.RHS, init as ASTNode); doRecursive = false; } } if (doRecursive) { this.ApplySingleNodeGrammar(assignOp.Right, true); } nodes[i] = new VarDeclNode(nodes[i].Pos, nodes[i].ToTypeIdentifier(), assignOp); this.ApplyModifiers(nodes[i] as VarDeclNode, accessModifier, storageModifiers); this.RemoveNode(nodes, i + 1, 2); } else if (TypeSequence <ASTNode, IdentifierNode, ExpressionNode, ASTNode, IdentifierNode, ScopeNode> .Match(nodes, i)) { if (nodes[i + 2].Content.CompareTo(":") == 0) { this.ApplyFunctionGrammar(nodes, ref i); } } else if (TypeSequence <ASTNode, IExpr, ExpressionNode> .Match(nodes, i)) { ExpressionNode groupNode = nodes[i + 1] as ExpressionNode; this.ApplyGrammar(groupNode.Nodes, 0, true); // apply grammar on arguments ==> should lead to a nice arg1,arg2,arg3 setup (otherwise error) CallNode callNode = new CallNode(nodes[i], nodes[i].Pos) { Arguments = new ArgumentsNode(groupNode) // Note: This constructor will apply the grammar rule on its own }; if (!callNode.Arguments.IsValid) { throw new Exception(); } this.RemoveNode(nodes, i + 1); nodes[i] = callNode; } else if (nodes[i] is IGroupedASTNode groupNode) { this.ApplyGrammar(groupNode.Nodes); } else { ApplySingleNodeGrammar(nodes[i]); } if (nodes[i] is IExpr && i + 1 < nodes.Count && nodes[i + 1] is SeperatorNode sepNode && sepNode.Content.CompareTo(";") == 0) { this.RemoveNode(nodes, i + 1); }