Exemplo n.º 1
0
 public override void PostDraw()
 {
     foreach (CannonHandler cannon in Cannons.OrderBy(x => x.drawLayer))
     {
         cannon.Draw();
     }
 }
Exemplo n.º 2
0
        public override string ToString()
        {
            var c = Cannons.OrderBy(x => x).ToArray();
            var a = Archers.OrderBy(x => x).ToArray();

            return(string.Join('-', c) + "," + string.Join('-', a));
        }
Exemplo n.º 3
0
    void UpgradeWeapon()
    {
        money -= nextUpgradeCost();
        cannonLevel++;
        CannonProperties newCannonProperties = Cannons.getCannonProperties(cannonLevel);

        if (cannonObj.GetComponent <Cannon>().GetCannonProperties().cannonType != newCannonProperties.cannonType)
        {
            InitCannon();
        }
        else
        {
            cannonObj.GetComponent <Cannon>().SetCannonProperties(newCannonProperties);
        }

        switch (newCannonProperties.cannonType)
        {
        case 1:
            upgradeButton.GetComponent <Image>().sprite = cannonSprites[0];
            break;

        case 2:
            upgradeButton.GetComponent <Image>().sprite = cannonSprites[1];
            break;

        case 3:
            upgradeButton.GetComponent <Image>().sprite = cannonSprites[2];
            break;
        }
    }
Exemplo n.º 4
0
        public Enemy3(Texture enemyTexture)
        {
            Dimensions.X = 255 * 0.3f * WindowProperties.ScaleX;
            Dimensions.Y = 255 * 0.3f * WindowProperties.ScaleY;

            for (var i = 0; i < 6; i++)
            {
                var enemyFrame = new Sprite(enemyTexture)
                {
                    Origin = new Vector2f(127.5f, 195.0f),
                    Scale  = new Vector2f(0.3f * WindowProperties.ScaleX,
                                          0.3f * WindowProperties.ScaleY),
                    Position    = RandomHorizontalPosition(),
                    TextureRect = new IntRect(i * 255, 0, 255, 390)
                };

                EnemyFrames.Add(enemyFrame);
            }

            HpBar = new HpBar(Dimensions);

            cannons = new Cannons(Position, Dimensions);

            HpMax = 12;
            Hp    = HpMax;
        }
Exemplo n.º 5
0
        private void AddCannon(Direction d, CannonPower type, int xOffset, int yOffset, int zOffset, bool oper = true)
        {
            MannedCannon cannon;
            BaseCreature mob = null;

            if (oper)
            {
                mob = new PirateCrew
                {
                    CantWalk = true
                };

                Crew.Add(mob);
            }

            switch (type)
            {
            default:
            case CannonPower.Light:
                cannon = new MannedCulverin(mob, d); break;

            case CannonPower.Heavy:
                cannon = new MannedCarronade(mob, d); break;

            case CannonPower.Massive:
                cannon = new MannedBlundercannon(mob, d); break;
            }

            if (mob == null)
            {
                cannon.CanFireUnmanned = true;
            }

            cannon.MoveToWorld(new Point3D(X + xOffset, Y + yOffset, Z + zOffset), Map);
            Cannons.Add(cannon);

            if (mob != null)
            {
                Point3D offset;

                switch (d)
                {
                default:
                case Direction.South:
                    offset = new Point3D(0, -1, 0); break;

                case Direction.North:
                    offset = new Point3D(0, 1, 0); break;

                case Direction.West:
                    offset = new Point3D(1, 0, 0); break;

                case Direction.East:
                    offset = new Point3D(-1, 0, 0); break;
                }

                mob.MoveToWorld(new Point3D(cannon.X + offset.X, cannon.Y + offset.Y, cannon.Z + offset.Z), Map);
            }
        }
