Ejemplo n.º 1
0
 public void OnPlayerDamageTaken(PlayerGameplay player)
 {
     if (null != PlayerArray[(int)(player.playerEnum)].Player)
     {
         PlayerArray[(int)(player.playerEnum)].UiPercentage.text = ((int)player.GetPercentage()).ToString("D3") + "%";
     }
 }
    private void OnCollisionEnter(Collision collision)
    {
        WeaponHolder componentWeaponHolder = collision.gameObject.GetComponent <WeaponHolder>();

        if (null != componentWeaponHolder)
        {
            //
            // Show correct weapon in body
            bool bCanSwitch = componentWeaponHolder.SetWeaponTypeToSwitchTo(_Weapon.WeaponType, gameObject.GetComponent <WeaponShot>().loaderSize);

            //
            // Destroy current weapon
            if (bCanSwitch)
            {
                Destroy(gameObject);

                //
                // Play the pick sound
                AudioManager.GetInstance().PlaySoundEffect(m_pickSound, 1.0f);
            }
            else
            {
                float fSpeed = gameObject.GetComponent <Rigidbody>().velocity.magnitude;
                if (fSpeed >= 5.0f)
                {
                    PlayerGameplay player = collision.gameObject.GetComponent <PlayerGameplay>();
                    Vector3        dir    = collision.contacts[0].point - transform.position;
                    player.TakeDamages(30.0f, dir, 1.3f);
                }
            }
        }
    }
Ejemplo n.º 3
0
    private void OnTriggerExit(Collider other)
    {
        if (other.gameObject.CompareTag("BulletShell"))
        {
            Destroy(other.gameObject);
            return;
        }

        PlayerGameplay pgpComponent = other.GetComponent <PlayerGameplay>();

        if (null != pgpComponent)
        {
            pgpComponent.OnDie();

            TriggerDeathEffect(pgpComponent.transform.position);
        }
        else
        {
            PlayerGameplayRunner pgpComponentRunner = other.GetComponent <PlayerGameplayRunner>();
            if (null != pgpComponentRunner)
            {
                pgpComponentRunner.OnDie();

                TriggerDeathEffect(pgpComponentRunner.transform.position);
            }
        }
    }
Ejemplo n.º 4
0
    private void OnTriggerEnter(Collider other)
    {
        PlayerGameplay player = other.gameObject.GetComponent <PlayerGameplay>();

        if (null != player && other.gameObject != transform.parent.gameObject)
        {
            Vector3 dir = player.transform.position - transform.position;
            player.TakeDamages(damages, dir, ejectionFactor);
        }
    }
    void OnCollisionEnter(Collision collision)
    {
        PlayerGameplay player = collision.gameObject.GetComponent <PlayerGameplay>();

        if (null != player)
        {
            Vector3 dir = collision.contacts[0].point - transform.position;
            player.TakeDamages(damages, dir, ejectionFactor);
        }
    }
Ejemplo n.º 6
0
    public void OnPlayerDied(PlayerGameplay player)
    {
        uint?stocks  = player.GetRemainingStocks();
        int  arrayId = (int)(player.playerEnum);

        if (null != stocks && null != PlayerArray[arrayId].Player)
        {
            PlayerArray[arrayId].UiPercentage.text = 0.ToString("D3") + "%";
            if (3 < stocks)
            {
                PlayerArray[arrayId].UiTextStockX.text = ((int)(stocks)).ToString("D2");
            }
            else if (2 < stocks)             // 3+ -> 3 = only panel 3 images
            {
                PlayerArray[arrayId].UiPanelStockX.SetActive(false);
                PlayerArray[arrayId].UiPanelStock3.SetActive(true);
            }
            else if (1 < stocks)             // 3 -> 2 = only panel 3 images
            {
                PlayerArray[arrayId].UiPanelStock3.GetComponent <StockDisplay>().Image3.enabled = false;
            }
            else if (0 < stocks)             // 2 -> 1, can be 3/2
            {
                if (PlayerArray[arrayId].UiPanelStock3.activeInHierarchy)
                {
                    PlayerArray[arrayId].UiPanelStock3.GetComponent <StockDisplay>().Image2.enabled = false;
                }
                else
                {
                    PlayerArray[arrayId].UiPanelStock2.GetComponent <StockDisplay>().Image2.enabled = false;
                }
            }
            else
            {
                bFinished = true;
                foreach (PlayerUI playerUI in PlayerArray)
                {
                    if (null != playerUI.Player)
                    {
                        playerUI.UiPanelStock3.SetActive(false);
                        playerUI.UiPanelStock2.SetActive(false);
                        playerUI.UiPanelStock1.SetActive(false);
                    }
                }
            }

            if (!bFinished)
            {
                Transform newPose = Spawner.GetSpawnLocation();
                PlayerArray[arrayId].Player.SetNextSpawnLocation(newPose);
            }
        }
    }
