public override void SceneMyInit() { Vector3 workpos = new Vector3(); //input = GetComponent<MultiInput>(); //CharCon = this.GetComponent<CharacterController>(); workpos.Set(transform.position.x, transform.position.y, transform.position.z); NowCharacter = Instantiate(NormalCharacter, workpos, Quaternion.identity) as GameObject; playerbase = NowCharacter.GetComponent <PlayerBase>(); playerbase.Playerinit(gameObject); CharacterSta = ConstPlayerSta.NormalCharacter; playersta = PLAYER_STA.NORMAL; isInitialized = true; }
private void OnTriggerStay(Collider other) { if (other.tag == ConstTags.City && playersta == PLAYER_STA.NORMAL) { if (m_input.GetButtonCrossTrigger() && playerbase.GetCharacterSta() == 0) { playersta = PLAYER_STA.CITYIN; ChangeStartPos = transform.position; ChangeCenterPos = other.gameObject.transform.position; ChangeStartPos.y = 0.0f; ChangeCenterPos.y = 0.0f; Vector3 v = ChangeStartPos - ChangeCenterPos; v.Normalize(); ChangeStartPos += v * MOVERITU; beforeCharacter = CharacterSta; GetComponent <CapsuleCollider>().enabled = false; } } }
// Update is called once per frame void Update() { if (!isInitialized) { return; } float r = 6.0f; switch (playersta) { case PLAYER_STA.NORMAL: playerbase.PlayerUpdate(); break; case PLAYER_STA.CITYIN: playerbase.SetCharConNoHit(true); playerbase.PlayerCityIn(ChangeCenterPos); r = (Mathf.Abs(transform.position.x - ChangeCenterPos.x) * Mathf.Abs(transform.position.x - ChangeCenterPos.x)) + (Mathf.Abs(transform.position.z - ChangeCenterPos.z) * Mathf.Abs(transform.position.z - ChangeCenterPos.z)); if (r < CORRECTION * CORRECTION) { playersta = PLAYER_STA.CHANGE; } break; case PLAYER_STA.CHANGE: if (m_input.GetButtonCircleTrigger()) { if (beforeCharacter != ConstPlayerSta.HeroCharacter) { ChangeCharacter(ConstPlayerSta.HeroCharacter); } playersta = PLAYER_STA.CITYOUT; } if (m_input.GetButtonTriangleTrigger()) { if (beforeCharacter != ConstPlayerSta.HeelCharacter) { ChangeCharacter(ConstPlayerSta.HeelCharacter); } playersta = PLAYER_STA.CITYOUT; } if (m_input.GetButtonSquareTrigger()) { if (beforeCharacter != ConstPlayerSta.SpecialistCharacter) { ChangeCharacter(ConstPlayerSta.SpecialistCharacter); } playersta = PLAYER_STA.CITYOUT; } break; case PLAYER_STA.CITYOUT: playerbase.PlayerCityOut(ChangeStartPos); r = (Mathf.Abs(transform.position.x - ChangeStartPos.x) * Mathf.Abs(transform.position.x - ChangeStartPos.x)) + (Mathf.Abs(transform.position.z - ChangeStartPos.z) * Mathf.Abs(transform.position.z - ChangeStartPos.z)); if (r < CORRECTION * CORRECTION) { playersta = PLAYER_STA.NORMAL; playerbase.SetCharConNoHit(false); GetComponent <CapsuleCollider>().enabled = true; if (CharacterSta != beforeCharacter) { playerbase.PlayerPause(); } } break; case PLAYER_STA.FORCIBLY: playerbase.ForciblyMove(ChangeCenterPos); r = (Mathf.Abs(transform.position.x - ChangeCenterPos.x) * Mathf.Abs(transform.position.x - ChangeCenterPos.x)) + (Mathf.Abs(transform.position.z - ChangeCenterPos.z) * Mathf.Abs(transform.position.z - ChangeCenterPos.z)); if (r < CORRECTION * CORRECTION) { playersta = PLAYER_STA.NORMAL; } break; } //print(hitcityflg); transform.position = playerbase.GetBodyPosition(); }
public void PlayerForcibly(Vector3 target) { playersta = PLAYER_STA.FORCIBLY; ChangeCenterPos = target; }