Exemplo n.º 6
0
        public void OnTick()
        {
            var map = Map;

            if (map == null)
            {
                return;
            }
            else if (CannonsOperational && NextShoot < DateTime.UtcNow)
            {
                foreach (var cannon in Cannons.Where(c => c != null && !c.Deleted && (c.CanFireUnmanned || (c.Operator != null && !c.Operator.Deleted && c.Operator.Alive))))
                {
                    cannon.Scan(true);
                }

                NextShoot = DateTime.UtcNow + TimeSpan.FromSeconds(2);
            }

            if (NextSpawn < DateTime.UtcNow)
            {
                if (SpawnCount() < MaxSpawn)
                {
                    Point3D p     = Location;
                    var     range = 15;

                    if (Beacon.LastDamager != null && Beacon.LastDamager.InRange(Location, 20))
                    {
                        p     = Beacon.LastDamager.Location;
                        range = 8;
                    }

                    BaseCreature creature = Activator.CreateInstance(_SpawnTypes[Utility.Random(_SpawnTypes.Length)]) as BaseCreature;

                    for (int i = 0; i < 50; i++)
                    {
                        var spawnLoc = new Point3D(Utility.RandomMinMax(p.X - range, p.X + range), Utility.RandomMinMax(p.Y - range, p.Y + range), -5);

                        if (map.CanFit(spawnLoc.X, spawnLoc.Y, spawnLoc.Z, 16, true, true, false, creature))
                        {
                            if (creature != null)
                            {
                                creature.MoveToWorld(spawnLoc, map);
                                creature.Home      = spawnLoc;
                                creature.RangeHome = 10;

                                Spawn.Add(creature);

                                NextSpawn = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(30, 60));
                                return;
                            }
                        }
                    }

                    creature.Delete();
                }
            }
        }
Exemplo n.º 7
0
 public Cannon GetCannon(Cannons cannonsEnum)
 {
     switch (cannonsEnum)
     {
         case Cannons.right:
             return cannon[0];
         case Cannons.left:
             return cannon[1];
     }
     return null;
 }
Exemplo n.º 8
0
    public Cannon GetCannon(Cannons cannonsEnum)
    {
        switch (cannonsEnum)
        {
        case Cannons.right:
            return(cannon[0]);

        case Cannons.left:
            return(cannon[1]);
        }
        return(null);
    }
Exemplo n.º 9
0
    public void Shot(Cannons cannonToUse)
    {
        int        chargeLevel  = GetCannon(cannonToUse).GetChargeLevel();
        Vector3    shotPosition = GetCannon(cannonToUse).toShotFrom.position;
        GameObject b            = Bullet.BulletInstantiate(shotPosition, Vector3.up * transform.rotation.eulerAngles.y, bulletSpeed);

        b.GetComponent <Bullet>().setColor(drawStuff.getNextColor((byte)chargeLevel));
        b.GetComponent <Bullet>().owner = transform;
        Vector3 force = -transform.forward * shotForce * chargeLevel;

        rigidbody.AddForceAtPosition(force, shotPosition, ForceMode.Impulse);
    }
Exemplo n.º 10
0
 public override void PostDrawExtraSelectionOverlays()
 {
     base.PostDrawExtraSelectionOverlays();
     if (Cannons?.Where(x => x.cannonDef.weaponType == WeaponType.Static).Count() > 0 && this.Pawn.Drafted)
     {
         if (MinRange > 0)
         {
             GenDraw.DrawRadiusRing(this.Pawn.DrawPosTransformed(CompShip.Props.hitboxOffsetX, CompShip.Props.hitboxOffsetZ, CompShip.Angle).ToIntVec3(), this.MinRange, Color.red);
         }
         GenDraw.DrawRadiusRing(this.Pawn.DrawPosTransformed(CompShip.Props.hitboxOffsetX, CompShip.Props.hitboxOffsetZ, CompShip.Angle).ToIntVec3(), this.Range);
     }
 }
Exemplo n.º 11
0
        public void OnTick()
        {
            if (_CheckSpawn)
            {
                if (BaseCreature.IsSoulboundEnemies && Spawn != null)
                {
                    foreach (BaseCreature bc in Spawn.Keys)
                    {
                        if (!bc.Deleted)
                        {
                            bc.IsSoulBound = true;
                        }
                    }
                }

                _CheckSpawn = false;
            }

            Map map = Map;

            if (map == null)
            {
                return;
            }
            else if (!InitialSpawn)
            {
                for (int i = 0; i < MaxSpawn; i++)
                {
                    SpawnHelper(true);
                    InitialSpawn = true;
                }
            }
            else if (CannonsOperational && NextShoot < DateTime.UtcNow)
            {
                foreach (MannedCannon cannon in Cannons.Where(c => c != null && !c.Deleted && (c.CanFireUnmanned || (c.Operator != null && !c.Operator.Deleted && c.Operator.Alive))))
                {
                    cannon.Scan(true);
                }

                NextShoot = DateTime.UtcNow + TimeSpan.FromSeconds(2);
            }

            if (NextSpawn < DateTime.UtcNow)
            {
                Timer.DelayCall(TimeSpan.FromSeconds(1), () =>
                {
                    if (SpawnCount() < MaxSpawn)
                    {
                        SpawnHelper(false);
                    }
                });
            }
        }
 private void Awake()
 {
     npc = GetComponent <OverWorldNPC>();
     startingSinkTime = sinkTime;
     lootTable        = GetComponent <LootTable>();
     sailHealth       = mySails.sailHealth;
     myHealth         = GetComponent <Health>();
     myCannons        = GetComponent <Cannons>();
     myRigidBody      = GetComponent <Rigidbody2D>();
     myHullCollider   = GetComponent <CapsuleCollider2D>();
     SetTarget();
 }
