Exemplo n.º 1
0
        void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            //   Arena.instance.VerticalAlignment = VerticalAlignment.Stretch;// .sca .RenderTransform = new ScaleTransform(1.5, 1.5);
            //  Arena.instance.HorizontalAlignment = HorizontalAlignment.Stretch;// .sca .RenderTransform = new ScaleTransform(1.5, 1.5);

            System.Xml.XPath.XPathDocument  GameData    = new System.Xml.XPath.XPathDocument(".\\GameData.xml");
            System.Xml.XPath.XPathNavigator GameDataNav = GameData.CreateNavigator();

            Arena.instance.BankBalance = double.Parse(GameDataNav.SelectSingleNode("/GameData/StartingCash").ToString());
            Arena.instance.Lifes       = 20;

            //GameDataNav.MoveToRoot();

            //System.Xml.XPath.XPathNodeIterator dx = GameDataNav.Select("/GameData/TowerTypes/RadiatorTowers/RadiatorTower");
            System.Xml.XPath.XPathNodeIterator dx = GameDataNav.Select("/GameData/TowerTypes/*/*/@Name");
            //"/GameData/TowerTypes/*/*/@Price"
            while (dx.MoveNext())
            {
                string      q = dx.Current.ToString();
                ListBoxItem x = new ListBoxItem();
                x.Content = q;
                System.Xml.XPath.XPathNavigator n = GameData.CreateNavigator();
                System.Xml.XPath.XPathNavigator o = n.SelectSingleNode("/GameData/TowerTypes/*/*[@Name='" + q + "']");
                TowerData PTD;
                if (o.Name == "ProjectileTower")
                {
                    PTD = new ProjectileTowerData(o);
                }
                else if (o.Name == "RadiatorTower")
                {
                    PTD = new HeatTowerData(o);
                }
                else if (o.Name == "BeamTower")
                {
                    PTD = new BeamTowerData(o);
                }
                else
                {
                    PTD = new TowerData(o);
                }
                x.Tag = PTD;
                Window1.instance.Towers.Items.Add(x);
            }
        }
Exemplo n.º 2
0
        public HeatTowerData SubClassData;// = new ProjectileTowerData();
        //   public TargetLock Target = new TargetLock();

        //    public Creep CurrentTarget;

        // public Shape Barrel;

        //  public float RefireCount = 0;

        //  static Random R = new Random();
        //   System.Windows.Media.Color ProjectileColor = Colors.Transparent;



        public new void Tick(int Frame)
        {
            if (this.SubClassData == null)
            {
                if (this.Data == null)
                {
                    return;
                }
                SubClassData = Data as HeatTowerData;
            }



            //Shape bb = LogicalTreeHelper.FindLogicalNode(VisualObject, "_Grill") as Shape;

            //Body.Fill = new System.Windows.Media.VisualBrush(this);
            //System.Windows.Media.Color bc = Color.FromScRgb(1f, (float)(Heat / Data.ShutdownHeat), 0f, 0f);
            //Body.Fill = new System.Windows.Media.SolidColorBrush(bc);

            List <Tower> HotNeighbor       = new List <Tower>();
            float        TotalNeighborHeat = 0;

            float startingheat        = this.Heat;
            float HottestNeighborHeat = 0;

            //Make of list of neighbors who's heat level is higher than self.
            foreach (EmptyCell C in this.OwningCell.Adjacent)
            {
                Tower CT = C.Occupant as Tower;

                if (CT != null)
                {
                    if (CT.Heat / CT.Data.ShutdownHeat > startingheat / Data.ShutdownHeat)
                    {
                        HotNeighbor.Add(CT);
                        TotalNeighborHeat  += (CT.Heat - startingheat);
                        HottestNeighborHeat = Math.Max(HottestNeighborHeat, CT.Heat);
                    }
                }
            }



            if (HotNeighbor.Count > 0 && TotalNeighborHeat > 1)
            {
                float RemainingHeatAbsorb = SubClassData.HeatAbsorb;

                // if self is close to overheating, don't take more heat than capacity, and never get hotter than hottest neighbor.

                float ModifiedHeatLimit = Math.Min(this.Data.ShutdownHeat, HottestNeighborHeat);

                if (RemainingHeatAbsorb + startingheat > ModifiedHeatLimit)
                {
                    RemainingHeatAbsorb = ModifiedHeatLimit - startingheat;
                }



                //ModifiedHeatAbsorb = SubClassData.HeatAbsorb / HotNeighbor.Count;


                foreach (Tower HN in HotNeighbor)
                {
                    float SplitHeatAbsorb;
                    float HeatDiff = (HN.Heat - startingheat);

                    //figure this neighors 'share' of heat absorbtion.
                    SplitHeatAbsorb = (HeatDiff / TotalNeighborHeat) * RemainingHeatAbsorb;

                    //Take no more than half the heat differance.
                    if (HeatDiff < SplitHeatAbsorb * 2)
                    {
                        //float s = (this.Heat +CT.Heat)
                        this.Heat += HeatDiff / 2;
                        HN.Heat   -= HeatDiff / 2;
                    }
                    else
                    {
                        this.Heat += SplitHeatAbsorb;
                        HN.Heat   -= SplitHeatAbsorb;
                    }
                }
            }

            //Body.Fill = new System.Windows.Media.SolidColorBrush(HeatColor(Heat, Data.ShutdownHeat));
            Body.Fill = StaticHelpers.HeatBrush(Heat, Data.ShutdownHeat);

            base.Tick(Frame);
        }
