예제 #1
0
파일: DamageSystem.cs 프로젝트: Deus0/zoxel
        private void RespondToAttack(Entity defenderEntity, Entity attackerEntity)
        {
            Targeter defenderTargeter = World.EntityManager.GetComponentData <Targeter>(defenderEntity);

            if (defenderTargeter.hasTarget == 0)
            {
                ZoxID       attackerID       = World.EntityManager.GetComponentData <ZoxID>(attackerEntity);
                Translation attackerPosition = World.EntityManager.GetComponentData <Translation>(attackerEntity);
                Translation defenderPosition = World.EntityManager.GetComponentData <Translation>(defenderEntity);
                // Now set to attack the attacker
                defenderTargeter.hasTarget       = 1;
                defenderTargeter.nearbyCharacter = new NearbyCharacter
                {
                    character = attackerEntity, // attackerID.id;
                    clan      = attackerID.clanID,
                    position  = attackerPosition.Value,
                    distance  = math.distance(defenderPosition.Value, attackerPosition.Value)
                };
                //defenderTargeter.targetClanID = attackerID.clanID;
                ////targeter.targetID = attackerEntityID;
                //defenderTargeter.targetPosition = attackerPosition.Value;
                //defenderTargeter.targetDistance =
                World.EntityManager.SetComponentData(defenderEntity, defenderTargeter);
                //Debug.LogError("Defender will now attack its target: " + attackerID.id);
            }
        }
예제 #2
0
파일: SkillsSystem.cs 프로젝트: Deus0/zoxel
        private void ShootBullet(SkillDatam skillDatam, Entity e)
        {
            if (World.EntityManager.HasComponent <Shooter>(e) == false)
            {
                return;
            }
            Shooter shooter = World.EntityManager.GetComponentData <Shooter>(e);

            if (shooter.CanTrigger(UnityEngine.Time.time))
            {
                shooter.triggered = 1;
                Entity camera;
                if (World.EntityManager.HasComponent <CameraLink>(e))
                {
                    camera = World.EntityManager.GetComponentData <CameraLink>(e).camera;
                }
                else
                {
                    camera = new Entity();
                }
                if (World.EntityManager.Exists(camera))
                {
                    //GameObject shooterCamera = CameraSystem.cameraObjects[cameraID];
                    //Debug.LogError("Shooting with camera: " + shooterCamera.name);
                    float3     position = World.EntityManager.GetComponentData <Translation>(camera).Value;
                    quaternion rotation = World.EntityManager.GetComponentData <Rotation>(camera).Value;
                    shooter.shootPosition = position + math.rotate(rotation, new float3(0, 0, 0.1f)); // shooterCamera.transform.position + shooterCamera.transform.forward * 0.1f;//aimer.originalPosition + math.mul(aimer.targetRotation, new float3(0, 0, 0.19f + 0.2f));
                    shooter.shootRotation = rotation;                                                 // shooterCamera.transform.rotation;
                }
                else
                {
                    Translation translation = World.EntityManager.GetComponentData <Translation>(e);
                    Rotation    rotation    = World.EntityManager.GetComponentData <Rotation>(e);
                    shooter.shootPosition = translation.Value;//aimer.originalPosition + math.mul(aimer.targetRotation, new float3(0, 0, 0.19f + 0.2f));

                    Targeter   targeter      = World.EntityManager.GetComponentData <Targeter>(e);
                    float3     normalBetween = math.normalizesafe(targeter.nearbyCharacter.position - translation.Value);
                    quaternion targetAngle   = quaternion.LookRotationSafe(normalBetween, math.up());
                    //rotation.Value = QuaternionHelpers.slerpSafe(rotation.Value, targetAngle, mover.turnSpeed);
                    shooter.shootRotation = targetAngle; // rotation.Value;
                                                         //Debug.LogError("Shoot Camera ID is 0.");
                }
                AudioManager.instance.PlaySound(skillDatam.audio, shooter.shootPosition);
                World.EntityManager.SetComponentData(e, shooter);
                //Debug.LogError("Shooting Bullet from: " + shooter.shootPosition);
            }
        }
예제 #3
0
        private void DebugAIStates()
        {
            EntityManager manager = booty.GetSystems().space.EntityManager;
            //for (int i = 0; i < booty.systemsManager.characterSpawnSystem.characters.Count; i++)
            int count = 1;

            foreach (Entity character in booty.GetSystems().characterSystemGroup.characterSpawnSystem.characters.Values)
            {
                if (manager.HasComponent <AIState>(character))
                {
                    AIState state = manager.GetComponentData <AIState>(character);
                    ZoxID   zoxID = manager.GetComponentData <ZoxID>(character);
                    GUILayout.Label("[" + count + "] State: " + ((AIStateType)(state.state)) + ", Clan: " + zoxID.clanID + ", Creator: " + zoxID.creatorID + ", ID: " + zoxID.id);
                    Mover    mover    = manager.GetComponentData <Mover>(character);
                    Wander   wander   = manager.GetComponentData <Wander>(character);
                    Targeter targeter = manager.GetComponentData <Targeter>(character);
                    //GUILayout.Label("       [" + count + "] Mover: " + mover.disabled + ", Wander: " + wander.disabled + ", Target ID: " + targeter.target.Index);
                }
                else
                {
                    ZoxID zoxID = manager.GetComponentData <ZoxID>(character);
                    GUILayout.Label("[" + count + "] Clan: " + zoxID.clanID + ", Creator: " + zoxID.creatorID + ", ID: " + zoxID.id);
                    if (manager.HasComponent <Shooter>(character))
                    {
                        Shooter  shooter  = manager.GetComponentData <Shooter>(character);
                        Targeter targeter = manager.GetComponentData <Targeter>(character);
                        //GUILayout.Label("       Shooter: " + Quaternion.ToEulerAngles(shooter.shootRotation).ToString() + ", Target ID: " + targeter.targetID);
                    }
                }
                count++;
                if (count == 31)
                {
                    break;
                }
            }
        }