Exemplo n.º 13
0
        private void RemoveCannon(int i)
        {
            Canon cannon = ClosestCannon(Enemies[i]);

            TheForm.GetControls().Remove(cannon);
            Cannons.Remove(cannon);
            TheForm.GetControls().Remove(Enemies[i]);
            Enemies.RemoveAt(i);

            SoundCollection.PlayerCannonCrush.Play();
            ShakeForm();
        }
Exemplo n.º 14
0
 private void InitializeCannons()
 {
     if (Cannons.Count <= 0 && Props.cannons.Any())
     {
         foreach (CannonHandler cannon in Props.cannons)
         {
             var cannonPermanent = new CannonHandler(this.Pawn, cannon);
             cannonPermanent.SetTarget(LocalTargetInfo.Invalid);
             cannonPermanent.ResetCannonAngle();
             Cannons.Add(cannonPermanent);
         }
     }
 }
Exemplo n.º 15
0
    static void Main(string[] args)
    {
        // 注册序列化类型
        PKG.AllTypes.Register();

        // 填充 ways
        Ways.Fill();

        // 填充 frames, fishFrames
        SpriteFrames.Fill();

        // 创建配置实例
        var cfg = new PKG.CatchFish.Configs.Config();

        cfg.cannons     = new xx.List <PKG.CatchFish.Configs.Cannon>();
        cfg.fishs       = new xx.List <PKG.CatchFish.Configs.Fish>();
        cfg.sitPositons = new xx.List <xx.Pos>();
        cfg.stages      = new xx.List <PKG.CatchFish.Stages.Stage>();
        cfg.fixedWays   = new xx.List <PKG.CatchFish.Way>();
        cfg.weapons     = new xx.List <PKG.CatchFish.Configs.Weapon>();

        // 基于 1280 x 720 的设计尺寸
        cfg.sitPositons.Add(new xx.Pos {
            x = -250, y = -335
        });
        cfg.sitPositons.Add(new xx.Pos {
            x = 250, y = -335
        });
        cfg.sitPositons.Add(new xx.Pos {
            x = 250, y = 335
        });
        cfg.sitPositons.Add(new xx.Pos {
            x = -250, y = 335
        });
        cfg.aimTouchRadius          = 20;
        cfg.normalFishMaxRadius     = 150;
        cfg.enableBulletFastForward = false;

        // 有前后依赖
        Cannons.Fill(cfg);
        Weapons.Fill(cfg);
        Fishs.Fill(cfg);
        Stages.Fill(cfg);

        // cfg 序列化存盘
        var bb = new xx.BBuffer();

        bb.WriteRoot(cfg);
        File.WriteAllBytes(Path.Combine(outputPath, "cfg.bin"), bb.DumpData());
        bb.ReadRoot(ref cfg);   // test read
    }
