Ejemplo n.º 1
0
    public void FlipCard(GameObject card)
    {
        if (openedCardsStack.Count > 0)
        {
            var prevCard = openedCardsStack.Peek();
            if (!_cardsDictionary[card].Equals(_cardsDictionary[prevCard]))
            {
                openedCardsStack.Push(card);
                StackClear(openedCardsStack);
                _health.TakeDamage(_damage);
            }
            else if (!openedCardsStack.Peek().Equals(card))
            {
                openedCardsStack.Push(card);
            }
        }
        else
        {
            openedCardsStack.Push(card);
        }

        if (openedCardsStack.Count == 2)
        {
            _points.AddPoints(_health.CurrentHealth);
        }

        if (openedCardsStack.Count != OpenCardNumber)
        {
            return;
        }

        _points.AddPoints(3 * _health.CurrentHealth);
        DeleteCards(openedCardsStack);
        openedCardsStack.Clear();
    }
Ejemplo n.º 2
0
    IEnumerator _Hit(CellHitInfo info)
    {
        yield return(new WaitForSeconds(0.05f));

        ChangeMaterial();
        GotHit(info);

        if (info.fatal)
        {
            if (finalBigCell && PongPadBuilder.instance.IsFinalLevel)
            {
                const int STEPS = 24;
                Vector3   point = Vector3.Lerp(info.hit_point, transform.position, 0.5f);
                for (int i = 0; i < STEPS; i++)
                {
                    Vector3 normal = Quaternion.Euler(0, 360 * i / (float)STEPS, 0) * Vector3.forward;
                    EmitHitPS(point, normal, Color.white, velocity_mul: 1.7f);
                }
            }

            Destroy((GameObject)gameObject);
            if (bonus)
            {
                Bonus.AddBonus(transform.position);
            }

            float cell_fraction = GetCellFraction();
            int   points1       = Mathf.RoundToInt(points * cell_fraction);
            Points.AddPoints(transform.position, MyMaterial.color, points1, pointsSize);
            PongPadBuilder.instance.KilledOneCell(cell_fraction);
        }
    }
Ejemplo n.º 3
0
 void IBall.SetPositionAndVelocity(PongPad pad, Vector3 position, Vector3 velocity)
 {
     StopAllCoroutines();
     free_falling = false;
     Hit(pad);
     Points.AddPoints(transform.position, GetColor(), GetPoints());
 }
Ejemplo n.º 4
0
    private void GoalCollision(Collision2D other)
    {
        Player hitPlayer = other.gameObject.GetComponent <Player>();

        if (!hitPlayer.hasShield)
        {
            lastPlayerHit = null;
            Destroy(gameObject);

            foreach (GameObject ball in GameObject.FindGameObjectsWithTag("Ball")) // Destroy all other balls
            {
                Destroy(ball);
            }
        }

        InGameManager.playerToDestroy = hitPlayer.playerOrder;

        if (InGameManager.innerPoints.Count < 4)
        {
            if (InGameManager.innerPoints.Count == 3)
            {
                Points.AddPoints(hitPlayer.Color);
            }

            hitPlayer.CircleDestroyPlayer();
            return;
        }

        hitPlayer.DestroyPlayer();
    }
Ejemplo n.º 5
0
 void CheckIfTheRightIngredientWasCollected()
 {
     if (uiManager.IngredientToBePickedID == ingredientID || isStarSelected)
     {
         points.AddPoints(1);
     }
     else
     {
         points.TakePoints(2);
     }
 }
Ejemplo n.º 6
0
    // Bei Kontakt mit PowerUp wird die entsprechende Funktion aufgerufen
    void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.gameObject.GetComponent <PowerUpObject>())
        {
            SoundManager.instance.PlayEffect(5);

            FireRate  powerUpFireRate  = collider.gameObject.GetComponent <FireRate>();
            Health    powerUpHealth    = collider.gameObject.GetComponent <Health>();
            Assistant powerUpAssistant = collider.gameObject.GetComponent <Assistant>();
            Points    powerUpPoints    = collider.gameObject.GetComponent <Points>();

#if UNITY_STANDALONE
            Speed powerUpSpeed = collider.gameObject.GetComponent <Speed>();

            if (powerUpSpeed)
            {
                powerUpSpeed.AddSpeed(pMovement);
                powerUpSpeed.gameObject.SetActive(false);
            }
#endif

            if (powerUpFireRate)
            {
                powerUpFireRate.AddFireRate(pWeapon);
                powerUpFireRate.AddFireRate(aWeapon);
                powerUpFireRate.AddFireRate(aWeapon2);
                powerUpFireRate.gameObject.SetActive(false);
            }
            else if (powerUpHealth)
            {
                powerUpHealth.AddHealth(pBHealth);
                powerUpHealth.gameObject.SetActive(false);
            }
            else if (powerUpPoints)
            {
                powerUpPoints.AddPoints();
                powerUpPoints.gameObject.SetActive(false);
            }
            else if (powerUpAssistant)
            {
                assistantCount = powerUpAssistant.AddAssistantCount(assistantCount);
                powerUpAssistant.gameObject.SetActive(false);

                if (assistantCount == 3)
                {
                    assistant.SetActive(true);
                }
                else if (assistantCount == 5)
                {
                    assistant2.SetActive(true);
                }
            }
        }
    }
