コード例 #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);
        }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        CameraAC.enabled    = false;
        _target             = GameObject.FindGameObjectWithTag("Player").transform;
        _lastTargetPosition = _target.position;
        _offsetZ            = (transform.position - _target.position).z;
        transform.parent    = null;
        _playerHealth       = _target.gameObject.GetComponent <HealthManager> ();
        _cameraStart        = GetComponent <CameraStart> ();
        _cameraEnd          = GetComponent <CameraEnd> ();

        Vector3 PlayerPos = GameObject.FindGameObjectWithTag("Player").transform.position;
        Vector3 Pos       = new Vector3(PlayerPos.x, PlayerPos.y, -10);

        Pos.x                 = Mathf.Clamp(Pos.x, -XBound, XBound);
        Pos.y                 = Mathf.Clamp(Pos.y, -YBound, YBound);
        _cameraTrans          = this.transform;
        _cameraTrans.position = Pos;
    }