Ejemplo n.º 1
0
 private static void Process(int i, PerformanceMeter parent)
 {
     using (PerformanceMeter pmeter = new PerformanceMeter("Process", parent))
         using (ResourceMeter meter = new ResourceMeter(resourceName))
         {
             Thread.Sleep(20);
         }
 }
Ejemplo n.º 2
0
    private void Start()
    {
        statusStuff = FindObjectOfType <ResourceMeter>();

        spawner = FindObjectOfType <EnemySpawner>();

        currentHealth = maxHealth;
    }
Ejemplo n.º 3
0
    //----------------------------------------------------------------//
    // Helper functions                                               //
    //----------------------------------------------------------------//

    private void CreateMeter(int id, Transform transform, float offset = 25)
    {
        m_baseHealthMeter.gameObject.SetActive(true);
        Vector3       location    = transform.position + new Vector3(0, offset, 0);
        ResourceMeter healthMeter = Instantiate(m_baseHealthMeter.GetComponentInChildren <ResourceMeter>(), location, Quaternion.identity, transform);

        m_meters.Add(id, healthMeter);
        m_baseHealthMeter.gameObject.SetActive(false);
    }
Ejemplo n.º 4
0
        public FillBarPane(ResourceMeter meter, String label, Color fillColor, Color capacityColor)
        {
            ResourceMeter  = meter;
            Label          = label;
            _fillColor     = fillColor;
            _capacityColor = capacityColor;
            Dirty          = true;

            Height = 1;

            ResourceMeter.OnValueChanged    += OnValueChanged;
            ResourceMeter.OnCapacityChanged += OnCapacityChanged;
        }
Ejemplo n.º 5
0
    // Start is called before the first frame update
    void Start()
    {
        target = PlayerManager.instance.player.transform;

        agent = GetComponent <UnityEngine.AI.NavMeshAgent>();

        statusStuff = FindObjectOfType <ResourceMeter>();

        theEnemy = FindObjectOfType <Enemy>();

        startingPosition = transform.position;

        positionSet = false;

        waitTime = 5f;

        playerDetected = false;
    }
