Beispiel #1
0
    private void OnControllerColliderHit(ControllerColliderHit hit)
    {
        if (falling > 1f && hit.transform.tag == "Enemy")
        {
            falling2 = 0f;
            Vector3 relpos = gameObject.transform.position - hit.transform.position;
            //Quaternion rotation = Quaternion.LookRotation(relpos, Vector3.up);
            //gameObject.transform.rotation = rotation;
            imp.AddImpact(Vector3.forward + relpos, 25f);
            Debug.Log("osuu " + hit.transform.name);
            Attack(hit.gameObject);
        }
        if (hit.transform.name == "Enemy")
        {
            Debug.Log("osuu " + hit.transform.name);
        }

        if (hit.transform.name == "Mouth")
        {
            Vector3    relpos   = gameObject.transform.position - hit.transform.position;
            Quaternion rotation = Quaternion.LookRotation(relpos, Vector3.up);
            gameObject.transform.rotation = rotation;
            imp.AddImpact(relpos, 50f);
        }
    }
Beispiel #2
0
    void OnTriggerStay(Collider other)
    {
        if (other.tag == "Player")
        {
            Vector3 force = other.transform.position - this.transform.position;
            force.Normalize();
            if (noForceInX)
            {
                force.x = 0;
            }
            if (noForceInY)
            {
                force.y = 0;
            }
            if (noForceInZ)
            {
                force.z = 0;
            }

            ImpactReceiver script = other.gameObject.GetComponent <ImpactReceiver>();
            if (script != null)
            {
                script.AddImpact(force, multiplier);
            }
        }
    }
Beispiel #3
0
    void Update()
    {
        SwitchPlayer(SelectPlayer);

        noStam = this.GetComponent <PlayerStats>().noStam;
        if (Boost)
        {
            audioSrc.PlayOneShot(Jump);
            BoostUp.AddImpact(Vector3.up, BoostForce);
            Boost = false;
        }
        if (inputX > 0)
        {
            SwitchMovement(MovementType.right);
        }
        else if (inputX < 0)
        {
            SwitchMovement(MovementType.left);
        }
        else if (inputY > 0)
        {
            SwitchMovement(MovementType.forward);
        }
        else if (inputY < 0)
        {
            SwitchMovement(MovementType.back);
        }
        else if (inputX == 0 && inputY == 0)
        {
            SwitchMovement(MovementType.none);
        }
        if (Time.time - lastFootstepPlayedTime > currentFootstepsWaitingPeriod && isMoving && isGrounded && !isJumping)
        {
            if (isRunning)
            {
                audioSrc.volume = Random.Range(0.7f, 1.0f);
                audioSrc.pitch  = Random.Range(0.9f, 1.5f);
                SetFootStep();
            }
            else
            {
                audioSrc.volume = Random.Range(0.3f, 0.6f);
                audioSrc.pitch  = Random.Range(0.6f, 0.8f);
                SetFootStep();
            }
            audioSrc.Play();
            lastFootstepPlayedTime = Time.time;
        }
        if (SprintButton && !noStam && isMoving && isGrounded)
        {
            isRunning   = true;
            playerSpeed = runSpeed;
        }
        else
        {
            isRunning   = false;
            playerSpeed = walkSpeed;
        }
    }
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.CompareTag("Player"))
     {
         Impact = collision.gameObject.GetComponent <ImpactReceiver>();
         Vector3 direction = (collision.transform.position - this.transform.position).normalized;
         Impact.AddImpact(direction, 20);
         playST = collision.gameObject.GetComponent <PlayerStats>();
         playST.doDamage(10);
     }
 }
Beispiel #5
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.CompareTag("Player"))
     {
         PhantomBreastEnabled = Breast.PhantomBreast;
         if (!PhantomBreastEnabled)
         {
             ImpactReceiver Impact    = collision.gameObject.GetComponent <ImpactReceiver>();
             Vector3        direction = (this.transform.position - collision.transform.position).normalized;
             Impact.AddImpact(direction, 100);
         }
     }
 }
Beispiel #6
0
 void OnTriggerEnter(Collider other)
 {
     if (StoveScript.isOn && other.tag == "Player")
     {
         Vector3 direction = other.transform.position - this.transform.position;
         direction.Normalize();
         ImpactReceiver script = other.gameObject.GetComponent <ImpactReceiver>();
         if (script != null)
         {
             script.AddImpact(direction, 50f);
         }
     }
 }
 private void OnControllerColliderHit(ControllerColliderHit hit)
 {
     if (hit.gameObject.CompareTag("Enemy"))
     {
         Vector3 direction = (this.transform.position - hit.transform.position).normalized;
         Impact.AddImpact(direction, 50);
         doDamage(Random.Range(1, 5));
     }
     if (hit.gameObject.CompareTag("IceSpike"))
     {
         Vector3 direction = (this.transform.position - hit.transform.position).normalized;
         Impact.AddImpact(direction, 50);
         IceSpike   = true;
         hurtPlayer = true;
         Destroy(hit.gameObject);
     }
     if (hit.collider.tag == "BigSpikeBall")
     {
         Vector3 direction = (this.transform.position - hit.transform.position).normalized;
         Impact.AddImpact(direction, 200);
         BigSpikeBall = true;
         hurtPlayer   = true;
     }
     if (hit.collider.tag == "SmallSpikeBall")
     {
         Vector3 direction = (this.transform.position - hit.transform.position).normalized;
         Impact.AddImpact(direction, 100);
         SmallSpikeBall = true;
         hurtPlayer     = true;
     }
     if (hit.gameObject.CompareTag("BossIceField"))
     {
         Vector3 direction = (this.transform.position - hit.transform.position).normalized;
         Impact.AddImpact(direction, 300);
         BossIceField = true;
         hurtPlayer   = true;
     }
 }