Ejemplo n.º 7
0
    protected IEnumerator DieT(GameObject enemy)
    {
        transform.SetPositionAndRotation(new Vector3(0, -20, 0), new Quaternion(0, 0, 0, 0));
        yield return(new WaitForSeconds(1));

        GameObject.Find("WaveController").GetComponent <WaveController>().RemoveFromWave(enemy.name);
        Debug.Log("Enemy Died");
        Destroy(enemy);
        Points sn = GameObject.Find("Points").gameObject.GetComponent <Points>();

        sn.AddPoints("Bow");
    }
Ejemplo n.º 8
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        if (owner.hasShield)
        {
            owner.hasShield = false;
            return;
        }

        Destroy(other.gameObject);
        Points.AddPoints(owner.Color);
        PlayerManager.players.Remove(owner);
        Points.AddPoints(PlayerManager.players.First().Color);
        RoundWin?.Invoke();
    }
Ejemplo n.º 9
0
    private IEnumerator Movement()
    {
        WaitForSeconds wait = new WaitForSeconds(0.15f);

        while (true)
        {
            Vector3 newPosition = head.transform.position + direction;
            TypeBox boxBusy     = GetMap(newPosition);

            if (boxBusy == TypeBox.Obstacle)
            {
                Dead();
                yield return(new WaitForSeconds(3));

                GameManager.sharedInstance.GameOver();
                //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
                yield break;
            }
            else
            {
                GameObject bodyPart;
                if (boxBusy == TypeBox.Item)
                {
                    bodyPart = NewBlock(newPosition.x, newPosition.y);
                    MoveItemPositionRandom();
                    pointsAdd.AddPoints();
                }
                else
                {
                    bodyPart = body.Dequeue();
                    SetMap(bodyPart.transform.position, TypeBox.Empty);
                    bodyPart.transform.position = newPosition;
                    SetMap(newPosition, TypeBox.Obstacle);
                    body.Enqueue(bodyPart);
                }

                head = bodyPart;

                yield return(wait);
            }
        }
    }
Ejemplo n.º 10
0
    public void DestroyPlayer()
    {
        if (hasShield)
        {
            hasShield = false;
            return;
        }

        if (ChooseControls.gameStarted)
        {
            Points.AddPoints(Color);
        }

        ChooseControls.playerStates[Color] = PlayerState.Deactivated;
        _inGameManager.StartLerpLevelSmaller(playerOrder);
        InGameManager.OnPlayerDestroy -= CheckPlayerOrderDecrease;
        DeactivePlayer();

        UpdateScoreboard?.Invoke();
    }
Ejemplo n.º 11
0
        public override void Execute(ICommand command)
        {
            List <string> args = command.Parameters();

            if (args.Count < 2)
            {
                TwitchWrapper.SendChatMessage($"@{command.Username()} to award {ToolkitPointsSettings.pointsBaseName} make sure to include a username then an amount.");
                return;
            }

            string username = args[0].Replace("@", "");

            if (!int.TryParse(args[1], out int points))
            {
                TwitchWrapper.SendChatMessage($"@{command.Username()} to award {ToolkitPointsSettings.pointsBaseName} make sure to include the amount after the username.");
                return;
            }

            Points.AddPoints(username, command.Service(), points);

            MessageSender.SendMessage($"@{username} you have been awarded {points} {ToolkitPointsSettings.pointsBaseName} from @{command.Username()}", command.Service());
        }
Ejemplo n.º 12
0
    //Just checks if a collider overlaps with a trigger. The thing that is in you. Overlap.
    private void OnTriggerEnter(Collider other)
    {
        bool whoDunIt;

        if (other.CompareTag("Boundary") || other.CompareTag("Enemy"))
        {
            return;
        }

        whatPlayer = other.GetComponent <PlayerController>();
        gunUpgrade = other.GetComponent <PlayerWeaponController>();

        if (gunUpgrade == null)
        {
            return;
        }

        whoDunIt = whatPlayer.whichPlayer;
        addScore.AddPoints(whoDunIt);
        gunUpgrade.MorePrimaryGun();
        Instantiate(pickUpSoundPlayer, gameObject.transform.position, gameObject.transform.rotation);

        Destroy(gameObject);
    }
