Exemplo n.º 1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Bullet"))
        {
            Bullet    bullet = other.GetComponent <Bullet>();
            TextPopup txtPop = PREFAB.SpawnPrefab(PREFAB.DAMAGE_TEXT, transform.position + new Vector3(Random.Range(-0.80f, 0.8f), Random.Range(-0.30f, 0.50f), -5), "1").GetComponent <TextPopup>();
            int       damage = bullet.damage;
            txtPop.ChangeText(damage.ToString("f0"));

            health -= damage;

            PREFAB.SpawnPrefab(PREFAB.HIT_IMPACT, other.transform.position - new Vector3(Random.Range(-0.1f, 0.1f), Random.Range(-0.1f, 0.1f), 5), "1");

            if (health > 0)
            {
                StartCoroutine(Blink());
                AudioSource.PlayClipAtPoint(PREFAB.audio.hitSound, transform.position);
            }
            else
            {
                PREFAB.SpawnPrefab(PREFAB.EXPLOSION, transform.position, "1");
                AudioSource.PlayClipAtPoint(PREFAB.audio.explosionSound, transform.position);
                if (bullet.mine)
                {
                    StartCoroutine(DeferredDestroy());
                }
            }

            PREFAB.DespawnPrefab(other.transform, "1");
        }
    }
Exemplo n.º 2
0
 private void GUIShareData()
 {
     is_data_share_expanded = Foldout("User Data Collection", is_data_share_expanded);
     if (is_data_share_expanded)
     {
         EditorGUI.indentLevel += 2;
         Toggle("share_user_data", "Share Anonomyous Data for usage statistics", "", EditorStyles.boldLabel);
         EditorGUILayout.LabelField("The data is identified by a hash of your macaddress. This is to make sure we don't log any user twice, while still keeping all data anonymous.");
         if (Config.Get().share_user_data)
         {
             Toggle("share_installed_unity_version", "Share my installed Unity Version", "");
             Toggle("share_installed_editor_version", "Share my installed Thry Editor Version", "");
             Toggle("share_used_shaders", "Share the names of installed shaders using thry editor", "");
             GUILayout.BeginHorizontal();
             GUILayout.Space(EditorGUI.indentLevel * 15);
             if (GUILayout.Button("Show all data collected about me", GUILayout.ExpandWidth(false)))
             {
                 Helper.DownloadStringASync(URL.DATA_SHARE_GET_MY_DATA + "?hash=" + Helper.GetMacAddress().GetHashCode(), delegate(string s){
                     TextPopup popup    = ScriptableObject.CreateInstance <TextPopup>();
                     popup.position     = new Rect(Screen.width / 2, Screen.height / 2, 512, 480);
                     popup.titleContent = new GUIContent("Your Data");
                     popup.text         = s;
                     popup.ShowUtility();
                 });
             }
             GUILayout.EndHorizontal();
         }
         EditorGUI.indentLevel -= 2;
     }
 }
Exemplo n.º 3
0
        public EndScreen(Game1 game, bool won) : base(game)
        {
            string endString;

            if (won)
            {
                endString = "You survived the " + GameManager.Instance.CurrentDay + " day quarantine.";
            }
            else
            {
                if (GameManager.Instance.CurrentDay == 1)
                {
                    endString = "You died in " + GameManager.Instance.CurrentDay + " day.";
                }
                else
                {
                    endString = "You died in " + GameManager.Instance.CurrentDay + " days.";
                }
            }

            _popups.Add((new FastMessage("Stats",
                                         new Vector2(GameConstants.GameWidth / 2, GameConstants.GameHeight / 2 + 60))));
            _popups.Add((new FastMessage("Times using radio: " + GameManager.Instance.TotalRadioUse,
                                         new Vector2(GameConstants.GameWidth / 2, GameConstants.GameHeight / 2 + 100))));
            _popups.Add((new FastMessage("Number of food eaten: " + GameManager.Instance.FoodEaten,
                                         new Vector2(GameConstants.GameWidth / 2, GameConstants.GameHeight / 2 + 120))));
            _popups.Add((new FastMessage("Quenched thirst: " + GameManager.Instance.DrankTimes,
                                         new Vector2(GameConstants.GameWidth / 2, GameConstants.GameHeight / 2 + 140))));
            _popups.Add((new FastMessage("Hit the sack: " + GameManager.Instance.TimesSlept,
                                         new Vector2(GameConstants.GameWidth / 2, GameConstants.GameHeight / 2 + 160))));
            _popups.Add((new FastMessage("Emptied the tank: " + GameManager.Instance.TotalToiletUse,
                                         new Vector2(GameConstants.GameWidth / 2, GameConstants.GameHeight / 2 + 180))));

            _message = new TextPopup(endString, false);
        }
