public void FillNext()
    {
        if (filling)
        {
            return;
        }

        switch (fillBar)
        {
        case FillBar.BAR_1:
            fillBar = FillBar.BAR_2;

            maxAmount = 0.915f;

            canFill = false;

            break;

        case FillBar.BAR_2:
            fillBar = FillBar.BAR_3;

            maxAmount = 1;

            canFill = false;
            break;
        }
    }
Beispiel #2
0
    // Use this for initialization
    void Awake()
    {
        UI_HANDLER  = FindObjectOfType <UI_Handler>();
        audioSource = GetComponent <AudioSource>();

        // another ugly hax
        reloadBar = transform.parent.parent.GetComponentInChildren <FillBar>();
    }
 public void Initialize()
 {
     health   = transform.FindChild("HealthBar").gameObject.GetComponent <FillBar>();
     unitName = transform.FindChild("Top Panel").FindChild("Unit Name").GetComponent <Text>();
     health.Initialize();
     mainResource = transform.FindChild("ResourceBar").gameObject.GetComponent <FillBar>();
     mainResource.Initialize();
 }
    void Start()
    {
        fillBar = FillBar.BAR_1;

        image            = GetComponent <Image>();
        image.type       = Image.Type.Filled;
        image.fillMethod = Image.FillMethod.Horizontal;
        image.fillAmount = 0.833f;
        maxAmount        = image.fillAmount;
    }
Beispiel #5
0
        public override void OnAwake()
        {
            base.OnAwake();

            RectTransform.Size = new Point(75f, 45f);

            fillBar = SceneObject.Instantiate <FillBar>(this);
            fillBar.RectTransform.Alignment = Alignment.Center;
            fillBar.RectTransform.Pivot     = new Point(0.5f, 0.5f);
            fillBar.RectTransform.Size      = new Point(RectTransform.Width, 5f);
            fillBar.BackgroundUrl           = AssetLibrary.UI.FillBarBackground;
            fillBar.Background.SliceType    = SliceType.Nine;
            fillBar.FillImage.Color         = AssetLibrary.Colors.Blue;
            fillBar.FillBarPadding          = 2f;
        }
Beispiel #6
0
            public override void OnAwake()
            {
                base.OnAwake();

                RectTransform.Size      = new Point(540f, (Parent as UIElement).RectTransform.Height);
                RectTransform.Alignment = Alignment.Center;
                Background.SliceType    = SliceType.ThreeHorizontal;
                //                container.Background.Source = ResourceManager.ImageFromFile(AssetLibrary.UI.Header);

                var content = SceneObject.Instantiate <UIElement>(this);

                content.RectTransform.Alignment = Alignment.Center;
                content.RectTransform.Size      = new Point(RectTransform.Width - 60f, RectTransform.Height - 10f);

                fillBar = SceneObject.Instantiate <FillBar>(this);
                fillBar.RectTransform.Size      = new Point(RectTransform.Width - 60f, 10f);
                fillBar.Background.Color        = Color.Black;
                fillBar.FillImage.Color         = Color.White;
                fillBar.Height                  = 6;
                fillBar.RectTransform.Alignment = Alignment.BottomLeft;
                fillBar.RectTransform.Padding   = new Padding(30f, -10f);
                fillBar.RectTransform.Pivot     = new Point(1f, 0f);

                var label = content.AddComponent <Text>();

                label.ApplyStyle(AssetLibrary.TextStyles.HudProperty);
                label.Alignment = Alignment.TopLeft;
                label.Content   = AssetLibrary.Strings.BaseHealth.ToUpper(); // TODO: Localisation?
                label.Offset    = new Point(-2f, 0f);

                healthText = content.AddComponent <Text>();
                healthText.ApplyStyle(AssetLibrary.TextStyles.HudValue);
                healthText.Alignment = Alignment.TopRight;
                healthText.Offset    = new Point(2f, 0f);

                // Assign default values
                healthText.Content = "N/A";

                fader        = AddComponent <UiImageFader>();
                fader.Active = false;
                fader.Add(fillBar.FillImage);
            }
    //Helper
    private void InitStats()
    {
        timeLeftToTurn = turnDelay;

        foreach (FillBar fillBar in GetComponentsInChildren<FillBar>())
        {
            if (fillBar.name == "HPbar")
            {
                hpBar = fillBar;
            }
            else if (fillBar.name == "ShieldBar")
            {
                shieldBar = fillBar;
            }
        #if FULL_DEBUG
            else
            {
                Debug.LogError("fillbar is not hp bar nor shield bar, but " + fillBar.name);
            }
        #endif

        }

        #if FULL_DEBUG
        if (!hpBar)
        {
            Debug.LogError("Could not find HPbar");
        }
        if (!shieldBar)
        {
            Debug.LogError("Could not find ShieldBar");
        }
        #endif
        ShowHPBars(false);
        maxHullHP = shipBP.Hull.HullHP;
        HullHP = maxHullHP;
        MaxShields = 0.0f;
        hpBarTrans = hpBar.transform;
        foreach (ShipComponent component in shipBP.Slot_component_table.Values)
        {
            component.Init(this);
            components.Add(component);
            if (component is Comp_Def_Shield)
            {
                MaxShields += ((Comp_Def_Shield)component).shieldStrength;
            }
        }
        ShieldStrength = MaxShields;

        maxPower = ShipBPMetaData.ExcessPower;
        currentPower = MaxPower;

        MoveCost = shipBPMetaData.MoveCost;
        //Debug.Log("Move cost " + MoveCost);
    }
Beispiel #8
0
 void Awake()
 {
     _fillBar = GetComponent <FillBar>();
 }
    // Use this for initialization
    void Awake()
    {
        // make sure mass is right
        rbody = this.GetComponent<Rigidbody2D>();
        rbody.mass = baseMass;

        if (!GameState.IsGameStarted)
                GameState.StartNewGame();

        muteSounds = true;
        Pickups = new List<Pickup>();

        ammobar = transform.FindChild("UI/ammobar").GetComponent<FillBar>();
        weaponCycler = GetComponentInChildren<WeaponCycler>();
    }
Beispiel #10
0
    // Use this for initialization
    void Start()
    {
        Health = StartingHealth;
        healthBar = transform.GetComponentInChildren<FillBar>();

        flashMaterial =  new Material(Shader.Find("Sprites/DefaultColorFlash"));
        flashMaterial.SetFloat("_FlashAmount", 0.75f);
        spriteRenderers = Helper.GetComponentsInChildrenRecursive<SpriteRenderer>(transform);
        defaultMaterials = new Dictionary<int, Material>();
        foreach (var sr in spriteRenderers)
        {
            var key = sr.gameObject.GetInstanceID();
            if(!defaultMaterials.ContainsKey(key))
                defaultMaterials.Add(key, sr.material);
        }
    }