Ejemplo n.º 13
0
    //Just checks if a collider overlaps with a trigger. The thing that is in you. Overlap.
    private void OnTriggerEnter(Collider other)
    {
        bool whoDunIt;

        if (other.CompareTag("Boundary") || other.CompareTag("Enemy"))
        {
            return;
        }

        whatPlayer = other.GetComponent <PlayerController>();
        health     = other.GetComponent <PlayerHealthSystem>();

        if (health == null)
        {
            return;
        }

        whoDunIt = whatPlayer.whichPlayer;
        addScore.AddPoints(whoDunIt);
        health.ExtraLife();
        Instantiate(pickUpSoundPlayer, gameObject.transform.position, gameObject.transform.rotation);

        Destroy(gameObject);
    }
 public void CoinGotCollected(int value)
 {
     points.AddPoints(value);
     CoinCollected(value);
 }
Ejemplo n.º 15
0
    IEnumerator Story()
    {
        yield return(new WaitForSeconds(1.5f));

        // play sound EnemyInfront
        controller.PlaySound(2, audioSource);
        yield return(new WaitForSeconds(6));

        // show image touch left
        ImageSpot.material.mainTexture = touchpadLeft;
        // enable the image
        ImageSpot.gameObject.SetActive(true);
        // wait for the bow is spawned
        yield return(new WaitUntil(() => bowIsSpawned == true));

        // after bow has been spawned
        // disable the image
        ImageSpot.gameObject.SetActive(false);
        yield return(new WaitForSeconds(0.5f));

        // Play sound pick up bow
        controller.PlaySound(3, audioSource);
        // set image to the triggerbutton image
        ImageSpot.material.mainTexture = triggerButton;
        // wait for ben to finish talking
        yield return(new WaitForSeconds(2.0f));

        // enable the image
        ImageSpot.gameObject.SetActive(true);
        // wait for the bow is child of any of the controllers
        yield return(new WaitUntil(() => bowIsInHand == true));

        // disable the image
        ImageSpot.gameObject.SetActive(false);
        yield return(new WaitForSeconds(0.5f));

        // play sound how to shoot with bow
        controller.PlaySound(4, audioSource);
        // wait for ben to finish talking
        yield return(new WaitForSeconds(8.5f));

        // play sound Note headshots
        controller.PlaySound(13, audioSource);
        yield return(new WaitForSeconds(4.5f));

        controller.PlaySound(5, audioSource);
        // Wait for the player has killed the enemy
        yield return(new WaitUntil(() => enemyDied == true));

        yield return(new WaitForSeconds(0.5f));

        // playsound open menu
        controller.PlaySound(6, audioSource);
        // set the image to the menubutton
        ImageSpot.material.mainTexture = menuButton;
        // wait for ben to finish talking
        yield return(new WaitForSeconds(3.0f));

        // enable the image
        ImageSpot.gameObject.SetActive(true);
        // set variable to listen for menu button pressed
        timeToShine = true;
        // Wait for buttonpress
        yield return(new WaitUntil(() => menuButtonPressed == true));

        // When button is pressed
        // disable the image
        ImageSpot.gameObject.SetActive(false);
        yield return(new WaitForSeconds(0.5f));

        // Play sound select build tower
        controller.PlaySound(7, audioSource);
        // wait for ben to finish talking
        yield return(new WaitForSeconds(6.0f));

        Points sn = GameObject.Find("Points").gameObject.GetComponent <Points>();

        sn.AddPoints("Tutorial");
        yield return(new WaitForSeconds(7.0f));

        // set image to towerbuild mode
        ImageSpot.material.mainTexture = touchpadTop;
        // Enable image
        ImageSpot.gameObject.SetActive(true);
        yield return(new WaitForSeconds(2.0f));

        // waitfor tower mode has been selected
        yield return(new WaitUntil(() => TeleporterHasBeenSelected == true));

        yield return(new WaitForSeconds(0.5f));

        // disable image
        ImageSpot.gameObject.SetActive(false);
        // play sound repair tower
        controller.PlaySound(8, audioSource);
        // wait for ben to finish talking
        yield return(new WaitForSeconds(4.0f));

        // wait for player to repair a tower
        yield return(new WaitUntil(() => Towerbuilt == true));

        yield return(new WaitForSeconds(0.5f));

        // play sound tower built
        controller.PlaySound(9, audioSource);
        // wait for ben to finish talking
        yield return(new WaitForSeconds(11.0f));

        ImageSpot.material.mainTexture = touchpadRight;
        ImageSpot.gameObject.SetActive(true);
        // wait for ben to finish talking s'more
        yield return(new WaitForSeconds(1.0f));

        // wait for player to select teleport mode
        yield return(new WaitUntil(() => TeleportMode == true));

        yield return(new WaitForSeconds(0.5f));

        ImageSpot.gameObject.SetActive(false);
        // play sound point at tower
        controller.PlaySound(10, audioSource);
        // wait for ben to finish talking
        yield return(new WaitForSeconds(4.0f));

        // wait for player to teleport to another tower
        yield return(new WaitUntil(() => playerIsTeleported == true));

        yield return(new WaitForSeconds(0.5f));

        controller.PlaySound(11, audioSource);
        // wait for ben to finish talking
        yield return(new WaitForSeconds(4.0f));

        // Enable the wavecontroller
        WaveController.gameObject.SetActive(true);
    }