Exemplo n.º 4
0
    // Create a resource popup next to Laborers when they gain gold or supplies
    public static TextPopup CreateResourceGainPopup(Vector3 position, float amount, ResourceType resourceType)
    {
        TextPopup resourceGainPopup = textPopupObjectPool.GetPooledObject().GetComponent <TextPopup>();

        resourceGainPopup.SetupResourceGainPopup(position, amount, resourceType);

        return(resourceGainPopup);
    }
Exemplo n.º 5
0
    // Create a resource popup in the resource display for when the player uses resources
    public static TextPopup CreateResourceDisplayPopup(Vector3 position, float amount)
    {
        TextPopup resourcePopup = textPopupObjectPool.GetPooledObject().GetComponent <TextPopup>();

        resourcePopup.SetupResourceDisplayPopup(position, amount);

        return(resourcePopup);
    }
Exemplo n.º 6
0
    // Create a text popup with a given string
    public static TextPopup CreateTextStringPopup(Vector3 position, string stringText)
    {
        TextPopup resourceGainPopup = textPopupObjectPool.GetPooledObject().GetComponent <TextPopup>();

        resourceGainPopup.SetupTextStringPopup(position, stringText);

        return(resourceGainPopup);
    }
    public TextPopup Damage(float damage, Vector3 position, Transform parentTo = null)
    {
        TextPopup popup = CreatePopup(position, parentTo);

        popup.ApplyStyle(settings.damagePopupStyle);
        popup.textComponent.text = "" + damage;
        return(popup);
    }
    public TextPopup InteractionHint(string text, Vector3 position, Transform parentTo = null)
    {
        TextPopup popup = CreatePopup(position, parentTo);

        popup.ApplyStyle(settings.interactnHintPopupStyle);
        popup.textComponent.text = text;
        return(popup);
    }
Exemplo n.º 9
0
    // Create a damage popup
    public static TextPopup CreateDamagePopup(Vector3 position, float damageAmount, bool isCriticalHit, bool isDefenderOrCastle)
    {
        TextPopup damagePopup = textPopupObjectPool.GetPooledObject().GetComponent <TextPopup>();

        damagePopup.SetupDamagePopup(position, damageAmount, isCriticalHit, isDefenderOrCastle);

        return(damagePopup);
    }
Exemplo n.º 10
0
    // Create a heal popup
    public static TextPopup CreateHealPopup(Vector3 position, float healAmount)
    {
        TextPopup healPopup = textPopupObjectPool.GetPooledObject().GetComponent <TextPopup>();

        healPopup.SetupHealPopup(position, healAmount);

        return(healPopup);
    }
Exemplo n.º 11
0
    public void TakeDamage(float damage)
    {
        health -= damage;
        health_slider.value = health;
        TextPopup t = Instantiate(textPopup_prefab, textPopupPosition.transform.position, transform.rotation).GetComponent <TextPopup>();

        t.Setup(hitPhrases[Mathf.FloorToInt(Random.Range(0, hitPhrases.Length))]);
        SoundManager.Instance.PlaySound(SoundManager.Sound.EnemyHit);
    }
Exemplo n.º 12
0
    public void IncreaseHitsSinceLastResourceProduction()
    {
        audioManager.PlayRandomSound(audioManager.pickaxeSounds);

        hitsSinceResourceProduced++;
        if (targetResourceDeposit != null && hitsSinceResourceProduced == targetResourceDeposit.hitsToProduce)
        {
            hitsSinceResourceProduced = 0;
            targetResourceDeposit.ProduceResources();
            TextPopup.CreateResourceGainPopup(transform.position + new Vector3(0f, 0.1f), targetResourceDeposit.goldEarnedEachProductionCycle, targetResourceDeposit.resourceType);
        }
    }
Exemplo n.º 13
0
    public void Heal(float healAmount)
    {
        currentHealth += Mathf.RoundToInt(healAmount);
        if (currentHealth > maxHealth)
        {
            SetCurrentHealthToMaxHealth();
        }

        if (PlayerPrefsController.DamagePopupsEnabled())
        {
            TextPopup.CreateHealPopup(transform.position + new Vector3(Random.Range(-0.05f, 0.05f), Random.Range(0.05f, 0.15f)), healAmount);
        }
    }
