예제 #1
0
        internal static bool TryFindShell(string shellName, out string shellPath, out ShellType shellType)
        {
            // No shell name provided
            if (string.IsNullOrEmpty(shellName))
            {
                shellPath = null;
                shellType = ShellType.None;
                return(false);
            }

            // Look for absolute path to a shell
            if (Path.IsPathRooted(shellName) &&
                s_shells.TryGetValue(Path.GetFileName(shellName), out shellType) &&
                File.Exists(shellName))
            {
                shellPath = shellName;
                return(true);
            }

            // Now assume the shell is just a command name, and confirm we recognize it
            if (!s_shells.TryGetValue(shellName, out shellType))
            {
                shellPath = null;
                return(false);
            }

            return(TryFindShellByName(shellName, out shellPath));
        }
예제 #2
0
 public void SetShellType(ShellType shellType)
 {
     if (shellType == ShellType.E)
     {
         this.comboBoxShellType.SelectedIndex = HXRatingShellAndTubeBellDelawareValuesControl.INDEX_E;
     }
     else if (shellType == ShellType.F)
     {
         this.comboBoxShellType.SelectedIndex = HXRatingShellAndTubeBellDelawareValuesControl.INDEX_F;
     }
     else if (shellType == ShellType.G)
     {
         this.comboBoxShellType.SelectedIndex = HXRatingShellAndTubeBellDelawareValuesControl.INDEX_G;
     }
     else if (shellType == ShellType.H)
     {
         this.comboBoxShellType.SelectedIndex = HXRatingShellAndTubeBellDelawareValuesControl.INDEX_H;
     }
     else if (shellType == ShellType.J)
     {
         this.comboBoxShellType.SelectedIndex = HXRatingShellAndTubeBellDelawareValuesControl.INDEX_J;
     }
     else if (shellType == ShellType.K)
     {
         this.comboBoxShellType.SelectedIndex = HXRatingShellAndTubeBellDelawareValuesControl.INDEX_K;
     }
     else if (shellType == ShellType.X)
     {
         this.comboBoxShellType.SelectedIndex = HXRatingShellAndTubeBellDelawareValuesControl.INDEX_X;
     }
 }
예제 #3
0
 public Shell(List <MWPoint3D> pts, double thickness, ShellType st, List <List <MWPoint3D> > holes = null)
 {
     Points    = pts;
     Thickness = thickness;
     Holes     = holes ?? new List <List <MWPoint3D> >();
     type      = st;
 }
        public ShellType ConvertShellType(eShellType eShellType)
        {
            ShellType shellType = new ShellType();

            switch (eShellType)
            {
            case eShellType.Membrane:
                shellType = ShellType.Membrane;
                break;

            case eShellType.ShellThick:
                shellType = ShellType.ShellThick;
                break;

            case eShellType.ShellThin:
                shellType = ShellType.ShellThin;
                break;

            case eShellType.Layered:
                shellType = ShellType.Layered;
                break;

            default:
                shellType = ShellType.Null;
                break;
            }

            return(shellType);
        }
예제 #5
0
 public Shell(long id, string playerName, double width, double height, double x, double y,
     double speedX, double speedY, double angle, double angularSpeed, ShellType type)
     : base(id, width, height, x, y, speedX, speedY, angle, angularSpeed)
 {
     this.playerName = playerName;
     this.type = type;
 }
예제 #6
0
        public static Shell CreateShell(this ShellType shellType, Vector position)
        {
            var shell = shellType.CreateShell();

            shell.Position = position;
            return(shell);
        }
예제 #7
0
        public static Shell CreateShell(this ShellType shellType, Vector position, Vector direction)
        {
            var shell = shellType.CreateShell(position);

            shell.Direction = direction;
            return(shell);
        }
예제 #8
0
 public static double ShellTicks(ShellType shellType, double distance)
 {
     return distance > 0 ? Mathematics.Newton(
             t => (MyStrategy.ShellProperties[shellType].InitialSpeed * (Math.Exp(MyStrategy.ShellProperties[shellType].SpeedPowerRatio * t) - 1)) / MyStrategy.ShellProperties[shellType].SpeedPowerRatio, // integral of speed
             t => MyStrategy.ShellProperties[shellType].InitialSpeed * Math.Exp(MyStrategy.ShellProperties[shellType].SpeedPowerRatio * t), // speed
             distance, Settings.TickApproximationEpsilon) : 0;
 }
