예제 #1
0
        public static Entity CreateProp(string name, string prefabName, Vector3 worldPos)
        {
            var transform = new TransformModule(name, worldPos);
            var prop      = new PrefabModule(prefabName);

            return(new Entity(transform, prop));
        }
예제 #2
0
        public static Entity CreateDestructible(string name, string prefabName, Vector3 worldPos, int maxHp)
        {
            var transform = new TransformModule(name, worldPos);
            var collision = new CollisionModule();
            var prop      = new PrefabModule(prefabName);
            var health    = new HealthModule(maxHp, maxHp);
            var destruct  = new DestructibleModule();

            return(new Entity(transform, collision, prop, health, destruct));
        }
예제 #3
0
        public static Entity CreateBullet(string name, string prefabName, Vector3 worldPos, Vector3 velocity, Team team)
        {
            var transform = new TransformModule(name, worldPos);
            var collision = new CollisionModule();
            var prop      = new PrefabModule <ColorizableBehaviour>(prefabName);
            var bullet    = new BulletModule(team, velocity);

            prop.component.SetColor(team == Team.Red ? Color.red : Color.cyan);

            return(new Entity(transform, prop, collision, bullet));
        }
예제 #4
0
        public static Entity CreateTerrain(string name, Vector3 worldPos, TileType tileType, bool isOpen, float size, int x, int y)
        {
            var transform = new TransformModule(name, worldPos);
            var terrain   = new TerrainModule(x, y, size);

            var tile = new PrefabModule <TerrainBehaviour>("TerrainTile");

            tile.component.SetTileSize(size, size);
            tile.component.SetTileType(tileType, isOpen);
            tile.component.SetTileCoordinates(x, y);

            return(new Entity(transform, tile, terrain));
        }
예제 #5
0
        public static Entity CreatePlayerTank(string name, Vector3 worldPosition, int maxHp)
        {
            var agent       = new AgentModule(name, "AgentController", worldPosition);
            var userInput   = new UserAgentModule(Team.Blue);
            var collision   = new CollisionModule();
            var health      = new HealthModule(maxHp, maxHp);
            var pathfinding = new PathfindingModule(true);              // only used for debugging

            var tankModel = new PrefabModule <TankModelBehaviour>("TankModel");

            tankModel.component.SetColor(Color.green);
            tankModel.component.SetAgent(agent);
            tankModel.component.SetHealth(health);

            return(new Entity(health, agent, tankModel, collision, pathfinding, userInput));
        }
예제 #6
0
        public static Entity CreateNpcTank(string name, Vector3 worldPosition, int maxHp, Team team)
        {
            var agent       = new AgentModule(name, "AgentController", worldPosition);
            var npc         = new NpcAgentModule(team);
            var collision   = new CollisionModule();
            var health      = new HealthModule(maxHp, maxHp);
            var pathfinding = new PathfindingModule();

            var tankModel = new PrefabModule <TankModelBehaviour>("TankModel");

            tankModel.component.SetColor(team == Team.Red ? Color.red : Color.cyan);
            tankModel.component.SetAgent(agent);
            tankModel.component.SetHealth(health);

            return(new Entity(health, agent, tankModel, collision, pathfinding, npc));
        }
예제 #7
0
        public override void LinkToDependency(Module dependency)
        {
            if (dependency.IsModuleType(ModuleType.Prefab))
            {
                _prefab = dependency as PrefabModule;
            }

            if (dependency.IsModuleType(ModuleType.Health))
            {
                _health = dependency as HealthModule;
                _health.OnHealthChanged += OnHealthChanged;
                _desiredScale            = (float)_health.HitPoints / (float)_health.MaxHitPoints;
                _scale = 1f;
            }

            if (dependency.IsModuleType(ModuleType.Collision))
            {
                (dependency as CollisionModule).collision.SetTriggerCallback(OnTrigger);
            }
        }
예제 #8
0
 protected override void DestroyInternal()
 {
     _health = null;
     _prefab = null;
 }