Beispiel #8
0
    public virtual void CmdFireShot(Vector3 origin, Vector3 direction, int layer)
    {
        RaycastHit hit;

        Ray ray = new Ray(origin, direction);

        Debug.DrawRay(ray.origin, ray.direction * 3f, Color.red, 1f);

        // Only shoot at layers that the shooter isn't on
        int mask = 1 << layer;

        mask = ~mask;

        bool result = Physics.SphereCast(ray, hitRadius, out hit, range, mask, QueryTriggerInteraction.UseGlobal);

        // Only show tracer when hunter hits something
        if (player.isHunter && result)
        {
            GameObject bulletTracer = Instantiate(tracerPrefab, gunShotPosition.position, Quaternion.identity);
            NetworkServer.Spawn(bulletTracer);
            bulletTracer.GetComponent <BulletTracer>().shoot(gunShotPosition.position, hit.point);
        }

        if (result)
        {
            Debug.DrawRay(ray.origin, ray.direction * hit.distance, Color.red, 5.0f);
            // Check if the thing hit was a player
            PlayerHealth enemy = hit.transform.GetComponent <PlayerHealth>();

            // If so, player takes damage
            if (enemy != null)
            {
                Debug.Log("Hit an enemy!");
                // Generates impact on enemy, kickback
                ImpactReceiver enemyImpactRec = hit.transform.GetComponent <ImpactReceiver>();
                enemyImpactRec.AddImpact(direction, forcePerHit);

                bool died = enemy.TakeDamage(dmgPerShot, direction);
                if (died)
                {
                    player.Won();
                }
            }
        }

        RpcProcessShotEffects(result, hit.point);
    }
Beispiel #9
0
    private IEnumerator Start()
    {
        // wait one frame because some explosions instantiate debris which should then
        // be pushed by physics force
        yield return(null);

        float multiplier = GetComponent <ParticleSystemMultiplier>().multiplier;

        float r           = 5 * multiplier;
        var   cols        = Physics.OverlapSphere(transform.position, r);
        var   rigidbodies = new List <Rigidbody>();

        foreach (var col in cols)
        {
            if (col.attachedRigidbody != null && !rigidbodies.Contains(col.attachedRigidbody))
            {
                rigidbodies.Add(col.attachedRigidbody);
            }
            else if (col.transform.tag == "Player")
            {
                rigidbodies.Add(col.GetComponent <Rigidbody>());

                FindObjectOfType <Rocket>().GetComponent <AudioSource>().Stop();
                FindObjectOfType <AudioManager>().Play("RocketHitPlayer");
            }
        }
        foreach (var rb in rigidbodies)
        {
            if (rb.transform.tag == "Player")
            {
                ImpactReceiver impactReceiver = rb.transform.GetComponent <ImpactReceiver>();
                Vector3        dir            = rb.transform.position - transform.position;
                float          force          = Mathf.Clamp((explosionForce) / 3, 0, 15);
                impactReceiver.AddImpact(dir, force);
            }
            else
            {
                rb.AddExplosionForce(explosionForce * multiplier, transform.position, r, 1 * multiplier, ForceMode.Impulse);
            }
        }
    }
Beispiel #10
0
    void DealDamage(Collider other)
    {
        //Deal Damage
        PlayerHealth.health -= damage;
        meleeIsOnCooldown    = true;

        //Knockback
        ImpactReceiver IR        = other.GetComponent <ImpactReceiver>();
        Vector3        direction = (other.transform.position - transform.position).normalized;

        IR.AddImpact(direction, knockbackForce);

        //BloodParticles
        bloodsplatter.DoBloodSplatter(other.gameObject.transform);

        //SoundEffect
        FindObjectOfType <AudioManager>().Play("PlayerHurt");

        //Animation
        attackAnim.SetBool("isAttacking", true);
    }
Beispiel #11
0
 private void OnCollisionEnter(Collision other)
 {
     if (other.gameObject.CompareTag("StormShield"))
     {
         audioSrc.PlayOneShot(frozen);
         FreezeEnemy(true);
     }
     if (other.gameObject.CompareTag("Player"))
     {
         if (isRamming)
         {
             SwitchState(EnemyState.teleport);
             isRamming = false;
         }
         Impact = other.gameObject.GetComponent <ImpactReceiver>();
         Vector3 direction = (other.transform.position - this.transform.position).normalized;
         Impact.AddImpact(direction, 10);
         playST = other.gameObject.GetComponent <PlayerStats>();
         playST.doDamage(Random.Range(1, 5));
     }
 }