Ejemplo n.º 7
0
    public void SetCanInteractFalse(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            canPickup      = false;
            canPlace       = false;
            activePlayerGP = other.GetComponent <PlayerGameplay>();
            activePlayerGP.activePickupPlace = null;

            activePlayerGP.activeAction = PlayerActions.NONE;
            activePlayerGP.ShowActionIndicator();
        }
    }
Ejemplo n.º 8
0
    private void OnTriggerExit(Collider other)
    {
        if (other.gameObject.CompareTag("BulletShell"))
        {
            Destroy(other.gameObject);
            return;
        }

        PlayerGameplay pgpComponent = other.GetComponent <PlayerGameplay>();

        if (null != pgpComponent)
        {
            pgpComponent.OnDie();

            if (null != DeathEffect)
            {
                Vector3    playerLocation = pgpComponent.transform.position;
                GameObject effect         = Instantiate(DeathEffect, playerLocation, Quaternion.identity);

                if (null != boundsCollider)
                {
                    Vector3 max      = boundsCollider.bounds.max;
                    Vector3 min      = boundsCollider.bounds.min;
                    Vector3 rotation = new Vector3(0.0f, 90.0f, 0.0f);

                    if (playerLocation.x >= max.x)
                    {
                        rotation.y = -90.0f;
                    }
                    else if (playerLocation.y >= max.y)
                    {
                        rotation.x = 90.0f;
                    }
                    else if (playerLocation.y <= min.y)
                    {
                        rotation.x = -90.0f;
                    }

                    effect.transform.Rotate(rotation);
                }
            }
        }
    }
Ejemplo n.º 9
0
    void OnCollisionEnter(Collision collision)
    {
        if (IsRocket)
        {
            TriggerHitEffect();
        }
        else
        {
            PlayerGameplay player = collision.gameObject.GetComponent <PlayerGameplay>();
            if (null != player)
            {
                // Collision orientation
                Vector3 dir = collision.contacts[0].point - transform.position;
                // Opposite
                dir = -dir.normalized;
                player.TakeDamages(Damages, dir, EjectionFactor);
                TriggerHitEffect();
            }
        }

        Destroy(gameObject);
    }
Ejemplo n.º 10
0
    public void SetCanInteractTrue(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            activePlayerGP = other.GetComponent <PlayerGameplay>();
            activePlayerGP.activePickupPlace = this;

            if (activePlayerGP.freeHands && (infinitePickup || vacant == false) && avalibleObjectsCount > 0)
            {
                canPickup = true;

                activePlayerGP.activeAction = PlayerActions.PICKUP;
                activePlayerGP.ShowActionIndicator();
            }

            if (!activePlayerGP.freeHands && vacant && pickupType == activePlayerGP.pickupObject.GetComponent <PickableObject>().pickableType)
            {
                canPlace = true;

                activePlayerGP.activeAction = PlayerActions.PLACE;
                activePlayerGP.ShowActionIndicator();
            }
        }
    }
Ejemplo n.º 11
0
    void OnTriggerExit(Collider collider)
    {
        PlayerGameplay player = collider.gameObject.GetComponent(typeof(PlayerGameplay)) as PlayerGameplay;

        player.Respawn();
    }