コード例 #1
0
    private void SpawnMarine(float3 spawnPosition)
    {
        EntityArchetype entityArchetype = entityManager.CreateArchetype(
            typeof(Marine),
            typeof(Translation),
            typeof(MoveTo),
            typeof(Skeleton_Data),
            typeof(Skeleton_PlayAnim)
            );

        Entity entity = entityManager.CreateEntity(entityArchetype);

        entityManager.SetComponentData(entity, new Translation {
            Value = spawnPosition
        });
        entityManager.SetComponentData(entity, new Skeleton_Data {
            frameRate = 1f
        });
        entityManager.SetComponentData(entity, new Skeleton_PlayAnim {
            ecsUnitAnimTypeEnum = ECS_UnitAnimType.TypeEnum.dBareHands_Idle, animDir = UnitAnim.AnimDir.Down
        });
        entityManager.SetComponentData(entity, new MoveTo {
            move = true, position = spawnPosition, moveSpeed = 40f
        });

        ECS_Animation.PlayAnimForced(entity, ECS_UnitAnimType.TypeEnum.dBareHands_Idle, new Vector3(0, -1), default);
    }
コード例 #2
0
    // 海兵隊の生成処理.
    private void SpawnMarine(float3 spawnPosition)
    {
        // 海兵隊のアーキタイプを作成.
        EntityArchetype entityArchetype = entityManager.CreateArchetype(
            typeof(Marine),
            typeof(Skeleton_Data),
            typeof(Skeleton_Material),
            typeof(Skeleton_PlayAnim),
            typeof(QuadrantEntity),
            typeof(FindTargetData),
            typeof(Health),
            typeof(MarineShoot),
            typeof(MoveTo),
            typeof(EntityAnims),
            typeof(Translation)
            );

        // エンティティの作成.
        Entity entity = entityManager.CreateEntity(entityArchetype);

        // 各種コンポーネントデータのセット.
        entityManager.SetComponentData(entity, new Translation {
            Value = spawnPosition
        });
        entityManager.SetComponentData(entity, new Skeleton_Data {
            frameRate = 1f
        });
        entityManager.SetComponentData(entity, new Skeleton_Material {
            materialTypeEnum = Skeleton_Material.TypeEnum.Marine
        });
        entityManager.SetComponentData(entity, new Skeleton_PlayAnim {
            ecsUnitAnimTypeEnum = ECS_UnitAnimType.TypeEnum.dBareHands_Idle, animDir = UnitAnim.AnimDir.Down
        });
        entityManager.SetComponentData(entity, new MarineShoot {
            nextShootTimerMax = .1f
        });
        entityManager.SetComponentData(entity, new Health {
            health = 50
        });
        entityManager.SetComponentData(entity, new MoveTo {
            move = false, position = spawnPosition, moveSpeed = 40f
        });
        entityManager.SetComponentData(entity, new EntityAnims {
            idleAnimType = ECS_UnitAnimType.TypeEnum.dMarine_Idle, walkAnimType = ECS_UnitAnimType.TypeEnum.dMarine_Walk
        });
        entityManager.SetComponentData(entity, new QuadrantEntity {
            typeEnum = QuadrantEntity.TypeEnum.Marine
        });
        entityManager.SetComponentData(entity, new FindTargetData {
            targetRange = 100f
        });

        // TODO : アニメーションの再生? 後でコードを見に行く.
        ECS_Animation.PlayAnimForced(entity, ECS_UnitAnimType.TypeEnum.dBareHands_Idle, new Vector3(0, -1), default);
    }
コード例 #3
0
 public void Execute(Entity entity, int index, ref Skeleton_Data skeletonData, ref Skeleton_PlayAnim skeletonPlayAnim)
 {
     if (skeletonPlayAnim.forced)
     {
         skeletonPlayAnim.forced = false;
         ECS_Animation.PlayAnimForcedJobs(entity, index, entityCommandBuffer, skeletonPlayAnim.ecsUnitAnimTypeEnum, skeletonPlayAnim.animDir, skeletonPlayAnim.onComplete);
     }
     else
     {
         ECS_Animation.PlayAnimJobs(entity, index, entityCommandBuffer, skeletonData, skeletonPlayAnim.ecsUnitAnimTypeEnum, skeletonPlayAnim.animDir, skeletonPlayAnim.onComplete);
     }
 }