Ejemplo n.º 6
0
    private void BuildResourceMeter(string name)
    {
        playerBattleManagerScript = playerBattleManager.GetComponent <PlayerBattleManager>();
        int resource;

        if (name == "Gold")
        {
            resource = 0;
            for (int i = 0; i < resourceMeterLocations.Count; i++)
            {
                GameObject newResourceMeter = Instantiate(resourceMeter, resourceMeterLocations[i].transform.position, Quaternion.identity);
                newResourceMeter.transform.SetParent(mainUIBackground.transform);
                newResourceMeter.transform.localScale = new Vector3(1, 1, 1);
                ResourceMeter myResourceMeter = newResourceMeter.GetComponent <ResourceMeter>();
                myResourceMeter.sliderFillSprite.sprite = myResourceMeter.resourceFill[resource];
                myResourceMeter.resourceFrontSprite.GetComponent <Image>().sprite = myResourceMeter.resourceFront[resource];
                myResourceMeter.resourceAmount.text = playerBattleManagerScript.playerResourcesAmount[resource].ToString();
                myResourceMeter.resourceType        = "Gold";
                spawnedResourceMeters.Add(myResourceMeter);
                resourceMeterLocations.RemoveAt(i);
                break;
            }
        }
        else if (name == "Iron")
        {
            resource = 1;
            for (int i = 0; i < resourceMeterLocations.Count; i++)
            {
                GameObject newResourceMeter = Instantiate(resourceMeter, resourceMeterLocations[i].transform.position, Quaternion.identity);
                newResourceMeter.transform.SetParent(mainUIBackground.transform);
                newResourceMeter.transform.localScale = new Vector3(1, 1, 1);
                ResourceMeter myResourceMeter = newResourceMeter.GetComponent <ResourceMeter>();
                myResourceMeter.sliderFillSprite.sprite = myResourceMeter.resourceFill[resource];
                myResourceMeter.resourceFrontSprite.GetComponent <Image>().sprite = myResourceMeter.resourceFront[resource];
                myResourceMeter.resourceAmount.text = playerBattleManagerScript.playerResourcesAmount[resource].ToString();
                myResourceMeter.resourceType        = "Iron";
                spawnedResourceMeters.Add(myResourceMeter);
                resourceMeterLocations.RemoveAt(i);
                break;
            }
        }
        else if (name == "Copper")
        {
            resource = 2;
            for (int i = 0; i < resourceMeterLocations.Count; i++)
            {
                GameObject newResourceMeter = Instantiate(resourceMeter, resourceMeterLocations[i].transform.position, Quaternion.identity);
                newResourceMeter.transform.SetParent(mainUIBackground.transform);
                newResourceMeter.transform.localScale = new Vector3(1, 1, 1);
                ResourceMeter myResourceMeter = newResourceMeter.GetComponent <ResourceMeter>();
                myResourceMeter.sliderFillSprite.sprite = myResourceMeter.resourceFill[resource];
                myResourceMeter.resourceFrontSprite.GetComponent <Image>().sprite = myResourceMeter.resourceFront[resource];
                myResourceMeter.resourceAmount.text = playerBattleManagerScript.playerResourcesAmount[resource].ToString();
                myResourceMeter.resourceType        = "Copper";
                spawnedResourceMeters.Add(myResourceMeter);
                resourceMeterLocations.RemoveAt(i);
                break;
            }
        }
        else if (name == "Nickel")
        {
            resource = 3;
            for (int i = 0; i < resourceMeterLocations.Count; i++)
            {
                GameObject newResourceMeter = Instantiate(resourceMeter, resourceMeterLocations[i].transform.position, Quaternion.identity);
                newResourceMeter.transform.SetParent(mainUIBackground.transform);
                newResourceMeter.transform.localScale = new Vector3(1, 1, 1);
                ResourceMeter myResourceMeter = newResourceMeter.GetComponent <ResourceMeter>();
                myResourceMeter.sliderFillSprite.sprite = myResourceMeter.resourceFill[resource];
                myResourceMeter.resourceFrontSprite.GetComponent <Image>().sprite = myResourceMeter.resourceFront[resource];
                myResourceMeter.resourceAmount.text = playerBattleManagerScript.playerResourcesAmount[resource].ToString();
                myResourceMeter.resourceType        = "Nickel";
                spawnedResourceMeters.Add(myResourceMeter);
                resourceMeterLocations.RemoveAt(i);
                break;
            }
        }
        else if (name == "Silver")
        {
            resource = 4;
            for (int i = 0; i < resourceMeterLocations.Count; i++)
            {
                GameObject newResourceMeter = Instantiate(resourceMeter, resourceMeterLocations[i].transform.position, Quaternion.identity);
                newResourceMeter.transform.SetParent(mainUIBackground.transform);
                newResourceMeter.transform.localScale = new Vector3(1, 1, 1);
                ResourceMeter myResourceMeter = newResourceMeter.GetComponent <ResourceMeter>();
                myResourceMeter.sliderFillSprite.sprite = myResourceMeter.resourceFill[resource];
                myResourceMeter.resourceFrontSprite.GetComponent <Image>().sprite = myResourceMeter.resourceFront[resource];
                myResourceMeter.resourceAmount.text = playerBattleManagerScript.playerResourcesAmount[resource].ToString();
                myResourceMeter.resourceType        = "Silver";
                spawnedResourceMeters.Add(myResourceMeter);
                resourceMeterLocations.RemoveAt(i);
                break;
            }
        }
        else if (name == "Cobalt")
        {
            resource = 5;
            for (int i = 0; i < resourceMeterLocations.Count; i++)
            {
                GameObject newResourceMeter = Instantiate(resourceMeter, resourceMeterLocations[i].transform.position, Quaternion.identity);
                newResourceMeter.transform.SetParent(mainUIBackground.transform);
                newResourceMeter.transform.localScale = new Vector3(1, 1, 1);
                ResourceMeter myResourceMeter = newResourceMeter.GetComponent <ResourceMeter>();
                myResourceMeter.sliderFillSprite.sprite = myResourceMeter.resourceFill[resource];
                myResourceMeter.resourceFrontSprite.GetComponent <Image>().sprite = myResourceMeter.resourceFront[resource];
                myResourceMeter.resourceAmount.text = playerBattleManagerScript.playerResourcesAmount[resource].ToString();
                myResourceMeter.resourceType        = "Cobalt";
                spawnedResourceMeters.Add(myResourceMeter);
                resourceMeterLocations.RemoveAt(i);
                break;
            }
        }
        else if (name == "Cadmium")
        {
            resource = 6;
            for (int i = 0; i < resourceMeterLocations.Count; i++)
            {
                GameObject newResourceMeter = Instantiate(resourceMeter, resourceMeterLocations[i].transform.position, Quaternion.identity);
                newResourceMeter.transform.SetParent(mainUIBackground.transform);
                newResourceMeter.transform.localScale = new Vector3(1, 1, 1);
                ResourceMeter myResourceMeter = newResourceMeter.GetComponent <ResourceMeter>();
                myResourceMeter.sliderFillSprite.sprite = myResourceMeter.resourceFill[resource];
                myResourceMeter.resourceFrontSprite.GetComponent <Image>().sprite = myResourceMeter.resourceFront[resource];
                myResourceMeter.resourceAmount.text = playerBattleManagerScript.playerResourcesAmount[resource].ToString();
                myResourceMeter.resourceType        = "Cadmium";
                spawnedResourceMeters.Add(myResourceMeter);
                resourceMeterLocations.RemoveAt(i);
                break;
            }
        }
        else if (name == "Iridium")
        {
            resource = 7;
            for (int i = 0; i < resourceMeterLocations.Count; i++)
            {
                GameObject newResourceMeter = Instantiate(resourceMeter, resourceMeterLocations[i].transform.position, Quaternion.identity);
                newResourceMeter.transform.SetParent(mainUIBackground.transform);
                newResourceMeter.transform.localScale = new Vector3(1, 1, 1);
                ResourceMeter myResourceMeter = newResourceMeter.GetComponent <ResourceMeter>();
                myResourceMeter.sliderFillSprite.sprite = myResourceMeter.resourceFill[resource];
                myResourceMeter.resourceFrontSprite.GetComponent <Image>().sprite = myResourceMeter.resourceFront[resource];
                myResourceMeter.resourceAmount.text = playerBattleManagerScript.playerResourcesAmount[resource].ToString();
                myResourceMeter.resourceType        = "Iridium";
                spawnedResourceMeters.Add(myResourceMeter);
                resourceMeterLocations.RemoveAt(i);
                break;
            }
        }
        else if (name == "Paladium")
        {
            resource = 8;
            for (int i = 0; i < resourceMeterLocations.Count; i++)
            {
                GameObject newResourceMeter = Instantiate(resourceMeter, resourceMeterLocations[i].transform.position, Quaternion.identity);
                newResourceMeter.transform.SetParent(mainUIBackground.transform);
                newResourceMeter.transform.localScale = new Vector3(1, 1, 1);
                ResourceMeter myResourceMeter = newResourceMeter.GetComponent <ResourceMeter>();
                myResourceMeter.sliderFillSprite.sprite = myResourceMeter.resourceFill[resource];
                myResourceMeter.resourceFrontSprite.GetComponent <Image>().sprite = myResourceMeter.resourceFront[resource];
                myResourceMeter.resourceAmount.text = playerBattleManagerScript.playerResourcesAmount[resource].ToString();
                myResourceMeter.resourceType        = "Paladium";
                spawnedResourceMeters.Add(myResourceMeter);
                resourceMeterLocations.RemoveAt(i);
                break;
            }
        }
    }