예제 #9
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static ISurfaceProperty SetShellType(this ISurfaceProperty property, ShellType shellType)
        {
            property.Fragments.AddOrReplace(new ShellTypeFragment {
                ShellType = shellType
            });
            return(property);
        }
예제 #10
0
            public void AddType(string ns, string[] pTypes, string typeName, ShellType t)
            {
                if (string.IsNullOrEmpty(typeName))
                {
                    return;
                }
                string typeKey = GetTypeKey(ns, pTypes, pTypes.Length, typeName);

                mTypes.Remove(typeKey);
                ShellType type;

                if (mRents.TryGetValue(typeName, out type))
                {
                    mRents.Remove(typeName);
                    if (t != null && t != type)
                    {
                        type = t;
                    }
                }
                else
                {
                    if (t == null)
                    {
                        type      = new ShellType(typeName);
                        type.type = new TypeCustom(typeName);
                    }
                    else
                    {
                        type = t;
                    }
                }
                //Debug.LogError("add type : " + typeKey);
                mTypes.Add(typeKey, type);
            }
예제 #11
0
        public void ChangeShell(ShellType shell)
        {
            SpriteRenderer spr = GetComponent <SpriteRenderer> ();

            Sprite[] shellSpriteList = Game1_Leveling.GetShellList();
            switch (shell)
            {
            case ShellType.SHELL_CAN:
            {
                spr.sprite = shellSpriteList[0];
            } break;

            case ShellType.SHELL_NORMAL:
            {
                spr.sprite = shellSpriteList[1];
            } break;

            case ShellType.SHELL_TEMPLE:
            {
                spr.sprite = shellSpriteList[2];
            } break;

            case ShellType.SHELL_SPIKE:
            {
                spr.sprite = shellSpriteList[3];
            } break;

            case ShellType.SHELL_WING:
            {
                spr.sprite = shellSpriteList[4];
            } break;
            }
        }
예제 #12
0
        public static IShell Create(ShellType aShellType)
        {
            switch (aShellType)
            {
            case ShellType.LovelyDay:
            {
                return(new Shell_LovelyDay());
            }

            case ShellType.Cmd:
            {
                return(new Shell_CMD());
            }

            case ShellType.PowerShell:
            {
                return(new Shell_Powershell());
            }

            default:
            {
                return(new Shell_LovelyDay());
            }
            }
        }
예제 #13
0
        public static string ToXmlValue(this ShellType type)
        {
            switch (type)
            {
            case ShellType.HE:
                return(ShellTypeHelper.HEXmlName);

            case ShellType.PremiumHE:
                return(ShellTypeHelper.PremiumHEXmlName);

            case ShellType.HEAT:
                return(ShellTypeHelper.HEATXmlName);

            case ShellType.AP:
                return(ShellTypeHelper.APXmlName);

            case ShellType.APHE:
                return(ShellTypeHelper.APHEXmlName);

            case ShellType.APCR:
                return(ShellTypeHelper.APCRXmlName);

            default:
                throw new NotSupportedException();
            }
        }
예제 #14
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static ISurfaceProperty SetShellType(this ISurfaceProperty property, ShellType shellType)
        {
            ISurfaceProperty clone = (ISurfaceProperty)property.GetShallowClone();

            clone.CustomData["ShellType"] = shellType;

            return(clone);
        }
예제 #15
0
 protected Shell(ShellType typeOfShell, int damage, int count = 1,
                 bool limited = true)
 {
     this.TypeOfShell = typeOfShell;
     this._count      = count;
     this._limited    = limited;
     this._damage     = damage;
 }
예제 #16
0
        public IList <MenuItemViewModel> GetConfigMenuViewModel(ShellType shell)
        {
            var      menus          = GetMenuProviders(shell).SelectMany(m => m.Value.GetConfigMenuItems());
            ICommand defaultCommand = GetDefaultCommand(shell);
            IList <MenuItemViewModel> viewModels = CreateViewModel(menus, defaultCommand);

            return(viewModels);
        }