Ejemplo n.º 16
0
    //Takes damage from another script and subtracts from the player health and shields.
    public void Damage(float damageAmmount, bool whatPlayer)
    {
        if (invulnerable)
        {
            return;
        }
        excessShieldDamage = currentShields - damageAmmount;

        //Checks if the player has shields
        //If player has shields damage is dealt to shields.
        if (currentShields > 0)
        {
            currentShields -= damageAmmount;
            //If shields go under 0 shields are set to 0
            if (currentShields <= 0)
            {
                currentShields = 0;
            }
        }
        //if excess shield damage is less than 0 it is substracted from health.
        if (excessShieldDamage < 0)
        {
            excessShieldDamage *= -1;
            currentHealth      -= excessShieldDamage;
        }

        if (currentHealth <= 0 && isMultiStageBoss && !isDead)
        {
            isDead = true;
            Debug.Log("I'm Supposed To Die");
            StartCoroutine(DeadStage());

            doesLootDrop = Random.Range(0.0f, 100.0f);

            if (addScore != null)
            {
                addScore.AddPoints(whatPlayer);
                if (doesLootDrop <= lootDropChance)
                {
                    callLoot.LootRoll(Random.Range(0.0f, 100.0f));
                }
            }

            return;
        }
        else if (currentHealth <= 0 && isBoss && !isDead)
        {
            isDead = true;

            doesLootDrop = Random.Range(0.0f, 100.0f);

            if (addScore != null)
            {
                addScore.AddPoints(whatPlayer);
                if (doesLootDrop <= lootDropChance)
                {
                    callLoot.LootRoll(Random.Range(0.0f, 100.0f));
                }
            }
            Instantiate(scrap, gameObject.transform.position, gameObject.transform.rotation);
            Destroy(gameObject);

            HUDcontroller.winLevel = true;
        }
        else if (currentHealth <= 0 && isBossPart && !isDead)
        {
            isDead       = true;
            doesLootDrop = Random.Range(0.0f, 100.0f);

            if (addScore != null)
            {
                addScore.AddPoints(whatPlayer);

                if (doesLootDrop <= lootDropChance)
                {
                    callLoot.LootRoll(Random.Range(0.0f, 100.0f));
                }
            }

            if (this.gameObject.tag == "Boss")
            {
                if (!whatPlayer)
                {
                    P1bossKill = true;
                }
                else
                {
                    P2bossKill = true;
                }
            }

            Instantiate(scrap, gameObject.transform.position, gameObject.transform.rotation);
            Destroy(gameObject);
        }
        else if (currentHealth <= 0 && !isDead)
        {
            isDead       = true;
            doesLootDrop = Random.Range(0.0f, 100.0f);

            if (this.gameObject.tag == "LightEnemy")
            {
                if (!whatPlayer)
                {
                    P1ramEnemy++;
                }
                else
                {
                    P2ramEnemy++;
                }
            }
            if (this.gameObject.tag == "MediumEnemy")
            {
                if (!whatPlayer)
                {
                    P1lightEnemy++;
                }
                else
                {
                    P2lightEnemy++;
                }
            }
            if (this.gameObject.tag == "HeavyEnemy")
            {
                if (!whatPlayer)
                {
                    P1missileEnemy++;
                }
                else
                {
                    P2missileEnemy++;
                }
            }
            if (this.gameObject.tag == "OverEnemy")
            {
                if (!whatPlayer)
                {
                    P1destroyerEnemy++;
                }
                else
                {
                    P2destroyerEnemy++;
                }
            }

            if (addScore != null)
            {
                addScore.AddPoints(whatPlayer);

                if (doesLootDrop <= lootDropChance)
                {
                    callLoot.LootRoll(Random.Range(0.0f, 100.0f));
                }

                Instantiate(explosion, gameObject.transform.position, gameObject.transform.rotation);
                if (heavyEnemy)
                {
                    Instantiate(scrap, gameObject.transform.position, gameObject.transform.rotation);
                }

                Destroy(gameObject);
            }
        }
    }