Exemplo n.º 14
0
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.collider.CompareTag("Enemy"))
     {
         TextPopup t = Instantiate(textPopup, transform.position, Quaternion.identity).GetComponent <TextPopup>();
         t.Setup(studentReact[Mathf.FloorToInt(Random.Range(0, studentReact.Length))]);
         StartCoroutine(IgnoreCollision(GetComponent <Collider2D>(), collision.collider));
     }
     if (collision.collider.CompareTag("Player"))
     {
         TextPopup t = Instantiate(textPopup, transform.position, Quaternion.identity).GetComponent <TextPopup>();
         t.Setup(teacherReact[Mathf.FloorToInt(Random.Range(0, teacherReact.Length))]);
     }
 }
Exemplo n.º 15
0
    // Update is called once per frame
    void Update()
    {
        if (health <= 0)
        {
            targetPlayer.GetComponent <Score>().IncrementScore(scoreValue);
            TextPopup t = Instantiate(textPopup_prefab, textPopupPosition.transform.position, transform.rotation).GetComponent <TextPopup>();
            t.Setup(diePhrases[Mathf.FloorToInt(Random.Range(0, diePhrases.Length))]);
            SoundManager.Instance.PlaySound(SoundManager.Sound.EnemyDie);
            Destroy(gameObject);
        }


        UpdateHealthBar();
    }
    void ResurrectUnits()
    {
        if (squadHighlighter.selectedSquad == null)
        {
            TextPopup.CreateTextStringPopup(Utilities.GetMouseWorldPosition(), "Invalid target");
            Reset();
            return;
        }
        else if (activeAbilitySquad.rangeCollider.squadsInRange.Contains(squadHighlighter.selectedSquad) == false && squadHighlighter.selectedSquad != activeAbilitySquad)
        {
            TextPopup.CreateTextStringPopup(squadHighlighter.selectedSquad.transform.position, "Target not in range");
            Reset();
            return;
        }
        else if (squadHighlighter.selectedSquad.deadUnits.Count == 0)
        {
            TextPopup.CreateTextStringPopup(squadHighlighter.selectedSquad.transform.position, "No units to resurrect");
            Reset();
            return;
        }

        int goldCost     = Mathf.RoundToInt(squadHighlighter.selectedSquad.GetGoldCost() / squadHighlighter.selectedSquad.maxUnitCount * squadHighlighter.selectedSquad.deadUnits.Count);
        int suppliesCost = Mathf.RoundToInt(squadHighlighter.selectedSquad.GetSuppliesCost() / squadHighlighter.selectedSquad.maxUnitCount * squadHighlighter.selectedSquad.deadUnits.Count);

        if (resourceDisplay.HaveEnoughGold(goldCost) && resourceDisplay.HaveEnoughSupplies(suppliesCost))
        {
            activeAbilitySquad.abilityActive = true;
            PlayCastSpellAnims_Priests(activeAbilitySquad);

            float resurrectAnimationTime = audioManager.resurrectSounds[0].clip.length;

            for (int i = 0; i < squadHighlighter.selectedSquad.deadUnits.Count; i++)
            {
                ResurrectUnitFromSquad(squadHighlighter.selectedSquad.deadUnits[i], resurrectAnimationTime);
            }

            resourceDisplay.SpendGold(goldCost);
            resourceDisplay.SpendSupplies(suppliesCost);

            audioManager.PlayRandomSound(audioManager.resurrectSounds);

            StartCoroutine(DeactivateResurrect(resurrectAnimationTime, activeAbilitySquad));
            Reset();
        }
        else // Not enough supplies or gold, so cancel using the ability
        {
            TextPopup.CreateTextStringPopup(squadHighlighter.selectedSquad.transform.position, "Not enough resources");
            Reset();
        }
    }
    TextPopup CreatePopup(Vector3 position, Transform parentTo = null)
    {
        TextPopup popup = Instantiate(settings.textPopupPrefab);

        if (parentTo != null)
        {
            popup.transform.SetParent(parentTo);
            popup.transform.localPosition = position;
        }
        else
        {
            popup.transform.position = position;
        }
        return(popup);
    }
Exemplo n.º 18
0
 public void Die(bool from_match = false, int match_count = 1)
 {
     if (from_match)
     {
         TextPopup.SpawnText((MatchScore * match_count).ToString(), transform.position);
         _player.AddScore(MatchScore * match_count);
     }
     else
     {
         TextPopup.SpawnText(DeathScore.ToString(), transform.position);
         CameraShake.ShakeCamera(2.5f);
         _player.AddScore(DeathScore);
     }
     Explode();
 }
Exemplo n.º 19
0
 // Use this for initialization
 void Awake()
 {
     Instance = this;
     CenterTextON = false;
     CenterText.gameObject.SetActive(false);
 }