// 两个刚体碰撞的时候用来判断跟我相撞的是什么 void OnCollisionEnter(Collision other) { switch (rockStates) { case RockStates.HitPlayer: if (other.gameObject.CompareTag("Player")) { // 停止主角移动 other.gameObject.GetComponent <NavMeshAgent>().isStopped = true; // 把主角击退 other.gameObject.GetComponent <NavMeshAgent>().velocity = direction * force; // 把主角眩晕 other.gameObject.GetComponent <Animator>().SetTrigger("Dizzy"); // 产生伤害 other.gameObject.GetComponent <CharacterStats>().TakeDamage(damage, other.gameObject.GetComponent <CharacterStats>()); rockStates = RockStates.HitNothing; } break; case RockStates.HitEnemy: // 只能攻击石头人 if (other.gameObject.GetComponent <Golem>()) { var otherStats = other.gameObject.GetComponent <CharacterStats>(); otherStats.TakeDamage(damage, otherStats); // 生成石头砸碎的粒子效果 Instantiate(breakEffect, transform.position, Quaternion.identity); Destroy(gameObject); } break; } }
private void FixedUpdate() { if (rb.velocity.sqrMagnitude < 1f) { rockState = RockStates.HitNothing; } }
private void OnCollisionEnter(Collision other) { switch (rockState) { case RockStates.HitPlayer: if (other.collider.CompareTag("Player")) { other.gameObject.GetComponent <NavMeshAgent>().isStopped = true; other.gameObject.GetComponent <NavMeshAgent>().velocity = force * direction; other.gameObject.GetComponent <Animator>().SetTrigger("Dizzy"); other.gameObject.GetComponent <CharacterStats>().TakeDamage(damage); rockState = RockStates.HitNothing; } break; case RockStates.HitEnemy: if (other.gameObject.GetComponent <GolemController>()) { other.gameObject.GetComponent <CharacterStats>().TakeDamage(damage); Instantiate(breakEffect, transform.position, quaternion.identity); Destroy(this.gameObject); } break; case RockStates.HitNothing: break; } }
private void OnCollisionEnter(Collision collision) { switch (rockState) { case RockStates.HitPlayer: if (collision.gameObject.CompareTag("Player")) { GameObject player = collision.gameObject; if (player.GetComponent <Animator>().GetBool("Defense") && player.transform.IsFacingAttackRange(-direction.normalized)) { player.GetComponent <Animator>().SetTrigger("Hit"); rockState = RockStates.HitNothing; } else { player.GetComponent <CharacterStates>().TakeDamage(damage); player.GetComponent <Animator>().SetTrigger("Hit"); rockState = RockStates.HitNothing; } } break; } Destroy(gameObject); Instantiate(breakEffect, transform.position, Quaternion.identity); }
private void Start() { rb = GetComponent <Rigidbody>(); rockState = RockStates.HitPlayer; rb.velocity = Vector3.one; FlyToTarget(); }
private void OnCollisionEnter(Collision other) { switch (rockStates) { case RockStates.HitPlayer: if (other.gameObject.CompareTag("Player")) { other.gameObject.GetComponent <NavMeshAgent>().isStopped = true; other.gameObject.GetComponent <NavMeshAgent>().velocity = direction * force; other.gameObject.GetComponent <Animator>().SetTrigger("dizzy"); other.gameObject.GetComponent <CharacterStats>().TakeDamage(damage, other.gameObject.GetComponent <CharacterStats>()); Debug.Log(other.gameObject.GetComponent <NavMeshAgent>().velocity); rockStates = RockStates.HitNothing; } break; case RockStates.HitEnemy: { if (other.gameObject.GetComponent <Golem>()) { var otherStats = other.gameObject.GetComponent <CharacterStats>(); otherStats.TakeDamage(damage, otherStats); Instantiate(breakEffect, transform.position, Quaternion.identity); Destroy(gameObject); } break; } } }
void FixedUpdate() { // 判定石头的速度 if (rb.velocity.sqrMagnitude < 1f) { rockStates = RockStates.HitNothing; } // Debug.Log(rb.velocity.sqrMagnitude); }
void Start() { rb = GetComponent <Rigidbody>(); // 石头生成的那一帧速度是0, 这里直接给他速度赋值1 rb.velocity = Vector3.one; rockStates = RockStates.HitPlayer; FlyToTarget(); }
public void SetIce() { rockState = RockStates.Ice; myRenderer.material = iceform; feedback.ChangeToIce(); rock.SetActive(false); fire.SetActive(false); grass.SetActive(false); ice.SetActive(true); sound.clip = formChange[3]; sound.Play(); Debug.Log("(PlayerManager.cs) is Ice"); }
public void SetGrass() { rockState = RockStates.Grass; myRenderer.material = grassform; feedback.ChangeToGrass(); rock.SetActive(false); fire.SetActive(false); grass.SetActive(true); ice.SetActive(false); sound.clip = formChange[2]; sound.Play(); Debug.Log("(PlayerManager.cs) is Grass"); }
public void SetRock() { rockState = RockStates.Rock; myRenderer.material = rockform; feedback.ChangeToRock(); rock.SetActive(true); rockpoof.Play(); fire.SetActive(false); grass.SetActive(false); ice.SetActive(false); sound.clip = formChange[0]; sound.Play(); Debug.Log("(PlayerManager.cs) is Rock"); }
void Update() { if (Input.GetKeyUp(KeyCode.N)) { Spawn(); } switch (rockStates) { case RockStates.Idle: rockSlider.gameObject.SetActive(false); //////////////////////////////////////do nothing until directed by manager break; case RockStates.Entering: /////////////////////////////////////add count to game manager if (!isTutorial) { //update UI manager CNui.nextAvailableBubbleContents = CNui.ImgRocks; CNui.playNextAvailableBubble = true; } //update wheel event wheel.isInteractable = true; timer = initialTime; rockStates = RockStates.Active; break; case RockStates.Active: rockSlider.gameObject.SetActive(true); timer -= Time.deltaTime; float percentageFill = Mathf.InverseLerp(0, initialTime, timer); rockSlider.value = percentageFill; if (timer <= 0) //wait for steering wheel, if not input { screenShake.lightShake = true; //shake screen screenShake.shouldShake = true; if (isTutorial) { floodController.IncreaseFloodAmount(5); } else { floodController.IncreaseFloodAmount(3); } rockStates = RockStates.Exiting; } break; case RockStates.Exiting: //remove from game manager rockSlider.gameObject.SetActive(false); rockStates = RockStates.Idle; //wheel.wheelStates = Wheel.WheelStates.Exiting; wheel.isInteractable = true; break; } }
public override void Spawn() { rockStates = RockStates.Entering; }
// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody>(); rockState = RockStates.HitPlayer; ThrowToTarget(); }