Esempio n. 1
0
 void Start()
 {
     this.statComponent   = gameObject.GetComponent <StatComponent>();
     this.playerRigidBody = gameObject.GetComponent <Rigidbody2D>();
     this.health          = statComponent.baseHealth;
     this.isAlive         = true;
 }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        StatComponent otherStats = collision.gameObject.GetComponent <StatComponent>();

        if (otherStats != null)
        {
            otherStats.ModifyHealthBy(-Random.Range(myStats.minimumDamage, myStats.maximumDamage), myStats.damageMultiplayer);
        }
    }
 public override void Update(GameTime gameTime)
 {
     if (tile is Building)
     {
         if (((Building)tile).trainingQueue.Count != prevCount)//Handle Queued item display
         {
             float x = 220;
             foreach (IComponent comp in QueueableUnits)
             {
                 if (components.Contains(comp))
                 {
                     components.Remove(comp);
                 }
             }
             QueueableUnits.Clear();
             foreach (IQueueable <TextureValue> queueable in ((Building)tile).trainingQueue)
             {
                 float width = ContentHandler.DrawnTexture(queueable.Icon).Bounds.Size.X;
                 x += 16 + 1;
                 QueueableUnits.Add(new ImageBox(queueable.Icon, new Vector2(x, 433), ContentHandler.DrawnTexture(queueable.Icon).Bounds.Size, Color.White));
                 float scale = width / 16;
                 ((Component)QueueableUnits[QueueableUnits.Count - 1]).Scale = 1f / scale;
                 components.Add(QueueableUnits[QueueableUnits.Count - 1]);
             }
             prevCount = ((Building)tile).trainingQueue.Count;
         }
     }
     for (int i = 0; i < components.Count; i++)
     {
         if (components[i] is StatComponent)
         {
             StatComponent component = (StatComponent)components[i];
             string        display   = component.component.Text;
             if (tile.stats[component.statType] is Health)
             {
                 if (prevHealth != tile.CurrentHealth)
                 {
                     display = $"{tile.CurrentHealth}/{tile.TotalHealth}";
                 }
             }
             else if (tile.stats[component.statType].Value + tile.TeamStats[component.statType].Value != component.value)
             {
                 display = tile.stats[component.statType].Value.ToString();
                 if (tile.TeamStats[component.statType] != null)
                 {
                     display += $"({tile.TeamStats[component.statType].Value})";
                 }
                 component.value = tile.stats[component.statType].Value + tile.TeamStats[component.statType].Value;
             }
             component.component.Text = display;
         }
     }
     base.Update(gameTime);
 }
Esempio n. 4
0
    void Start()
    {
        if (damageType == DamageType.Enemy)
        {
            EnemyStats = GetComponent <StatComponent>();
        }

        if (trapType == TrapType.Rotating)
        {
            foreach (Transform child in transform.parent.transform)
            {
                conjoinedTraps.Add(child.GetComponent <DamageComponent>());
            }
        }
    }
Esempio n. 5
0
    private void PerformDamage(Collider2D collision)
    {
        if (Spawner != null)
        {
            if (Spawner == collision.gameObject)
            {
                return;
            }
        }

        if (collision.gameObject.tag == "Player" || collision.gameObject.tag == "Enemies")
        {
            StatComponent hitStat = collision.gameObject.GetComponent <StatComponent>();
            if (!hitStat.CanBeDealtDamage)
            {
                return;
            }

            switch (damageType)
            {
            case DamageType.Null:
                break;

            case DamageType.Enemy:
                if (collision.transform.position.y - 1f < transform.position.y)
                {
                    hitStat.ModifyHealthBy(-EnemyStats.damage, 1f);
                }
                else
                {
                    EnemyStats.ModifyHealthBy(-hitStat.damage, 1f);
                }
                break;

            case DamageType.Trap:
                hitStat.ModifyHealthBy(-trapDamage, 1f);
                break;

            case DamageType.Projectile:
                hitStat.ModifyHealthBy(-trapDamage, 0.1f);
                StopCoroutine(GetComponent <projectile>().DestroySelf(0f));
                StartCoroutine(GetComponent <projectile>().DestroySelf(0.1f));
                break;

            default:
                break;
            }

            if (trapType != TrapType.Rotating)
            {
                TempDisable();
            }
            else
            {
                foreach (DamageComponent dc in conjoinedTraps)
                {
                    dc.TempDisable();
                }
            }
            StartCoroutine(LaunchPlayer(hitStat.gameObject.GetComponent <Rigidbody2D>()));
        }
    }
