public override void OnRecycled() { base.OnRecycled(); Anim.ResetTrigger("TurnToFront"); Anim.ResetTrigger("TurnToBack"); Anim.ResetTrigger("ResetToFront"); Anim.ResetTrigger("ResetToBack"); FragmentCollider.OnRecycled(); }
public void Update() { if (GameStateManager.Instance.GetState() == GameState.Playing) { //SkillGridIndicatorGroup.RectTransform.anchoredPosition = Input.mousePosition - new Vector3(Screen.width / 2f, Screen.height / 2f, 0); if (Input.GetKeyDown(KeyCode.R)) { if (currentSkill != null) { currentSkill.RotateOccupiedPositions(); SkillGridIndicatorGroup.Init(currentSkill.OccupiedPositions, SkillIndicatorGridSize, false, CurrentScale * SkillIndicatorScaleFactor); } } if ((!EventSystem.current.IsPointerOverGameObject() && Input.GetMouseButtonUp(0)) || Input.GetMouseButtonUp(1)) { if (Reward + CurrentCoin > 0) { Ray cursorRay = Camera.main.ScreenPointToRay(Input.mousePosition); ArchivedStep archivedStep = new ArchivedStep(); if (currentSkill != null) { foreach (SkillConfig.SkillGrid sg in currentSkill.OccupiedPositions) { Ray ray = new Ray(cursorRay.origin + new Vector3(sg.GridPos.x, sg.GridPos.z, 0) * CurrentScale, cursorRay.direction); if (Physics.Raycast(ray, out RaycastHit hit, 1000, LayerManager.Instance.LayerMask_Fragment)) { FragmentCollider fc = hit.collider.gameObject.GetComponent <FragmentCollider>(); switch (sg.SkillGridType) { case SkillGridType.Flip: { ArchivedStep.Step step = new ArchivedStep.Step(fc.SquireFragment.GridPos, fc.SquireFragment.Front); archivedStep.AllGridChanges.Add(step); fc.SquireFragment.FlipFragment(); break; } case SkillGridType.TintWhite: { if (!fc.SquireFragment.Front) { ArchivedStep.Step step = new ArchivedStep.Step(fc.SquireFragment.GridPos, fc.SquireFragment.Front); archivedStep.AllGridChanges.Add(step); fc.SquireFragment.Front = true; } break; } case SkillGridType.TintBlack: { if (fc.SquireFragment.Front) { ArchivedStep.Step step = new ArchivedStep.Step(fc.SquireFragment.GridPos, fc.SquireFragment.Front); archivedStep.AllGridChanges.Add(step); fc.SquireFragment.Front = false; } break; } } } } } else // no skill, can only flip one grid { if (Physics.Raycast(cursorRay, out RaycastHit hit, 1000, LayerManager.Instance.LayerMask_Fragment)) { FragmentCollider fc = hit.collider.gameObject.GetComponent <FragmentCollider>(); ArchivedStep.Step step = new ArchivedStep.Step(fc.SquireFragment.GridPos, fc.SquireFragment.Front); archivedStep.AllGridChanges.Add(step); fc.SquireFragment.FlipFragment(); } } if (archivedStep.AllGridChanges.Count > 0) { CurrentSelectedSkillKey = String.Empty; ArchivedSteps.Push(archivedStep); MoveCount++; Reward--; } if (CurrentFrontCount >= SuccessFrontCount) { LevelPass(); } } else { Failed(); } } if (Input.GetKeyUp(KeyCode.F9)) { LoadNextLevel(); } if (Input.GetKeyUp(KeyCode.Escape)) { CurrentSelectedSkillKey = String.Empty; } } }