Example #1
0
        public static PlayerLanceSpawnerGameLogic CreatePlayerLanceSpawner(GameObject parent, string name, string guid, string teamDefinitionGuid, bool spawnUnitsOnActivation,
                                                                           SpawnUnitMethodType spawnMethod, List <string> unitGuids, bool includeCameraStart)
        {
            GameObject lanceSpawnerGo = new GameObject(name);

            lanceSpawnerGo.transform.parent = parent.transform;

            PlayerLanceSpawnerGameLogic lanceSpawnerGameLogic = lanceSpawnerGo.AddComponent <PlayerLanceSpawnerGameLogic>();

            lanceSpawnerGameLogic.encounterObjectGuid    = guid;
            lanceSpawnerGameLogic.teamDefinitionGuid     = teamDefinitionGuid;
            lanceSpawnerGameLogic.spawnMethod            = spawnMethod;
            lanceSpawnerGameLogic.spawnUnitsOnActivation = spawnUnitsOnActivation;

            float x = 0;
            float z = 0;

            for (int i = 0; i < unitGuids.Count; i++)
            {
                CreateUnitSpawnPoint(lanceSpawnerGo, $"PlayerLanceSpawnPoint{i + 1}", new Vector3(x, 0, z), unitGuids[i]);
                x += 24;
                z += 24;
            }

            lanceSpawnerGo.AddComponent <SnapToTerrain>();

            if (includeCameraStart)
            {
                GameObject cameraStartGo = new GameObject("CameraStart");
                cameraStartGo.transform.parent = lanceSpawnerGo.FindRecursive("PlayerLanceSpawnPoint1").transform;
                CameraStart cameraStart = cameraStartGo.AddComponent <CameraStart>();
            }

            return(lanceSpawnerGameLogic);
        }
Example #2
0
        public override void Build()
        {
            SpawnUnitMethodType spawnMethodType = SpawnUnitMethodType.ViaLeopardDropship;

            switch (spawnType)
            {
            case "Leopard": spawnMethodType = SpawnUnitMethodType.ViaLeopardDropship; break;

            case "DropPod": spawnMethodType = SpawnUnitMethodType.DropPod; break;

            case "Instant": spawnMethodType = SpawnUnitMethodType.InstantlyAtSpawnPoint; break;

            default: Main.LogDebug($"[SpawnBuilder.{contractTypeBuilder.ContractTypeKey}] No support for spawnType '{spawnType}'. Check for spelling mistakes."); break;
            }

            string teamId = EncounterRules.PLAYER_TEAM_ID;

            switch (team)
            {
            case "Player1": {
                teamId = EncounterRules.PLAYER_TEAM_ID;
                PlayerLanceSpawnerGameLogic playerLanceSpawnerGameLogic = LanceSpawnerFactory.CreatePlayerLanceSpawner(parent, name, guid, teamId, true, spawnMethodType, spawnPointGuids, true);
                if (position != null)
                {
                    SetPosition(playerLanceSpawnerGameLogic.gameObject, position);
                }
                if (rotation != null)
                {
                    SetRotation(playerLanceSpawnerGameLogic.gameObject, rotation);
                }
                break;
            }

            case "Target": {
                teamId = EncounterRules.TARGET_TEAM_ID;
                LanceSpawnerGameLogic lanceSpawnerGameLogic = LanceSpawnerFactory.CreateLanceSpawner(parent, name, guid, teamId, true, spawnMethodType, spawnPointGuids);
                if (position != null)
                {
                    SetPosition(lanceSpawnerGameLogic.gameObject, position);
                }
                if (rotation != null)
                {
                    SetRotation(lanceSpawnerGameLogic.gameObject, rotation);
                }
                break;
            }

            case "TargetAlly": {
                teamId = EncounterRules.TARGETS_ALLY_TEAM_ID;
                LanceSpawnerGameLogic lanceSpawnerGameLogic = LanceSpawnerFactory.CreateLanceSpawner(parent, name, guid, teamId, true, spawnMethodType, spawnPointGuids);
                if (position != null)
                {
                    SetPosition(lanceSpawnerGameLogic.gameObject, position);
                }
                if (rotation != null)
                {
                    SetRotation(lanceSpawnerGameLogic.gameObject, rotation);
                }
                break;
            }

            case "Employer": {
                teamId = EncounterRules.EMPLOYER_TEAM_ID;
                LanceSpawnerGameLogic lanceSpawnerGameLogic = LanceSpawnerFactory.CreateLanceSpawner(parent, name, guid, teamId, true, spawnMethodType, spawnPointGuids);
                if (position != null)
                {
                    SetPosition(lanceSpawnerGameLogic.gameObject, position);
                }
                if (rotation != null)
                {
                    SetRotation(lanceSpawnerGameLogic.gameObject, rotation);
                }
                break;
            }

            default: Main.LogDebug($"[SpawnBuilder.{contractTypeBuilder.ContractTypeKey}] No support for team '{team}'. Check for spelling mistakes."); break;
            }
        }