Esempio n. 6
0
        private void SelectedUnitDisplay(ModifiableTile tile)
        {
            if (EntityDetails != null)
            {
                overlay.RemoveComponent(EntityDetails);
            }
            EntityDetails = new UpdatePanel(tile, Game, new Rectangle(new Point(217, 359), new Point(336, 121)), this);//TODO this will need to be more automatic if I add different resolutions/screen sizes
            EntityDetails.Initialize();
            Component com = new ImageBox(tile.block.texture, new Vector2(227, 359), (tile.Size * 16).ToPoint(), Color.White);

            com.Scale = 2 / (tile.Size.X);
            if (tile is Building)
            {
                com       = new ImageBox(((Building)tile).Icon, new Vector2(227, 359), (tile.Size * 16).ToPoint(), Color.White);
                com.Scale = 0.25f;
            }
            EntityDetails.AddComponent(com);
            float y = 359;

            for (int i = 0; i < tile.stats.Count; i++)
            {
                if (tile.stats[i] is Health)
                {
                    com       = new ImageBoxHealth(tile.healthBar.Health, new Vector2(227, 359 + 32), new Point((int)com.Scale, 1), Color.White, tile);
                    com.Scale = 2;
                    EntityDetails.AddComponent(com);
                    if (tile.TeamStats != null)
                    {
                        com = new StatComponent(new Label(new Vector2(224, 359 + 46), $"{tile.CurrentHealth}/{tile.TotalHealth}", Color.White), tile.stats[typeof(Health)].GetType(), tile.stats[typeof(Health)].Value + tile.stats[typeof(Health)].Value);
                    }
                    else
                    {
                        com = new StatComponent(new Label(new Vector2(224, 359 + 46), $"{tile.CurrentHealth}/{tile.TotalHealth}", Color.White), tile.stats[typeof(Health)].GetType(), tile.stats[typeof(Health)].Value);
                    }
                }
                else
                {
                    com       = new ImageBox(tile.stats[i].Texture, new Vector2(300, y - 8), new Point(16), Color.White);
                    com.Scale = 0.25f;
                    EntityDetails.AddComponent(com);
                    string display = tile.stats[i].Value.ToString();
                    if (tile is BasicUnit)
                    {
                        Stat stat = null;
                        if (((BasicUnit)tile).teamStats != null)
                        {
                            stat = ((BasicUnit)tile).teamStats[tile.stats[i].GetType()];
                        }
                        if (stat != null)
                        {
                            display += $" ({stat.Value.ToString()})";
                        }
                    }
                    if (tile.TeamStats != null)
                    {
                        com = new StatComponent(new Label(new Vector2(330, y - 8), display, Color.White), tile.stats[i].GetType(), tile.stats[i].Value + tile.TeamStats[i].Value);
                    }
                    else
                    {
                        com = new StatComponent(new Label(new Vector2(330, y - 8), display, Color.White), tile.stats[i].GetType(), tile.stats[i].Value);
                    }
                    com.Scale = 1;
                }
                com.drawComponent = true;
                EntityDetails.AddComponent(com);
                y += 12 + 5;
            }
            overlay.AddComponent(EntityDetails);
        }
Esempio n. 7
0
 void Start()
 {
     this.statComponent   = gameObject.GetComponent <StatComponent>();
     this.playerRigidBody = gameObject.GetComponent <Rigidbody2D>();
     this.vialAmount      = statComponent.baseVialAmount;
 }
 void Awake()
 {
     myStats = GetComponent <StatComponent>();
 }
