예제 #1
0
    /// <summary>
    /// 初始化 找到前面背景各32张图
    /// </summary>
    void InitMethod()
    {
        int count = Force.transform.childCount;//count==32;

        for (int i = 0; i < count / 8; i++)
        {
            //4row 4个list
            List <GameObject> list = new List <GameObject>();
            //8列 column
            for (int k = 0; k < count / 4; k++)
            {
                //根据二维坐标计算,(0,0)(0,1)(r,c)(当前r*总列数+当前列数);总列数为:固定值;
                list.Add(Force.transform.GetChild(k + i * 8).gameObject);
            }
            ForceList.Add(list);
        }

        count = Back.transform.childCount;
        for (int i = 0; i < count / 8; i++)
        {
            List <GameObject> list = new List <GameObject>();
            for (int k = 0; k < count / 4; k++)
            {
                list.Add(Back.transform.GetChild(k + i * 8).gameObject);
            }
            BackList.Add(list);
        }
    }
예제 #2
0
        public cCritterBoss(cGame pOwnerGame = null) : base(pOwnerGame)
        {
            MaxSpeed = 40;
            Health   = 5;
            ForceList.RemoveAll();
            ForceList.Add(new cForceBossMovement(150000.0f));
            Sprite = new cSpriteQuake(ModelsMD2.Eva01);
            Radius = 3;
            moveTo(new cVector3(Game.Border.Midx, Game.Border.Loy, Game.Border.Midz));
            Target            = Game.Player;
            AimToAttitudeLock = false;
            //copyMotionMatrixToAttitudeMatrix();
            AttitudeToMotionLock = false;
            BULLETRADIUS         = 0.4f;
            setMoveBox(new cRealBox3(new cVector3(Game.Border.Lox, Game.Border.Loy, Game.Border.Loz + 3),
                                     new cVector3(Game.Border.Hix, Game.Border.Hiy, Game.Border.Hiz - 3)));

            //set upright
            rotateAttitude(new cSpin((float)Math.PI * 3f / 2f, new cVector3(1, 0, 0)));
            //set looking left
            rotateAttitude(new cSpin((float)Math.PI * 3f / 2f, new cVector3(0, 0, 1)));
            _dead = false;
        }
예제 #3
0
        protected override IEnumerable <YieldInstruction> before_vessel_launch(PackedVessel vsl)
        {
            if (fairings.Count == 0 || jettisoned)
            {
                yield break;
            }
            //save part mass for the future
            var partMass = part.Rigidbody.mass - vsl.mass - part.resourceMass;

            //store crew
            vsl.crew.Clear();
            vsl.crew.AddRange(part.protoModuleCrew);
            //decouple surface attached parts and decoupleNodes
            var decouple = part.children
                           .Where(p => p.srfAttachNode?.attachedPart == part)
                           .ToList();

            // ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
            foreach (var node in decoupleNodes)
            {
                if (node.attachedPart == null)
                {
                    continue;
                }
                decouple.Add(node.attachedPart == part.parent ? part : node.attachedPart);
                disable_decouplers(node.id);
            }
            jettisonForces.Clear();
            var jettisonPower = JettisonPower <= 1
                ? Mathf.LerpUnclamped(MinJettisonPower, 1, JettisonPower)
                : JettisonPower;
            var jettisonForce  = JettisonForce * jettisonPower / 2;
            var jettisonTorque = JettisonTorque * jettisonPower;

            foreach (var p in decouple)
            {
                var force_target = p;
                if (p == part)
                {
                    force_target = part.parent;
                }
                p.decouple();
                if (force_target.Rigidbody != null)
                {
                    var pos      = force_target.Rigidbody.worldCenterOfMass;
                    var minForce = (float)(force_target == part.parent
                                       ? vessel.totalMass - part.MassWithChildren()
                                       : force_target.MassWithChildren())
                                   / TimeWarp.fixedDeltaTime;
                    var force = (pos - part.Rigidbody.worldCenterOfMass).normalized
                                * Utils.Clamp(jettisonForce, minForce, minForce * 10);
                    jettisonForces.Add(force_target.Rigidbody, force, pos);
                }
                yield return(null);

                force_target.vessel.IgnoreGForces(10);
            }
            //apply force to decoupled parts and wait for them to clear away
            if (jettisonForces.Count > 0)
            {
                FX?.Burst();
                jettisonForces.Apply(part.Rigidbody);
                yield return(new WaitForSeconds(3));
            }
            //spawn debris
            debris.Clear();
            debris_cost = 0;
            debris_mass = 0;
            var debrisDestroyCountdown = Utils.ClampL(DestroyDebrisIn, 1);

            jettisonForce /= fairingsSpecificMass.Values.Max();
            foreach (var f in fairings)
            {
                var specMass = fairingsSpecificMass[f];
                var d        = Debris.SetupOnTransform(part, f, partMass * specMass, FairingsCost, DebrisLifetime);
                var force    = f.TransformDirection(JettisonDirection) * (jettisonForce * specMass);
                var pos      = d.Rigidbody.worldCenterOfMass;
                if (!JettisonForcePos.IsZero())
                {
                    pos += f.TransformVector(JettisonForcePos);
                }
                jettisonForces.Add(d.Rigidbody, force, pos, jettisonTorque);
                if (DestroyDebrisIn > 0)
                {
                    d.selfDestruct = debrisDestroyCountdown;
                }
                d.DetectCollisions(false);
                d.vessel.IgnoreGForces(10);
                debris_cost += FairingsCost;
                debris_mass += d.Rigidbody.mass;
                if (DestroyDebrisIn > 0)
                {
                    d.selfDestructPower = explosionPower(d.Rigidbody);
                }
                debris.Add(d);
            }
            vessel.IgnoreGForces(10);
            jettisonForces.Apply(part.Rigidbody
#if DEBUG
                                 ,
                                 false
#endif
                                 );
            //update drag cubes
            part.DragCubes.SetCubeWeight("Fairing ", 0f);
            part.DragCubes.SetCubeWeight("Clean ", 1f);
            part.DragCubes.ForceUpdate(true, true, true);
            //this event is catched by FlightLogger
            StartCoroutine(CallbackUtil.DelayedCallback(10, update_debris_after_launch));
            GameEvents.onStageSeparation.Fire(new EventReport(FlightEvents.STAGESEPARATION,
                                                              part,
                                                              vsl.name,
                                                              vessel.GetDisplayName(),
                                                              vessel.currentStage,
                                                              $"{vsl.name} separated from {vessel.GetDisplayName()}"));
            FX?.Burst();
            if (DestroyDebrisIn > 0 && vessel.Parts.Count == 1 && vessel.Parts.First() == part)
            {
                StartCoroutine(self_destruct(debrisDestroyCountdown));
            }
            part.UpdateCoMOffset(Vector3.Lerp(
                                     BaseCoMOffset,
                                     part.CoMOffset,
                                     vsl.mass / (part.Rigidbody.mass - debris_mass)));
            jettisoned = true;
            update_PAW();
        }
예제 #4
0
 public cCritterMinion(cGame pOwnerGame) : base(pOwnerGame)
 {
     ForceList.Add(new cForceMinionMovement(pOwnerGame.Player));
     Sprite        = new cSpriteQuake(ModelsMD2.Hunter);
     Sprite.Radius = 1;
 }