示例#1
0
    void Start()
    {
        allpoints = GameObject.Find("PointsController").GetComponent <AllPoints>();
        if (allpoints == null)
        {
            Debug.Log("The game object -PointsController- not find in scene");
        }

        moneyCollect = GameObject.Find("PointsController").GetComponent <MoneyCollect>();
        if (moneyCollect == null)
        {
            Debug.Log("The game object -PointsController- not find in scene");
        }

        pointsCollect = GameObject.Find("PointsController").GetComponent <PointsCollect>();
        if (pointsCollect == null)
        {
            Debug.Log("The game object -PointsController- not find in scene");
        }

        nightController = GetComponent <NightController>();

        storageTime    = Time.time + waitTime;
        storageTimeDay = Time.time + dayChange;
    }
示例#2
0
 private async Task _setCovMatrix()
 {
     //var tasks = new List<Task>();
     //object lc = new object();
     _covMatrix = new double[AllPoints.Count][];
     for (int i = 0; i < Dimension; i++)
     {
         _covMatrix[i] = new double[AllPoints.Count];
         for (int j = 0; j < Dimension; j++)
         {
             //tasks.Add(Task.Run(() =>
             //{
             double val = -1;
             for (int k = 0; k < AllPoints.Count; k++)
             {
                 var avI = AllPoints.Average(el => el.Characters[i]);
                 var avJ = AllPoints.Average(el => el.Characters[j]);
                 val += (AllPoints[k].Characters[i] - avI) * (AllPoints[k].Characters[j] - avJ);
             }
             //lock (lc)
             //{
             _covMatrix[i][j] = (double)val / (AllPoints.Count - 1);
             //}
             //}));
         }
     }
     //await Task.WhenAll(tasks);
 }
示例#3
0
 void Start()
 {
     allPoints    = GetComponent <AllPoints>();
     finishGame   = GetComponent <FinishGame>();
     vibration    = GetComponent <Vibration>();
     levelManager = GameObject.Find("LevelManager").GetComponent <LevelManager>();
     if (levelManager == null)
     {
         Debug.Log("The game object -LevelManager- not find in scene");
     }
     timeController = GameObject.Find("TimeController").GetComponent <TimeController>();
     if (timeController == null)
     {
         Debug.Log("The game object -TimeController- not find in scene");
     }
     moneyCollect = GetComponent <MoneyCollect>();
     if (moneyCollect == null)
     {
         Debug.Log("The game object -PointsController- not find in scene");
     }
     alertButton = GameObject.Find("LevelManager").GetComponent <AlertButton>();
     if (alertButton == null)
     {
         Debug.Log("The object -LevelManager- Dont find in scene");
     }
     finishAnimation = GameObject.Find("LevelManager").GetComponent <FinishAnimationController>();
 }
示例#4
0
        public override void Build()
        {
            AllPoints.Clear();
            if (closedCurve)
            {
                Close();
            }
            CaculateSpline();

            var totalSudivisions = Nodes.Count * TOTAL_SUBDIVISIONS_PER_NODE;

            PathLength = 0.0f;
            float timePerSlice = 1.0f / totalSudivisions;

            SegmentTimeForDistance.Clear();
            var lastPoint = GetPosition(0.0f);

            for (var i = 1; i < totalSudivisions + 1; i++)
            {
                float currentTime  = timePerSlice * i;
                var   currentPoint = GetPosition(currentTime);
                PathLength += Vector3.Distance(currentPoint, lastPoint);
                lastPoint   = currentPoint;
                SegmentTimeForDistance.Add(currentTime, PathLength);
            }
        }
示例#5
0
        /// <summary>
        /// Remove all points corresponding to the argument date. Do nothing if there are no appearances for the date.
        /// </summary>
        /// </summary>
        /// <param name="date">date to remove.</param>
        public void RemovePoints(DateType date)
        {
            if (this.AllPoints.Exists(dateCheck => dateCheck.Date == date))
            {
                this.AllPoints.Remove(AllPoints.Find(dateCheck => dateCheck.Date == date));
            }

            this.ModelUpdateEvent?.Invoke(this, EventArgs.Empty);
        }