コード例 #4
0
    private void Start()
    {
        cameraFollowZoom = 80f;
        cameraFollow.Setup(() => cameraFollowPosition, () => cameraFollowZoom, true, true);
        entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

        ECS_Animation.Init();

        shadowMesh             = ECS_Animation.CreateMesh(9f, 6f);
        unitSelectedCircleMesh = ECS_Animation.CreateMesh(8f, 5f);

        for (int i = 0; i < 30; i++)
        {
            SpawnMarine();
        }
    }
コード例 #5
0
    private void Start()
    {
        cameraFollowZoom = 80f;
        cameraFollow.Setup(() => cameraFollowPosition, () => cameraFollowZoom, true, true);
        entityManager = World.Active.EntityManager;

        // 各システムの初期化.
        ECS_Animation.Init();
        ECS_QuadrantSystem.Init();

        shadowMesh = ECS_Animation.CreateMesh(9f, 6f);

        // 海兵隊の生成.
        for (int i = 0; i < 30; i++)
        {
            SpawnMarine();
        }

        // ゾンビの生成.
        for (int i = 0; i < 1; i++)
        {
            SpawnZombie(true);
        }
    }
コード例 #6
0
    // ゾンビのスポーン処理.
    private void SpawnZombie(
        bool spawnZombieTop)
    {
        // ゾンビのアーキタイプを作成.
        EntityArchetype zombieArchetype = entityManager.CreateArchetype(
            typeof(Zombie),
            typeof(Skeleton_Data),
            typeof(Skeleton_Material),
            typeof(Skeleton_PlayAnim),
            typeof(QuadrantEntity),
            typeof(FindTargetData),
            typeof(Health),
            typeof(ZombieAttack),
            typeof(MoveTo),
            typeof(EntityAnims),
            typeof(Translation)
            );

        // ゾンビエンティティの作成.
        Entity entity = entityManager.CreateEntity(zombieArchetype);

        float3 spawnPosition;

        if (spawnZombieTop)
        {
            spawnPosition = new float3(UnityEngine.Random.Range(-100f, 100f), 400f, 0f);
        }
        else
        {
            spawnPosition = UtilsClass.GetRandomDir() * 400f;
        }

        // 各種コンポーネントデータのセット.
        entityManager.SetComponentData(entity, new Translation {
            Value = spawnPosition
        });
        entityManager.SetComponentData(entity, new Skeleton_Data {
            frameRate = 1f
        });
        entityManager.SetComponentData(entity, new Skeleton_Material {
            materialTypeEnum = Skeleton_Material.TypeEnum.Zombie
        });
        entityManager.SetComponentData(entity, new Skeleton_PlayAnim {
            ecsUnitAnimTypeEnum = ECS_UnitAnimType.TypeEnum.dBareHands_Idle, animDir = UnitAnim.AnimDir.Down
        });
        entityManager.SetComponentData(entity, new ZombieAttack {
            nextAttackTimerMax = .1f
        });
        entityManager.SetComponentData(entity, new Health {
            health = 30
        });

        entityManager.SetComponentData(entity, new MoveTo {
            move      = true,
            position  = spawnZombieTop ? spawnPosition + new float3(0, -700f, 0) : (float3)Vector3.zero,
            moveSpeed = 15f
        });

        bool useZombieAims = UnityEngine.Random.Range(0, 100) < 50;

        entityManager.SetComponentData(entity, new EntityAnims {
            idleAnimType = useZombieAims ? ECS_UnitAnimType.TypeEnum.dZombie_Idle : ECS_UnitAnimType.TypeEnum.dBareHands_Idle,
            walkAnimType = useZombieAims ? ECS_UnitAnimType.TypeEnum.dZombie_Walk : ECS_UnitAnimType.TypeEnum.dBareHands_Walk
        });

        entityManager.SetComponentData(entity, new QuadrantEntity {
            typeEnum = QuadrantEntity.TypeEnum.Zombie
        });
        entityManager.SetComponentData(entity, new FindTargetData {
            targetRange = 100f
        });

        // TODO : アニメーションの再生? 後でコードを見る.
        ECS_Animation.PlayAnimForced(entity, ECS_UnitAnimType.TypeEnum.dBareHands_Idle, new Vector3(0, -1), default);
    }