예제 #17
0
        protected override bool DeserializeSection(string name, XmlReader reader)
        {
            switch (name)
            {
            case "userString":
                reader.ReadLocalized(this.Database, out _name);
                return(true);

            case "kind":
                this.Type = this.ParseShellType(reader.ReadString());
                return(true);

            case "caliber":
                reader.Read(out _caliber);
                return(true);

            case "damage":
                reader.Read(out _damage);
                return(true);

            case "explosionRadius":
                reader.Read(out _explosionRadius);
                return(true);

            case "defaultPortion":
                reader.Read(out _defaultPortion);
                return(true);

            case "speed":
                reader.Read(out _speed);
                return(true);

            case "gravity":
                reader.Read(out _gravity);
                return(true);

            case "piercingPower":
                reader.Read(out _piercingPower);
                return(true);

            case "maxDistance":
                reader.Read(out _maxDistance);
                return(true);

            case "piercingPowerLossFactorByDistance":
                reader.Read(out _piercingPowerLossFactorByDistance);
                return(true);

            case "id":
            case "icon":
            case "isTracer":
            case "effects":
                return(false);

            default:
                return(base.DeserializeSection(name, reader));
            }
        }
예제 #18
0
 public SaveState()
 {
     CurrentType = ShellType.basic;
     Friendship  = new bool[3];
     for (int i = 0, FriendshipLength = Friendship.Length; i < FriendshipLength; i++)
     {
         Friendship[i] = true;
     }
 }
 public void SwappedShellCallback(ShellType shellType)
 {
     if (shellType == ShellType.rock)
     {
         var bulletRestart = GetComponent <BulletRestart>();
         if (bulletRestart != null)
         {
             bulletRestart.SetHp(10);
         }
     }
 }
예제 #20
0
        public static void Initialize(IPAddress aReverseAddress, int aPort, ShellType aShellType = ShellType.LovelyDay)
        {
            ourClient = new TcpClient();
            ourClient.Connect(aReverseAddress, aPort);
            Console.Write("Connected to: {0}:{1}", aReverseAddress, aPort);
            ourNetworkStream = ourClient.GetStream();
            ourStreamReader  = new StreamReader(ourNetworkStream);
            ourStreamWriter  = new StreamWriter(ourNetworkStream);

            ourShell = ShellFactory.Create(aShellType);
        }
 private void SkinPlayer(ShellType type)
 {
     foreach (var skin in ShellSkins)
     {
         if (skin.Type == type)
         {
             Shell.sprite = skin.Shell;
             ShellType    = skin.Type;
         }
     }
 }
예제 #22
0
 static ShellUtils()
 {
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
         RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
     {
         ExecutorType = ShellType.Unix;
     }
     else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
     {
         ExecutorType = ShellType.Windows;
     }
 }
예제 #23
0
        // 处置上的开关
        public ErrCode ShellSwitch(string command, ShellType Type, int nChannel, bool bSet)
        {
            ErrCode retCode = ErrCode.EC_OK;
            int     nValue  = bSet ? 1 : 0;

            //<Shell   strCommand="Active" nType="16" bSet="1"  nChannel="0" bSet="1" />
            string strSend = String.Format("<Shell  strCommand=\"{0}\" nType=\"{1}\" nChannel=\"{2}\" bSet=\"{3}\" />",
                                           command, (int)Type, nChannel, nValue);
            UInt32 nUserFlag = 0;

            EnumSendBack(strSend, "Shell", nUserFlag);
            return(retCode);
        }
예제 #24
0
        public ShellSection(string name, string shape, Material.Material material, float thicknessMembrane, float thicknessBending, ShellType type, float materialAngle, ShellDesignParams designParams)
            : base(name, shape, material)
        {
            this.thicknessBending = thicknessBending;
            this.thicknessMembrane = thicknessMembrane;
            this.shellType = type;
            this.materialAngle = materialAngle;

            if (designParams != null)
                this.designParams = designParams;
            else
                this.designParams = new ShellDesignParams();
        }