示例#6
0
        /// <summary>
        /// Remove all points corresponding to the argument date. Do nothing if there are no appearances for the date.
        /// </summary>
        /// </summary>
        /// <param name="date">date to remove.</param>
        public void RemovePoints(DateType date)
        {
            if (AllPoints.Exists(dateCheck => dateCheck.Date == date))
            {
                AllPoints.Remove(AllPoints.Find(dateCheck => dateCheck.Date == date));
            }

            this.PositionPoints = this.CalculatePositionPoints();
        }
示例#7
0
        private void DrawPoints(IWorkbook Doc)
        {
            AllPoints.Clear();
            int    errcount = 0;
            ISheet Sheet    = Doc.GetSheetAt(0);

            for (int i = 1; i < Sheet.PhysicalNumberOfRows; i++)
            {
                if (Sheet.GetRow(i) != null)
                {
                    try
                    {
                        IRow      Row       = Sheet.GetRow(i);
                        string    name      = Row.GetCell(0).ToString();
                        string    badsymbol = @"'";
                        double    X         = Convert.ToDouble(Row.GetCell(1).ToString().Replace('.', ',').Replace(badsymbol, "").Replace(" ", ""));
                        double    Y         = Convert.ToDouble(Row.GetCell(2).ToString().Replace('.', ',').Replace(badsymbol, "").Replace(" ", ""));
                        double    Z         = Convert.ToDouble(Row.GetCell(3).ToString().Replace('.', ',').Replace(badsymbol, "").Replace(" ", ""));
                        NodePoint iNode     = new NodePoint(name, X, Y, Z, null);
                        AllPoints.Add(iNode);
                    }
                    catch
                    {
                        errcount++;
                    }
                }
            }
            ////
            CATIA = (INFITF.Application)Marshal.GetActiveObject("Catia.Application");
            var partDoc = CATIA.ActiveDocument as PartDocument;

            if (partDoc != null)
            {
                var Part    = partDoc.Part;
                var HBodies = Part.HybridBodies;
                var HBody   = HBodies.Add();
                HBody.set_Name("Import Points_" + AllPoints.Count.ToString());
                Part.Update();
                var ShapeFactory = Part.HybridShapeFactory as HybridShapeFactory;
                foreach (NodePoint iNode in AllPoints)
                {
                    var Point = ShapeFactory.AddNewPointCoord(iNode.X, iNode.Y, iNode.Z);
                    Point.set_Name(iNode.Name);
                    iNode.link = Point as HybridShapeTypeLib.Point;
                    HBody.AppendHybridShape(Point);
                }
                Part.Update();
            }
            else
            {
                throw new InvalidOperationException("Документ не найден.Проставление точек невозможно при работе с CATProduct.Откройте нужную деталь(CATPart) отдельно.");
            }
        }
示例#8
0
    void Start()
    {
        allPoints = GetComponent <AllPoints>();

        technologyItens  = GameObject.Find("ItensBuyManager").GetComponent <TechnologyItens>();
        scienceItens     = GameObject.Find("ItensBuyManager").GetComponent <ScienceItens>();
        armyItens        = GameObject.Find("ItensBuyManager").GetComponent <ArmyItens>();
        populationsItens = GameObject.Find("ItensBuyManager").GetComponent <PopulationsItens>();
        energyItens      = GameObject.Find("ItensBuyManager").GetComponent <EnergyItens>();
        foodItens        = GameObject.Find("ItensBuyManager").GetComponent <FoodItens>();
        natureItens      = GameObject.Find("ItensBuyManager").GetComponent <NatureItens>();
        waterItens       = GameObject.Find("ItensBuyManager").GetComponent <WaterItens>();
    }
示例#9
0
        private static Target GetTownHallPoints(this TownHall th)
        {
            Target target = new Target();

            target.Center = th.Location.GetCenter(); //Center of the Town Hall that was found.
            target.Edge   = Origin.PointOnLineAwayFromEnd(target.Center, _townHallCenterToOuterEdgeDistance);

            target.NearestRedLine = AllPoints.OrderBy(p => p.DistanceSq(target.Edge)).First();
            target.EdgeToRedline  = target.Edge.DistanceSq(target.NearestRedLine);
            target.TargetBuilding = th;

            return(target);
        }
