public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var Velocities = chunk.GetNativeArray(VelocityType); var Entities = chunk.GetNativeArray(EntityType); var Sizes = chunk.GetNativeArray(SizeType); var Timers = chunk.GetNativeArray(TimerType); for (int i = 0; i < chunk.Count; ++i) { var originalVel = Velocities[i].Value; var newVel = new C_Velocity() { Value = Velocities[i].Value }; newVel.Value = PortionOfOriginalVelocity * originalVel + Rand.NextFloat3Direction() * Spread; Velocities[i] = newVel; var timer = new C_DeathTimer() { TimeRemaining = Rand.NextFloat(LifeSpanRange.x, LifeSpanRange.y) }; Timers[i] = timer; var size = new C_Size() { Value = Rand.NextFloat(SizeRange.x, SizeRange.y) }; Sizes[i] = size; ecb.RemoveComponent(chunkIndex, Entities[i], typeof(Tag_Particle_Init)); } }
private void Awake() { photonView = GetComponent <PhotonView>(); audioSource = GetComponent <AudioSource>(); velocity = GetComponent <C_Velocity>(); attributes = GetComponent <C_Attributes>(); }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { C_Velocity vel = new C_Velocity() { Value = Vector3.zero }; C_Shared_Team team = new C_Shared_Team() { Team = myTeam }; dstManager.AddComponent(entity, typeof(Tag_Bee)); dstManager.AddComponent(entity, typeof(C_TargetType)); dstManager.AddComponent(entity, typeof(C_Random)); dstManager.AddComponent(entity, typeof(C_PreviousPos)); dstManager.AddComponent(entity, typeof(C_DeathTimer)); dstManager.AddComponentData(entity, vel); dstManager.AddComponent(entity, typeof(C_Size)); dstManager.AddComponent(entity, typeof(NonUniformScale)); dstManager.AddSharedComponentData(entity, team); dstManager.AddComponent(entity, typeof(Tag_Bee_Init)); dstManager.AddComponent(entity, typeof(Tag_Random_Init)); dstManager.AddComponent(entity, typeof(Tag_ILookWhereImGoing)); dstManager.AddComponent(entity, typeof(Tag_StretchByVelocity)); }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var Velocities = chunk.GetNativeArray(VelocityType); var Translations = chunk.GetNativeArray(TranslationType); var Targets = chunk.GetNativeArray(TargetType); var Entities = chunk.GetNativeArray(EntityType); for (int i = 0; i < chunk.Count; ++i) { var Target = Targets[i]; if (DyingType.Exists(Target.Value))//This code reads: "If Target is dead, stop following it" { ecb.RemoveComponent(chunkIndex, Entities[i], typeof(C_Target)); continue; } var translation = Translations[i]; var velocity = Velocities[i]; float3 targetPos = TranslationData[Target.Value].Value; float3 delta = targetPos - translation.Value; float distanceSquared = delta.x * delta.x + delta.y * delta.y + delta.z * delta.z; if (distanceSquared < HitDistance * HitDistance) { C_DeathTimer timer = new C_DeathTimer() { TimeRemaining = BeeTimeToDeath }; Tag_IsDying tag; ecb.AddComponent(chunkIndex, Target.Value, tag); ecb.SetComponent(chunkIndex, Target.Value, timer); ecb.RemoveComponent(chunkIndex, Entities[i], typeof(C_Target)); //Spawn particles; var bloodVel = new C_Velocity() { Value = velocity.Value * .35f }; for (int particle = 0; particle < 6; ++particle) { var blood = ecb.Instantiate(chunkIndex, BloodPrefab); ecb.SetComponent(chunkIndex, blood, translation); ecb.SetComponent(chunkIndex, blood, bloodVel); } continue; } float force = max(1.0, distanceSquared) < AttackDistance * AttackDistance ? AttackForce : ChaseForce; velocity.Value += delta * (force * dt / sqrt(distanceSquared)); Velocities[i] = velocity; } }
public override void Init(GameObject obj) { _velocity = obj.GetComponent <C_Velocity>(); _iKManager = obj.GetComponent <C_IKManager>(); _weaponHandle = obj.GetComponent <C_WeaponHandle>(); _weaponAttribute = GetComponent <WeaponAttribute>(); _photonView = obj.GetComponent <PhotonView>(); }
private void OnEnable() { var stateMgr = GetComponent <CS_StateMgr>(); stateMgr.RegState(_name, this); animator = GetComponent <C_Animator>(); velocity = GetComponent <C_Velocity>(); }
public override void Init(GameObject obj) { _velocity = obj.GetComponent <C_Velocity>(); _iKManager = obj.GetComponent <C_IKManager>(); _weaponHandle = obj.GetComponent <C_WeaponHandle>(); _camera = obj.GetComponent <C_Camera>(); _uiMgr = obj.GetComponent <C_UiEventMgr>(); _weaponAttribute = GetComponent <WeaponAttribute>(); }
private void OnEnable() { _velocity = GetComponent <C_Velocity>(); _characterController = GetComponent <CharacterController>(); _camera = GetComponent <C_Camera>(); var stateMgr = GetComponent <CS_StateMgr>(); stateMgr.RegState(_name, this); }
private void Awake() { _camera = GetComponent <C_Camera>(); _animator = GetComponent <C_Animator>(); _velocity = GetComponent <C_Velocity>(); _stateMgr = GetComponent <CS_StateMgr>(); _attributes = GetComponent <C_Attributes>(); _iKManager = GetComponent <C_IKManager>(); _audioSource = GetComponent <AudioSource>(); _characterController = GetComponent <CharacterController>(); }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { C_Velocity vel = new C_Velocity() { Value = Vector3.zero }; dstManager.AddComponent(entity, typeof(Tag_Resource)); dstManager.AddComponentData(entity, vel); dstManager.AddComponent(entity, typeof(C_GridIndex)); dstManager.AddComponent(entity, typeof(C_Held)); }
public override void Init(GameObject obj) { _animator = obj.GetComponent <C_Animator>(); _velocity = obj.GetComponent <C_Velocity>(); _iKManager = obj.GetComponent <C_IKManager>(); _weaponHandle = obj.GetComponent <C_WeaponHandle>(); _uiMgr = obj.GetComponent <C_UiEventMgr>(); _photonView = obj.GetComponent <PhotonView>(); _audioSource = GetComponent <AudioSource>(); _weaponAttribute = GetComponent <WeaponAttribute>(); }
// Use this for initialization void Awake() { velocity = GetComponentInParent <C_Velocity>(); if (!velocity.isLocalPlayer) { this.enabled = false; return; } uiMgr = GetComponentInParent <C_UiEventMgr>(); weaponAttribute = GetComponent <WeaponAttribute>(); weaponAttribute.OnFire = Reset; }
// Use this for initialization void Awake() { velocity = GetComponentInParent <C_Velocity>(); if (!velocity.isLocalPlayer) { this.enabled = false; return; } myCamera = GetComponentInParent <C_Camera>(); weaponAttribute = GetComponent <WeaponAttribute>(); occlusionPoint = GetComponentInParent <C_WeaponHandle>().OcclusionPoint; uiMgr = GetComponentInParent <C_UiEventMgr>(); }
private void OnEnable() { _camera = GetComponent <C_Camera>(); _animator = GetComponent <C_Animator>(); _velocity = GetComponent <C_Velocity>(); _attributes = GetComponent <C_Attributes>(); _audioSource = GetComponent <AudioSource>(); _characterController = GetComponent <CharacterController>(); var stateMgr = GetComponent <CS_StateMgr>(); //_name = "aim"; stateMgr.RegState(_name, this); }
private void Awake() { _uiMgr = GetComponent <C_UiEventMgr>(); _weaponHandle = GetComponent <C_WeaponHandle>(); _camera = GetComponent <C_Camera>(); _animator = GetComponent <C_Animator>(); _velocity = GetComponent <C_Velocity>(); _attributes = GetComponent <C_Attributes>(); _audioSource = GetComponent <AudioSource>(); _characterController = GetComponent <CharacterController>(); var stateMgr = GetComponent <CS_StateMgr>(); //_name = "aim"; stateMgr.RegState(_name, this); }
public override void Init(GameObject obj) { _uiMgr = obj.GetComponent <C_UiEventMgr>(); _camera = obj.GetComponent <C_Camera>(); _velocity = obj.GetComponent <C_Velocity>(); _iKManager = obj.GetComponent <C_IKManager>(); _photonView = obj.GetComponent <PhotonView>(); _attributes = obj.GetComponent <C_Attributes>(); _weaponHandle = obj.GetComponent <C_WeaponHandle>(); _battleMgr = obj.GetComponent <C_BattleMgr>(); _audio = GetComponent <AudioSource>(); _weaponAttribute = GetComponent <WeaponAttribute>(); timer = new Timer(); }
public void Execute(Entity ent, int index, [ReadOnly] ref C_DeathTimer Timer, ref C_Random Rand, [ReadOnly] ref Translation Position) { if (Rand.Generator.NextFloat(0f, 1f) > (Timer.TimeRemaining - .5f) * .5f) { return; } //Spawn particles; var bloodVel = new C_Velocity() { Value = float3(0f) }; var blood = ecb.Instantiate(index, BloodPrefab); ecb.SetComponent(index, blood, Position); ecb.SetComponent(index, blood, bloodVel); }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { C_Velocity vel = new C_Velocity() { Value = Vector3.zero }; dstManager.AddComponent(entity, typeof(Tag_Particle)); dstManager.AddComponent(entity, typeof(Tag_Particle_Init)); dstManager.AddComponent(entity, typeof(Tag_IsDying)); dstManager.AddComponent(entity, typeof(C_PreviousPos)); dstManager.AddComponent(entity, typeof(C_DeathTimer)); dstManager.AddComponent(entity, typeof(C_Size)); dstManager.AddComponentData(entity, vel); dstManager.AddComponent(entity, typeof(Tag_ILookWhereImGoing)); dstManager.AddComponent(entity, typeof(Tag_StretchByVelocity)); dstManager.AddComponent(entity, typeof(Tag_Sticky)); }
private void OnEnable() { anim = GetComponent <C_Animator>(); uiMgr = GetComponent <C_UiEventMgr>(); myCamera = GetComponent <C_Camera>(); velocity = GetComponent <C_Velocity>(); iKManager = GetComponent <C_IKManager>(); attributes = GetComponent <C_Attributes>(); weaponHandle = GetComponent <C_WeaponHandle>(); bornProtector = GetComponent <C_BornProtector>(); attackListener = GetComponent <C_AttackListener>(); avatarMeshRanderMgr = GetComponentInChildren <AvatarMeshRanderMgr>(); var stateMgr = GetComponent <CS_StateMgr>(); //_name = "aim"; stateMgr.RegState(_name, this); //meshRenderers = GetComponentsInChildren<MeshRenderer>(); //skinnedMeshRenderers = GetComponentsInChildren<SkinnedMeshRenderer>(); }
public static void SetFreeDirection(Transform transform, C_Velocity _velocity, C_Camera _camera) { // follow the camera when movecharacter var directionIndex = 0; if (_velocity.Dfwd) { directionIndex = 1; if (_velocity.Dleft) { directionIndex = 8; } if (_velocity.Dright) { directionIndex = 2; } } if (_velocity.Dbwd) { directionIndex = 5; if (_velocity.Dleft) { directionIndex = 6; } if (_velocity.Dright) { directionIndex = 4; } } if (_velocity.Dleft) { directionIndex = 7; if (_velocity.Dfwd) { directionIndex = 8; } if (_velocity.Dbwd) { directionIndex = 6; } } if (_velocity.Dright) { directionIndex = 3; if (_velocity.Dfwd) { directionIndex = 2; } if (_velocity.Dbwd) { directionIndex = 4; } } if (directionIndex != 0) { Vector3 targetAngles = new Vector3(); switch (directionIndex) { case 1: targetAngles.Set(0, _camera.Carryer.localEulerAngles.y, 0); break; case 2: targetAngles.Set(0, _camera.Carryer.localEulerAngles.y + 45, 0); break; case 3: targetAngles.Set(0, _camera.Carryer.localEulerAngles.y + 90, 0); break; case 4: targetAngles.Set(0, _camera.Carryer.localEulerAngles.y + 135, 0); break; case 5: targetAngles.Set(0, _camera.Carryer.localEulerAngles.y + 180, 0); break; case 6: targetAngles.Set(0, _camera.Carryer.localEulerAngles.y + -135, 0); break; case 7: targetAngles.Set(0, _camera.Carryer.localEulerAngles.y - 90, 0); break; case 8: targetAngles.Set(0, _camera.Carryer.localEulerAngles.y - 45, 0); break; } transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(targetAngles), Time.deltaTime * 10); } }
void Awake() { velocity = GetComponent <C_Velocity>(); targetFloat = new Dictionary <string, float>(); layerTransform = new Dictionary <int, float>(); }
private void Awake() { this.velocity = GetComponent <C_Velocity>(); }