Exemplo n.º 16
0
        public override void PostDraw()
        {
            foreach (CannonHandler cannon in Cannons.OrderBy(x => x.drawLayer))
            {
                if (cannon.CannonTexture != null && cannon.cannonRenderLocation != null)
                {
                    cannon.ValidateLockStatus();
                    try
                    {
                        Vector3             topVectorRotation = new Vector3(cannon.cannonRenderOffset.x, 1f, cannon.cannonRenderOffset.y).RotatedBy(cannon.TurretRotation);
                        Pair <float, float> drawOffset        = HelperMethods.ShipDrawOffset(Pawn.GetComp <CompShips>(), cannon.cannonRenderLocation.x, cannon.cannonRenderLocation.y);
                        Vector3             topVectorLocation = new Vector3(parent.DrawPos.x + drawOffset.First, parent.DrawPos.y + cannon.drawLayer, parent.DrawPos.z + drawOffset.Second);
                        Mesh cannonMesh = cannon.CannonGraphic.MeshAt(Rot4.North);

                        if (RimShipMod.mod.settings.debugDrawCannonGrid)
                        {
                            Material  debugCenterMat = MaterialPool.MatFrom("Debug/cannonCenter");
                            Matrix4x4 debugCenter    = default;
                            debugCenter.SetTRS(topVectorLocation + Altitudes.AltIncVect, Quaternion.identity, new Vector3(0.15f, 1f, 0.15f));
                            Graphics.DrawMesh(MeshPool.plane10, debugCenter, debugCenterMat, 0);
                        }

                        Graphics.DrawMesh(cannonMesh, topVectorLocation, cannon.TurretRotation.ToQuat(), cannon.CannonMaterial, 0);

                        if (cannon.CannonBaseMaterial != null && cannon.baseCannonRenderLocation != null)
                        {
                            Matrix4x4           baseMatrix         = default;
                            Pair <float, float> baseDrawOffset     = HelperMethods.ShipDrawOffset(Pawn.GetComp <CompShips>(), cannon.baseCannonRenderLocation.x, cannon.baseCannonRenderLocation.y);
                            Vector3             baseVectorLocation = new Vector3(parent.DrawPos.x + baseDrawOffset.First, parent.DrawPos.y, parent.DrawPos.z + baseDrawOffset.Second);
                            baseMatrix.SetTRS(baseVectorLocation + Altitudes.AltIncVect, parent.Rotation.AsQuat, new Vector3(cannon.baseCannonDrawSize.x, 1f, cannon.baseCannonDrawSize.y));
                            Graphics.DrawMesh(MeshPool.plane10, baseMatrix, cannon.CannonBaseMaterial, 0);
                        }

                        if (RimShipMod.mod.settings.debugDrawCannonGrid)
                        {
                            Material  debugMat  = MaterialPool.MatFrom("Debug/cannonAlignment");
                            Matrix4x4 debugGrid = default;
                            debugGrid.SetTRS(topVectorLocation + Altitudes.AltIncVect, 0f.ToQuat(), new Vector3(5f, 1f, 5f));
                            Graphics.DrawMesh(MeshPool.plane10, debugGrid, debugMat, 0);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(string.Format("Error occurred during rendering of cannon {0}. Exception: {1}", cannon.cannonDef.label, ex.Message));
                    }
                }
            }
        }
 public void OnObjectSpawn()
 {
     gameObject.SetActive(true);
     lootTable      = GetComponent <LootTable>();
     sailHealth     = mySails.sailHealth;
     myCannons      = GetComponent <Cannons>();
     myRigidBody    = GetComponent <Rigidbody2D>();
     myHullCollider = GetComponent <CapsuleCollider2D>();
     ResetSinkTime();
     sailHealth.ResetHealth();
     myHealth.ResetHealth();
     GetComponent <SpriteRenderer>().sprite = damageSprites[0];
     SetTarget();
     EnableExtraColliders();
     isAlive = true;
 }
Exemplo n.º 18
0
        private void InitializeCannons()
        {
            if (Cannons.Count <= 0 && Props.cannons.AnyNullified())
            {
                foreach (CannonHandler cannon in Props.cannons)
                {
                    var cannonPermanent = new CannonHandler(this.Pawn, cannon);
                    cannonPermanent.SetTarget(LocalTargetInfo.Invalid);
                    cannonPermanent.ResetCannonAngle();
                    Cannons.Add(cannonPermanent);
                }

                if (Cannons.Select(x => x.key).GroupBy(y => y).AnyNullified(key => key.Count() > 1))
                {
                    Log.Warning("Duplicate CannonHandler key has been found. These are intended to be unique.");
                }
            }
        }
Exemplo n.º 19
0
    private void Start()
    {
        //get the cannons script
        cannonManager  = GameObject.Find("Cannons Manager");
        cannonScript   = cannonManager.GetComponent <Cannons>();
        cannonballList = cannonScript.cannonballList;

        //get launch angle
        if (shootingFromTheLeft = cannonScript.getActiveCannon() == true)
        {
            launchAngle = cannonScript.getCurRotleft();
        }
        else
        {
            launchAngle = cannonScript.getCurRotRight();
        }

        //decomposing the launch speed into it's x and y components
        xVel = cannonScript.getLaunchVelocity() * Mathf.Cos(launchAngle);
        yVel = cannonScript.getLaunchVelocity() * Mathf.Sin(launchAngle);

        //Velocity's sign depends on which cannon we are firing from
        if (shootingFromTheLeft == false)
        {
            xVel *= -1;
        }

        //get terrain data points
        GameObject mountains     = GameObject.Find("Mountain range");
        Terrain    terrainScript = mountains.GetComponent <Terrain>();

        mountainPoints = terrainScript.mountainPoints;

        leftSidePoints  = terrainScript.leftSidePoints;
        rightSidePoints = terrainScript.rightSidePoints;

        waterPoints    = terrainScript.waterPoints;
        waterAvgHeight = terrainScript.getWaterAvgHeight();

        //Getting the balloon manager script
        balloonManager       = GameObject.Find("Balloon Spawner");
        balloonManagerScript = balloonManager.GetComponent <BalloonSpawner>();
    }
Exemplo n.º 20
0
        public override void PostSpawnSetup(bool respawningAfterLoad)
        {
            base.PostSpawnSetup(respawningAfterLoad);
            if (!respawningAfterLoad)
            {
                InitializeCannons();
            }

            foreach (CannonHandler cannon in Cannons)
            {
                if (!string.IsNullOrEmpty(cannon.key))
                {
                    Cannons.Where(x => x.parentKey == cannon.key).ToList().ForEach(y => y.attachedTo = cannon);
                }
            }

            broadsideFire   = new List <SPTuple <Stack <int>, CannonHandler, int> >();
            multiFireCannon = new List <SPTuple <int, CannonHandler, SPTuple2 <int, int> > >();
        }
Exemplo n.º 21
0
    void InitCannon()
    {
        CannonProperties cannonProperties = Cannons.getCannonProperties(cannonLevel);

        if (cannonObj != null)
        {
            GameObject newcannonObj = (GameObject)GameObject.Instantiate(Resources.Load(string.Format("Prefabs/{0}", Cannons.getPrefabName(cannonProperties.cannonType))));

            newcannonObj.GetComponent <Cannon>().SetCannonProperties(cannonProperties);

            initiateStylishCannonSwitch(cannonObj.GetComponent <Cannon>().transform, newcannonObj.transform);
            cannonObj.GetComponent <Cannon>().Kill();
            cannonObj = newcannonObj;
        }
        else
        {
            cannonObj = (GameObject)GameObject.Instantiate(Resources.Load(string.Format("Prefabs/{0}", Cannons.getPrefabName(cannonProperties.cannonType))));
            cannonObj.GetComponent <Cannon>().SetCannonProperties(cannonProperties);
        }
    }
        public void OnTick()
        {
            var map = Map;

            if (map == null)
            {
                return;
            }
            else if (!InitialSpawn)
            {
                for (int i = 0; i < MaxSpawn; i++)
                {
                    SpawnHelper(true);
                    InitialSpawn = true;
                }
            }
            else if (CannonsOperational && NextShoot < DateTime.UtcNow)
            {
                foreach (var cannon in Cannons.Where(c => c != null && !c.Deleted && (c.CanFireUnmanned || (c.Operator != null && !c.Operator.Deleted && c.Operator.Alive))))
                {
                    cannon.Scan(true);
                }

                NextShoot = DateTime.UtcNow + TimeSpan.FromSeconds(2);
            }

            if (NextSpawn < DateTime.UtcNow)
            {
                Timer.DelayCall(TimeSpan.FromSeconds(1), () =>
                {
                    if (SpawnCount() < MaxSpawn)
                    {
                        SpawnHelper(false);
                    }
                });
            }
        }
Exemplo n.º 23
0
        public override void Shoot(List <Bullet> enemiesBullets)
        {
            if (ReloadingClock.ElapsedTime.AsMilliseconds() <= 200)
            {
                return;
            }

            var cannons = new Cannons(Position, Dimensions);

            var bullet = new Bullet(cannons.Cannon1.Position, cannons.Cannon1.BulletVector);

            enemiesBullets.Add(bullet);

            bullet = new Bullet(cannons.Cannon2.Position, cannons.Cannon2.BulletVector);
            enemiesBullets.Add(bullet);

            bullet = new Bullet(cannons.Cannon3.Position, cannons.Cannon3.BulletVector);
            enemiesBullets.Add(bullet);

            bullet = new Bullet(cannons.Cannon4.Position, cannons.Cannon4.BulletVector);
            enemiesBullets.Add(bullet);

            ReloadingClock.Restart();
        }
Exemplo n.º 24
0
 public void Shot(Cannons cannonToUse)
 {
     int chargeLevel = GetCannon(cannonToUse).GetChargeLevel();
     Vector3 shotPosition = GetCannon(cannonToUse).toShotFrom.position;
     GameObject b = Bullet.BulletInstantiate(shotPosition, Vector3.up * transform.rotation.eulerAngles.y, bulletSpeed);
     b.GetComponent<Bullet>().setColor(drawStuff.getNextColor((byte) chargeLevel));
     b.GetComponent<Bullet>().owner = transform;
     Vector3 force = -transform.forward * shotForce * chargeLevel;
     rigidbody.AddForceAtPosition(force, shotPosition, ForceMode.Impulse);
 }
Exemplo n.º 25
0
 // Start is called before the first frame update
 void Start()
 {
     wall   = new ObjectWall();
     cannon = new Cannons();
 }
Exemplo n.º 26
0
 public void Charge(Cannons cannonToCharge)
 {
     GetCannon(cannonToCharge).Charge();
 }
Exemplo n.º 27
0
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            if (this.Pawn.Drafted)
            {
                if (Cannons.Count > 0)
                {
                    if (Cannons.Any(x => x.cannonDef.weaponType == WeaponType.Rotatable))
                    {
                        int i = 0;
                        foreach (CannonHandler cannon in Cannons.Where(x => x.cannonDef.weaponLocation == WeaponLocation.Turret))
                        {
                            Command_TargeterCooldownAction turretCannons = new Command_TargeterCooldownAction();
                            turretCannons.cannon       = cannon;
                            turretCannons.comp         = this;
                            turretCannons.defaultLabel = "TestFire".Translate(cannon.cannonDef.label) + i;
                            turretCannons.icon         = cannon.GizmoIcon;
                            if (!string.IsNullOrEmpty(cannon.cannonDef.gizmoDescription))
                            {
                                turretCannons.defaultDesc = cannon.cannonDef.gizmoDescription;
                            }
                            turretCannons.targetingParams = new TargetingParameters
                            {
                                //Buildings, Things, Animals, Humans, and Mechs default to targetable
                                canTargetLocations = true
                            };
                            i++;
                            yield return(turretCannons);
                        }
                    }
                    if (Cannons.Any(x => x.cannonDef.weaponType == WeaponType.Static))
                    {
                        if (Cannons.Any(x => x.cannonDef.weaponLocation == WeaponLocation.Port))
                        {
                            foreach (CannonHandler cannon in Cannons.Where(x => x.cannonDef.weaponLocation == WeaponLocation.Port))
                            {
                                Command_CooldownAction portSideCannons = new Command_CooldownAction();
                                portSideCannons.cannon       = cannon;
                                portSideCannons.comp         = this;
                                portSideCannons.defaultLabel = "CannonLabel".Translate(cannon.cannonDef.label);
                                if (!string.IsNullOrEmpty(cannon.cannonDef.gizmoDescription))
                                {
                                    portSideCannons.defaultDesc = cannon.cannonDef.gizmoDescription;
                                }
                                portSideCannons.icon = cannon.GizmoIcon;
                                if (!string.IsNullOrEmpty(cannon.cannonDef.gizmoDescription))
                                {
                                    portSideCannons.defaultDesc = cannon.cannonDef.gizmoDescription;
                                }
                                portSideCannons.action = delegate()
                                {
                                    SPTuple <Stack <int>, CannonHandler, int> tmpCannonItem = new SPTuple <Stack <int>, CannonHandler, int>(new Stack <int>(), cannon, 0);
                                    List <int> cannonOrder = Enumerable.Range(0, cannon.cannonDef.numberCannons).ToList();
                                    if (RimShipMod.mod.settings.shuffledCannonFire)
                                    {
                                        cannonOrder.Shuffle();
                                    }
                                    foreach (int i in cannonOrder)
                                    {
                                        tmpCannonItem.First.Push(i);
                                    }
                                    this.broadsideFire.Add(tmpCannonItem);
                                };
                                foreach (ShipHandler handler in this.CompShip.handlers)
                                {
                                    if (!RimShipMod.mod.settings.debugDraftAnyShip && handler.role.handlingType == HandlingTypeFlags.Cannons && handler.handlers.Count < handler.role.slotsToOperate)
                                    {
                                        portSideCannons.Disable("NotEnoughCannonCrew".Translate(this.Pawn.LabelShort, handler.role.label));
                                    }
                                }
                                yield return(portSideCannons);
                            }
                        }
                        if (Cannons.Any(x => x.cannonDef.weaponLocation == WeaponLocation.Starboard))
                        {
                            foreach (CannonHandler cannon in Cannons.Where(x => x.cannonDef.weaponLocation == WeaponLocation.Starboard))
                            {
                                Command_CooldownAction starboardSideCannons = new Command_CooldownAction();
                                starboardSideCannons.cannon       = cannon;
                                starboardSideCannons.comp         = this;
                                starboardSideCannons.defaultLabel = "CannonLabel".Translate(cannon.cannonDef.label);
                                if (!string.IsNullOrEmpty(cannon.cannonDef.gizmoDescription))
                                {
                                    starboardSideCannons.defaultDesc = cannon.cannonDef.gizmoDescription;
                                }
                                starboardSideCannons.icon   = cannon.GizmoIcon;
                                starboardSideCannons.action = delegate()
                                {
                                    SPTuple <Stack <int>, CannonHandler, int> tmpCannonItem = new SPTuple <Stack <int>, CannonHandler, int>(new Stack <int>(), cannon, 0);
                                    List <int> cannonOrder = Enumerable.Range(0, cannon.cannonDef.numberCannons).ToList();
                                    if (RimShipMod.mod.settings.shuffledCannonFire)
                                    {
                                        cannonOrder.Shuffle();
                                    }
                                    foreach (int i in cannonOrder)
                                    {
                                        tmpCannonItem.First.Push(i);
                                    }
                                    this.broadsideFire.Add(tmpCannonItem);
                                };
                                foreach (ShipHandler handler in this.CompShip.handlers)
                                {
                                    if (!RimShipMod.mod.settings.debugDraftAnyShip && handler.role.handlingType == HandlingTypeFlags.Cannons && handler.handlers.Count < handler.role.slotsToOperate)
                                    {
                                        starboardSideCannons.Disable("NotEnoughCannonCrew".Translate(Pawn.LabelShort, handler.role.label));
                                    }
                                }
                                yield return(starboardSideCannons);
                            }
                        }
                        if (Cannons.Any(x => x.cannonDef.weaponLocation == WeaponLocation.Bow))
                        {
                            foreach (CannonHandler cannon in Cannons.Where(x => x.cannonDef.weaponLocation == WeaponLocation.Bow))
                            {
                                Command_CooldownAction bowSideCannons = new Command_CooldownAction();
                                bowSideCannons.cannon       = cannon;
                                bowSideCannons.comp         = this;
                                bowSideCannons.defaultLabel = "CannonLabel".Translate(cannon.cannonDef.label);
                                if (!string.IsNullOrEmpty(cannon.cannonDef.gizmoDescription))
                                {
                                    bowSideCannons.defaultDesc = cannon.cannonDef.gizmoDescription;
                                }
                                bowSideCannons.icon   = cannon.GizmoIcon;
                                bowSideCannons.action = delegate()
                                {
                                    SPTuple <Stack <int>, CannonHandler, int> tmpCannonItem = new SPTuple <Stack <int>, CannonHandler, int>(new Stack <int>(), cannon, 0);
                                    List <int> cannonOrder = Enumerable.Range(0, cannon.cannonDef.numberCannons).ToList();
                                    if (RimShipMod.mod.settings.shuffledCannonFire)
                                    {
                                        cannonOrder.Shuffle();
                                    }
                                    foreach (int i in cannonOrder)
                                    {
                                        tmpCannonItem.First.Push(i);
                                    }
                                    this.broadsideFire.Add(tmpCannonItem);
                                };
                                foreach (ShipHandler handler in this.CompShip.handlers)
                                {
                                    if (!RimShipMod.mod.settings.debugDraftAnyShip && handler.role.handlingType == HandlingTypeFlags.Cannons && handler.handlers.Count < handler.role.slotsToOperate)
                                    {
                                        bowSideCannons.Disable("NotEnoughCannonCrew".Translate(Pawn.LabelShort, handler.role.label));
                                    }
                                }
                                yield return(bowSideCannons);
                            }
                        }
                        if (Cannons.Any(x => x.cannonDef.weaponLocation == WeaponLocation.Stern))
                        {
                            foreach (CannonHandler cannon in Cannons.Where(x => x.cannonDef.weaponLocation == WeaponLocation.Starboard))
                            {
                                Command_CooldownAction sternSideCannons = new Command_CooldownAction();
                                sternSideCannons.cannon       = cannon;
                                sternSideCannons.comp         = this;
                                sternSideCannons.defaultLabel = "CannonLabel".Translate(cannon.cannonDef.label);
                                if (!string.IsNullOrEmpty(cannon.cannonDef.gizmoDescription))
                                {
                                    sternSideCannons.defaultDesc = cannon.cannonDef.gizmoDescription;
                                }
                                sternSideCannons.icon   = cannon.GizmoIcon;
                                sternSideCannons.action = delegate()
                                {
                                    SPTuple <Stack <int>, CannonHandler, int> tmpCannonItem = new SPTuple <Stack <int>, CannonHandler, int>(new Stack <int>(), cannon, 0);
                                    List <int> cannonOrder = Enumerable.Range(0, cannon.cannonDef.numberCannons).ToList();
                                    if (RimShipMod.mod.settings.shuffledCannonFire)
                                    {
                                        cannonOrder.Shuffle();
                                    }
                                    foreach (int i in cannonOrder)
                                    {
                                        tmpCannonItem.First.Push(i);
                                    }
                                    this.broadsideFire.Add(tmpCannonItem);
                                };
                                foreach (ShipHandler handler in this.CompShip.handlers)
                                {
                                    if (!RimShipMod.mod.settings.debugDraftAnyShip && handler.role.handlingType == HandlingTypeFlags.Cannons && handler.handlers.Count < handler.role.slotsToOperate)
                                    {
                                        sternSideCannons.Disable("NotEnoughCannonCrew".Translate(Pawn.LabelShort, handler.role.label));
                                    }
                                }
                                yield return(sternSideCannons);
                            }
                        }

                        Command_SetRange range = new Command_SetRange();
                        range.defaultLabel  = "SetRange".Translate();
                        range.icon          = TexCommand.Attack;
                        range.activeCannons = Cannons.FindAll(x => x.cannonDef.weaponType == WeaponType.Static);
                        range.cannonComp    = this;
                        yield return(range);
                    }
                }
            }
        }
