private static Attack CreateAttack(Dictionary <string, object> attackProperties)
        {
            Attack attack = null;

            string          attackName = (string)attackProperties["attackName"];
            Projectile      projectile = ProjectileFactory.CreateProjectile((Dictionary <string, object>)attackProperties["projectile"]);
            MovementPattern movement   = MovementPatternFactory.CreateMovementPattern((Dictionary <string, object>)attackProperties["movementPattern"]);

            Timer cooldownToAttack = EntityGroupBuilder.CreateTimer((float)attackProperties["cooldownToAttack"]);

            cooldownToAttack.Stop();
            cooldownToAttack.AutoReset = true;

            Timer cooldownToCreateProjectile = EntityGroupBuilder.CreateTimer((float)attackProperties["cooldownToCreateProjectile"]);

            cooldownToCreateProjectile.Stop();
            cooldownToCreateProjectile.AutoReset = true;

            switch (attackName)
            {
            case "basicLinear":
                attack = new BasicLinear(projectile, movement, cooldownToAttack, cooldownToCreateProjectile);
                break;

            case "circularHoming":
                attack = new CircularHoming(projectile, (Circular)movement, cooldownToAttack, cooldownToCreateProjectile);
                break;

            case "circularTriHoming":
                attack = new CircularTriHoming(projectile, (Circular)movement, cooldownToAttack, cooldownToCreateProjectile);
                break;

            case "circle":
                int   numberOfProjectiles = Convert.ToInt32((float)attackProperties["numberOfProjectiles"]);
                float degreesToStart      = (float)attackProperties["degreesToStart"];
                float degreesToEnd        = (float)attackProperties["degreesToEnd"];
                attack = new Circle(projectile, movement, cooldownToAttack, cooldownToCreateProjectile, numberOfProjectiles, degreesToStart, degreesToEnd);
                break;

            case "arrow":
                int widthOfArrow = Convert.ToInt32((float)attackProperties["widthOfArrow"]);
                attack = new Arrow(projectile, movement, cooldownToAttack, cooldownToCreateProjectile, widthOfArrow);
                break;

            default:
                throw new Exception("Invalid Entity");
            }

            return(attack);
        }
示例#2
0
        /// <summary>
        /// Get the offset from reference in microns
        /// Apply any defined correction
        /// </summary>
        /// <param name="greyScale"></param>
        /// <param name="planarDatum"></param>
        /// <param name="max2"></param>
        /// <param name="min2"></param>
        /// <returns></returns>
        public double GetMicronOffsetFromReference(double greyScale, double greyScaleX, double greyScaleY, BasicLinear planarDatum, double max2, double min2)
        {
            double greyScaleRef = planarDatum.Evaluate(greyScaleX, greyScaleY);

            double micronOffset = ConvertGreyScaleToRawDel(greyScale - greyScaleRef, max2, min2) / CountsPerMicron;

            return(micronOffset * CorrectionSlope + CorrectionIntercept);
        }