Esempio n. 9
0
        public Form1()
        {
            Model = new Model();
            InitializeComponent();

            Groups();

            imageResource = new ImageResource(this.imageList1)
            {
                Resource = "UI/Icons/"
            };
            imageResource.ImageSizeChange(Settings.Default.IconSize);
            largeImageResource = new ImageResource(this.imageList2)
            {
                Resource = "UI/Images/"
            };
            largeImageResource.Load(largeImageResource.Resource);

            contextMenu = new ContextMenuComponent(metroContextMenu1)
            {
                GetStatistic = (x) => Model.Hero.Statistic(x)
            };

            playerPick = new PlayerPickInfo(playerpickButton)
            {
                GetImage  = imageResource.Bitmap,
                GetHeroId = (x) => Model.Hero.Select(x).Item[0].Id
            };

            forecastResultComponent = new ForecastResultComponent(metroListView1, btn_forecast)
            {
                Compute        = Model.ForecastService.Select(x => x).ToList(),
                GetHeroes      = () => Model.Hero,
                GetPlayersPick = playerPick.GetPlayerPics,
                MatchupWith    = Model.Statistic.MatchUp.With,
                MatchupAgainst = Model.Statistic.MatchUp.Against
            };

            filterTab = new FilterTab(cont_Filter, btn_FilterVisibleChange);
            filterTab.Collapse();

            statfilterTab = new FilterTab(splitContainer2, bunifuTileButton1);
            statfilterTab.Collapse();

            heroFilter     = new HeroFilter(groupCheckBox, subgroupCheckBox, franchiseCheckBox, metroTextBox9);
            heroStatFilter = new HeroFilter(groupStatCheckBox, subgroupStatCheckBox,
                                            franchiseStatCheckBox, metroTextBox1);

            heroPicker = new HeroPicker(listView1)
            {
                GetImageId = imageResource.Index,
                GetHeroes  = () => Model.Hero
            };

            heroSelector = new HeroSelector(listView2)
            {
                GetImageId         = imageResource.Index,
                GetHeroes          = () => Model.Hero,
                GetFranchiseFilter = heroFilter.GetFranchiseFilter,
                GetGroupFilter     = heroFilter.GetGroupsFilter,
                GetSubGroupFilter  = heroFilter.GetSubGroupFilter,
                GetTextFilter      = heroFilter.GetTextFilter
            };

            heroComponent = new HeroComponent(controls)
            {
                GetImage      = imageResource.Bitmap,
                GetLargeImage = largeImageResource.Bitmap,
                GetHero       = (x) => Model.Hero.Select(x).Item[0]
            };

            renderSettings = new RenderSettings(metroComboBox1, metroTextBox15, metroCheckBox2, numericUpDown1)
            {
                GetRenderType = () => imageResource.RenderType.ToArray()
            };
            renderSettings.Init();

            styleManager = new StyleManager(controls, metroContextMenu1, metroStyleManager1, this);

            themeSelector = new ThemeSelector(metroComboBox2, metroComboBox3);

            statComponent = new StatComponent(zedGraphControl1)
            {
                Hero = x => Model.Hero.Item[x].Hero,
                HeroesAvgStatistic = () => Model.Statistic.HeroStatistic.All().Item1,
                HeroGameCount      = x => Model.Hero.Select(x).Item[0].Statistic.count,
                Image  = imageResource.Bitmap,
                Style  = () => styleManager.Style,
                Filter = () =>
                {
                    return(Model.Hero.
                           Select(heroStatFilter.GetGroupsFilter()).
                           Select(heroStatFilter.GetSubGroupFilter()).
                           Select(heroStatFilter.GetFranchiseFilter()).
                           Select(heroStatFilter.GetTextFilter()).Select(X => X.Id).ToList());
                }
            };
            statComponent.Init();

            statGraph = new StatGraph(metroComboBox4)
            {
                GetSupportHeroStatistic = () => statComponent.HeroStat
            };
            statGraph.HeroesSelectionChanged += statComponent.ComputeHeroesStat;
            statGraph.Init();

            heroSelector.SelectionChanged += contextMenu.SelectPlayer;

            heroPicker.SelectionChanged += heroComponent.Render;

            playerPick.PickChanged     += contextMenu.ChangeElement;
            contextMenu.OnPlayerPicked += playerPick.SetPick;

            heroFilter.OnGroupChanged     += heroSelector.Render;
            heroFilter.OnSubGroupChanged  += heroSelector.Render;
            heroFilter.OnFranchiseChanged += heroSelector.Render;
            heroFilter.OnTextСhanged      += heroSelector.Render;

            heroStatFilter.OnGroupChanged     += statComponent.ComputeHeroesStat;
            heroStatFilter.OnSubGroupChanged  += statComponent.ComputeHeroesStat;
            heroStatFilter.OnFranchiseChanged += statComponent.ComputeHeroesStat;
            heroStatFilter.OnTextСhanged      += statComponent.ComputeHeroesStat;

            themeSelector.OnThemeChanged += styleManager.ChangeTheme;
            themeSelector.OnStyleChanged += styleManager.ChangeStyle;

            renderSettings.OnBackgroundChanged  += styleManager.SetBackground;
            renderSettings.OnTransparentChanged += styleManager.TransparentChange;
            renderSettings.OnBackgroundChanged  += heroPicker.ChangeBackGround;
            renderSettings.OnRenderModeChanged  += heroPicker.RenderModeChange;
            renderSettings.OnImageSizeChanged   += heroPicker.ItemSizeChange;
            renderSettings.OnBackgroundChanged  += heroSelector.ChangeBackGround;
            renderSettings.OnRenderModeChanged  += heroSelector.RenderModeChange;
            renderSettings.OnImageSizeChanged   += heroSelector.ItemSizeChange;
            renderSettings.OnImageSizeChanged   += imageResource.ImageSizeChange;

            LoadToolTip();
            Render();
        }
Esempio n. 10
0
		public Enemy(StatComponent statComponent){

		}