Пример #1
0
    // 两个刚体碰撞的时候用来判断跟我相撞的是什么
    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;
        }
    }
Пример #2
0
 private void FixedUpdate()
 {
     if (rb.velocity.sqrMagnitude < 1f)
     {
         rockState = RockStates.HitNothing;
     }
 }
Пример #3
0
    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;
        }
    }
Пример #4
0
 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);
 }
Пример #5
0
 private void Start()
 {
     rb          = GetComponent <Rigidbody>();
     rockState   = RockStates.HitPlayer;
     rb.velocity = Vector3.one;
     FlyToTarget();
 }
Пример #6
0
    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;
        }
        }
    }
Пример #7
0
 void FixedUpdate()
 {
     // 判定石头的速度
     if (rb.velocity.sqrMagnitude < 1f)
     {
         rockStates = RockStates.HitNothing;
     }
     // Debug.Log(rb.velocity.sqrMagnitude);
 }
Пример #8
0
    void Start()
    {
        rb = GetComponent <Rigidbody>();
        // 石头生成的那一帧速度是0, 这里直接给他速度赋值1
        rb.velocity = Vector3.one;

        rockStates = RockStates.HitPlayer;
        FlyToTarget();
    }
Пример #9
0
 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");
 }
Пример #10
0
 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");
 }
Пример #11
0
 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");
 }
Пример #12
0
    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;
        }
    }
Пример #13
0
 public override void Spawn()
 {
     rockStates = RockStates.Entering;
 }
Пример #14
0
 // Start is called before the first frame update
 void Start()
 {
     rb        = GetComponent <Rigidbody>();
     rockState = RockStates.HitPlayer;
     ThrowToTarget();
 }