Exemplo n.º 28
0
 private static Boolean KawigiEdit_RunTest(int testNum, int[] p0, int[] p1, Boolean hasAnswer, string p2)
 {
     Console.Write("Test " + testNum + ": [" + "{");
     for (int i = 0; p0.Length > i; ++i) {
         if (i > 0) {
             Console.Write(",");
         }
         Console.Write(p0[i]);
     }
     Console.Write("}" + "," + "{");
     for (int i = 0; p1.Length > i; ++i) {
         if (i > 0) {
             Console.Write(",");
         }
         Console.Write(p1[i]);
     }
     Console.Write("}");
     Console.WriteLine("]");
     Cannons obj;
     string answer;
     obj = new Cannons();
     DateTime startTime = DateTime.Now;
     answer = obj.getDirections(p0, p1);
     DateTime endTime = DateTime.Now;
     Boolean res;
     res = true;
     Console.WriteLine("Time: " + (endTime - startTime).TotalSeconds + " seconds");
     if (hasAnswer) {
         Console.WriteLine("Desired answer:");
         Console.WriteLine("\t" + "\"" + p2 + "\"");
     }
     Console.WriteLine("Your answer:");
     Console.WriteLine("\t" + "\"" + answer + "\"");
     if (hasAnswer) {
         res = answer == p2;
     }
     if (!res) {
         Console.WriteLine("DOESN'T MATCH!!!!");
     } else if ((endTime - startTime).TotalSeconds >= 2) {
         Console.WriteLine("FAIL the timeout");
         res = false;
     } else if (hasAnswer) {
         Console.WriteLine("Match :-)");
     } else {
         Console.WriteLine("OK, but is it right?");
     }
     Console.WriteLine("");
     return res;
 }
Exemplo n.º 29
0
 public void Charge(Cannons cannonToCharge)
 {
     GetCannon(cannonToCharge).Charge();
 }