Beispiel #12
0
    void OnTouch(SocketIOEvent socketIOEvent)
    {
        Debug.Log(" i got shot");
        string  data     = socketIOEvent.data.ToString();
        HitJSON touch    = HitJSON.CreateFromJSON(data);
        Vector3 position = new Vector3(touch.position[0], touch.position[1], touch.position[2]);

        if (localName == touch.pseudo)
        {
            //find the gameobject
            GameObject p = GameObject.Find(localName);
            if (p != null)
            {
                ImpactReceiver script = p.GetComponent <ImpactReceiver> ();
                if (script)
                {
                    script.AddImpact(position * 2);
                    Debug.Log(" i have been shot");
                }
            }
        }
    }
Beispiel #13
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            Vector3 direction = (this.transform.position - collision.transform.position).normalized;
            impact = collision.gameObject.GetComponent <ImpactReceiver>();
            PlayST = collision.gameObject.GetComponent <PlayerStats>();

            audioSrc.PlayOneShot(collide);
            impact.AddImpact(direction, 100);
            PlayST.doDamage(SetDamage);
            if (!Shield)
            {
                Destroy(gameObject, 1);
            }
        }
        else
        {
            audioSrc.PlayOneShot(collide);
            Destroy(gameObject, 1);
        }
    }
Beispiel #14
0
    void Explode()
    {
        Instantiate(explosionEffect, transform.position, transform.rotation);
        model.SetActive(false);
        bombSizzle.Stop();

        Collider [] colliders = Physics.OverlapSphere(transform.position, radius);

        foreach (Collider nearbyObject in colliders)
        {
            EnemyDetectionMovement EDM = nearbyObject.gameObject.GetComponent <EnemyDetectionMovement>();
            Rigidbody      rb          = nearbyObject.GetComponent <Rigidbody>();
            ImpactReceiver IR          = nearbyObject.GetComponent <ImpactReceiver>();

            if (rb != null) //Add explosion force to rigidbody objects
            {
                float distance = Vector3.Distance(transform.position, nearbyObject.transform.position);

                //If within a 4 range distance of the pipebomb
                if (distance <= 4)
                {
                    if (EDM != null)
                    {
                        StartCoroutine(EDM.ChangeIsKinematic());
                        EDM.isWithinDetectionRange = true;
                    }
                    rb.AddExplosionForce(force, transform.position, radius);
                }
                else
                {
                    if (EDM != null)
                    {
                        StartCoroutine(EDM.ChangeIsKinematic());
                        EDM.isWithinDetectionRange = true;
                    }
                    rb.AddExplosionForce((force / 1.5f), transform.position, radius);
                }
            }

            if (IR != null) //Add explosion force to CharacterController objects
            {
                Vector3 dir      = nearbyObject.transform.position - transform.position;
                float   distance = Vector3.Distance(transform.position, nearbyObject.transform.position);

                //If within a 4 range distance of the pipebomb
                if (distance <= 4)
                {
                    IR.AddImpact(dir, (force / 8));
                }
                else
                {
                    IR.AddImpact(dir, (force / 10));
                }
            }

            if (nearbyObject.tag == "Player") //If the object's tag is a player, deal some damage depending on the player's distance to the explosion.
            {
                DealExplosionDamage(nearbyObject);
            }
            if (nearbyObject.tag == "Enemy") //If the object's tag is an enemy, deal some damage depending on the enemy's distance to the explosion.
            {
                EnemyHealth enemyHealthScript = nearbyObject.GetComponent <EnemyHealth>();

                if (enemyHealthScript != null)
                {
                    DealExplosionDamage(nearbyObject, enemyHealthScript);
                }
            }
        }
    }
Beispiel #15
0
    public void AddDamageType(DamageElement element)
    {
        switch (element)
        {
        case DamageElement.Blaster:
        {
            Impact.AddImpact(direction, 5);
            takeDamage(5);
            blasterHit = false;
            break;
        }

        case DamageElement.Flak:
        {
            Impact.AddImpact(direction, 5);
            takeDamage(3);
            flakHit = false;
            break;
        }

        case DamageElement.Photon:
        {
            Impact.AddImpact(direction, 3);
            takeDamage(4);
            photonHit = false;
            break;
        }

        case DamageElement.Piercer:
        {
            Impact.AddImpact(direction, 1);
            takeDamage(1);
            piercerHit = false;
            break;
        }

        case DamageElement.Titan:
        {
            Impact.AddImpact(direction, 50);
            takeDamage(10);
            titanHit = false;
            break;
        }

        case DamageElement.Hyper:
        {
            Impact.AddImpact(direction, 30);
            takeDamage(30);
            hyperHit = false;
            break;
        }

        case DamageElement.Vortex:
        {
            Impact.AddImpact(direction, 50);
            takeDamage(80);
            vortexHit = false;
            break;
        }
        }
    }