// Update is called once per frame void Update() { if (GameManager.Instance.GameState == GameManager.State.PLAY) { if (_isKicking == false && _isAnim == false) { if (Input.GetButtonDown(throwInputs[_playerID]) && spawner.CanTake()) { _block = spawner.TakeBlock(); _animator.SetTrigger("Throw"); } else if (Input.GetButtonDown(buildInputs[_playerID]) && spawner.CanTake()) { _block = spawner.TakeBlock(); _animator.SetTrigger("Build"); } if (_block) { var point = spawner.GetLastPoint(); _block.transform.position = Vector3.MoveTowards(_block.transform.position, point, spawner.blockSpeed * Time.deltaTime * 2); } } else if (_isKicking) { if (_block) { _block.transform.position = Vector3.MoveTowards(_block.transform.position, targetKick.position, kickSpeed * Time.deltaTime); _block.transform.localScale = Vector3.Slerp(_block.transform.localScale, _finalScale, kickSpeed * Time.deltaTime); } } } }
public AILEmitter(ABlock[] Graph, ABlock Root, string SubName) { this.SubName = SubName; Locals = new Dictionary <ARegister, int>(); ILBlocks = new AILBlock[Graph.Length]; AILBlock GetBlock(int Index) { if (Index < 0 || Index >= ILBlocks.Length) { return(null); } if (ILBlocks[Index] == null) { ILBlocks[Index] = new AILBlock(); } return(ILBlocks[Index]); } for (int Index = 0; Index < ILBlocks.Length; Index++) { AILBlock Block = GetBlock(Index); Block.Next = GetBlock(Array.IndexOf(Graph, Graph[Index].Next)); Block.Branch = GetBlock(Array.IndexOf(Graph, Graph[Index].Branch)); } this.Root = ILBlocks[Array.IndexOf(Graph, Root)]; }
private ATranslatedSub TranslateTier0(AThreadState State, AMemory Memory, long Position) { ABlock Block = ADecoder.DecodeBasicBlock(State, Memory, Position); ABlock[] Graph = new ABlock[] { Block }; string SubName = GetSubroutineName(Position); AILEmitterCtx Context = new AILEmitterCtx(Cache, Graph, Block, SubName); do { Context.EmitOpCode(); }while (Context.AdvanceOpCode()); ATranslatedSub Subroutine = Context.GetSubroutine(); Subroutine.SetType(ATranslatedSubType.SubTier0); Cache.AddOrUpdate(Position, Subroutine, Block.OpCodes.Count); AOpCode LastOp = Block.GetLastOp(); return(Subroutine); }
public DialogCell getNextDialogCellFromCurrentDCell(DialogCell iDialogCell) { DialogCell nextCell = null; if (iDialogCell != null) { ABlock selectedAnswer = iDialogCell.selectedAnswer; string defaultSuccessorID = iDialogCell.defaultSuccessorID; string answerSuccessorID = (selectedAnswer != null) ? selectedAnswer.successor_dcell_ID : ""; string successorID = (answerSuccessorID.Length > 0) ? answerSuccessorID : defaultSuccessorID; Debug.Log(" SUCCESSOR ID " + successorID); if (successorID.Length <= 0) { return(null); } foreach (DialogCell dcell in loadedCells) { if (dcell.getID() == successorID) { nextCell = dcell; break; } }//! foreach activeAnswer } return(nextCell); }
public string getSelectedAnswer() { if (activeDCell != null) { ABlock answer = activeDCell.getSelectedAnswer(); if (answer != null) { string s = answer.getMessage(); return((s != null) ? s : "not found"); } } return("no answer found"); }
private void MoveBlockTowardNext(ABlock block) { var point = m_path[block.currentID + 1]; block.transform.position = Vector3.MoveTowards(block.transform.position, point.position, blockSpeed * Time.deltaTime); block.transform.rotation = Quaternion.RotateTowards(block.transform.rotation, point.rotation, angularSpeed * Time.deltaTime); if (Vector3.Distance(block.transform.position, point.position) < 0.0001f) { ++block.currentID; } }
public void EndKick() { _isKicking = false; if (playerID == Player.P1) { _blockBuilder.PushBlockLeft(_block); } else { _blockBuilder.PushBlockRight(_block); } _block = null; }
public void Throw() { _isKicking = false; GetComponent <AudioSource>().Play(); var rb = _block.GetComponent <Rigidbody2D>(); _block.GetComponent <Collider2D>().enabled = true; rb.bodyType = RigidbodyType2D.Dynamic; rb.AddTorque(100f, ForceMode2D.Impulse); var obj = Instantiate(playerID == Player.P2 ? kickEffectInvert : kickEffect, throwEffetOrigin.position, Quaternion.identity, throwEffetOrigin); Destroy(obj, 0.5f); _block = null; }
public static NPCDialogDico wizard1() { NPCDialogDico dico = new NPCDialogDico(); // CREATE CELLS QBlock q0 = new QBlock("Wizard : Good morning sir."); DialogCell cell0 = new DialogCell(q0); dico.addDialogCell(cell0); QBlock q1 = new QBlock("Beautiful Princess, heh?"); DialogCell cell1 = new DialogCell(q1); dico.addDialogCell(cell1); QBlock q2 = new QBlock("I can help you pass this weird door but it will cost you an arm."); ABlock a21 = new ABlock("OK, Let's do this !"); ABlock a22 = new ABlock("No way I'm doing it."); DialogCell cell2 = new DialogCell(q2); cell2.addAnswer(a21); cell2.addAnswer(a22); dico.addDialogCell(cell2); QBlock q3 = new QBlock("You made the right decision my friend!", DBlock.DBLOCK_EFFECTS.LOSE_ARM); DialogCell cell3 = new DialogCell(q3); dico.addDialogCell(cell3); QBlock q4 = new QBlock("As you wish..."); DialogCell cell4 = new DialogCell(q4); dico.addDialogCell(cell4); // UPDATE LINKS cell0.defaultSuccessorID = cell1.getID(); cell1.defaultSuccessorID = cell2.getID(); a21.successor_dcell_ID = cell3.getID(); a22.successor_dcell_ID = cell4.getID(); // SET STARTING CELL dico.setStartingCellFromID(cell0.getID()); dico.finishDicoCreation(); return(dico); }
private ATranslatedSub TranslateTier0(AMemory Memory, long Position) { ABlock Block = ADecoder.DecodeBasicBlock(this, Memory, Position); ABlock[] Graph = new ABlock[] { Block }; string SubName = GetSubName(Position); AILEmitterCtx Context = new AILEmitterCtx(this, Graph, Block, SubName); do { Context.EmitOpCode(); }while (Context.AdvanceOpCode()); ATranslatedSub Subroutine = Context.GetSubroutine(); lock (SubBlocks) { if (SubBlocks.Contains(Position)) { SubBlocks.Remove(Position); Subroutine.SetType(ATranslatedSubType.SubBlock); } else { Subroutine.SetType(ATranslatedSubType.SubTier0); } } CachedSubs.AddOrUpdate(Position, Subroutine, (Key, OldVal) => Subroutine); AOpCode LastOp = Block.GetLastOp(); lock (SubBlocks) { if (LastOp.Emitter != AInstEmit.Ret && LastOp.Emitter != AInstEmit.Br) { SubBlocks.Add(LastOp.Position + 4); } } return(Subroutine); }
/// <summary> /// Checks if two elements are pairs. /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public bool CheckPair(ABlock a, ABlock b) { var spriteA = a.GetComponent <SpriteRenderer>().sprite; var spriteB = b.GetComponent <SpriteRenderer>().sprite; foreach (Pair pair in _combinationList) { Sprite pairSprite = pair.GetPair(spriteA); if (pairSprite == spriteB) { return(true); } } return(false); }
public AILEmitterCtx(ATranslator Translator, ABlock[] Graph, ABlock Root) { this.Translator = Translator; this.Graph = Graph; this.Root = Root; string SubName = $"Sub{Root.Position:X16}"; Labels = new Dictionary <long, AILLabel>(); Emitter = new AILEmitter(Graph, Root, SubName); ILBlock = Emitter.GetILBlock(0); OpcIndex = -1; if (!AdvanceOpCode()) { throw new ArgumentException(nameof(Graph)); } }
public AILEmitterCtx( ATranslator Translator, ABlock[] Graph, ABlock Root, string SubName) { if (Translator == null) { throw new ArgumentNullException(nameof(Translator)); } if (Graph == null) { throw new ArgumentNullException(nameof(Graph)); } if (Root == null) { throw new ArgumentNullException(nameof(Root)); } this.Translator = Translator; this.Graph = Graph; this.Root = Root; Callees = new HashSet <long>(); Labels = new Dictionary <long, AILLabel>(); Emitter = new AILEmitter(Graph, Root, SubName); ILBlock = Emitter.GetILBlock(0); OpcIndex = -1; if (Graph.Length == 0 || !AdvanceOpCode()) { throw new ArgumentException(nameof(Graph)); } }
public AILEmitterCtx( ATranslatorCache Cache, ABlock[] Graph, ABlock Root, string SubName) { this.Cache = Cache ?? throw new ArgumentNullException(nameof(Cache)); this.Graph = Graph ?? throw new ArgumentNullException(nameof(Graph)); this.Root = Root ?? throw new ArgumentNullException(nameof(Root)); Labels = new Dictionary <long, AILLabel>(); Emitter = new AILEmitter(Graph, Root, SubName); ILBlock = Emitter.GetILBlock(0); OpcIndex = -1; if (Graph.Length == 0 || !AdvanceOpCode()) { throw new ArgumentException(nameof(Graph)); } }
public void addAnswer(ABlock iABlock) { answers.Add(iABlock); }
public void addBlock(ABlock block) { blocks.Add(block); }
public void EmitLoadState(ABlock RetBlk) { ILBlock.Add(new AILOpCodeLoad(Array.IndexOf(Graph, RetBlk), AIoType.Fields)); }
private void panelcontrol_MouseUp(object sender, MouseEventArgs e) { End.X = e.X; End.Y = e.Y; g = panelcontrol.CreateGraphics(); DiagramFactory fac = new DfdFactory(); ShapeInfo temp = new ShapeInfo(Start, End); DiagramFactory fac2 = new FCFactory(); CommonGraphics gdi1 = new GdiPlusCommonGraphics(g, panelcontrol); //chon graphic if (GraphicType == 0) { gdi = gdi1; } else { try { Surface s = new Win32Surface(g.GetHdc()); Context c = new Context(s); gdi = new CairoCommonGraphics(c); }catch (System.DllNotFoundException) { GraphicType = 0; MessageBox.Show("DllNotFoundException", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //chon hinh ve switch (ShapeType) { case 0: Shape line = new Line(Start, End); line.draw(gdi); break; case 1: Shape rect = new Rect(Start, End); rect.draw(gdi); break; case 2: Shape eclip = new Eclip(Start, End); eclip.draw(gdi); break; case 3: ABlock startblock = fac.createStartBlock(temp); startblock.draw(gdi); break; case 4: ABlock input = fac.createInputBlock(temp); input.draw(gdi); break; case 5: ABlock startbl = fac2.createStartBlock(temp); startbl.draw(gdi); break; case 6: ABlock inputbl = fac2.createInputBlock(temp); inputbl.draw(gdi); break; case 7: Shape star = new Star(Start, End); star.draw(gdi); break; default: break; } }