/// <summary>
    /// Convenience function for adding new SCT entries.
    /// </summary>

    public static void Print(GameObject go, string text, Color color)
    {
        ScrollingCombatText sct = go.GetComponent <ScrollingCombatText>();

        if (sct == null)
        {
            sct       = go.AddComponent <ScrollingCombatText>();
            sct.style = Config.Instance.infoStyle;
        }
        sct.Add(text, color);
    }
예제 #2
0
    /// <summary>
    /// Dock the ship at the specified town.
    /// </summary>

    void DockShip(Town town)
    {
        int gold = SellCargo(town);

        if (gold > 0)
        {
            mCurrentRevenue      += gold;
            Config.Instance.gold += gold;
            ScrollingCombatText.Print(gameObject, "$" + gold, (gold < prefab.price / 10) ? Color.yellow : Color.green);
        }
        LoadCargo(town);

        mStartTime = Time.time + 2f;
        mLastTown  = town;
    }
예제 #3
0
    public void TakeDamage(int value, bool isCrit)
    {
        if (healthbar == null)
        {
            healthbar = FindObjectOfType <GameVariables>().CreateHealthbar(this.gameObject);
        }
        ScrollingCombatText battleText = Instantiate(scrollingBattleText).GetComponent <ScrollingCombatText>();

        battleText.Create(gameObject.transform, value.ToString(), isCrit);
        currentHealth -= value;
        if (currentHealth <= 0)
        {
            Die();
        }
    }
예제 #4
0
    /// <summary>
    /// React to the ship being hit by cannon fire.
    /// </summary>

    void OnCollisionEnter(Collision col)
    {
        Cannonball cb = col.collider.GetComponent <Cannonball>();

        if (cb != null && cb.damage > 0f)
        {
            // Damage the hull
            float damage = mStats.ApplyDamage(cb.damage, cb.owner);

            // Print the damage text over the hull
            if (damage > 0f)
            {
                ScrollingCombatText.Print(gameObject, "-" + Mathf.RoundToInt(damage), Color.red);
            }
        }
    }
예제 #5
0
    /// <summary>
    /// Damage the sail when hit by a cannonball.
    /// </summary>

    void OnTriggerEnter(Collider col)
    {
        Cannonball cb = col.GetComponent <Cannonball>();

        if (cb != null && cb.damage > 0f)
        {
            // Damage the sails
            float damage = mStats.ApplyDamageToSails(cb.damage);

            // Print the damage text over the sail
            if (damage > 0f)
            {
                ScrollingCombatText.Print(gameObject, "-" + Mathf.RoundToInt(damage), new Color(1f, .4f, 0f));
            }
        }
    }
예제 #6
0
    /// <summary>
    /// Show a useful tooltip regarding the ship's weekly income.
    /// </summary>

    void OnMouseEnter()
    {
        int profit = mLastRevenue - mLastUpkeep;

        if (profit == 0)
        {
            profit = mCurrentRevenue - mCurrentUpkeep;
        }

        if (profit < 0)
        {
            ScrollingCombatText.Print(gameObject, "Weekly Loss: $" + profit, Color.red);
        }
        else
        {
            ScrollingCombatText.Print(gameObject, "Weekly Profit: $" + profit,
                                      (profit < prefab.price / 10) ? Color.yellow : Color.green);
        }
    }
    public void Spawn(Vector3 position, string text, float duration)
    {
        ScrollingCombatText instance = Instantiate(Prefab, position, Quaternion.identity);

        instance.Initialize(text, duration, Color, TargetRelativeOffset);
    }