Beispiel #1
0
 private void DamagePlayer()
 {
     Debug.Log("Enemy: Damage player event");
     Resource_Inventory.RemoveLives(damage_to_player);
     Text_Bubble.CreateTemporaryTextBubble("-" + damage_to_player.ToString(), 3f, transform.position, Color.red);
     DamagePlayerEvent?.Invoke(this, new EnemyV2RefEventArgs(this));
 }
Beispiel #2
0
    public static Text_Bubble CreateTemporaryTextBubble(string message, float duration, Vector3 position, Color color)
    {
        Text_Bubble txt = CreateTemporaryTextBubble(message, duration, position);

        txt.text_mesh.color = color;
        return(txt);
    }
Beispiel #3
0
    public static Text_Bubble CreateTemporaryTextBubble(string message, float duration, Vector3 position)
    {
        Text_Bubble txt = CreateTemporaryTextBubble(message, duration);

        txt.gameObject.transform.position = position;
        return(txt);
    }
Beispiel #4
0
    public static Text_Bubble CreateTemporaryTextBubble(string message, float duration, GameObject parent, Color color)
    {
        Text_Bubble txt = CreateTemporaryTextBubble(message, duration, parent);

        txt.text_mesh.color = color;
        return(txt);
    }
Beispiel #5
0
    //Public Methods:
    public static Text_Bubble CreateTemporaryTextBubble(string message, float duration, GameObject parent)
    {
        Text_Bubble txt = CreateTemporaryTextBubble(message, duration);

        txt.gameObject.transform.SetParent(parent.transform);
        return(txt);
    }
Beispiel #6
0
    //Helper Method(s):
    private static Text_Bubble CreateTemporaryTextBubble(string message, float duration)
    {
        GameObject  goj = new GameObject("Text Bubble");
        Text_Bubble txt = goj.AddComponent <Text_Bubble>();

        txt.RemoveAfterSeconds(duration);
        txt.UpdateTextMessage(message);
        return(txt);
    }
Beispiel #7
0
    public void ApplyDamage(float damage)
    {
        current_hp -= damage;

        //hit number
        Text_Bubble.CreateTemporaryTextBubble(damage.ToString(), .75f, transform.position, new Color(1f, .01f, .01f, .85f)); //a transparentish red

        //check for death
        if (current_hp <= 0)
        {
            HandleDeath();
        }
    }
    void OnNodeSelect(object caller, TowerPlaceSelectEventArgs args)
    {
        //Debug.Log("node selected");

        //TODO: Have an actual, nonmagical cost
        //handle placing tower
        //Can only place if there is no tower already present and we are currently trying to place a tower
        if (flag_placement_in_progress)
        {
            if (!args.node.IsOccupied())
            {
                //Debug.Log("placement attempt");
                if (Resource_Inventory.TryTakeResources(tower_to_place.price_list))
                {
                    RemoveGhostFade();

                    Tower_V2 tower_instance = Instantiate(tower_to_place, new Vector3(0, 0, 0), Quaternion.identity);
                    //if the node can't attach the new tower instance, we destroy it
                    if (!args.node.TryAttachTower(tower_instance))
                    {
                        //Debug.Log("placement attempt failed! destroying instance...");
                        Destroy(tower_instance);
                    }
                    else
                    {
                        //Debug.Log("placement attempt successful!");
                        EndTowerPlacement();
                    }

                    TowerPlacedEvent?.Invoke(this, new TowerV2RefEventArgs(tower_instance));
                }
                else
                {
                    //Write tower construction failed! code here.
                    //Text bubble explains why placement cant happen. Make sure this isnt spammable!?

                    Text_Bubble.CreateTemporaryTextBubble("Not enough resources!", info_bubble_duration, args.node.gameObject.transform.position);
                }
            }
            else
            {
                //TODO: Tower failed! reason: space is already occupied!
                Text_Bubble.CreateTemporaryTextBubble("Space occuupied!", info_bubble_duration, args.node.gameObject.transform.position);
            }
        }
    }
    //TODO:
    private void ResourceCollectTextBalloon()
    {
        string msg = "+" + resource_amount.ToString() /* + " " + GetResourceTypeString(resource_name)*/; //kinda lengthy to include name. Removing for now

        Text_Bubble.CreateTemporaryTextBubble(msg, pickup_message_duration, gameObject.transform.position, pickup_text_color);
    }