コード例 #1
0
    /// <summary>
    /// This is called when one of our hitboxes collides with something while we're attacking.
    /// </summary>
    /// <param name="collision">Collision, the collision that took place</param>
    void hitBoxCollisionEnter(Collision collision)
    {
        //If we hit ourself some how...
        if (collision.gameObject.transform == this.transform)
        {
            return;
        }


        if (currentState == ChickenState.Dashing && dashingDirection == Vector3.forward)
        {
            ChickenControlBehavior otherChicken = collision.gameObject.GetComponent <ChickenControlBehavior>();

            if (otherChicken != null && (otherChicken.team != team || otherChicken.team == ChickenTeam.None))             //added here disables friendly fire

            {
                if (otherChicken.gameObject.GetComponent <NetworkChickenCharacter>() != null)
                {
                    SpecialEffectsFactory.createEffect(otherChicken.gameObject.transform.position, SpecialEffectType.TakeDamage);
                    otherChicken.gameObject.GetComponent <PhotonView>().RPC("takeDamage", otherChicken.gameObject.GetComponent <PhotonView>().owner, power);
                    //otherChicken.gameObject.GetComponent<PhotonView>().RPC("takeDamage",PhotonTargets.All,power);
                }
                else
                {
                    otherChicken.takeDamage(power);
                }
            }
            else if (collision.transform.tag == "Hitbox")
            {
                //play a ting noise like in smashbros.
            }

            stopDashing();
        }
    }
コード例 #2
0
    /// <summary>
    /// Used to transition to the dead state.
    /// </summary>
    void enterDeadState()
    {
        currentState = ChickenState.Dead;

        GameState.getInstance().removeCharacter(this);

        timeOfDeath = Time.time;

        SpecialEffectsFactory.createEffect(transform.position, SpecialEffectType.ChickenDeath);

        if (gameObject.GetComponent <PhotonView> () != null)
        {
            ChickenFactory.createNetworkPlayerChicken(new Vector3(0, 1, 0), ChickenTeam.None);
            PhotonNetwork.Destroy(gameObject);
        }
    }
コード例 #3
0
    public void takeDamage(float damageAmount)
    {
        if (currentState == ChickenState.Dead)
        {
            return;
        }

        SpecialEffectsFactory.createEffect(transform.position, SpecialEffectType.TakeDamage);

        // added check to see if player is dead
        if (health <= 0)
        {
            enterDeadState();
            return;
        }

        currentState    = ChickenState.TakingDamage;
        damageStartTime = Time.time;
        transform.FindChild("graphics").GetComponent <MeshRenderer>().material.color = Color.red;
        health -= damageAmount;
        print("health hit");
    }