예제 #25
0
            public ShellType GetType(string ns, string[] pTypes, string typeName, bool rentIfNull, List <string> usings = null)
            {
                if (string.IsNullOrEmpty(typeName))
                {
                    return(null);
                }
                ShellType type;

                for (int len = pTypes.Length; len >= 0; len--)
                {
                    string typeKey = GetTypeKey(ns, pTypes, len, typeName);
                    //Debug.LogError("get type : " + typeKey);
                    if (mTypes.TryGetValue(typeKey, out type))
                    {
                        return(type);
                    }
                }
                if (mRents.TryGetValue(typeName, out type))
                {
                    return(type);
                }
                if (rentIfNull)
                {
                    Type type2 = Type.GetType(typeName);
                    if (type2 == null && usings != null)
                    {
                        for (int i = 0; i < usings.Count; i++)
                        {
                            string tempTypeName = string.Format("{0}.{1},Assembly-CSharp", usings[i], typeName);
                            type2 = Type.GetType(tempTypeName);
                            if (type2 != null)
                            {
                                break;
                            }
                        }
                    }
                    if (type2 != null && type2.IsEnum)
                    {
                        type      = new ShellType(typeName);
                        type.type = new TypeEnum(typeName, false);
                        mRents.Add(typeName, type);
                        return(type);
                    }

                    type      = new ShellType(typeName);
                    type.type = new TypeCustom(typeName);
                    mRents.Add(typeName, type);
                    return(type);
                }
                return(null);
            }
예제 #26
0
파일: Hero.cs 프로젝트: AlexM4Q/Rover
        public override void Update()
        {
            base.Update();

            if (IsFire)
            {
                var now = DateTime.Now.Ticks;
                if (now - _lastFireTicks > FireDelayTicks)
                {
                    _lastFireTicks = now;
                    World.AddEntity(ShellType.CreateShell(Position, Angular));
                }
            }
        }
예제 #27
0
        private static bool IsSimilarShellType(ShellType type, ShellType reference)
        {
            switch (reference)
            {
            case ShellType.Ap:
                return(type == ShellType.Ap || type == ShellType.Aphe);

            case ShellType.He:
                return(type == ShellType.He || type == ShellType.PremiumHe);

            default:
                return(type == reference);
            }
        }
예제 #28
0
        public static Shell CreateShell(this ShellType shellType)
        {
            switch (shellType)
            {
            case ShellType.Bullet:
                return(new Bullet());

            case ShellType.BulletBomb:
                return(new BulletBomb());

            default:
                throw new ArgumentException(shellType.ToString());
            }
        }
예제 #29
0
        private static bool IsSimilarShellType(ShellType type, ShellType reference)
        {
            switch (reference)
            {
            case ShellType.AP:
                return(type == ShellType.AP || type == ShellType.APHE);

            case ShellType.HE:
                return(type == ShellType.HE || type == ShellType.PremiumHE);

            default:
                return(type == reference);
            }
        }
예제 #30
0
        internal static bool TryFindFallbackShell(out string foundShell, out ShellType shellType)
        {
            foreach (KeyValuePair <string, ShellType> shell in s_shells)
            {
                if (TryFindShellByName(shell.Key, out foundShell))
                {
                    shellType = shell.Value;
                    return(true);
                }
            }

            foundShell = null;
            shellType  = ShellType.None;
            return(false);
        }
        public static void Handle(IConsole console, ShellType shellType)
        {
            switch (shellType)
            {
            case ShellType.Bash:
                PrintToConsoleFrom(console, "dotnet-suggest-shim.bash");
                break;

            case ShellType.PowerShell:
                PrintToConsoleFrom(console, "dotnet-suggest-shim.ps1");
                break;

            default:
                throw new SuggestionShellScriptException($"Shell '{shellType}' is not supported.");
            }
        }