Ejemplo n.º 7
0
    // Update is called once per frame
    private void Update()
    {
        m_logTextTimer -= Time.deltaTime;
        if (m_logTextTimer <= 0.0f)
        {
            m_gameLogText.text = "";
            m_logTextTimer     = 5.0f;
        }

        ResourceMeter playerHealth = m_meters[m_playerHealthMeter.GetInstanceID()];
        ResourceMeter shipTreasure = m_meters[m_shipUI.GetInstanceID()];

        playerHealth.m_value    = (int)PlayerShipData.Health;
        playerHealth.m_maxValue = (int)PlayerShipData.MaxHealth;
        shipTreasure.m_value    = PlayerShipData.Treasure;
        shipTreasure.m_maxValue = PlayerShipData.MaxShipTreasure;

        m_ammoText.text   = "Ammo: " + PlayerShipData.CurrAmmo.ToString() + "/" + PlayerShipData.MaxAmmo.ToString();
        m_islandText.text = "Pirate Bank: " + PirateIsland.BankTreasure.ToString();

        // grab current scene index
        int sceneIndex = SceneManager.GetActiveScene().buildIndex;

        // updates unless in pirate island
        if (sceneIndex != 1)
        {
            // enemy health meters
            for (int i = 0; i < m_enemies.Count; ++i)
            {
                GameObject enemy = m_enemies[i];

                // check if ship has been destroyed
                if (enemy)
                {
                    ResourceMeter enemyMeter = m_meters[enemy.GetInstanceID()];

                    // check if damaged
                    if (enemy.GetComponent <EnemyShipAI>().Health < enemy.GetComponent <EnemyShipAI>().MaxHealth)
                    {
                        enemyMeter.gameObject.SetActive(true);
                    }
                    else
                    {
                        enemyMeter.gameObject.SetActive(false);
                    }

                    enemyMeter.m_value    = (int)enemy.GetComponent <EnemyShipAI>().Health;
                    enemyMeter.m_maxValue = (int)enemy.GetComponent <EnemyShipAI>().MaxHealth;
                    Vector3 enemyPos = enemy.gameObject.transform.position;
                    enemyMeter.transform.position = new Vector3(enemyPos.x, enemyMeter.transform.position.y, enemyPos.z);
                    enemyMeter.transform.LookAt(Camera.main.transform);
                }
            }

            // merchant health meters
            for (int i = 0; i < m_merchants.Count; ++i)
            {
                GameObject merchant = m_merchants[i];

                // check if ship has been destroyed
                if (merchant)
                {
                    ResourceMeter meter = m_meters[merchant.GetInstanceID()];

                    // check if damaged
                    if (merchant.GetComponent <MerchantShipAI>().Health < merchant.GetComponent <MerchantShipAI>().MaxHealth)
                    {
                        meter.gameObject.SetActive(true);
                    }
                    else
                    {
                        meter.gameObject.SetActive(false);
                    }

                    meter.m_value    = (int)merchant.GetComponent <MerchantShipAI>().Health;
                    meter.m_maxValue = (int)merchant.GetComponent <MerchantShipAI>().MaxHealth;
                    Vector3 pos = merchant.GetComponent <MerchantShipAI>().transform.position;
                    meter.transform.position = new Vector3(pos.x, meter.transform.position.y, pos.z);
                    meter.transform.LookAt(Camera.main.transform);
                }
            }
        }
    }