コード例 #1
0
            public void Execute(ref ActorAttribute3 <_Power> attribute3, ref ControlForceDirection controlForceDirection, ref ControlTorqueAngular controlTorqueAngular)
            {
                var scale = 1f;

                if (controlForceDirection.force > 0f)
                {
                    scale -= 0.5f;
                }
                if (controlTorqueAngular.torque > 0f)
                {
                    scale -= 0.25f;
                }

#if ENABLE_UNITY_COLLECTIONS_CHECKS
                if (attribute3.regain < 0f)
                {
                    throw new System.Exception("attribute3.regain < 0f");
                }
#endif
                //value
                attribute3.value += attribute3.regain * scale * fixedDeltaTime;
                if (attribute3.value >= attribute3.max)
                {
                    attribute3.value = attribute3.max;
                }
            }
コード例 #2
0
            public void Execute([ReadOnly] ref ShipPowers shipPowers, ref ActorAttribute3 <_Power> power, [ReadOnly, ChangedFilter] ref ActorAttribute1 <_PowerLevel> powerLevel)
            {
                var level     = (int)powerLevel.value;
                var powerInfo = shipPowers.get(level);

                power.max    = powerInfo.max;
                power.regain = powerInfo.regain;
            }
コード例 #3
0
        protected override void OnUpdate()
        {
            //on
            Entities
            .WithAll <ActorLifetime, ActorAttribute3 <_HP>, Translation, Shield>().WithAllReadOnly <ActorCreator, OnCreateMessage>()
            .ForEach((Entity shieldEntity, ref ActorCreator shipCreator, ref ActorLifetime actorLifetime, ref ActorAttribute3 <_HP> _hp, ref Translation translation, ref Shield shield) =>
            {
                //
                var shipT        = EntityManager.GetComponentObject <Transform>(shipCreator.entity);
                var _ShieldLevel = EntityManager.GetComponentData <ActorAttribute1 <_ShieldLevel> >(shipCreator.entity);
                var shieldLevel  = (short)(_ShieldLevel.value - 1);
                if (shieldLevel < 0)
                {
                    Debug.LogError($"shieldLevel < 0  shipT={shipT}", shipT);
                    return;
                }

                var shieldRootT = shipT.GetChild(ShipSpawner.ShieldRoot_TransformIndex);
                EntityBehaviour._initComponent(shieldRootT, shieldEntity, EntityManager);
                EntityManager.AddComponentObject(shieldEntity, shieldRootT);
                EntityManager.AddComponentObject(shieldEntity, shieldRootT.GetComponent <Rigidbody>());


                var shieldT = shieldRootT.GetChild(shieldLevel);
                shieldT.gameObject.SetActive(true);



                //
                var shipShieldInfos = EntityManager.GetComponentData <ShipShields>(shipCreator.entity);
                var shieldInfo      = shipShieldInfos.get(shieldLevel);
                actorLifetime       = new ActorLifetime {
                    lifetime = shieldInfo.lifetime, value = shieldInfo.lifetime
                };
                _hp = new ActorAttribute3 <_HP> {
                    max = shieldInfo.hp, regain = 0f, value = shieldInfo.hp
                };

                translation = new Translation {
                    Value = shieldRootT.position
                };
                //rotation = new Rotation { Value = shieldRootT.rotation };

                shield = new Shield {
                    curLevel = shieldLevel
                };



                //
                var shipWeaponInstalledArray          = EntityManager.GetComponentData <ShipWeaponArray>(shipCreator.entity);
                shipWeaponInstalledArray.shieldEntity = shieldEntity;
                EntityManager.SetComponentData(shipCreator.entity, shipWeaponInstalledArray);
            });
        }
コード例 #4
0
            public void Execute(Entity shipEntity, int index,
                                [ReadOnly] ref ActorAttribute3 <_Power> power,
                                [ReadOnly] ref ShipPowers shipPowers, [ReadOnly] ref Translation translation)
            {
                if (power.value <= 0f)
                {
                    var lostInputTime = shipPowers.lostInputTime + math.abs(power.value) * shipPowers.power2Time;

                    endCommandBuffer.AddComponent(index, shipEntity, new ShipLostInputState {
                        time = shipPowers.lostInputTime = lostInputTime
                    });
                    endCommandBuffer.SetComponent(index, shipEntity, new ShipMoveInput {
                        lost = true
                    });

                    ShipLostInputFxSpawner.createInServer(endCommandBuffer, index, shipEntity, translation, lostInputTime);
                }
            }