Exemplo n.º 3
0
        public HeatTowerData SubClassData;// = new ProjectileTowerData();
        //   public TargetLock Target = new TargetLock();

        //    public Creep CurrentTarget;

        // public Shape Barrel;

        //  public float RefireCount = 0;

        //  static Random R = new Random();
        //   System.Windows.Media.Color ProjectileColor = Colors.Transparent;



        public new void Tick(int Frame)
        {
            if (this.SubClassData == null)
            {
                if (this.Data == null)
                {
                    return;
                }
                SubClassData = Data as HeatTowerData;
            }

            
            

            //Shape bb = LogicalTreeHelper.FindLogicalNode(VisualObject, "_Grill") as Shape;

            //Body.Fill = new System.Windows.Media.VisualBrush(this);
            //System.Windows.Media.Color bc = Color.FromScRgb(1f, (float)(Heat / Data.ShutdownHeat), 0f, 0f);
            //Body.Fill = new System.Windows.Media.SolidColorBrush(bc);

            List<Tower> HotNeighbor = new List<Tower>();
            float TotalNeighborHeat = 0;

            float startingheat = this.Heat;
            float HottestNeighborHeat = 0;

            //Make of list of neighbors who's heat level is higher than self.
            foreach (EmptyCell C in this.OwningCell.Adjacent)
            {
                Tower CT = C.Occupant as Tower;

                if (CT != null)
                {
                    if (CT.Heat / CT.Data.ShutdownHeat > startingheat / Data.ShutdownHeat)
                    {
                        HotNeighbor.Add(CT);
                        TotalNeighborHeat += (CT.Heat - startingheat);
                        HottestNeighborHeat = Math.Max(HottestNeighborHeat, CT.Heat);
                    }
                }
            }

            
            
            if (HotNeighbor.Count > 0 && TotalNeighborHeat > 1)
            {
                float RemainingHeatAbsorb = SubClassData.HeatAbsorb;

                // if self is close to overheating, don't take more heat than capacity, and never get hotter than hottest neighbor.

                float ModifiedHeatLimit = Math.Min(this.Data.ShutdownHeat, HottestNeighborHeat);

                if (RemainingHeatAbsorb + startingheat > ModifiedHeatLimit)
                {
                    RemainingHeatAbsorb = ModifiedHeatLimit - startingheat;
                }
                

                

                //ModifiedHeatAbsorb = SubClassData.HeatAbsorb / HotNeighbor.Count;


                foreach (Tower HN in HotNeighbor)
                {
                    float SplitHeatAbsorb;
                    float HeatDiff = (HN.Heat - startingheat);

                    //figure this neighors 'share' of heat absorbtion.
                    SplitHeatAbsorb = (HeatDiff / TotalNeighborHeat) * RemainingHeatAbsorb;

                    //Take no more than half the heat differance.
                    if (HeatDiff < SplitHeatAbsorb * 2)
                    {
                        //float s = (this.Heat +CT.Heat)
                        this.Heat += HeatDiff / 2;
                        HN.Heat -= HeatDiff / 2;
                    }
                    else
                    {
                        this.Heat += SplitHeatAbsorb;
                        HN.Heat -= SplitHeatAbsorb;
                    }

                }
            }

            //Body.Fill = new System.Windows.Media.SolidColorBrush(HeatColor(Heat, Data.ShutdownHeat));
            Body.Fill = StaticHelpers.HeatBrush(Heat, Data.ShutdownHeat);

            base.Tick(Frame);
        }
Exemplo n.º 4
0
        void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            
         //   Arena.instance.VerticalAlignment = VerticalAlignment.Stretch;// .sca .RenderTransform = new ScaleTransform(1.5, 1.5);
          //  Arena.instance.HorizontalAlignment = HorizontalAlignment.Stretch;// .sca .RenderTransform = new ScaleTransform(1.5, 1.5);
            
            System.Xml.XPath.XPathDocument GameData = new System.Xml.XPath.XPathDocument(".\\GameData.xml");
            System.Xml.XPath.XPathNavigator GameDataNav = GameData.CreateNavigator();

            Arena.instance.BankBalance = double.Parse(GameDataNav.SelectSingleNode("/GameData/StartingCash").ToString());
            Arena.instance.Lifes = 20;

            //GameDataNav.MoveToRoot();

            //System.Xml.XPath.XPathNodeIterator dx = GameDataNav.Select("/GameData/TowerTypes/RadiatorTowers/RadiatorTower");
            System.Xml.XPath.XPathNodeIterator dx = GameDataNav.Select("/GameData/TowerTypes/*/*/@Name");
            //"/GameData/TowerTypes/*/*/@Price"
            while (dx.MoveNext())
            {
                string q = dx.Current.ToString();
                ListBoxItem x = new ListBoxItem();
                x.Content = q;
                System.Xml.XPath.XPathNavigator n = GameData.CreateNavigator();
                System.Xml.XPath.XPathNavigator o = n.SelectSingleNode("/GameData/TowerTypes/*/*[@Name='" + q + "']");
                TowerData PTD;
                if (o.Name == "ProjectileTower")
                {
                    PTD = new ProjectileTowerData(o);
                }
                else if (o.Name == "RadiatorTower")
                {
                    PTD = new HeatTowerData(o);
                }
                else if (o.Name == "BeamTower")
                {
                    PTD = new BeamTowerData(o);
                }
                else
                {
                    PTD = new TowerData(o);
                }
                x.Tag = PTD;
                Window1.instance.Towers.Items.Add(x);
            }
        }