Exemplo n.º 1
0
 public override void Touch(Movier other)
 {
     if (other != null && other is Food && !other.ground)
     {
         DoDamage(other);
     }
 }
Exemplo n.º 2
0
        public double Dist(Movier other)
        {
            if (other == null)
            {
                return(double.MaxValue);
            }
            var cx = other.x - this.x;
            var cy = other.y - this.y;

            return(Math.Sqrt(cx * cx + cy * cy));
        }
Exemplo n.º 3
0
        public void DoDamage(Movier other)
        {
            if (other == null)
            {
                return;
            }
            var dmg = Math.Min(other.hp, this.damage);

            this.hp  += dmg;
            other.hp -= dmg;
        }
Exemplo n.º 4
0
        void AquariumObjectWhantToSpawn(Movier obj)
        {
            if (obj == null)
            {
                return;
            }
            var child = obj.CreateChild();

            if (child == null)
            {
                return;
            }
            objects.AddRange(child);
        }
Exemplo n.º 5
0
        protected (double dx, double dy) Shift(Movier other, double shift)
        {
            if (other == null)
            {
                return(0, 0);
            }
            var dist = Dist(other);

            if (dist < 0.00001)
            {
                return(0, 0);
            }
            var cx = other.x - this.x;
            var cy = other.y - this.y;

            shift = Math.Min(shift, dist);
            return(shift * cx / dist, shift *cy / dist);
        }
Exemplo n.º 6
0
        public override (double dx, double dy) GetNextMove(IEnumerable <Movier> others)
        {
            //var enemy = Nearest(others, obj => obj is BadFish && Dist(obj) < EYE_RANGE);
            //if (enemy == null)
            //    return Shift(enemy, -speed);

            var target = Nearest(others, obj => obj is Food && !obj.ground && Dist(obj) < EYE_RANGE);

            if (target == null)
            {
                target = new Movier()
                {
                    x = this.x + targetx, y = this.y + targety
                }
            }
            ;
            return(Shift(target, speed));
        }
Exemplo n.º 7
0
 public virtual void Touch(Movier other)
 {
 }