Beispiel #1
0
        public List <Vector> Evaluate(CosmicShip myShip, Ship ship, CosmicMap map)
        {
            if (ship.WeaponProductionStatus < 1)
            {
                return(new List <Vector>());
            }

            float shotRadius = ship.WeaponShot.Speed.Limit * ship.WeaponShot.Time.Limit;

            targetUnits.Clear();

            // Looking for enemies in range
            List <CosmicUnit> unitsInRange = map.Query(myShip.Position.X - shotRadius, myShip.Position.Y - shotRadius, myShip.Position.X + shotRadius, myShip.Position.Y + shotRadius);
            List <Vector>     shotOptions  = new List <Vector>();

            foreach (CosmicUnit unit in unitsInRange)
            {
                if (!(unit is CosmicShip) && !(unit is CosmicMissionTarget && unit.Team.Name == myShip.Team.Name))
                {
                    ;                                                                                               //uncomment while playing
                }
                continue;

                targetUnits.Add(unit);

                if ((unit.Position - myShip.Position).Length <= shotRadius + unit.Radius)
                {
                    shotOptions.Add(new Vector(unit.Position));
                    Console.WriteLine("in range: " + unit.Name + " with move vector: " + unit.MoveVector);
                }
            }

            return(shotOptions);
        }
Beispiel #2
0
        public Routing(Vector destination, CosmicMap map, CosmicOwnership routingShip)
        {
            directionList = new List <Vector>();
            closedList    = new List <RoutingPoint>();
            openList      = new List <RoutingPoint>();
            this.map      = map;


            ownShip          = routingShip;
            unitLength       = routingShip.Radius * 4;
            ownShip          = routingShip;
            minimumDistance  = routingShip.Radius * 4;
            destinationPoint = new RoutingPoint(destination, null, routingShip, 0);

            Vector rightVector = new Vector(1, 0);

            rightVector.Length = unitLength;
            directionList.Add(rightVector);

            Vector righttopVector = new Vector(1, 1);

            righttopVector.Length = unitLength * (float)Math.Sqrt(2);
            directionList.Add(righttopVector);

            Vector rightdownVector = new Vector(1, -1);

            rightdownVector.Length = unitLength * (float)Math.Sqrt(2);
            directionList.Add(rightdownVector);

            Vector leftVector = new Vector(-1, 0);

            leftVector.Length = unitLength;
            directionList.Add(leftVector);

            Vector lefttopVector = new Vector(-1, 1);

            lefttopVector.Length = unitLength * (float)Math.Sqrt(2);
            directionList.Add(lefttopVector);

            Vector leftdownVector = new Vector(-1, -1);

            leftdownVector.Length = unitLength * (float)Math.Sqrt(2);
            directionList.Add(leftdownVector);

            Vector topVector = new Vector(0, 1);

            topVector.Length = unitLength;
            directionList.Add(topVector);

            Vector downVector = new Vector(0, -1);

            downVector.Length = unitLength;
            directionList.Add(downVector);

            openList.Add(new RoutingPoint(routingShip.Position, null, routingShip, 0));
            openList.Sort();
        }