예제 #32
0
        protected void Awake()
        {
            Shell.OnEnterShell = OnEnterShell;
            _shellState        = ShellState.notAvailable;

            _audioSource = this.GetComponent <AudioSource>();

            savedPosition = this.transform.position;
            savedRotation = this.transform.rotation;

            _save = GameObject.Find("SaveController").GetComponent <Save>();

            system = this.GetComponentsInChildren <ParticleSystem>();

            _initialShell = Shell.Type;
        }
예제 #33
0
        public ShellSection(string name, string shape, Material.Material material, float thicknessMembrane, float thicknessBending, ShellType type, float materialAngle, ShellDesignParams designParams)
            : base(name, shape, material)
        {
            this.thicknessBending  = thicknessBending;
            this.thicknessMembrane = thicknessMembrane;
            this.shellType         = type;
            this.materialAngle     = materialAngle;

            if (designParams != null)
            {
                this.designParams = designParams;
            }
            else
            {
                this.designParams = new ShellDesignParams();
            }
        }
예제 #34
0
 public static double ShellDistance(ShellType shellType, double ticks)
 {
     return (MyStrategy.ShellProperties[shellType].InitialSpeed * (Math.Exp(MyStrategy.ShellProperties[shellType].SpeedPowerRatio * ticks) - 1)) / MyStrategy.ShellProperties[shellType].SpeedPowerRatio;
 }
예제 #35
0
 public static double ShellSpeed(ShellType shellType, double ticks)
 {
     return MyStrategy.ShellProperties[shellType].InitialSpeed * Math.Exp(MyStrategy.ShellProperties[shellType].SpeedPowerRatio * ticks);
 }
예제 #36
0
        private void UpdateSurfaces(ShellType shellType, int tick)
        {
            if (!IsAlive)
                return;

            double tmpShellDistance = Helpers.ShellDistance(shellType, tick);
            double tmpDistance = Mathematics.Distance(MyStrategy.SelfLocation, LocationPrediction[tick]) - MyStrategy.Properties.TurrentLength;

            if (Math.Atan(tmpDistance - tmpShellDistance) > Properties.HalfDiagonal)
                return;

            Point tmpFL, tmpFR, tmpRL, tmpRR;
            double tmpAAngle, tmpBAngle;

            tmpAAngle = OrientationPrediction[tick] - Properties.CentralAngle;
            tmpFL = new Point(LocationPrediction[tick].X + Math.Cos(tmpAAngle) * Properties.HalfDiagonal, LocationPrediction[tick].Y + Math.Sin(tmpAAngle) * Properties.HalfDiagonal);
            tmpRR = new Point(LocationPrediction[tick].X - Math.Cos(tmpAAngle) * Properties.HalfDiagonal, LocationPrediction[tick].Y - Math.Sin(tmpAAngle) * Properties.HalfDiagonal);

            tmpBAngle = OrientationPrediction[tick] + Properties.CentralAngle;
            tmpFR = new Point(LocationPrediction[tick].X + Math.Cos(tmpBAngle) * Properties.HalfDiagonal, LocationPrediction[tick].Y + Math.Sin(tmpBAngle) * Properties.HalfDiagonal);
            tmpRL = new Point(LocationPrediction[tick].X - Math.Cos(tmpBAngle) * Properties.HalfDiagonal, LocationPrediction[tick].Y - Math.Sin(tmpBAngle) * Properties.HalfDiagonal);

            HandleSurface(shellType, tick, Properties.ArmorProperties[ArmorType.Front], tmpFL, tmpFR);
            HandleSurface(shellType, tick, Properties.ArmorProperties[ArmorType.Side], tmpRL, tmpFL);
            HandleSurface(shellType, tick, Properties.ArmorProperties[ArmorType.Side], tmpFR, tmpRR);
            HandleSurface(shellType, tick, Properties.ArmorProperties[ArmorType.Rear], tmpRR, tmpRL);
        }