示例#10
0
        private static bool IsPointOutsideRedline(this PointFT start)
        {
            var nearestRedLine = AllPoints.OrderBy(p => p.DistanceSq(start)).First();
            var distance       = start.DistanceSq(nearestRedLine);

            if (distance == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public override Vector3 GetPosition(float time)
        {
            if (AllPoints != null && AllPoints.ContainsKey(time))
            {
                return(AllPoints[time]);
            }

            int     numSections = Nodes.Count - 1;
            int     currentNode = Mathf.Min(Mathf.FloorToInt(time * (float)numSections), numSections - 1);
            float   u           = time * (float)numSections - (float)currentNode;
            Vector3 point       = GetHermitNode(currentNode + 1, u);

            AllPoints.Add(time, point);
            return(point);
        }
示例#12
0
    void Start()
    {
        allPoints = GameObject.Find("PointsController").GetComponent <AllPoints>();
        firstBuy  = GameObject.Find("UpdateWorld").GetComponent <FirstBuy>();
        infoShop  = GetComponent <InfoShopPageController>();

        technology = GameObject.Find("ItensBuyManager").GetComponent <TechnologyItens>();
        science    = GameObject.Find("ItensBuyManager").GetComponent <ScienceItens>();
        army       = GameObject.Find("ItensBuyManager").GetComponent <ArmyItens>();
        food       = GameObject.Find("ItensBuyManager").GetComponent <FoodItens>();
        water      = GameObject.Find("ItensBuyManager").GetComponent <WaterItens>();
        population = GameObject.Find("ItensBuyManager").GetComponent <PopulationsItens>();
        nature     = GameObject.Find("ItensBuyManager").GetComponent <NatureItens>();
        energy     = GameObject.Find("ItensBuyManager").GetComponent <EnergyItens>();
    }
示例#13
0
        public override Vector3 GetPosition(float time)
        {
            if (time == 0)
            {
                return(Nodes[0].Position);
            }
            if (AllPoints != null && AllPoints.ContainsKey(time))
            {
                return(AllPoints[time]);
            }
            Vector3 output = cubicSplineInterpolation(time);

            AllPoints.Add(time, output);
            return(output);
        }
示例#14
0
        public static PointFT[] GetFunnelingPoints(this Target mainGroupDeployPoint, double angleOfFunnel)
        {
            //Get the Distance From the Origin to the Center - main deploy point.
            var distance = Math.Sqrt((Math.Pow(mainGroupDeployPoint.DeployGrunts.X - 0, 2) + Math.Pow(mainGroupDeployPoint.DeployGrunts.Y - 0, 2)));

            Log.Debug($"[Berts Algorithms] Distance {distance.ToString("F1")}");

            Log.Debug($"[Berts Algorithms] Main     ({mainGroupDeployPoint.DeployGrunts.X.ToString("F1")},{mainGroupDeployPoint.DeployGrunts.Y.ToString("F1")})");

            //Determine the angle of the main deploy point from the X-axis.
            double ang1 = Math.Atan(mainGroupDeployPoint.DeployGrunts.Y / mainGroupDeployPoint.DeployGrunts.X);

            //Determine the Angles of the funnel points from the X-axis, by adding/subtracting half of the desired angle of the funnel.
            var ang2 = ang1 + (angleOfFunnel / 2);
            var ang3 = ang1 - (angleOfFunnel / 2);

            Log.Debug($"[Berts Algorithms] Funneling Points - Angles from X:{mainGroupDeployPoint.DeployGrunts.X} Main:{ang1} Funnel1:{ang2} Funnel2:{ang3}");

            //Determine the Funnel Points
            PointFT funnel1;
            PointFT funnel2;

            if (mainGroupDeployPoint.DeployGrunts.X > 0)
            {
                funnel1 = SafePoint(-(float)(distance * Math.Cos(ang2)), -(float)(distance * Math.Sin(ang2)));
                funnel2 = SafePoint(-(float)(distance * Math.Cos(ang3)), -(float)(distance * Math.Sin(ang3)));
            }
            else
            {
                funnel1 = SafePoint((float)(distance * Math.Cos(ang2)), (float)(distance * Math.Sin(ang2)));
                funnel2 = SafePoint((float)(distance * Math.Cos(ang3)), (float)(distance * Math.Sin(ang3)));
            }

            Log.Debug($"[Berts Algorithms] Point1   ({funnel1.X.ToString("F1")},{funnel1.Y.ToString("F1")})");
            Log.Debug($"[Berts Algorithms] Point2   ({funnel2.X.ToString("F1")},{funnel2.Y.ToString("F1")})");

            //Find the closest Redline points to these two funnel points.
            var red1 = AllPoints.OrderBy(p => p.DistanceSq(funnel1)).First();
            var red2 = AllPoints.OrderBy(p => p.DistanceSq(funnel2)).First();

            //Return the two points
            List <PointFT> points = new List <PointFT>();

            points.Add(red1);
            points.Add(red2);

            return(points.ToArray());
        }
示例#15
0
        public override Vector3 GetPosition(float time)
        {
            if (AllPoints != null && AllPoints.ContainsKey(time))
            {
                return(AllPoints[time]);
            }

            int     N     = Nodes.Count - 1;
            Vector3 point = deCasteljauBezier(N, 0, time);

            AllPoints.Add(time, point);
            return(point);

            // float d = 1f - time;
            //return d * d * d * Nodes[0].Position + 3f * d * d * time * Nodes[1].Position + 3f * d * time * time * Nodes[2].Position + time * time * time * Nodes[3].Position;
        }
示例#16
0
 private void Start()
 {
     allPoints = GameObject.Find("PointsController").GetComponent <AllPoints>();
     if (allPoints == null)
     {
         Debug.Log("The script energy dont fint the Game Object 'PointsController'");
     }
     moneyCollect = GameObject.Find("PointsController").GetComponent <MoneyCollect>();
     if (moneyCollect == null)
     {
         Debug.Log("The script energy dont fint the Game Object 'PointsController'");
     }
     requirement = GameObject.Find("ItensRequirementManager").GetComponent <EnergyRequirement>();
     if (requirement == null)
     {
         Debug.Log("The script energy dont find the Game Object 'ItensRequirementManager'");
     }
     musicController = GameObject.Find("LevelManager").GetComponent <MusicController>();
     SetCompanyValue = CompanyValue;
 }
示例#17
0
    void Start()
    {
        //Debug.Log(PlayerPrefs.GetFloat("Difficult"));
        allPoints      = GetComponent <AllPoints>();
        randonDestroy  = GetComponent <RandonDestroy>();
        removePoints   = GetComponent <RemovePointsController>();
        timeController = GameObject.Find("TimeController").GetComponent <TimeController>();
        if (timeController == null)
        {
            Debug.Log("The object 'TimeController' not find in scene");
        }

        worldController = GameObject.Find("LevelManager").GetComponent <WorldController>();
        if (worldController == null)
        {
            Debug.Log("The object 'LevelManager' not find in scene");
        }

        technology = GameObject.Find("ItensBuyManager").GetComponent <TechnologyItens>();
        science    = GameObject.Find("ItensBuyManager").GetComponent <ScienceItens>();
        army       = GameObject.Find("ItensBuyManager").GetComponent <ArmyItens>();
        food       = GameObject.Find("ItensBuyManager").GetComponent <FoodItens>();
        water      = GameObject.Find("ItensBuyManager").GetComponent <WaterItens>();
        population = GameObject.Find("ItensBuyManager").GetComponent <PopulationsItens>();
        nature     = GameObject.Find("ItensBuyManager").GetComponent <NatureItens>();
        energy     = GameObject.Find("ItensBuyManager").GetComponent <EnergyItens>();

        if (PlayerPrefs.GetInt("NewGame") == 1)
        {
            randonDestroy.LotteryNumbers();
            SavePrefabs("Save");
            DeleteData();
            ResetData();
            SavePrefabs("Load");
            SaveData();
        }
        else
        {
            LoadData();
        }
    }
示例#18
0
        private void Form1_Load(object sender, EventArgs e)
        {
            comboBox1.DisplayMember         = "Name";
            comboBox1.DataSource            = Helpers.HelpUrls.AllHelps;
            comboBox1.SelectedIndex         = 0;
            comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
            APIHelper.RegisterHotKey(Handle, 100, APIHelper.KeyModifiers.Alt, Keys.S);

            AllMaps.Init_AllMaps();
            comb_map.Items.Clear();
            comb_map.DisplayMember = "NameDetail";
            comb_map.ValueMember   = "Key";
            var dt = AllMaps.Data.Select(x => x.Value);

            comb_map.DataSource    = dt.ToArray();
            comb_map.SelectedIndex = 0;

            AllPlaces.Init_Place();
            AllPoints.Init_Points();

            button7_Click(null, null);
        }
示例#19
0
        public static Target TargetDarkElixirStorage(CacheBehavior behavior = CacheBehavior.Default)
        {
            var target = new Target();

            var des = DarkElixirStorage.Find(behavior);

            target.ValidTarget = false;

            if (des.Length > 0)
            {
                target.ValidTarget    = true;
                target.TargetBuilding = des[0];
                target.Center         = des[0].Location.GetCenter();

                target.Edge           = Origin.PointOnLineAwayFromEnd(target.Center, _DEStorageCenterToOuterEdgeDistance);
                target.NearestRedLine = AllPoints.OrderBy(p => p.DistanceSq(target.Edge)).First();
                target.EdgeToRedline  = target.Edge.DistanceSq(target.NearestRedLine);

                //Fill the DeployGrunts Property with where out main dragon force should go.
                target.DeployGrunts = Origin.PointOnLineAwayFromEnd(target.NearestRedLine, 0.2f); //TODO Move to Constants..
            }

            return(target);
        }
示例#20
0
 public override int GetHashCode()
 {
     return(AllPoints.GetHashCode());
 }
示例#21
0
        public static Target[] GenerateTargets(string algorithmName, float minimumDistance, bool ignoreGold, bool ignoreElixir, string AttackId, out double avgFillstate, out double avgCollectorLvl, CacheBehavior behavior = CacheBehavior.Default, bool outputDebugImage = false, bool activeBase = false)
        {
            // Find all Collectors & storages just sitting around...
            List <Building> buildings = new List <Building>();

            //Get a list of Gold Mines.
            List <GoldMine> goldMines = new List <GoldMine>();

            goldMines.AddRange(GoldMine.Find(behavior));

            //Get a list of Elixir Collectors.
            List <ElixirCollector> elixirCollectors = new List <ElixirCollector>();

            elixirCollectors.AddRange(ElixirCollector.Find(behavior));
            avgFillstate = 0;

            //Get the Average Fill State of all the Elixir Collectors - From this we can tell what percentage of the loot is in Collectors.
            if (elixirCollectors.Count > 1)
            {
                avgFillstate = elixirCollectors.Average(c => c.FillState);
            }

            //Log the Average Fill State of aLL elixir Collectors...
            Log.Debug($"[Berts Algorithms] - Fill State Average of ALL Elixir Collectors: {(avgFillstate * 10).ToString("F1")}");

            if (!ignoreGold)
            {
                buildings.AddRange(goldMines);
                if (activeBase)
                {
                    buildings.AddRange(GoldStorage.Find(behavior));
                }
            }
            if (!ignoreElixir)
            {
                buildings.AddRange(elixirCollectors);
                if (activeBase)
                {
                    buildings.AddRange(ElixirStorage.Find(behavior));
                }
            }

            //Determine the Average Collector Level.
            avgCollectorLvl = 0;

            if (ignoreGold && !ignoreElixir)
            {
                if (elixirCollectors.Count(c => c.Level.HasValue) > 1)
                {
                    avgCollectorLvl = elixirCollectors.Where(c => c.Level.HasValue).Average(c => (int)c.Level);
                }
            }
            else if (ignoreElixir && !ignoreGold)
            {
                if (goldMines.Count(c => c.Level.HasValue) > 1)
                {
                    avgCollectorLvl = goldMines.Where(c => c.Level.HasValue).Average(c => (int)c.Level);
                }
            }
            else if (!ignoreElixir && !ignoreGold)
            {
                if (buildings.Count(c => c.Level.HasValue) > 1)
                {
                    avgCollectorLvl = buildings.Where(c => c.Level.HasValue).Average(c => (int)c.Level);
                }
            }

            //We always includ DarkElixir - Because who doesnt love dark Elixir?
            buildings.AddRange(DarkElixirDrill.Find(behavior));
            if (activeBase)
            {
                buildings.AddRange(DarkElixirStorage.Find(behavior));
            }

            List <Target> targetList = new List <Target>();

            foreach (Building building in buildings)
            {
                Target current = new Target();

                current.TargetBuilding  = building;
                current.Center          = building.Location.GetCenter();
                current.Edge            = Origin.PointOnLineAwayFromEnd(current.Center, 1.0f);
                current.NearestRedLine  = AllPoints.OrderBy(p => p.DistanceSq(current.Edge)).First();
                current.CenterToRedline = current.Center.DistanceSq(current.NearestRedLine);
                if (current.CenterToRedline < minimumDistance)  //Compare distance to Redline to the Minimum acceptable distance Passed in
                {
                    Log.Debug($"[Berts Algorithms] Distance from {current.Name} to red point: {Math.Sqrt(current.CenterToRedline).ToString("F1")}, Min Distance: {Math.Sqrt(minimumDistance).ToString("F1")} - GO!");
                    current.DeployGrunts = current.Center.PointOnLineAwayFromEnd(current.NearestRedLine, _gruntDeployDistanceFromRedline);  //Barbs & Goblins
                    current.DeployRanged = current.Center.PointOnLineAwayFromEnd(current.NearestRedLine, _rangedDeployDistanceFromRedline); //Archers & Minions

                    targetList.Add(current);
                }
                else
                {
                    Log.Debug($"[Berts Algorithms] Distance from {current.Name} to red point: {Math.Sqrt(current.CenterToRedline).ToString("F1")}, Min Distance: {Math.Sqrt(minimumDistance).ToString("F1")} - TOO FAR!");
                }
            }

            if (outputDebugImage)
            {
                OutputDebugImage(algorithmName, buildings, targetList, AttackId);
            }

            return(targetList.ToArray());
        }
示例#22
0
 void Start()
 {
     allPoints       = GameObject.Find("PointsController").GetComponent <AllPoints>();
     nightController = GameObject.Find("TimeController").GetComponent <NightController>();
 }
示例#23
0
 void Start()
 {
     science   = GameObject.Find("ItensBuyManager").GetComponent <ScienceItens>();
     allPoints = GameObject.Find("PointsController").GetComponent <AllPoints>();
 }
示例#24
0
 private void Start()
 {
     allPoints = GetComponent <AllPoints>();
 }
示例#25
0
 /// <summary>
 /// Update the points earnt for position for the indicated athlete on the indicated date.
 /// </summary>
 /// <param name="date">date of the event</param>
 /// <param name="points">earned points</param>
 public void UpdatePositionPoints(DateType date, int points)
 {
     AllPoints.Find(allPoints => allPoints.Date == date).PositionPoints = points;
     this.PositionPoints = this.CalculatePositionPoints();
 }
示例#26
0
        /// <summary>
        /// Add a new entry to represent a new event.
        /// </summary>
        /// <param name="date">Date of the event</param>
        public void AddNewEvent(CommonPoints newPoints)
        {
            AllPoints.Add(newPoints);

            this.PositionPoints = this.CalculatePositionPoints();
        }
示例#27
0
 void Start()
 {
     allPoints      = GetComponent <AllPoints>();
     timeController = GameObject.Find("TimeController").GetComponent <TimeController>();
     vibration      = GetComponent <Vibration>();
 }
示例#28
0
 void Start()
 {
     population = GameObject.Find("ItensBuyManager").GetComponent <PopulationsItens>();
     allPoints  = GameObject.Find("PointsController").GetComponent <AllPoints>();
 }
示例#29
0
 void Start()
 {
     energy    = GameObject.Find("ItensBuyManager").GetComponent <EnergyItens>();
     allPoints = GameObject.Find("PointsController").GetComponent <AllPoints>();
 }
示例#30
0
 void Start()
 {
     allPoints      = GetComponent <AllPoints>();
     timeController = GameObject.Find("TimeController").GetComponent <TimeController>();
     totalDays      = timeController.totalDays + eachDays;
 }