コード例 #1
0
ファイル: ShieldCrystal.cs プロジェクト: JKDaluga/AlmostRace
    public IEnumerator ResetShield(float timeToReset, CarHealthBehavior carToReset)
    {
        yield return(new WaitForSeconds(timeToReset));

        carToReset.RemoveExtraShields(shieldGainAmount);
        _shieldedCars.Remove(carToReset);
    }
コード例 #2
0
 void Start()
 {
     _carHealthScript = gameObject.GetComponent <CarHealthBehavior>();
     foreach (GameObject shield in shields)
     {
         shield.GetComponent <ParticleSystem>().Stop();
     }
 }
コード例 #3
0
 public void TurnOnShieldShock()
 {
     _playerPainTrainScript = _immunePlayer.GetComponent <CarHealthBehavior>();
     if (_playerPainTrainScript != null)
     {
         StartCoroutine(TrackHealth());
     }
 }
コード例 #4
0
    public void GiveInfo(float zapDamage, float zapCoolDown, GameObject immunePlayer)
    {
        _zapDamage    = zapDamage;
        _zapCoolDown  = zapCoolDown;
        _immunePlayer = immunePlayer;

        _playerPainTrainScript = _immunePlayer.GetComponent <CarHealthBehavior>();
    }
コード例 #5
0
 public void TrackDuringRuntime(GameObject givenTarget)
 {
     _target                  = givenTarget;
     _carHealthStatus         = _target.GetComponent <CarHealthBehavior>();
     _interactableStatus      = _target.GetComponent <Interactable>();
     _canTrack                = true;
     normalizerScript.enabled = false;
 }
コード例 #6
0
 public void RemoveCarFromDamage(CarHealthBehavior carToRemove)
 {
     if (carToRemove != _immunePlayer)
     {
         if (_carsToDamage.Contains(carToRemove))
         {
             _carsToDamage.Remove(carToRemove);
         }
     }
 }
コード例 #7
0
 void Start()
 {
     _carHealthScript        = gameObject.GetComponent <CarHealthBehavior>();
     _objectPooler           = ObjectPooler.instance;
     _startParticleLifetimes = new float[shields.Count];
     for (int i = 0; i < shields.Count; i++)
     {
         _startParticleLifetimes[i] = shields[i].GetComponent <ParticleSystem>().main.startLifetime.constant;
     }
 }
コード例 #8
0
 public void AddCarToDamage(CarHealthBehavior carToAdd)
 {
     if (carToAdd != _immunePlayer)
     {
         if (!_carsToDamage.Contains(carToAdd))
         {
             _carsToDamage.Add(carToAdd);
         }
     }
 }
コード例 #9
0
 // Start is called before the first frame update
 void Start()
 {
     _carHealthScript   = gameObject.GetComponent <CarHealthBehavior>();
     _shockShieldScript = shockShield.GetComponent <PainTrain_ShieldShock>();
     _shockShieldScript.GiveInfo(zapDamage, zapCoolDown, gameObject);
     AbilityOffOfCooldown();
     foreach (GameObject shield in shields)
     {
         shield.GetComponent <ParticleSystem>().Stop();
     }
 }
コード例 #10
0
 public void AddCarToDamage(CarHealthBehavior carToAdd)
 {
     if (carToAdd != _immunePlayer)
     {
         if (!_carsToDamage.Contains(carToAdd))
         {
             _carsToDamage.Add(carToAdd);
         }
         if (_carsToDamage.Count == 1)
         {
             StartCoroutine(DamageCars());
         }
     }
 }
コード例 #11
0
    public void RemoveCarFromDamage(CarHealthBehavior carToRemove)
    {
        if (carToRemove != _immunePlayer)
        {
            if (_carsToDamage.Contains(carToRemove))
            {
                _carsToDamage.Remove(carToRemove);
            }

            if (_carsToDamage.Count > 1)
            {
                StopCoroutine(DamageCars());
            }
        }
    }
