IEnumerator absorbCharacter(CharacterMove character) { yield return StartCoroutine(character.walkToAndStop(new Vector2(transform.position.x, character.transform.position.y))); myAnimator.SetTrigger("isClosed"); doorAnimator.SetTrigger("isClosed"); //Disable this character's collider, so others will walk by. character.GetComponent<Collider2D>().enabled = false; character.GetComponent<Rigidbody2D>().gravityScale = 0; character.GetComponent<Rigidbody2D>().velocity = Vector2.zero; //Render the door over the character. doorRenderer.sortingLayerName = "Character"; character.GetComponent<SpriteRenderer>().sortingLayerName = "Pre-Character"; //Wait for animation to finish. yield return new WaitForSeconds(1.5f); MasterDriver.levelDriver.saveCharacter(character); //Destroy the character, render the door back again. DestroyImmediate(character.gameObject); doorRenderer.sortingLayerName = "Background Object"; yield return new WaitForSeconds(1f); isTakingCharacter = false; yield return null; }
// Update is called once per frame void Update() { if (isFollowing) { xOffset = Player.GetComponent <Rigidbody2D>().velocity.x / 400; yOffset = Player.GetComponent <Rigidbody2D>().velocity.y / 450; transform.position = new Vector3(transform.position.x + xOffset, transform.position.y + yOffset, transform.position.z); Debug.Log(xOffset); } }
//移動先選択の開始 IEnumerator MoveStart(bool isAI = false) { if (player == null || CMove == null) { yield break; } Debug.Log("移動開始"); GameController.Gcon.SetGamePhase(Phase.Move); MoveCancel(); MapChipFormat(); //ルーレットを回して移動力決定 Character c = CMove.GetComponent <Character>(); Debug.Log(c.GetMaxMove() + "から" + c.GetMinMove()); rouletteScript.RS.RouletStart(c.GetMove()); do //移動力が決定するまで待機 { yield return(null); } while (!rouletteScript.RS.isMoveSpeedEnter); rouletteScript.RS.Initialize(); CMove.MovePower = rouletteScript.RS.nowMoveSpeed; //CMove.SetNowpos (0, 0); CMove.gameObject.transform.position = MapCreateScript.mapChips [CMove.nowPos [0], CMove.nowPos [1]].getPos(); StartCoroutine(MoveCost(CMove.nowPos [0], CMove.nowPos [1], isAI)); Debug.Log("MoveStart"); }
public void OnKilled() { m_character.SetActive(false); m_spriteRenderer.enabled = true; m_boxCollider2D.enabled = false; m_mover.StopMoving(); m_mover.GetComponent <BoxCollider2D>().enabled = false; }
// Update is called once per frame void Update() { if (isFollowing) { xOffset = Player.GetComponent <Rigidbody2D>().velocity.x / 100; transform.position = new Vector3(transform.position.x + xOffset, transform.position.y, transform.position.z); //transform.position.x = Player.transform.position.x; } }
void toggleMenu(bool toggle) { gameOver.SetActive(toggle); retry.SetActive(toggle); quit.SetActive(toggle); player.GetComponent <MouseLook>().enabled = !toggle; player.GetComponent <CharacterMove>().enabled = !toggle; playerCamera.GetComponent <MouseLook>().enabled = !toggle; cursor.SetActive(!toggle); if (toggle) { Time.timeScale = 0; Cursor.lockState = CursorLockMode.None; } else { Time.timeScale = 1; Cursor.lockState = CursorLockMode.Locked; } }