コード例 #1
0
        public static WaterDrop operator +(WaterDrop water1, WaterDrop water2)
        {
            var result = new WaterDrop(water1.Mass + water2.Mass)
            {
                Speed   = water1.Speed + water2.Speed,
                MudMass = water1.MudMass + water2.MudMass
            };

            return(result);
        }
コード例 #2
0
 public void AddDrop(WaterDrop drop, (int, int) p) => AddDrop(drop, new Vector(p.Item1, p.Item2));
コード例 #3
0
        private Dictionary <Vector, double> _getMoveRanks(double[,] map, Vector currentDropPosition, WaterDrop dropObj)
        {
            var moveRanks = new Dictionary <Vector, double>();

            foreach (var targetCell in _neighborsGetter(currentDropPosition))
            {
                if (!IsInMap(map, targetCell))
                {
                    continue;
                }
                var rank = GetHeight(map, currentDropPosition) - GetHeight(map, targetCell);
                if (rank < 0)
                {
                    continue;
                }
                var range = Math.Sqrt(Math.Pow(currentDropPosition.X + dropObj.Speed.X - targetCell.X, 2)
                                      + Math.Pow(currentDropPosition.Y + dropObj.Speed.Y - targetCell.Y, 2));
                var factor = range != 0 ? range : 0.00001;
                moveRanks[targetCell] = rank / factor;
            }

            return(moveRanks);
        }