コード例 #12
0
 private void OnMissileActivation()
 {
     GiveSpeed();
     if (_target != null)
     {
         normalizerScript.enabled = false;
         StartCoroutine(hangTimeSequence());
         _carHealthStatus    = _target.GetComponent <CarHealthBehavior>();
         _interactableStatus = _target.GetComponent <Interactable>();
     }
     else
     {
         normalizerScript.enabled = true;
     }
 }
コード例 #13
0
    public void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Vehicle") && _immunePlayer != null && other.gameObject != _immunePlayer && !_immuneCars.Contains(other.gameObject))
        {
            carHit = other.gameObject.GetComponent <CarHealthBehavior>();
            carHit.DamageCar(_projectileDamage, _immunePlayerScript.playerID);
            _immuneCars.Add(other.gameObject);
            ObjectPooler.instance.Deactivate(poolTag, gameObject);
        }
        if (other.CompareTag("Interactable"))
        {
            hitInteractable = other.GetComponent <Interactable>();

            hitInteractable.DamageInteractable(hitInteractable.interactableHealth);
        }
    }
コード例 #14
0
    private void OnTriggerEnter(Collider collision)
    {
        if (collision.gameObject.GetComponent <CarHealthBehavior>() != null)
        {
            interactingPlayer = collision.gameObject;
            _carToAdd         = collision.gameObject.GetComponent <CarHealthBehavior>();
            if (!_shieldedCars.Contains(_carToAdd))
            {
                _shieldedCars.Add(_carToAdd);
                _carToAdd.AddExtraShields(extraShieldAmount);
                StartCoroutine(ResetShield(shieldDuration, _carToAdd));
            }

            linkedMill.GetComponent <WindmillSpeed>().UpdateBaseSpeed(laserSpeedUpAmount);
        }
    }
コード例 #15
0
ファイル: ShieldCrystal.cs プロジェクト: JKDaluga/AlmostRace
 public void OnTriggerEnter(Collider other)
 {
     if (isActive)
     {
         if (other.gameObject.GetComponent <CarHealthBehavior>() != null)
         {
             _carToAdd = other.gameObject.GetComponent <CarHealthBehavior>();
             if (!_shieldedCars.Contains(_carToAdd))
             {
                 _shieldedCars.Add(_carToAdd);
                 _carToAdd.AddExtraShields(shieldGainAmount);
                 StartCoroutine(ResetShield(shieldDuration, _carToAdd));
             }
         }
     }
 }
コード例 #16
0
    private void OnCollisionEnter(Collision collision)
    {
        CarCollision other = collision.gameObject.GetComponent <CarCollision>();

        if (other != null && _invulTime <= 0f)
        {
            _invulTime = .5f;
            Rigidbody           rb               = GetComponent <Rigidbody>();
            Rigidbody           other_rb         = other.GetComponent <Rigidbody>();
            SphereCarController otherCar         = other.car.GetComponent <SphereCarController>();
            CarHealthBehavior   otherCarHeat     = other.car.GetComponent <CarHealthBehavior>();
            Vector3             relativeVelocity = rb.velocity - other_rb.velocity;
            Vector3             relativePosition = rb.position - other_rb.position;
            collisionEffectsScript.CreateSparks(collision);
            AudioManager.instance.Play("General collision", transform);

            //calculating the angle in radians then converting it to degrees
            float angleBetween = Mathf.Acos(Vector3.Dot(relativeVelocity.normalized, relativePosition.normalized)) * 180 / Mathf.PI;

            // We only want the player instigating the collision to damage the other so this angle helps determing who the instigating player is
            float instigatingPlayerAngle = Mathf.Acos(Vector3.Dot(rb.velocity.normalized, -relativePosition.normalized)) * 180 / Mathf.PI;

            frontCollisionParticles.GetComponent <ParticleSystem>().Play();

            // If the angleBetween < 90 then the collision exists
            // If instigatingPlayerAngle < 90 then that player is moving in the direction of the other player and should assign damage
            if (angleBetween < 90 & instigatingPlayerAngle < 90)
            {
                float percentDamage = 0f;
                if (rb.velocity.magnitude > 10f)
                {
                    percentDamage = Vector3.Project(relativePosition.normalized, rb.velocity.normalized).magnitude;
                }
                if (percentDamage > 0)
                {
                    float damage = percentDamage * weight * relativeVelocity.magnitude;
                    otherCarHeat.healthCurrent -= damage;
                }
            }
        }
    }
