Пример #1
0
        public void Build(EnemySpawnData enemySpawnData, ref EnemyAttackStruct enemyAttackstruct)
        {
            // Find a random index between zero and one less than the number of spawn points.
            int spawnPointIndex = UnityEngine.Random.Range(0, enemySpawnData.spawnPoints.Length);
            // Create an instance of the enemy prefab at the randomly selected spawn point position and rotation.
            var go           = _gameobjectFactory.Build(enemySpawnData.enemyPrefab);
            var implementors = go.GetComponentsInChildren <IImplementor>();

            var initializer = _entityFactory.BuildEntity <EnemyEntityDescriptor>(go.GetInstanceID(),
                                                                                 implementors);

            var playerTargetTypeEntityStruct = new PlayerTargetTypeEntityStruct {
                targetType = enemySpawnData.targetType
            };
            var healthEntityStruct = new HealthEntityStruct {
                currentHealth = 100
            };

            initializer.Init(enemyAttackstruct);
            initializer.Init(healthEntityStruct);
            initializer.Init(playerTargetTypeEntityStruct);

            var transform = go.transform;
            var spawnInfo = enemySpawnData.spawnPoints[spawnPointIndex];

            transform.position = spawnInfo.position;
            transform.rotation = spawnInfo.rotation;
        }
        public void Step(ref DamageInfo token, DamageCondition condition)
        {
            int hudEntityViewsCount;
            var hudEntityViews = entitiesDB.QueryEntities <HUDEntityView>(out hudEntityViewsCount);

            if (hudEntityViewsCount > 0)
            {
                uint index;
                PlayerTargetTypeEntityStruct playerTarget =
                    entitiesDB.QueryEntitiesAndIndex <PlayerTargetTypeEntityStruct>(token.entityDamagedID, out index)[index];

                switch (playerTarget.targetType)
                {
                case PlayerTargetType.Bunny:
                    hudEntityViews[0].scoreComponent.score += 10;
                    break;

                case PlayerTargetType.Bear:
                    hudEntityViews[0].scoreComponent.score += 20;
                    break;

                case PlayerTargetType.Hellephant:
                    hudEntityViews[0].scoreComponent.score += 30;
                    break;
                }
            }
        }