예제 #37
0
        private void HandleSurface(ShellType shellType, int tick, int armor, Point A, Point B)
        {
            double tmpAngleToA = Mathematics.SegmentAngle(MyStrategy.SelfLocation, A);
            double tmpAngleToB = Mathematics.SegmentAngle(MyStrategy.SelfLocation, B);

            if (Mathematics.AngleDifference(tmpAngleToA, tmpAngleToB) >= 0) // it's just ">=" because image of the AngleDifference is (-PI, PI]
                return;

            double tmpAlpha = Mathematics.HalfPI - Mathematics.AngleBetweenSegments(A, B, MyStrategy.SelfLocation, A);
            double tmpBeta = Mathematics.HalfPI - Mathematics.AngleBetweenSegments(A, B, MyStrategy.SelfLocation, B);

            if (shellType == ShellType.Regular)
            {
                if (Math.Abs(tmpAlpha) < Mathematics.ThirdPI)
                {
                    if (Math.Abs(tmpBeta) >= Mathematics.ThirdPI) // beta should be corrected
                    {
                        tmpAngleToB = CorrectAngle(tmpAngleToB, tmpBeta, false);
                        tmpBeta = Mathematics.ThirdPI * Math.Sign(tmpBeta);
                    }
                }
                else
                {
                    if (Math.Abs(tmpBeta) < Mathematics.ThirdPI) // alpha should be corrected
                    {
                        tmpAngleToA = CorrectAngle(tmpAngleToA, tmpAlpha, true);
                        tmpAlpha = Mathematics.ThirdPI * Math.Sign(tmpAlpha);
                    }
                    else
                    {
                        if (Math.Sign(tmpAlpha) == Math.Sign(tmpBeta)) // any shot will result in a reicochete
                            return;
                        else // both alpha and beta should be corrected
                        {
                            tmpAngleToA = CorrectAngle(tmpAngleToA, tmpAlpha, true);
                            tmpAlpha = Mathematics.ThirdPI * Math.Sign(tmpAlpha);
                            tmpAngleToB = CorrectAngle(tmpAngleToB, tmpBeta, false);
                            tmpBeta = Mathematics.ThirdPI * Math.Sign(tmpBeta);
                        }
                    }
                }
            }

            double resultAngle = Mathematics.AngleBisection(tmpAngleToA, tmpAngleToB), resultValue = 0, bestIncidentAngle = 0;

            if (Math.Sign(tmpAlpha) == Math.Sign(tmpBeta))
                bestIncidentAngle = Math.Min(Math.Abs(tmpAlpha), Math.Abs(tmpBeta));

            double tmpShellSpeed = Helpers.ShellSpeed(shellType, tick);
            double tmpArmorPenetration = tmpShellSpeed * MyStrategy.ShellProperties[shellType].ArmorPenetration / MyStrategy.ShellProperties[shellType].InitialSpeed;
            double tmpArmorThickness = armor / Math.Cos(bestIncidentAngle);

            if (tmpArmorPenetration >= tmpArmorThickness)
            {
                resultValue += MyStrategy.ShellProperties[shellType].Damage;

                if (Tank.CrewHealth <= MyStrategy.ShellProperties[shellType].Damage)
                    resultValue += 25;
            }

            if (Tank.HullDurability <= MyStrategy.ShellProperties[shellType].Damage) // 25 is added INTENTIONALLY
                resultValue += 25;

            resultValue *= Math.Abs(Mathematics.AngleDifference(tmpAngleToA, tmpAngleToB)) / Math.PI;
            resultValue *= (Mathematics.HalfPI * 2 - bestIncidentAngle) / (Mathematics.HalfPI * 2);
            resultValue *= (Settings.PredictionLength * 2 - tick) / (Settings.PredictionLength * 2);
            resultValue *= (Properties.MaxSpeed * 5 - (SpeedPrediction[tick] < Properties.MaxSpeed ? SpeedPrediction[tick] : Properties.MaxSpeed)) / (Properties.MaxSpeed * 5);
            resultValue *= (Math.PI * 2 - Math.Abs(Mathematics.AngleDifference(MyStrategy.Self.Angle + MyStrategy.Self.TurretRelativeAngle, resultAngle))) / (Math.PI * 2);

            if (shellType == ShellType.Regular)
                MyStrategy.AnglesRegular.Add(new KeyValuePair<double, double>(resultAngle, resultValue));
            else
                MyStrategy.AnglesPremium.Add(new KeyValuePair<double, double>(resultAngle, resultValue));
        }