コード例 #1
0
ファイル: Contrail.cs プロジェクト: Iran/ClassicRA
 public Contrail(Actor self, ContrailInfo info)
 {
     contrailTurret = new Turret(info.ContrailOffset);
     history = new ContrailHistory(info.TrailLength,
         info.UsePlayerColor ? ContrailHistory.ChooseColor(self) : info.Color);
     facing = self.Trait<IFacing>();
     move = self.Trait<IMove>();
 }
コード例 #2
0
ファイル: Weapon.cs プロジェクト: Iran/ClassicRA
        public Turret Turret; // where this weapon is mounted -- possibly shared

        #endregion Fields

        #region Constructors

        public Weapon(string weaponName, Turret turret, int[] localOffset, int recoil)
        {
            Info = Rules.Weapons[weaponName.ToLowerInvariant()];
            Burst = Info.Burst;
            Turret = turret;
            Recoil = recoil;

            var barrels = new List<Barrel>();
            for (var i = 0; i < localOffset.Length / 5; i++)
                barrels.Add(new Barrel
                {
                    TurretSpaceOffset = new PVecInt(localOffset[5 * i], localOffset[5 * i + 1]),
                    ScreenSpaceOffset = new PVecInt(localOffset[5 * i + 2], localOffset[5 * i + 3]),
                    Facing = localOffset[5 * i + 4]
                });

            // if no barrels specified, the default is "turret position; turret facing".
            if (barrels.Count == 0)
                barrels.Add(new Barrel { TurretSpaceOffset = PVecInt.Zero, ScreenSpaceOffset = PVecInt.Zero, Facing = 0 });

            Barrels = barrels.ToArray();
        }
コード例 #3
0
ファイル: Combat.cs プロジェクト: Iran/ClassicRA
        public static PVecInt GetTurretPosition(Actor self, IFacing facing, Turret turret)
        {
            if (facing == null) return turret.ScreenSpacePosition;	/* things that don't have a rotating base don't need the turrets repositioned */

            var ru = self.TraitOrDefault<RenderUnit>();
            var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8;
            var bodyFacing = facing.Facing;
            var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);

            return (PVecInt) ((PVecFloat)(Util.RotateVectorByFacing(turret.UnitSpacePosition.ToFloat2(), quantizedFacing, .7f)
                + GetRecoil(self, turret.Recoil))
                + turret.ScreenSpacePosition);
        }
コード例 #4
0
ファイル: Combat.cs プロジェクト: Iran/ClassicRA
        // gets the screen-space position of a barrel.
        public static PVecInt GetBarrelPosition(Actor self, IFacing facing, Turret turret, Barrel barrel)
        {
            var turreted = self.TraitOrDefault<Turreted>();

            if (turreted == null && facing == null)
                return PVecInt.Zero;

            var turretFacing = turreted != null  ? turreted.turretFacing : facing.Facing;

            return GetTurretPosition(self, facing, turret) + barrel.ScreenSpaceOffset
                + (PVecInt)(PVecFloat)Util.RotateVectorByFacing(barrel.TurretSpaceOffset.ToFloat2(), turretFacing, .7f);
        }
コード例 #5
0
 public SmokeTrailWhenDamaged(Actor self, SmokeTrailWhenDamagedInfo info)
 {
     smokeTurret = new Turret(info.Offset);
     interval = info.Interval;
 }