コード例 #17
0
 public void AttackTriggered(GameObject givenCollision)
 {
     if (givenCollision.gameObject.layer == LayerMask.NameToLayer("Wall"))
     {
         Explode();
     }
     if (givenCollision.gameObject.GetComponent <CarHealthBehavior>() != null)
     {
         if (givenCollision.gameObject != _immunePlayer)
         {
             carHit = givenCollision.gameObject.GetComponent <CarHealthBehavior>();
             carHit.DamageCar(_projectileDamage, _immunePlayerScript.playerID);
             Explode();
         }
     }
     if (givenCollision.gameObject.GetComponent <Interactable>() != null)
     {
         givenCollision.gameObject.GetComponent <Interactable>().DamageInteractable(_projectileDamage);
         Explode();
     }
 }
コード例 #18
0
    // Start is called before the first frame update
    void Start()
    {
        arenaStatus.SetActive(false);
        if (GameObject.FindGameObjectWithTag("GameManager") != null)
        {
            _hypeManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <HypeManager>();
            _rm          = GameObject.FindGameObjectWithTag("GameManager").GetComponent <RaceManager>();
        }
        else
        {
            Debug.LogWarning("Game Manager Can Not be Found");
        }
        int numPlayers = 1;

        if (DataManager.instance != null)
        {
            numPlayers = DataManager.instance.getNumActivePlayers();
            _dm        = DataManager.instance;
        }
        else
        {
            Debug.LogWarning("Data Manager Can Not be Found");
        }

        int playerNum = vehicleInputScript.getPlayerNum();

        _chb = vehicleInputScript.GetComponent <CarHealthBehavior>();

        _raycastCarHolder = vehicleInputScript.GetComponent <RaycastCar>();
        _dm.playerUIDictionary.Add(_raycastCarHolder.playerID, this);

        //Old Attack Indicator Setup

        /*
         * if (numPlayers > 1)
         * {
         *  _heightOffset = 0.057f;
         *  for (int i = 0; i < attackIndicators.Count; i++)
         *  {
         *      attackIndicators[i].transform.localScale = multiplePlayerScale;
         *  }
         * }
         * else
         * {
         *  for (int i = 0; i < attackIndicators.Count; i++)
         *  {
         *      attackIndicators[i].transform.localScale = onePlayerScale;
         *  }
         * }
         */
        switch (playerNum)
        {
        case 1:     //is player 1
            if (numPlayers == 2)
            {
                offSetVector = new Vector3(0, localCam.pixelHeight, 0);
            }
            else if (numPlayers >= 3)
            {
                offSetVector = new Vector3(0, localCam.pixelHeight, 0);
            }
            break;

        case 2:     //is player 2
            if (numPlayers >= 3)
            {
                offSetVector = new Vector3(localCam.pixelWidth, localCam.pixelHeight, 0);
            }
            break;

        case 3:     //is player 3
            offSetVector = new Vector3(0, 0, 0);
            break;

        case 4:     //is player 4
            offSetVector = new Vector3(localCam.pixelWidth, 0, 0);
            break;
        }
        //Legacy Hype and Pole position Setters, Assigned per player
        //hypeText.color = Color.cyan;
        //hypeDisplay.sprite = hypeDisplayColors[playerNum - 1];
        //poleBean.sprite = beanSprites[playerNum - 1];
    }
コード例 #19
0
 private void Start()
 {
     _immunePlayer = gameObject.GetComponent <CarHealthBehavior>();
 }
コード例 #20
0
 // Start is called before the first frame update
 void Start()
 {
     _carHealthScript = _immunePlayer.GetComponent <CarHealthBehavior>();
     _carsToDamage    = new List <CarHealthBehavior>();
 }
コード例 #21
0
 public void GiveInfo(CarHealthBehavior carHealthScript)
 {
     _carHealthScript = carHealthScript;
 }